#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
"""DOCS HERE.
"""

# Copyright (C) 2008
# $Id: main_window.py 1916 2006-11-21 17:21:05Z  $
__version__ = "$Revision: 1916 $"[11:-2]

# import Qt modules
from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4 import QtOpenGL

class CustomOpenGL(QtOpenGL.QGLWidget):
    
    def __init__(self, parent=None):
        super(CustomOpenGL, self).__init__(parent)
        
    def initializeGL(self):
        pass
    
    def resizeGL(self,  width,  height):
        pass
    
    def paintGL(self):
        pass

class CustomItem(QtGui.QGraphicsItem):
    
    def boundingRect(self):
        return QtCore.QRectF(0, 0, 10, 10)

    def paint(self, painter,  option,  widget):
        painter.drawRoundedRect(0, 0, 10, 10, 5, 5)

class FrustumTracerMainWindow(QtGui.QMainWindow):
    
    env = None
    cmd = None
    
    def __init__(self, environment,  commands_handler,  parent=None):
        # init widget (otherway it will be destroyed)
        QtGui.QWidget.__init__(self, parent)
        self.setFixedWidth(1000)
        self.setFixedHeight(800)
        
        # build interface
        label = QtGui.QLabel('Frustum Tracer GUI version %s' % __version__, self)
        
        grview = QtGui.QGraphicsView(self)
        #grview.setViewport(QtOpenGL.QGLWidget())
        grview.setViewport(CustomOpenGL(self))
        grview.setFixedWidth(900)
        grview.setFixedHeight(700)
        
        scene = QtGui.QGraphicsScene(self)
        scene.addText("GL ViewPort")
        #scene.addRect(0, 0, 100, 100)
        scene.addItem(CustomItem())
        
        grview.setScene(scene)
        grview.show()
        
        # set environment and command handler that comes from CORE module
        self.env = environment
        self.cmd = commands_handler

