コード例 #1
0
    def _setUpResources(self):
        sf.setupLogging()
        sf.info ("Entering _setupresources")
        # register the quickgui script handler..
        gui.registerScriptReader()

        # load the default resources
        sf.Application._setUpResources ( self )
        
        # Now load any extra resource locations that we might need..  
        Ogre.ResourceGroupManager.getSingleton().addResourceLocation("media/textures","FileSystem", "General")
        Ogre.ResourceGroupManager.getSingleton().addResourceLocation("media/qgui.core.zip", "Zip")
        #Ogre.ResourceGroupManager.getSingleton().addResourceLocation("media","FileSystem", "General")
        sf.info ( "Done _setup resources")
コード例 #2
0
    def createGUI ( self ):  
        self.callbacks=[]
        sf.info ("Creating GUI")
        dm = gui.DescManager.getSingletonPtr()
        
        sd = dm.getDefaultSheetDesc()
        sd.resetToDefault()
        sd.widget_name = "QuickGui.MainSheet"
        sd.widget_dimensions.size = gui.Size(800,600)
        self.mSheet = gui.SheetManager.getSingleton().createSheet(sd)
        self.mSheet.addWidgetEventHandler(gui.WIDGET_EVENT_SIZE_CHANGED,self.MakeCallback( self.onSheetResized) )
        
		
        
        self.TreeView = createWidget ( self.mSheet,"TreeView", gui.Rect(0,75,200,300) )
        self.Panel = createWidget (  self.mSheet,"Panel", gui.Rect(225,75,150,217), name="MainPanel", 
                        widget_resizeFromBottom=True, widget_resizeFromRight = True )
        #self.bd = createWidget(  self.mSheet,"ScrollButton", gui.Rect(400,250,75,23) )
        self.tb = createWidget(  self.mSheet,"ToolBar", gui.Rect(0,0,800,20), name="TestToolBar")
        print dir(self.tb)
        self.tb.createMenu("File")

        menu = dm.getDefaultMenuDesc()
        menu.resetToDefault()
        menu.widget_name = "Edit"
        menu.textDesc.segments.append(gui.TextSegment("micross.12",gui.ColourValue().Black,"Edit"))
        
        sv = gui.vector_QuickGUITextSegment()
        sv.append (gui.TextSegment("micross.12",gui.ColourValue().Black,"Edit"))
        
        m = self.tb.createMenu()
        m.createSubMenu ("test")
        
        m.createTextItem ( sv )
        m.createTextItem ( "Item2" )
        m.createSubMenu ("test")
        #m.createTextItem ( gui.TextSegment("micross.12",gui.ColourValue().Black,"Item1") )
        #m.createTextItem ( gui.TextSegment("micross.12",gui.ColourValue().Black,"Item2") )
        
        self.tb.createMenu("Format")
        
        
        ##self.addMenuItem ( self.tb, "File")
        self.combo = createWidget ( self.mSheet,"ComboBox", gui.Rect(400,100,125,20), combobox_dropDownMaxHeight = 60 )
        
        if False:
          pd = descFactory.getInstance("DefaultPanelDesc")
          bd = descFactory.getInstance("DefaultButtonDesc")
          cbd = descFactory.getInstance("DefaultCheckBoxDesc")
          ltiDesc = descFactory.getInstance("DefaultListTextItemDesc")
          vsd = descFactory.getInstance("DefaultVScrollBarDesc")
          tad = descFactory.getInstance("DefaultTextAreaDesc")
          combod = descFactory.getInstance("DefaultComboBoxDesc")
          md = descFactory.getInstance("DefaultMenuDesc")
          textBoxD = descFactory.getInstance("DefaultTextBoxDesc")
          hsd = descFactory.getInstance("DefaultHScrollBarDesc")
          progDesc =descFactory.getInstance("DefaultProgressBarDesc")
          listDesc = descFactory.getInstance("DefaultListDesc")
          mld = descFactory.getInstance("DefaultMenuLabelDesc")
          tbd = descFactory.getInstance("DefaultToolBarDesc")
          cd = descFactory.getInstance("DefaultConsoleDesc")
          tvd = descFactory.getInstance("DefaultTreeViewDesc")
          sf.info ("CreateGUI part 1")

          md.resetToDefault()
          md.widget_name = "File"
          md.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"File"))
          tb.createMenu(md)

          md.resetToDefault()
          md.widget_name = "Edit"
          md.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"Edit"))
          tb.createMenu(md)

          md.resetToDefault()
          md.widget_name = "Format"
          md.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"Format"))
          m1 = tb.createMenu(md)

          md.resetToDefault()
          md.widget_name = "WordWrap"
          md.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"Word Wrap"))
          m2 = m1.createSubMenu(md)

          mld.resetToDefault()
          mld.widget_name = "Font"
          mld.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"Font..."))
          m1.createMenuLabel(mld)

          mld.resetToDefault()
          mld.widget_name = "Item1"
          mld.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"Item 1"))
          m2.createMenuLabel(mld)

          md.resetToDefault()
          md.widget_name = "Item2"
          md.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"Item 2"))
          m3 = m2.createSubMenu(md)

          mld.resetToDefault()
          mld.widget_name = "Item2.1"
          mld.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Green,"Item 2.1"))
          m3.createMenuLabel(mld)


          ltiDesc.resetToDefault()
          ltiDesc.textDesc.horizontalTextAlignment = gui.TEXT_ALIGNMENT_HORIZONTAL_CENTER
          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().White,"CB Item 1"))
          ltiDesc.textDesc.segments=t
          comboBox.createItem(ltiDesc)

          ltiDesc.resetToDefault()
          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().White,"CB Item 2"))
          ltiDesc.textDesc.segments=t
          comboBox.createItem(ltiDesc)

          ltiDesc.resetToDefault()
          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().White,"CB Item 3"))
          ltiDesc.textDesc.segments=t
          comboBox.createItem(ltiDesc)

          textBoxD.widget_name = "TestTextBox"
          textBoxD.textbox_defaultFontName = "micross.12"
          textBoxD.widget_dimensions = gui.Rect(350,350,100,20)
          textBoxD.textbox_maskText = True
          textBoxD.textbox_maskSymbol = 42
          self.mGUIManager.getActiveSheet().createTextBox(textBoxD)

          tad.widget_name = "TestArea1"
          tad.textarea_defaultFontName = "micross.16"
          tad.widget_dimensions = gui.Rect(575,300,200,200)
          self.mGUIManager.getActiveSheet().createTextArea(tad)

          cd.resetToDefault()
          cd.widget_dimensions = gui.Rect(300,300,200,200)

          vsd.resetToDefault() 
          vsd.widget_name = "TestVSD1" 
          vsd.widget_dimensions = gui.Rect(50,50,15,100) 
          win.createVScrollBar(vsd) 

          vsd.widget_name = "TestVSD2" 
          vsd.vscrollbar_scrollBarButtonLayout = gui.VSCROLL_BAR_BUTTON_LAYOUT_ADJACENT_UP 
          vsd.widget_dimensions = gui.Rect(70,50,15,100) 
          win.createVScrollBar(vsd) 

          vsd.widget_name = "TestVSD3" 
          vsd.vscrollbar_scrollBarButtonLayout = gui.VSCROLL_BAR_BUTTON_LAYOUT_ADJACENT_DOWN 
          vsd.widget_dimensions = gui.Rect(90,50,15,100) 
          win.createVScrollBar(vsd) 

          vsd.widget_name = "TestVSD4" 
          vsd.vscrollbar_scrollBarButtonLayout = gui.VSCROLL_BAR_BUTTON_LAYOUT_MULTIPLE_BOTH 
          vsd.widget_dimensions = gui.Rect(110,50,15,100) 
          win.createVScrollBar(vsd) 

          vsd.widget_name = "TestVSD5" 
          vsd.vscrollbar_scrollBarButtonLayout = gui.VSCROLL_BAR_BUTTON_LAYOUT_MULTIPLE_DOWN 
          vsd.widget_dimensions = gui.Rect(130,50,15,100) 
          win.createVScrollBar(vsd) 

          vsd.widget_name = "TestVSD6" 
          vsd.vscrollbar_scrollBarButtonLayout = gui.VSCROLL_BAR_BUTTON_LAYOUT_MULTIPLE_UP 
          vsd.widget_dimensions = gui.Rect(150,50,15,100) 
          win.createVScrollBar(vsd) 

          vsd.widget_name = "TestVSD7" 
          vsd.vscrollbar_scrollBarButtonLayout = gui.VSCROLL_BAR_BUTTON_LAYOUT_NONE 
          vsd.widget_dimensions = gui.Rect(170,50,15,100) 
          win.createVScrollBar(vsd) 

          hsd.resetToDefault() 
          hsd.widget_name = "TestHSD1" 
          hsd.widget_dimensions = gui.Rect(50,160,100,15) 
          win.createHScrollBar(hsd) 

          progDesc.widget_name = "Prog"
          progDesc.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().White,"Progress Bar"))
          progDesc.textDesc.horizontalTextAlignment = gui.TEXT_ALIGNMENT_HORIZONTAL_CENTER
          progDesc.widget_dimensions = gui.Rect(100,400,200,35)
          progDesc.progressbar_fillDirection = gui.PROGRESSBAR_FILLS_POSITIVE_TO_NEGATIVE
          progDesc.progressbar_clippingEdge = gui.PROGRESSBAR_CLIP_RIGHT_TOP
          progDesc.progressbar_layout = gui.PROGRESSBAR_LAYOUT_VERTICAL
          self.mGUIManager.getActiveSheet().createProgressBar(progDesc)

          bd.resetToDefault()
          bd.widget_name = "Minus"
          bd.widget_dimensions = gui.Rect(100,440,100,35)
          bd.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Green,"Minus"))
          bd.textDesc.horizontalTextAlignment = gui.TEXT_ALIGNMENT_HORIZONTAL_CENTER
          minus = self.mGUIManager.getActiveSheet().createButton(bd)
          
          minus.addWidgetEventHandler(gui.WIDGET_EVENT_MOUSE_BUTTON_UP,self.MakeCallback (self.test1) )

          bd.widget_name = "Plus"
          bd.widget_dimensions = gui.Rect(200,440,100,35)
          bd.textDesc.segments.append(gui.TextSegment("micross.12",Ogre.ColourValue().Green,"Plus"))
          plus = self.mGUIManager.getActiveSheet().createButton(bd)
          
          plus.addWidgetEventHandler(gui.WIDGET_EVENT_MOUSE_BUTTON_UP,self.MakeCallback (self.test2) )

          listDesc.widget_name = "TestList"
          listDesc.widget_dimensions = gui.Rect(330,400,200,100)
          listDesc.list_listItemHeight = 20
          listDesc.list_supportMultiSelect = True
          list_ = self.mGUIManager.getActiveSheet().createList(listDesc)
          
          ## PythonOgre change - we don't have a clear() function on vectors so have
          ## to create a new one each time
          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().White,"Item 1"))
          ltiDesc.textDesc.segments= t
          list_.createItem(ltiDesc)

          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().Green,"Item 2"))
          ltiDesc.textDesc.segments=t
          list_.createItem(ltiDesc)

          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().Red,"Item 3"))
          ltiDesc.textDesc.segments=t
          list_.createItem(ltiDesc)

          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().Blue,"Item 4"))
          ltiDesc.textDesc.segments=t
          list_.createItem(ltiDesc)

          t =gui.VectorTextSegment()
          t.append(gui.TextSegment("micross.12",Ogre.ColourValue().Black,"Item 5"))
          ltiDesc.textDesc.segments=t
          list_.createItem(ltiDesc)

          cbd.widget_name = "TestCheckBox"
          cbd.widget_dimensions.size = gui.Size(25,25)
          cbd.widget_dimensions.position = gui.Point(250,350)
          self.mGUIManager.getActiveSheet().createCheckBox(cbd)
          
        self.mGUIManager.setActiveSheet(self.mSheet);
        
        if False:
            pd = dm.getDefaultPanelDesc()
            pd.resetToDefault()
            pd.widget_name = "AnimationViewerControlPanel"
            pd.widget_dimensions = gui.Rect(0,450,600,150)
            pd.containerwidget_supportScrollBars = False
            self.mControlPanel = self.mSheet.createPanel(pd)
            # CREATE IMAGES
            self.mGridMaterial = "AnimationViewer.Grid.Material"
            self.mDefaultCameraRTTName = "AnimationViewer.DefaultCam.RTT"
            self.mSideCameraRTTName = "AnimationViewer.SideCam.RTT"
            self.mTopCameraRTTName = "AnimationViewer.TopCam.RTT"
            self.mFrontCameraRTTName = "AnimationViewer.FrontCam.RTT"
            
            id = dm.getDefaultImageDesc()
            id.resetToDefault()
            id.image_updateEveryFrame = True
            id.widget_name = "TopView"
            id.image_imageName = self.mTopCameraRTTName
            id.widget_dimensions.size = gui.Size(300,225)
            self.mTopViewImage = self.mSheet.createImage(id)

            id.widget_name = "SideView"
            id.widget_dimensions.position = gui.Point(300,0)
            id.image_imageName = self.mSideCameraRTTName
            self.mSideViewImage = self.mSheet.createImage(id)

            id.widget_name = "FrontView"
            id.widget_dimensions.position = gui.Point(0,225)
            id.image_imageName = self.mFrontCameraRTTName
            self.mFrontViewImage = self.mSheet.createImage(id)

            id.widget_name = "PerspectiveView"
            id.widget_dimensions.position = gui.Point(300,225)
            id.image_imageName = self.mDefaultCameraRTTName
            self.mPerspectiveViewImage = self.mSheet.createImage(id)