From: <spo...@us...> - 2008-05-31 21:57:03
|
Revision: 907 http://opengate.svn.sourceforge.net/opengate/?rev=907&view=rev Author: spom_spom Date: 2008-05-31 14:57:05 -0700 (Sat, 31 May 2008) Log Message: ----------- Add Drag&Drop for resources, e.g. you can add an object to the scene by dragging a mesh from resource tree to a node on the scene tree, Fix camera movement Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/plugins.cfg branches/ogEditor/propgridtest.py branches/ogEditor/resources.cfg branches/ogEditor/src/ObjectInspectorPanels.py branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/PropertyGrid.py branches/ogEditor/src/ResourceTreePane.py Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/ogEditor.py 2008-05-31 21:57:05 UTC (rev 907) @@ -108,7 +108,109 @@ opengateNode = tree.AppendItem( node, "Opengate" ) tree.SetPyData( opengateNode, self ) +class DropData(wx.CustomDataObject): + def __init__(self): + wx.CustomDataObject.__init__(self, wx.CustomDataFormat("MyDropData")) + #self.setObject(None) + + def setObject(self, obj): + print "drag data: ", obj +# global val is weird maybee using pyPickle/cpickle or something smarter + global dndObj__ + dndObj__=obj + self.SetData( "dndObj" ) + def getObject(self): + print "drop data: ", dndObj__ + return dndObj__ + +class MyDropTarget(wx.PyDropTarget): + def __init__(self, tree): + wx.PyDropTarget.__init__(self) + self._makeObjects() + self.tree = tree + self.selections=[] + + def _makeObjects(self): + self.data = DropData() + self.fileObject = wx.FileDataObject() + comp = wx.DataObjectComposite() + comp.Add(self.data) + comp.Add(self.fileObject) + self.comp = comp + self.SetDataObject(comp) + + def _saveSelection(self): + self.selections = self.tree.GetSelections() + self.tree.UnselectAll() + + def _restoreSelection(self): + self.tree.UnselectAll() + for i in self.selections: + self.tree.SelectItem(i) + self.selections=[] + + def OnEnter(self, x, y, d): + self._saveSelection() + return d + + def OnLeave(self): + self._restoreSelection() + + def OnDrop(self, x, y): + self._restoreSelection() + #item, flags = self.tree.HitTest((x, y)) + + print "got an drop event at", x, y + return True + + def OnDragOver(self, x, y, d): + # provide visual feedback by selecting the item the mouse is over + print x ,y, d + item, flags = self.tree.HitTest(wx.Point(x,y)) + print item, flags + selections = self.tree.GetSelections() + if item: + if selections != [item]: + self.tree.UnselectAll() + self.tree.SelectItem(item) + elif selections: + self.tree.UnselectAll() + + # The value returned here tells the source what kind of visual + # feedback to give. For example, if wxDragCopy is returned then + # only the copy cursor will be shown, even if the source allows + # moves. You can use the passed in (x,y) to determine what kind + # of feedback to give. In this case we return the suggested value + # which is based on whether the Ctrl key is pressed. + return d + + # Called when OnDrop returns True. We need to get the data and + # do something with it. + def OnData(self, x, y, d): + if self.GetData(): + obj = self.data.getObject() + + if obj: + print "item: ", obj, + + item, flags = self.tree.HitTest(wx.Point(x,y)) + if item: + print "dropped on item:", self.tree.GetItemText(item) + #print type( self.tree.GetPyData( item ) ) + #print type( obj ) + if ( type( self.tree.GetPyData( item ) ) == ogre.SceneNode ) and ( type( obj ) == ogre.Mesh ): + print "add mesh" + self.tree.parent_.createObject( obj.getName(), obj.getName(), self.tree.GetPyData( item ) ) + else: + print "dropped nowhere" + + self._makeObjects() # reset data objects.. + + return d # what is returned signals the source what to do + # with the original data (move, copy, etc.) In this + # case we just return the suggested value given to us. + class OGEditorPane: def __init__( self, ID, Name, mbShortcut, creator, defaultCheck ): self.ID_ = ID @@ -128,9 +230,9 @@ ws = WorkSpace self.allPanes = [] self.allPanes.append( OGEditorPane( ID_MB_VIEW_SCENETREE, NAME_SCENETREE, "\tF1", None, True ) ) - self.allPanes.append( OGEditorPane( ID_MB_VIEW_OBJECT, NAME_OBJECT , "\tF2", None, True ) ) - self.allPanes.append( OGEditorPane( ID_MB_VIEW_RESOURCE, NAME_RESOURCE , "\tF3", None, False ) ) - self.allPanes.append( OGEditorPane( ID_MB_VIEW_MATERIAL, NAME_MATERIAL , "\tF4", None, True ) ) + self.allPanes.append( OGEditorPane( ID_MB_VIEW_OBJECT, NAME_OBJECT , "\tF2", None, False ) ) + self.allPanes.append( OGEditorPane( ID_MB_VIEW_RESOURCE, NAME_RESOURCE , "\tF3", None, True ) ) + self.allPanes.append( OGEditorPane( ID_MB_VIEW_MATERIAL, NAME_MATERIAL , "\tF4", None, False ) ) self.allPanes.append( OGEditorPane( ID_MB_VIEW_PYCRUST, NAME_PYCRUST , "\tF9", None, False ) ) self.initMenuBar_() @@ -249,7 +351,7 @@ CT.TR_HAS_VARIABLE_ROW_HEIGHT | wx.WANTS_CHARS | wx.TR_TWIST_BUTTONS ) self.sceneTree.SetConnectionPen( wx.Pen( wx.Colour(100,100,100), 1, wx.SOLID) ) #self.sceneTree.SetFont( wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.TR_DEFAULT_STYLE, wx.FONTWEIGHT_NORMAL ) ) - #self.sceneTree.SetFont( wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL ) ) + self.sceneTree.SetFont( wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL ) ) il = wx.ImageList(12, 12) self.SceneNodeIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_GO_FORWARD, wx.ART_TOOLBAR, ( 12, 12 ) ) ) @@ -257,7 +359,9 @@ self.SceneUnknownIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_QUESTION, wx.ART_TOOLBAR, ( 12, 12 ) ) ) self.sceneTree.AssignImageList( il ) - + + self.sceneTree.SetDropTarget( MyDropTarget( self.sceneTree ) ) + self.Bind( wx.EVT_TREE_SEL_CHANGED, self.doSelectTreeObject, self.sceneTree ) self.Bind( CT.EVT_TREE_ITEM_CHECKED, self.doCheckTreeObject, self.sceneTree ) #EVT_TREE_ITEM_CHECKING @@ -275,6 +379,9 @@ self.resourceTree = ResourceTreePane( self, -1, wx.Point( 0, 0 ), wx.Size( 160, 250 ), wx.TR_DEFAULT_STYLE | wx.NO_BORDER ); self.Bind( wx.EVT_TREE_SEL_CHANGED, self.doSelectTreeObject, self.resourceTree ) + self.resourceTree.Bind( wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag ) + self.resourceTree.Bind( wx.EVT_TREE_BEGIN_RDRAG, self.OnBeginRDrag ) + self.resourceTree.Bind( wx.EVT_TREE_END_DRAG, self.OnEndDrag ) return self.resourceTree def setDefaultProperties_( self ): @@ -318,12 +425,49 @@ self.auiMgr.Update() event.Skip() + + def OnBeginDrag( self, event = None ): + print "OnBeginDrag", event + obj = event.GetEventObject().GetPyData( event.GetEventObject().GetSelection() ) + if obj: + dd=DropData() + dd.setObject( obj ) + comp = wx.DataObjectComposite() + comp.Add( dd ) + dropSource = wx.DropSource(self) + dropSource.SetData( comp ) + result = dropSource.DoDragDrop(wx.Drag_AllowMove) + else: + print "this is not dragable" + def OnBeginRDrag( self, event = None ): + print "OnBeginRDrag", event + print item.GetWindow() + if item: + event.Allow() + + def OnEndDrag( self, event = None ): + print "OnEndDrag", event + #event.GetEventObject().Layout() + event.GetEventObject().RefreshSubtree( event.GetEventObject().root_ ) + #print item + def doSelectTreeObject( self, event ): obj = event.GetEventObject().GetPyData( event.GetEventObject().GetSelection() ) if type( obj ) == ogre.SceneNode: - self.ogreRenderWindow.camera.lookAt( obj.getWorldPosition() ) + #targetDir = ( obj.getWorldPosition()- self.ogreRenderWindow.sceneEntities.cameraNode.getWorldPosition() ).normalisedCopy() + #camDir = self.ogreRenderWindow.sceneEntities.cameraNode.getWorldOrientation() * ogre.Vector3.NEGATIVE_UNIT_Z + #camDir.normalise() + #rot = camDir.getRotationTo( targetDir ); + #rot.normalise() + #self.ogreRenderWindow.sceneEntities.cameraNode.rotate( rot ) + #print targetDir, camDir + #print self.ogreRenderWindow.sceneEntities.cameraNode.getWorldOrientation() * ogre.Vector3.NEGATIVE_UNIT_Z + #quat = self.ogreRenderWindow.sceneEntities.cameraNode.getOrientation() + #print (quat * rot)*ogre.Vector3.NEGATIVE_UNIT_Z + self.ogreRenderWindow.sceneEntities.cameraNode.lookAt( obj.getWorldPosition(), ogre.Node.TS_WORLD ); + #self.ogreRenderWindow.camera.setDirection( targetDir ) if type( obj ) == ogre.Material: self.materialInspector.showData( obj ); @@ -353,9 +497,14 @@ # utils ################################################################################# - def createObject( self, name, meshname ): + def createObject( self, name, meshname, rootNode = None ): sceneManager = self.ogreRenderWindow.sceneManager; - node = sceneManager.getRootSceneNode().createChildSceneNode( name ); + + if not rootNode: + node = sceneManager.getRootSceneNode().createChildSceneNode( name ); + else: + node = rootNode.createChildSceneNode( name ); + entity = sceneManager.createEntity( name, meshname ); node.attachObject( entity ); self.UpdateSceneGraphEvent(); Modified: branches/ogEditor/plugins.cfg =================================================================== --- branches/ogEditor/plugins.cfg 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/plugins.cfg 2008-05-31 21:57:05 UTC (rev 907) @@ -2,18 +2,18 @@ ## Use this for Windows # Define plugin folder -PluginFolder=c:\PythonOgre/plugins -Plugin=RenderSystem_GL.dll -Plugin=RenderSystem_Direct3D9.dll -Plugin=Plugin_ParticleFX.dll +#PluginFolder=c:\PythonOgre/plugins +#Plugin=RenderSystem_GL.dll +#Plugin=RenderSystem_Direct3D9.dll +#Plugin=Plugin_ParticleFX.dll #Plugin=Plugin_BSPSceneManager.dll #Plugin=Plugin_OctreeSceneManager.dll -Plugin=Plugin_CgProgramManager.dll +#Plugin=Plugin_CgProgramManager.dll ## NOTE use this for MacOS or Linux -#PluginFolder=/usr/lib/OGRE -#Plugin=RenderSystem_GL -#Plugin=Plugin_ParticleFX +PluginFolder=/usr/lib/OGRE +Plugin=RenderSystem_GL +Plugin=Plugin_ParticleFX #Plugin=Plugin_BSPSceneManager #Plugin=Plugin_OctreeSceneManager -#Plugin=Plugin_CgProgramManager +Plugin=Plugin_CgProgramManager Modified: branches/ogEditor/propgridtest.py =================================================================== --- branches/ogEditor/propgridtest.py 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/propgridtest.py 2008-05-31 21:57:05 UTC (rev 907) @@ -34,6 +34,8 @@ self.propertyGrid.appendRowItemSlider( "slider", cback = test.printValue, toolTip = "toolTip" ) self.propertyGrid.appendRowItemColourSelect( "Colour", cback = test.printValue, toolTip = "toolTip" ) + self.propertyGrid.appendRowItemVector3( "scale", cback = test.printValue, toolTip = "vector3 property " ) + collpane = self.propertyGrid.createAndAppendPane( "Child 1", toolTip = "toolTip" ) collpane.appendRowItemName( "Child 1 A", "name", toolTip = "toolTip" ) collpane.appendRowItemName( "Child 1 B", "name", toolTip = "toolTip" ) Modified: branches/ogEditor/resources.cfg =================================================================== --- branches/ogEditor/resources.cfg 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/resources.cfg 2008-05-31 21:57:05 UTC (rev 907) @@ -1,28 +1,28 @@ +#[Bootstrap] +#Zip=c:\PythonOgre/demos/media/packs/OgreCore.zip + +#[General] +#FileSystem=c:\PythonOgre/demos/models +#FileSystem=c:\PythonOgre/demos/media +#FileSystem=c:\PythonOgre/demos/media/fonts +#FileSystem=c:\PythonOgre/demos/media/materials/programs +#FileSystem=c:\PythonOgre/demos/media/materials/scripts +#FileSystem=c:\PythonOgre/demos/media/materials/textures +#FileSystem=c:\PythonOgre/demos/media/models +#FileSystem=c:\PythonOgre/demos/media/overlays +#FileSystem=c:\PythonOgre/demos/media/particle +#FileSystem=c:\PythonOgre/demos/media/gui [Bootstrap] -Zip=c:\PythonOgre/demos/media/packs/OgreCore.zip - +Zip=../../../../local/python-ogre/python-ogre/demos/media/packs/OgreCore.zip +# [General] -FileSystem=c:\PythonOgre/demos/models -FileSystem=c:\PythonOgre/demos/media -FileSystem=c:\PythonOgre/demos/media/fonts -FileSystem=c:\PythonOgre/demos/media/materials/programs -FileSystem=c:\PythonOgre/demos/media/materials/scripts -FileSystem=c:\PythonOgre/demos/media/materials/textures -FileSystem=c:\PythonOgre/demos/media/models -FileSystem=c:\PythonOgre/demos/media/overlays -FileSystem=c:\PythonOgre/demos/media/particle -FileSystem=c:\PythonOgre/demos/media/gui -#[Bootstrap] -#Zip=../../../../local/python-ogre/python-ogre/demos/media/packs/OgreCore.zip -# -#[General] -#FileSystem=../../../../local/python-ogre/python-ogre/demos/imemodels -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/fonts -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/programs -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/scripts -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/textures -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/models -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/overlays -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/particle -#FileSystem=../../../../local/python-ogre/python-ogre/demos/media/gui +FileSystem=../../../../local/python-ogre/python-ogre/demos/imemodels +FileSystem=../../../../local/python-ogre/python-ogre/demos/media +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/fonts +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/programs +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/scripts +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/textures +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/models +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/overlays +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/particle +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/gui Modified: branches/ogEditor/src/ObjectInspectorPanels.py =================================================================== --- branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-31 21:57:05 UTC (rev 907) @@ -102,7 +102,7 @@ wx.Panel.__init__(self, *args, **kwds) self.parent_ = parent self.typeStaticText = wx.StaticText(self, -1, "Type") - self.propertyGrid = PropertyMainGrid( self, -1, style=wx.SIMPLE_BORDER ) + self.propertyGrid = PropertyMainGrid( self ) self.__set_properties() self.__do_layout() @@ -205,13 +205,52 @@ def showSceneNode( self, data ): self.typeStaticText.SetLabel( "SceneNode" ) self.showName( data ) - self.propertyGrid.appendRowItemInfo( "world AABB min %s" % toStr( data._getWorldAABB().getMinimum() ) ) + + info1 = self.propertyGrid.appendRowItemInfo( ) + info2 = self.propertyGrid.appendRowItemInfo( ) + info3 = self.propertyGrid.appendRowItemInfo( ) + info4 = self.propertyGrid.appendRowItemInfo( ) + info5 = self.propertyGrid.appendRowItemInfo( ) + + def updateInfo(): + info1.setInfo( "world AABB min %s" % toStr( data._getWorldAABB().getMinimum() ) ) + info2.setInfo( "world AABB max %s" % toStr( data._getWorldAABB().getMaximum() ) ) + info3.setInfo( "world size %s" % toStr(data._getWorldAABB().getMaximum()-data._getWorldAABB().getMinimum() ) ) + info4.setInfo( "world position %s" % toStr(data.getWorldPosition() ) ) + info5.setInfo( "scale %s" % toStr( data.getScale() ) ) + + + updateInfo() - self.propertyGrid.appendRowItemInfo( "world AABB max %s" % toStr( data._getWorldAABB().getMaximum() ) ) - self.propertyGrid.appendRowItemInfo( "world size %s" % toStr(data._getWorldAABB().getMaximum()-data._getWorldAABB().getMinimum() ) ) + #self.propertyGrid.appendRowItemSlider( "yaw", start = -180, end = 180, format = FORMAT_INT, cback = yaw ) + #self.propertyGrid.appendRowItemSlider( "pitch", cback = data.pitch ) + #self.propertyGrid.appendRowItemSlider( "roll", cback = data.roll ) - self.propertyGrid.appendRowItemInfo( "world position %s" % toStr(data.getWorldPosition() ) ) - self.propertyGrid.appendRowItemInfo( "scale %s" % toStr( data.getScale() ) ) + def getPosition( ): + val = [0.0, 0.0, 0.0] + val[0] = data.getPosition().x; + val[1] = data.getPosition().y; + val[2] = data.getPosition().z; + return val + + def setPosition( val ): + data.setPosition( val[0], val[1], val[2] ); + updateInfo() + + self.propertyGrid.appendRowItemVector3( "position", minVal = -65500, maxVal = 65500, cfront = getPosition, cback = setPosition ) + + def getScale( ): + scale = [1.0, 1.0, 1.0] + scale[0] = data.getScale().x; + scale[1] = data.getScale().y; + scale[2] = data.getScale().z; + return scale + + def setScale( val ): + data.setScale( val[0], val[1], val[2] ); + updateInfo() + + self.propertyGrid.appendRowItemVector3( "scale", minVal = 0, maxVal = 65500, cfront = getScale, cback = setScale ) #getWorldOrientation #getOrientation @@ -268,6 +307,11 @@ else: print "data is no material", data + def save( self, filename ): + matSerializer = ogre.MaterialSerializer(); + matSerializer.exportMaterial( self.material_, filename ) + #, bool exportDefaults=false, const bool includeProgDef=false, const String &programFilename="") + def showPass( self, data, parenpane ): collpane = parenpane.createAndAppendPane( "Pass " + data.getName() ) @@ -411,8 +455,12 @@ self.showPass( data.getPass( i ), collpane ) def showMaterial( self, data ): + self.material_ = data; + self.typeStaticText.SetLabel( "Material" ) self.showResource( data ) - self.typeStaticText.SetLabel( "Material" ) + self.propertyGrid.appendRowItemFileSelect("save", cback= self.save, toolTip = "Save the material script" , + wildcard = "*.material" ) + nTechniques = data.getNumTechniques() for i in range(0,nTechniques): self.showTechnique( data.getTechnique( i ) ) \ No newline at end of file Modified: branches/ogEditor/src/OgreWindowWx.py =================================================================== --- branches/ogEditor/src/OgreWindowWx.py 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/src/OgreWindowWx.py 2008-05-31 21:57:05 UTC (rev 907) @@ -111,7 +111,7 @@ self.ogreRoot.initialise(False) # tempory condition until code cleaning - tmpLinux = False; + tmpLinux = True; if tmpLinux: lastValid = self.parent parent = lastValid @@ -209,12 +209,10 @@ # create the camera nodes & attach camera cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( self.camera.getName(), ogre.Vector3( 0, 0, 0 ) ) - pitchNode = cameraNode.createChildSceneNode( cameraNode.getName() + "/PitchNode" ) - pitchNode.attachObject( self.camera ) + cameraNode.attachObject( self.camera ) self.sceneEntities.camera = self.camera self.sceneEntities.cameraNode = cameraNode - self.sceneEntities.cameraPitchNode = pitchNode def _CreateViewport(self): "create a Viewport" @@ -274,5 +272,5 @@ self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 5.0 ), ogre.Node.TS_LOCAL ) self.sceneEntities.cameraNode.pitch( ogre.Degree( dy / 5.0 ), ogre.Node.TS_LOCAL ) - #self.sceneEntities.cameraPitchNode.pitch( ogre.Degree( dy / 3.0 ), ogre.Node.TS_LOCAL ) + event.Skip() Modified: branches/ogEditor/src/PropertyGrid.py =================================================================== --- branches/ogEditor/src/PropertyGrid.py 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/src/PropertyGrid.py 2008-05-31 21:57:05 UTC (rev 907) @@ -2,7 +2,10 @@ import string import wx.combo import wx.lib.colourselect as csel +import wx.lib.scrolledpanel as scrolled +import PyCollapsiblePane as PCP + FORMAT_INT=0 FORMAT_FLOAT=1 FORMAT_LOG10=2 @@ -213,8 +216,7 @@ self.parent_ = parent self.sizer_ = wx.BoxSizer( wx.HORIZONTAL ) - self.labelTextCtrl_ = wx.TextCtrl( parent, -1, name, - style = wx.NO_BORDER | wx.ALIGN_LEFT ) + self.labelTextCtrl_ = wx.TextCtrl( parent, -1, name, style = wx.NO_BORDER | wx.ALIGN_LEFT ) if toolTip: self.labelTextCtrl_.SetToolTip( wx.ToolTip( toolTip ) ) @@ -243,6 +245,9 @@ self.labelTextCtrl_.SetEditable( False ) self.sizer_.Add( self.labelTextCtrl_, 1, wx.EXPAND | wx.ALIGN_RIGHT ) + def setInfo( self, txt ): + self.labelTextCtrl_.SetValue( txt ) + class PropertyRowItemName( PropertyRowItem ): valueTextCtrl_ = None format_ = None @@ -342,7 +347,7 @@ self.fileSelectButton.Bind( wx.EVT_BUTTON, self.OnButton ) def OnButton( self, event): - dlg = wx.FileDialog( self.parent, message="Choose a file", + dlg = wx.FileDialog( self.parent_, message="Choose a file", defaultDir=os.getcwd(), defaultFile="", wildcard=self.wildcard, @@ -488,6 +493,57 @@ if self.cback_ != None: self.cback_( self.value ) +class PropertyRowItemVector3( PropertyRowItem ): + def __init__( self, parent, name, value = [ 0.0, 0.0, 0.0 ], minVal = 0, maxVal = 100, cfront = None, cback = None, toolTip = None ): + PropertyRowItem.__init__( self, parent, name, cback = cback, toolTip = toolTip ) + self.cfront_ = cfront + + self.value_ = value + if self.cfront_: + self.value_ = self.cfront_() + + self.spinX_ = wx.SpinCtrl( parent, -1, size = (50, self.rowHeight_), style = wx.NO_BORDER | wx.NO_3D | wx.TAB_TRAVERSAL ) + self.spinX_.SetRange( minVal, maxVal ) + self.spinX_.SetValue( self.value_[ 0 ] ); + + self.spinY_ = wx.SpinCtrl( parent, -1, size = (50, self.rowHeight_), style = wx.NO_BORDER | wx.NO_3D | wx.TAB_TRAVERSAL ) + self.spinY_.SetRange( minVal, maxVal ) + self.spinY_.SetValue( self.value_[ 1 ] ); + + self.spinZ_ = wx.SpinCtrl( parent, -1, size = (50, self.rowHeight_), style = wx.NO_BORDER | wx.NO_3D | wx.TAB_TRAVERSAL ) + self.spinZ_.SetRange( minVal, maxVal ) + self.spinZ_.SetValue( self.value_[ 2 ] ); + + #self.spin.SetRange(1, 100) + #self.spin.SetValue(1) + self.sizer_.Add( self.spinX_, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.sizer_.Add( self.spinY_, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.sizer_.Add( self.spinZ_, 1, wx.EXPAND | wx.ALIGN_LEFT ) + + self.spinX_.Bind(wx.EVT_SPINCTRL, self.OnSpinX ) + self.spinY_.Bind(wx.EVT_SPINCTRL, self.OnSpinY ) + self.spinZ_.Bind(wx.EVT_SPINCTRL, self.OnSpinZ ) + + def OnSpinX( self, event = None): + if event: + self.value_[ 0 ] = event.GetInt() + self.applyValue( True ) + + def OnSpinY( self, event = None): + if event: + self.value_[ 1 ] = event.GetInt() + self.applyValue( True ) + + def OnSpinZ( self, event = None): + if event: + self.value_[ 2 ] = event.GetInt() + self.applyValue( True ) + + def applyValue( self, update = True ): + if update: + if self.cback_: + self.cback_( self.value_ ) + class PropertyRowItemChoice( PropertyRowItem ): def __init__( self, parent, name, value = None, itemList = None, itemMap = None, cback = None, toolTip = None): PropertyRowItem.__init__( self, parent, name, cback = cback, toolTip = toolTip ) @@ -605,7 +661,7 @@ rowsizer.Add( row.sizer_, 1, wx.EXPAND ) self.sizer_.Add( rowsizer, 0, wx.EXPAND ) - def appendRowItemInfo(self, name, toolTip = None): + def appendRowItemInfo(self, name = "Not assigned", toolTip = None): item = PropertyRowItemInfo( self.pane, name, toolTip = toolTip ) self.appendRow( item ) return item @@ -645,6 +701,12 @@ self.appendRow( item ) return item + def appendRowItemVector3( self, name, value = [ 0.0, 0.0, 0.0 ], minVal = 0, maxVal = 100, + cfront = None, cback = None, toolTip = None ): + item = PropertyRowItemVector3( self.pane, name, value = value, minVal = minVal, maxVal = maxVal, cfront = cfront, cback = cback, toolTip = toolTip ) + self.appendRow( item ) + return item + def appendRowItemColourSelect( self, name, cback = None, toolTip = None ): item = PropertyRowItemColourSelect( self.pane, name, cback = cback, toolTip = toolTip ) self.appendRow( item ) @@ -669,16 +731,20 @@ return pane -#class PropertyPaneItem( wx.Panel, PropertyGrid ): class PropertyPaneItem( wx.CollapsiblePane, PropertyGrid ): +#class PropertyPaneItem( PCP.PyCollapsiblePane, PropertyGrid ): def __init__(self, parent, name, toolTip = None): - self.parent_ = parent + self.name_ = name + self.parent_ = parent if issubclass( type( parent ), PropertyPaneItem ): parentWin = self.parent_.GetPane() else: parentWin = self.parent_ - wx.CollapsiblePane.__init__( self, parentWin, -1, name, style = wx.CP_DEFAULT_STYLE | wx.CP_NO_TLW_RESIZE ) + wx.CollapsiblePane.__init__( self, parentWin, -1, name, style = wx.CP_DEFAULT_STYLE | + wx.CP_NO_TLW_RESIZE ) + #PCP.PyCollapsiblePane.__init__( self, parentWin, -1, name, style = wx.CP_DEFAULT_STYLE | + #wx.CP_NO_TLW_RESIZE | PCP.CP_GTK_EXPANDER ) #wx.Panel.__init__( self, parent, -1 ) if toolTip: self.SetToolTip( wx.ToolTip( toolTip ) ) @@ -698,10 +764,13 @@ def OnPaneChanged(self, event = None): if ( issubclass( type( self.parent_ ), PropertyPaneItem ) ): + print self.parent_.name_ self.parent_.Collapse( ) +# self.parent_.Layout() self.parent_.Expand( ) + # self.parent_.Layout() - self.GetParent().Layout() + self.GetParent().GetParent().GetParent().Layout() class PropertyPaneItemColour( PropertyPaneItem ): @@ -750,17 +819,23 @@ self.cback( map(lambda x: x / self.scale, self.value) ) -class PropertyMainGrid( wx.Panel, PropertyGrid ): - def __init__(self, *argc, **argv): - argv["style"] = wx.TAB_TRAVERSAL - wx.Panel.__init__(self, *argc, **argv) +class PropertyMainGrid( wx.PyScrolledWindow, PropertyGrid ): + def __init__(self, parent, id = -1, pos = (0,0), size= wx.DefaultSize): + #argv["style"] = wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL + + wx.PyScrolledWindow.__init__( self, parent, id, pos, size, style = wx.SUNKEN_BORDER | wx.HSCROLL | wx.VSCROLL | wx.TAB_TRAVERSAL) + + self.SetVirtualSize( (30,20)) + self.SetScrollRate(20,20) + + #wx.PyScrolledWindow.__init__(self, parent, id, pos, size, style|wx.HSCROLL|wx.VSCROLL, name) PropertyGrid.__init__(self) self.SetSizer( self.sizer_ ) self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) #self.SetBackgroundColour( wx.Colour(200, 200, 200) ) - self.pane = self + self.pane = self def clean( self ): self.sizer_.Clear( True ) Modified: branches/ogEditor/src/ResourceTreePane.py =================================================================== --- branches/ogEditor/src/ResourceTreePane.py 2008-05-25 14:21:26 UTC (rev 906) +++ branches/ogEditor/src/ResourceTreePane.py 2008-05-31 21:57:05 UTC (rev 907) @@ -7,6 +7,7 @@ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TR_DEFAULT_STYLE, ctstyle=0, validator=wx.DefaultValidator, name="MyCustomTreeCtrl"): + self.parent_ = parent CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle, validator, name) def OnInternalIdle(self): @@ -14,14 +15,15 @@ CT.CustomTreeCtrl.OnInternalIdle( self ) -class ResourceTreePane( MyCustomTree ): +class ResourceTreePane( CT.CustomTreeCtrl ): def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TR_DEFAULT_STYLE, ctstyle=0, validator=wx.DefaultValidator, name="MyCustomTreeCtrl"): + self.parent_ = parent CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle, validator, name) CT.CustomTreeCtrl.SetConnectionPen( self, wx.Pen( wx.Colour(100,100,100), 1, wx.SOLID) ) - #CT.CustomTreeCtrl.SetFont( self, wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.TR_DEFAULT_STYLE, wx.FONTWEIGHT_NORMAL ) ) + CT.CustomTreeCtrl.SetFont( self, wx.Font( 8, wx.FONTFAMILY_DEFAULT, wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL ) ) def OnInternalIdle(self): wx.PyScrolledWindow.OnInternalIdle( self ) @@ -53,7 +55,8 @@ resManIter.getNext() - + + ## Insert resources sorted by resource groups resGroupManNode = self.addItem( root, "Ogre resource groups", ogreResourceGroupManager ) resGroups = ogreResourceGroupManager.getResourceGroups( ) @@ -64,7 +67,21 @@ for i in range( 0, len( resGroups ) ): resGroupName = resGroups[ i ] resGroupNode = self.addItem( resGroupManNode, resGroupName, None ) + + resManIter = ogreResourceGroupManager.getResourceManagerIterator() + while resManIter.hasMoreElements(): + resManNodeIter = self.addItem( resGroupNode, resManIter.peekNextKey(), resManIter.peekNextValue() ) + resIter = resManIter.peekNextValue().getResourceIterator() + + while resIter.hasMoreElements(): + if resIter.peekNextValue().getGroup() == resGroupName: + self.addItem( resManNodeIter, resIter.peekNextValue().getName(), resIter.peekNextValue() ) + + resIter.getNext() + resManIter.getNext() + + #ogResourceManager = og.ResourceManager.getSingleton() #if ogResourceManager: #resLocNode = self.addItem( resGroupNode, "Resource group locations", None ) @@ -75,11 +92,11 @@ #self.addItem( resLocNode, resLocation, None ) ## Insert resources for each groups - resNameNode = self.addItem( resGroupNode, "Resources", None ) - resNameList = ogre.ResourceGroupManager.getSingleton().listResourceNames( resGroupName ) - for j in range( 0, len( resNameList ) ): - res = resNameList[ j ] - self.addItem( resNameNode, res, None ); + #resNameNode = self.addItem( resGroupNode, "Resources", None ) + #resNameList = ogre.ResourceGroupManager.getSingleton().listResourceNames( resGroupName ) + #for j in range( 0, len( resNameList ) ): + #res = resNameList[ j ] + #self.addItem( resNameNode, res, None ); # insert Opengate specific resources This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |