From: <spo...@us...> - 2008-05-18 19:50:16
|
Revision: 899 http://opengate.svn.sourceforge.net/opengate/?rev=899&view=rev Author: spom_spom Date: 2008-05-18 12:29:16 -0700 (Sun, 18 May 2008) Log Message: ----------- Add opengate python bindings for the opengate editor Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/plugins.cfg branches/ogEditor/resources.cfg Added Paths: ----------- branches/ogEditor/Makefile branches/ogEditor/build.sh branches/ogEditor/environment.py branches/ogEditor/generate_code.py branches/ogEditor/generated/ branches/ogEditor/hand_made_wrappers.py branches/ogEditor/ogtest.py branches/ogEditor/python_ogre_masterlist.h branches/ogEditor/python_opengate.h branches/ogEditor/python_opengate_aliases.h branches/ogEditor/python_opengate_sizeof.h branches/ogEditor/src/ branches/ogEditor/src/ObjectInspectorPanels.py branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/PropertyGrid.py branches/ogEditor/src/PythonOgreConfig.py branches/ogEditor/src/ResourceTreePane.py Removed Paths: ------------- branches/ogEditor/ObjectInspectorPanels.py branches/ogEditor/OgreWindowWx.py branches/ogEditor/PropertyGrid.py branches/ogEditor/PythonOgreConfig.py branches/ogEditor/ResourceTreePane.py Added: branches/ogEditor/Makefile =================================================================== --- branches/ogEditor/Makefile (rev 0) +++ branches/ogEditor/Makefile 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,34 @@ +BOOSTINC=-I /usr/include/boost +PYTHONINC=-I /usr/include/python2.5 +OGREINC=`pkg-config --cflags OGRE gtk+-2.0 ogreopcode` +OPENGATEINC=-I $(HOME)/local/opengate/trunk/src + +BOOSTLIB=-L /usr/lib64 -lboost_python +EXTLIB=/usr/lib64/libCEGUIOgreRenderer.so -L/var/tmp/portage/media-libs/devil-1.6.7-r2/work/DevIL-1.6.7/src-IL/src -L/usr/lib64 /usr/lib64/libCEGUIBase.so /usr/lib64/libpcre.so -lbz2 -lxerces-c /usr/lib64/libalut.so /usr/lib64/libopenal.so /usr/lib64/libvorbisfile.so /usr/lib64/libvorbis.so -lm /usr/lib64/libogg.so /usr/lib64/libOIS.so -L/usr/X11R6/lib /usr/lib64/libopcode.so /usr/lib64/libogreopcode.so /usr/lib64/libOgreMain.so /usr/lib64/libzzip.so /usr/lib64/libgtk-x11-2.0.so /usr/lib64/libgdk-x11-2.0.so /usr/lib64/libatk-1.0.so /usr/lib64/libgdk_pixbuf-2.0.so /usr/lib64/libpangocairo-1.0.so /usr/lib64/libpangoft2-1.0.so /usr/lib64/libpango-1.0.so /usr/lib64/libcairo.so /usr/lib64/libfontconfig.so /usr/lib64/libfreetype.so /usr/lib64/libexpat.so /usr/lib64/libXrender.so /usr/lib64/libgobject-2.0.so /usr/lib64/libgmodule-2.0.so /usr/lib64/libglib-2.0.so /usr/lib64/libX11.so /usr/lib64/libXau.so /usr/lib64/libXdmcp.so -lXaw /usr/lib64/libILU.so /usr/lib64/libIL.so -lCg /usr/lib64/libpng12.so /usr/lib64/libtiff.so /usr/lib64/libjpeg.so -lpthread -lz -ldl -lboost_thread -lboost_regex + +OGREGEN=-I /home/carsten/local/python-ogre/python-ogre/generated/ogre_1.4/ +TARGET=opengate +COPT=-Os -fPIC + +#CONTAINERSUITE= -I ./indexing_suite_v2 + +CPPCFILES = $(wildcard generated/*.cpp) +OBJECTS = $(patsubst %.cpp,%.o,$(CPPCFILES)) +OPENGATEOBJ=$(wildcard $(HOME)/local/opengate/trunk/src/opengateclient*.o) + +default: $(TARGET) + +.cpp.o: + g++ $(COPT) $(DEFINES) -c -o $(patsubst %.cpp,%.o, $<) -I ./ $(CONTAINERSUITE) $(BOOSTINC) $(OPENGATEINC) $(PYTHONINC) $(OGREGEN) $(OGREINC) $< + +$(TARGET): $(OBJECTS) + g++ -o generated/$(TARGET).so -Wl,-rpath=\/../../lib `pkg-config --libs OGRE` --strip-all -lstdc++ --shared \ + $(OBJECTS) \ + $(BOOSTLIB) \ + $(OPENGATEOBJ) \ + $(EXTLIB) + strip -g -S -d --strip-debug -s generated/$(TARGET).so +clean: + rm -rf generated/* + rm -f *.so + rm -f *.cache Deleted: branches/ogEditor/ObjectInspectorPanels.py =================================================================== --- branches/ogEditor/ObjectInspectorPanels.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/ObjectInspectorPanels.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,214 +0,0 @@ -#!/usr/bin/env python -# -*- coding: ansi_x3.4-1968 -*- -# generated by wxGlade 0.6.2 on Mon Jan 7 21:02:32 2008 - -import wx -import sys - -import PythonOgreConfig -import ogre.renderer.OGRE as ogre - -from PropertyGrid import * - -class PropertyCollapsibleOgreFogPane( PropertyPaneItem ): - def __init__( self, parent, name, object = None ): - PropertyPaneItem.__init__(self, parent, name) - - self.object = object - self.colour = [255, 255, 255, 255] - self.mode = 0 - self.expDensity = 0.01 - self.linearStart = 0.0 - self.linearEnd = 1.0 -# self.fogmodes = {"FOG_NONE" :"No fog. Duh.", -# "FOG_EXP": "Fog density increases exponentially from the camera (fog = 1/e^(distance * density)).", -# "FOG_EXP2": "Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)." -# "FOG_LINEAR": "Fog density increases linearly between the start and end distances."} -# - modes = ((ogre.FOG_NONE, "FOG_NONE"), - (ogre.FOG_EXP, "FOG_EXP"), - (ogre.FOG_EXP2, "FOG_EXP2"), - (ogre.FOG_LINEAR,"FOG_LINEAR")) - - self.m = self.appendRowItemChoice( "Mode", itemMap=modes, cback = self.setMode ) - self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGBA ) - self.min = self.appendRowItemSlider( "linearStart", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMin ) - self.max = self.appendRowItemSlider( "linearEnd", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMax ) - self.exp = self.appendRowItemSlider( "expDensity", 0.0001, 0.01, format = SLIDER_LOG10, cback = self.setExpDens ) - - if object != None: - mode = object.getFogMode() - #self.mode = ogre.mode - col = object.getFogColour() - print col - self.colour = map( lambda x: x * 255.0, [col[0],col[1], col[2], col[3]] ) - self.linearStart = object.getFogStart() - self.linearEnd = object.getFogEnd() - self.expDensity= object.getFogDensity() - - self.applyValues( False ) - - def setMode( self, value ): - self.mode = value - self.applyValues( ) - def setRGBA( self, value ): - self.colour[ 0:3 ] = value - self.applyValues( ) - def setLinMin( self, value ): - self.linearStart = value - self.applyValues( ) - def setLinMax( self, value ): - self.linearEnd = value - self.applyValues( ) - def setExpDens( self, value ): - self.expDensity = value - self.applyValues( ) - - def applyValues(self, update = True): - self.m.setValue( self.mode ) - self.c.setValue( self.colour ) - self.min.setValue( self.linearStart ) - self.max.setValue( self.linearEnd ) - self.exp.setValue( self.expDensity ) - - if update == True: - if self.object != None: - col = map( lambda x: x / 255.0, self.colour ) - self.object.setFog(self.mode, col, self.expDensity, self.linearStart, self.linearEnd ) - -class ObjectInspectorPanel(wx.Panel): - def __init__(self, *args, **kwds): - kwds["style"] = wx.TAB_TRAVERSAL - wx.Panel.__init__(self, *args, **kwds) - self.typeStaticText = wx.StaticText(self, -1, "Type") - self.propertyGrid = PropertyMainGrid( self, -1, style=wx.SIMPLE_BORDER ) - - self.__set_properties() - self.__do_layout() - - il = wx.ImageList(16, 16) - self.ColourIconID = il.Add( wx.ArtProvider_GetBitmap( wx.ART_GO_DOWN, wx.ART_TOOLBAR, ( 16, 16 ) ) ) - #self.propertyList.AssignImageList( il, wx.IMAGE_LIST_SMALL ) - - def __set_properties(self): - self.SetBackgroundColour(wx.Colour(255, 255, 255)) - self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - self.typeStaticText.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - - def __do_layout(self): - sizer_1 = wx.BoxSizer(wx.HORIZONTAL) - content = wx.BoxSizer(wx.VERTICAL) - sizer_1.Add((5, 20), 0, 0, 0) - content.Add((20, 5), 0, 0, 0) - content.Add(self.typeStaticText, 0, 0, 0) - content.Add((20, 3), 0, 0, 0) - content.Add(self.propertyGrid, 1, wx.EXPAND, 0) - content.Add((20, 5), 0, 0, 0) - sizer_1.Add(content, 1, wx.EXPAND, 0) - sizer_1.Add((5, 20), 0, 0, 0) - self.SetSizer(sizer_1) - sizer_1.Fit(self) - - def showData( self, data ): - self.propertyGrid.clean() - if type( data ) == None: - self.showNone() - if type( data ) == ogre.SceneNode: - self.showSceneNode( data ) - elif issubclass( type( data ), ogre.SceneManager): - self.showSceneManager( data ) - elif issubclass( type( data ), ogre.Resource ): - self.showResource( data ) - elif issubclass( type( data ), ogre.MovableObject ): - self.showMovableObject( data ) - elif issubclass( type( data ), ogre.ResourceManager ): - self.showResourceManager( data ) - else: - self.showUnknown( data ) - self.propertyGrid.sizer.Layout() - - def showNone( self ): - self.typeStaticText.SetLabel( "None" ) - - def showUnknown( self, data ): - self.typeStaticText.SetLabel( "Unknown" ) - self.showName( data ); - - def showSceneManager( self, data ): - self.typeStaticText.SetLabel( "SceneManager" ) - self.showName( data ); - - self.propertyGrid.appendRowItemName( "Type name", data.getTypeName() ) - self.propertyGrid.appendPaneColourSelect( "Ambient color", - cfront = data.getAmbientLight, - cback = data.setAmbientLight ) - - print data - fog = PropertyCollapsibleOgreFogPane( self.propertyGrid, "Fog", object = data ) - self.propertyGrid.appendPane( fog ) - -# self.propertyTree.createTextBoolRow( "SkyPlane", data.isSkyPlaneEnabled() ) -# self.propertyTree.createTextBoolRow( "SkyBox", data.isSkyBoxEnabled() ) -# self.propertyTree.createTextBoolRow( "SkyDone", data.isSkyDomeEnabled() ) -# -# fogmodes = {"FOG_NONE":"No fog. Duh.", -# "FOG_EXP": "Fog density increases exponentially from the camera (fog = 1/e^(distance * density)).", -# "FOG_EXP2": "Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)." -# "FOG_LINEAR": "Fog density increases linearly between the start and end distances."} -# -# pane = self.propertyTree.createPane( "Fog" ) - - #pane.AppendSelectFromDictRow( "Mode", fogmodes ) - #self.propertyTree.createColourPane( "fog color" ) - - -# getFogColour (void) const -# virtual Real getFogStart (void) const -# virtual Real getFogEnd (void) const -# virtual Real getFogDensity (void) const -# getRenderQueue -# showBoundingBoxes (bool bShow) -# getShowBoundingBoxes () -# getCameraIterator -# getAnimationIterator -# getShadowTechnique -# many props - - def showSceneNode( self, data ): - self.typeStaticText.SetLabel( "SceneNode" ) - self.showName( data ); - - def showResource( self, data ): - self.typeStaticText.SetLabel( "Resource: " + data.getCreator().getResourceType() ) - self.showName( data ); - self.appendRowItemName( "Group", data.getGroup() ) - self.appendRowItemName( "Origin", data.getOrigin() ) - -# params = data.getParameters() -# if len( params ) > 0: -# pane = self.propertyTree.createPane( "Parameters" ) -# -# for i in params: -# self.propertyTree.createTextRow( i.name, data.getParameter( i.name ), pane ) -# -# if type( data ) == ogre.Texture: -# print "Texture" - - def showMovableObject( self, data ): - self.typeStaticText.SetLabel( "Movable object: " + data.getMovableType() ) - self.showName( data ); - - def showResourceManager( self, data ): - self.typeStaticText.SetLabel( "Resourcemanager: " + data.getResourceType() ) - self.propertyGrid.appendRowItemName( "Memory budget", "%.3g Mb" - % (data.getMemoryBudget()/ 1024.0 /1024.0 ) ) - self.propertyGrid.appendRowItemName( "Memory usage", "%.3g Mb" - % (data.getMemoryUsage()/ 1024.0 /1024.0 ) ) - - def showName( self, data ): - self.propertyGrid.appendRowItemName( "Name", data.getName() ) - - -# end of class ObjectInspectorPanel - - Deleted: branches/ogEditor/OgreWindowWx.py =================================================================== --- branches/ogEditor/OgreWindowWx.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/OgreWindowWx.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,262 +0,0 @@ -import wx -import ogre.renderer.OGRE as ogre -import wxogre_util as wxHandle -import os -import os.path - -try : - import psyco #use psyco if available (JIT compiler) - psyco.full() -except ImportError: - pass - -def getPluginPath(): - """Return the absolute path to a valid plugins.cfg file.""" -# import sys - - paths = [ os.path.join( os.getcwd(), 'plugins.cfg'), - os.path.join( os.path.dirname( os.path.abspath( __file__ ) ), 'plugins.cfg'), - '/etc/OGRE/plugins.cfg' ] - - for path in paths: - if os.path.exists(path): - return path - - sys.stderr.write("\n" - "** Warning: Unable to locate a suitable plugins.cfg file.\n" - "** Warning: Please check your ogre installation and copy a\n" - "** Warning: working plugins.cfg file to the current directory.\n\n") - raise ogre.Exception(0, "can't locate the 'plugins.cfg' file", "") - -class Struct: - "simple dummy class to regroup scene entities in a single parameter" - pass - -class OgreWindow( wx.PyWindow ): - """wx.Frame subclass to embed an Ogre window in wxPython - It is somewhat inspired from SampleFramework.py""" - - #all animation states included in this dictionary will be automatically updated at each render - animStates = {} #the values have to be (AnimationState, SpeedFactor) tuples - - #namespace for holding a reference to the entities you create. You can comment it out - #if you don't like the idea - sceneEntities = Struct() - - def __init__( self, parent, ID, size = wx.Size( 800, 600 ), renderSystem = "OpenGL", **kwargs ): - self.parent = parent - wx.PyWindow.__init__( self, parent, ID, size = size, **kwargs ) - #Event bindings - self.Bind( wx.EVT_CLOSE, self._OnCloseWindow) - self.Bind( wx.EVT_SIZE, self._OnSize) - self.Bind( wx.EVT_TIMER, self.UpdateRender) #Bind the timer events to Ogre rendering - self.Bind( wx.EVT_ERASE_BACKGROUND, self._OnEraseBackground) - - #Timer creation - self.timer = wx.Timer() - self.timer.SetOwner( self ) #Sets the timer to notify self: binding the timer event is not enough - - #Ogre Initialisation - self._OgreInit( size, renderSystem ) - self.SceneInitialisation() - self.UpdateRender() - self.SetFocus() #Gives KeyboardFocus - - def _OgreInit(self,size,renderSystem): - #Root creation - root = ogre.Root( getPluginPath(), "ogre.cfg" ) - self.ogreRoot = root - - # setup resources - config = ogre.ConfigFile() - config.load( 'resources.cfg' ) - - section_iter = config.getSectionIterator() - while section_iter.hasMoreElements(): - section_name = section_iter.peekNextKey() - settings = section_iter.getNext() - for key, path in settings: - ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section_name, False) - - if os.path.exists( "ogre.cfg" ): - root.restoreConfig() - else: - carryOn = root.showConfigDialog() - if not carryOn: - sys.exit('Quit from Config Dialog') - - #The following section tries to avoid showing the configuration dilaog. -# rsList = root.getAvailableRenderers() #Gets the available RenderSystems -# rs = None -# CouldNotFindRequestedRenderer = False -# for i in rsList: -# print i - -# if renderSystem in i.name: #Tries to locate the requested render system -# rs=i -# if rs is not None : -# root.renderSystem=rs -# rs.setConfigOption("Full Screen","No") -# try : -# rs.setConfigOption("Video Mode","800 x 600 @ 16-bit colour") -# except : -# CouldNotFindRequestedRenderer=True -# else : -# CouldNotFindRequestedRenderer=True -# -# if CouldNotFindRequestedRenderer: #Calls Ogre's default Config dialog if failed -# carryOn = root.showConfigDialog() -# if not carryOn: -# sys.exit('Quit from Config Dialog') - -# carryOn = root.showConfigDialog() -# if not carryOn: -# sys.exit('Quit from Config Dialog') - -#get the topmost window and make it visible, otherwise we cant get a valid windowhandle - - lastValid = self.parent - parent = lastValid - while parent != None: - lastValid = parent - parent = lastValid.GetParent() - lastValid.Show( True ) - - root.initialise(False) - renderParameters = ogre.NameValuePairList() - handle = wxHandle.get_window_handle_str( self ) - if handle == "No window found": - print handle - renderParameters = ogre.NameValuePairList(); - else: - renderParameters['externalWindowHandle'] = handle - print handle, lastValid.GetHandle(), self.parent.GetHandle() - - renderWindow = root.createRenderWindow('wxPython render window', size[ 0 ], size[ 1 ], False, renderParameters) - renderWindow.active = True - self.renderWindow = renderWindow - ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups() - - def _OnSize(self, event): - if getattr(self, 'ogreRoot', None): - self.UpdateRender() - self.renderWindow.windowMovedOrResized() - event.Skip() - - def _OnEraseBackground(self, event): - pass # Do nothing, to avoid flashing on MSW. - - def _OnCloseWindow(self, event): - self.Destroy() - - def AcceptsFocus(self): - return True - - def StartRendering(self,interval=33): - "Activates the timer. A rendering will be triggered at each interval (default :33ms)" - self.timer.Start(interval) - - def OnFrameStarted(self,event): - "SubClass and fill in this declaration if you want something done before each rendering" - pass - - def OnFrameEnded(self,event): - "SubClass and fill in this declaration if you want something done after each rendering" - pass - - def UpdateRender(self,event=None): - """Method that can be called manually or by a wx.Timer - If the method is called by timer, the animation states contained in - the self.animStates variable get updated before rendering the frame""" - - #Enables the user to define actions to be undertaken before the frame is started - self.OnFrameStarted(event) - - if hasattr(event ,"GetInterval"): #Timer Events have a GetInterval method that returns the time interval between events - for anim,speed in self.animStates.itervalues(): - anim.addTime(speed*event.GetInterval()/1000.0) #updates the animations - - self.ogreRoot.renderOneFrame()#Asks Ogre to render a frame - - #Enables the user to define actions to be undertaken after the frame has been drawn - self.OnFrameEnded(event) - - def SceneInitialisation(self): - """This method can be replaced completely to suit your needs or you can - subclass only the helper methods such as self._CreateCamera""" - self._ChooseSceneManager() - self._CreateCamera() - self._CreateViewport() - self._PopulateScene() - self._MouseAndKeysBindings() - - #You will want to subclass the following methods to suit your needs - - def _ChooseSceneManager(self): - "choose SceneManager" - self.sceneManager = self.ogreRoot.createSceneManager(ogre.ST_GENERIC,"ExampleSMInstance") - - def _CreateCamera(self): - "create a Camera" - camera = self.sceneManager.createCamera('Camera') - camera.lookAt(ogre.Vector3(0, 0, 0)) - camera.nearClipDistance = 1 - camera.setAutoAspectRatio( True ) - - self.sceneEntities.camera = camera - - # create the camera nodes & attach camera - cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( camera.getName() + "/Node", - ogre.Vector3( 0, 0, 250 ) ) - pitchNode = cameraNode.createChildSceneNode( cameraNode.getName() + "/PitchNode" ) - pitchNode.attachObject( camera ) - - self.sceneEntities.cameraNode = cameraNode - self.sceneEntities.cameraPitchNode = pitchNode - - def _CreateViewport(self): - "create a Viewport" - renderWindow=self.renderWindow - viewport = renderWindow.addViewport( self.sceneEntities.camera, 0, 0.0, 0.0, 1.0, 1.0) - viewport.backgroundColour = ogre.ColourValue(0, 0, 0) - - def _PopulateScene(self): - "Implement this method to put entities in your scene" - pass - - def _MouseAndKeysBindings(self): - "Some Additional mouse and keys bindings" - d=10.0 #displacement for key strokes - self.ControlKeyDict={ wx.WXK_LEFT :ogre.Vector3( -d, 0.0, 0.0), - wx.WXK_RIGHT :ogre.Vector3( d, 0.0, 0.0), - wx.WXK_UP :ogre.Vector3( 0.0, 0.0, -d), - wx.WXK_DOWN :ogre.Vector3( 0.0, 0.0, d), - wx.WXK_PAGEUP :ogre.Vector3( 0.0, d, 0.0), - wx.WXK_PAGEDOWN :ogre.Vector3( 0.0, -d, 0.0)} - self.Bind( wx.EVT_KEY_DOWN, self._DefaultKeyDownManager ) - self.Bind( wx.EVT_MOUSE_EVENTS, self._DefaultMouseEventManager) - ##self.Bind(wx.EVT_ENTER_WINDOW,lambda evt : self.SetFocus()) - - def _DefaultKeyDownManager( self, event ): - "If you want to implement a similar callback function, do not forget the event.Skip() at the end" - validMove = self.ControlKeyDict.get( event.m_keyCode, False ) - if validMove: - self.sceneEntities.cameraNode.translate( validMove, self.sceneEntities.cameraNode.TS_LOCAL ) - event.Skip() - - def _DefaultMouseEventManager( self, event ): - "If you want to implement a similar callback function, do not forget the event.Skip() at the end" - self.SetFocus() #Gives Keyboard focus to the window - - if event.RightDown(): #Precedes dragging - self.StartDragX, self.StartDragY = event.GetPosition() #saves position of initial click - - if event.Dragging() and event.RightIsDown(): #Dragging with RMB - x,y = event.GetPosition() - dx = x-self.StartDragX - dy = y-self.StartDragY - self.StartDragX, self.StartDragY = x, y - - self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 3.0 ) ) - self.sceneEntities.cameraPitchNode.pitch( ogre.Degree( dy / 3.0 ) ) - event.Skip() Deleted: branches/ogEditor/PropertyGrid.py =================================================================== --- branches/ogEditor/PropertyGrid.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/PropertyGrid.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,435 +0,0 @@ -#!/usr/bin/env python - -import wx -import wx.combo -import wx.lib.colourselect as csel - -SLIDER_INT=0 -SLIDER_FLOAT=1 -SLIDER_LOG10=2 - -class NullLog: - def write(*args): - pass - -class SimpleLog: - def write(*args): - print args - - -class ListCtrlComboPopup( wx.ListCtrl, wx.combo.ComboPopup ): - def __init__( self, log = None, cback = None ): - if log: - self.log = log - else: - self.log = NullLog() - - self.cback = cback - - # Since we are using multiple inheritance, and don't know yet - # which window is to be the parent, we'll do 2-phase create of - # the ListCtrl instead, and call its Create method later in - # our Create method. (See Create below.) - self.PostCreate(wx.PreListCtrl()) - - # Also init the ComboPopup base class. - wx.combo.ComboPopup.__init__(self) - - def AddItem(self, txt): - self.InsertStringItem(self.GetItemCount(), txt) - - def OnMotion(self, evt): - item, flags = self.HitTest(evt.GetPosition()) - if item >= 0: - self.Select(item) - self.curitem = item - - def OnLeftDown(self, evt): - self.value = self.curitem - self.Dismiss() - - # The following methods are those that are overridable from the - # ComboPopup base class. Most of them are not required, but all - # are shown here for demonstration purposes. - - - # This is called immediately after construction finishes. You can - # use self.GetCombo if needed to get to the ComboCtrl instance. - def Init(self): - self.log.write("ListCtrlComboPopup.Init") - self.value = -1 - self.curitem = -1 - - # Create the popup child control. Return true for success. - def Create(self, parent): - self.log.write("ListCtrlComboPopup.Create") - wx.ListCtrl.Create(self, parent, - style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER) - self.Bind(wx.EVT_MOTION, self.OnMotion) - self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) - return True - - # Return the widget that is to be used for the popup - def GetControl(self): - return self - - # Called just prior to displaying the popup, you can use it to - # 'select' the current item. - def SetStringValue(self, val): - self.log.write("ListCtrlComboPopup.SetStringValue") - idx = self.FindItem(-1, val) - if idx != wx.NOT_FOUND: - self.Select(idx) - - # Return a string representation of the current item. - def GetStringValue(self): - self.log.write("ListCtrlComboPopup.GetStringValue") - if self.value >= 0: - return self.GetItemText(self.value) - return "" - - # Called immediately after the popup is shown - def OnPopup(self): - self.log.write("ListCtrlComboPopup.OnPopup") - wx.combo.ComboPopup.OnPopup(self) - - # Called when popup is dismissed - def OnDismiss(self): - self.log.write("ListCtrlComboPopup.OnDismiss") - if self.cback != None: - self.cback( self.value ) - wx.combo.ComboPopup.OnDismiss(self) - - # This is called to custom paint in the combo control itself - # (ie. not the popup). Default implementation draws value as - # string. - def PaintComboControl(self, dc, rect): - self.log.write("ListCtrlComboPopup.PaintComboControl") - wx.combo.ComboPopup.PaintComboControl(self, dc, rect) - - # Receives key events from the parent ComboCtrl. Events not - # handled should be skipped, as usual. - def OnComboKeyEvent(self, event): - self.log.write("ListCtrlComboPopup.OnComboKeyEvent") - wx.combo.ComboPopup.OnComboKeyEvent(self, event) - - # Implement if you need to support special action when user - # double-clicks on the parent wxComboCtrl. - def OnComboDoubleClick(self): - self.log.write("ListCtrlComboPopup.OnComboDoubleClick") - wx.combo.ComboPopup.OnComboDoubleClick(self) - - # Return final size of popup. Called on every popup, just prior to OnPopup. - # minWidth = preferred minimum width for window - # prefHeight = preferred height. Only applies if > 0, - # maxHeight = max height for window, as limited by screen size - # and should only be rounded down, if necessary. - def GetAdjustedSize(self, minWidth, prefHeight, maxHeight): - self.log.write("ListCtrlComboPopup.GetAdjustedSize: %d, %d, %d" % (minWidth, prefHeight, maxHeight)) - return wx.combo.ComboPopup.GetAdjustedSize(self, minWidth, prefHeight, maxHeight) - - # Return true if you want delay the call to Create until the popup - # is shown for the first time. It is more efficient, but note that - # it is often more convenient to have the control created - # immediately. - # Default returns false. - def LazyCreate(self): - self.log.write("ListCtrlComboPopup.LazyCreate") - return wx.combo.ComboPopup.LazyCreate(self) - - -class PropertyRowItem( ): - def __init__( self, parent, name ): - self.sizer = wx.BoxSizer( wx.HORIZONTAL ) - - labelTextCtrl = wx.TextCtrl( parent, -1, name, - style = wx.NO_BORDER | wx.ALIGN_LEFT ) - self.rowHeight = labelTextCtrl.GetSize()[ 1 ] - labelTextCtrl.SetEditable( False ) - self.sizer.Add( labelTextCtrl, 0, wx.EXPAND | wx.ALIGN_RIGHT ) - -class PropertyRowItemName( PropertyRowItem ): - def __init__( self, parent, name, value = "" ): - PropertyRowItem.__init__( self, parent, name ) - self.valueTextCtrl = wx.TextCtrl( parent, -1, value, - size = wx.Size( 30, self.rowHeight ), - style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.valueTextCtrl, 1, wx.EXPAND | wx.ALIGN_LEFT ) - -class PropertyRowItemSlider( PropertyRowItem ): - def __init__( self, parent, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): - PropertyRowItem.__init__( self, parent, name ) - self.format = format - self.cback = cback - self.value = 0 - self.start = start - self.end = end - self.sliderValue = 0 - - if self.format == SLIDER_INT: - self.sliderStart = start - self.sliderEnd = end - else: - self.sliderStart = 0 - self.sliderEnd = 100 - - self.scale = float( self.end - self.start )/( self.sliderEnd - self.sliderStart ) - - self.valueTextCtrl = wx.TextCtrl( parent, -1, "", - size = wx.Size( 30, self.rowHeight ), - style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) - - self.slider = wx.Slider( parent, -1, self.sliderValue, self.sliderStart, self.sliderEnd, - size = wx.Size( 100, self.rowHeight ), - style = wx.NO_BORDER | wx.NO_3D ) - - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.valueTextCtrl, 0, wx.EXPAND | wx.ALIGN_LEFT ) - self.sizer.Add( self.slider, 1, wx.EXPAND | wx.ALIGN_LEFT ) - self.slider.Bind(wx.EVT_SLIDER, self.OnSlide ) - - def OnSlide(self, event): - val = event.GetEventObject().GetValue() - self.value = self.start + self.scale * val; - self.applyValue() - - def setValue(self, value): - self.value = value - self.applyValue( False ) - - def applyValue( self, update = True ): - if self.format == SLIDER_INT: - self.valueTextCtrl.SetValue( "%d" % self.value ) - else: - self.valueTextCtrl.SetValue( "%.1g" % self.value ) - - self.slider.SetValue( (self.value -self.start)/ self.scale ) - - if update == True: - if self.cback != None: - self.cback( self.value ) - -class PropertyRowItemChoice( PropertyRowItem ): - def __init__( self, parent, name, itemList = None, itemMap = None, cback = None): - PropertyRowItem.__init__( self, parent, name ) - - self.cback = cback - self.value = "None" - - if itemList != None: - self.ITEMDICT = False - self.itemList = itemList - elif itemMap != None: - self.ITEMDICT = True - self.itemList = itemMap - - self.choice = wx.combo.ComboCtrl( parent, -1, - size = wx.Size( 100, self.rowHeight ), - style = wx.NO_BORDER | wx.NO_3D | wx.CB_READONLY ) - - #self.choice.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - - self.popup = ListCtrlComboPopup( cback = self.choiceChanged ) - self.popup.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - - self.choice.SetPopupControl( self.popup ) - - - if self.ITEMDICT == False: - for i in self.itemList: - self.popup.AddItem( i ) - else: - for i in self.itemList: - self.popup.AddItem( i[ 1 ] ) - - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.choice, 1, wx.EXPAND | wx.ALIGN_LEFT ) - - def choiceChanged(self, idx): - if self.ITEMDICT == False: - self.value = self.itemList[ idx ] - else: - self.value = self.itemList[idx][ 0 ] - - self.applyValue() - - def setValue(self, value): - self.value = value - self.applyValue( False ) - - def applyValue( self, update = True ): - #print self.value - #item = self.value in self.itemList - # for val in self.itemList: -# if self.ITEMDICT == False: -# if self.value == val: -# item = val -# else: -# if self.value == val[0]: -# item = val -# print item - - if update == True: - if self.cback != None: - self.cback( self.value ) - -class PropertyRowItemColourSelect( PropertyRowItemName ): - def __init__( self, parent, name, cback = None ): - PropertyRowItemName.__init__( self, parent, name ) - self.cback = cback - self.value = wx.Colour(0,0,0) - - self.colourButton = csel.ColourSelect( parent, -1, "", - colour = self.value, - size = wx.Size( self.rowHeight,self.rowHeight ), - style = wx.NO_BORDER ) - - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.colourButton, 0, wx.EXPAND ) - self.colourButton.Bind( csel.EVT_COLOURSELECT, self.OnColour ) - - def OnColour(self, event): - self.value = event.GetValue() - self.applyValue() - - def setValue(self, value): - self.value = value - self.applyValue( False ) - - def applyValue( self, update = True ): - self.valueTextCtrl.SetValue( "%d,%d,%d" % (self.value[0],self.value[1],self.value[2]) ) - self.colourButton.SetColour( self.value ) - if update == True: - if self.cback != None: - self.cback( self.value ) - - -class PropertyGrid( ): - def __init__(self): - self.sizer = wx.BoxSizer( wx.VERTICAL ) - self.SetSizer( self.sizer ) - self.widthCol0 = 70 - self.widthCol2 = 24 - self.xOffset = 17 - - def appendRow(self, row ): - self.sizer.AddSpacer(1) - self.sizer.Add( row.sizer, 0, wx.EXPAND ) - - def appendRowItemName(self, name, value = "" ): - item = PropertyRowItemName( self.pane, name, value ) - self.appendRow( item ) - return item - - def appendRowItemChoice(self, name, itemList = None, itemMap = None, cback = None ): - item = PropertyRowItemChoice( self.pane, name, itemList, itemMap, cback ) - self.appendRow( item ) - return item - - def appendRowItemSlider(self, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): - item = PropertyRowItemSlider( self.pane, name, start, end, format, cback ) - self.appendRow( item ) - return item - - def appendRowItemColourSelect( self, name, cback = None ): - item = PropertyRowItemColourSelect( self.pane, name, cback ) - self.appendRow( item ) - return item - - def appendPane(self, pane ): - self.sizer.AddSpacer(1) - self.sizer.Add( pane, 0, wx.EXPAND ) - - def appendPaneColourSelect( self, name, cfront = None, cback = None ): - pane = PropertyPaneItemColour( self.pane, name, cfront, cback ) - self.appendPane( pane ) - return pane - - -class PropertyPaneItem( wx.CollapsiblePane, PropertyGrid ): - def __init__(self, parent, name): - - wx.CollapsiblePane.__init__( self, parent, -1, name, - style = wx.CP_DEFAULT_STYLE - | wx.CP_NO_TLW_RESIZE ) - PropertyGrid.__init__(self) - - - self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged ) - - self.pane = self.GetPane() - self.pane.SetFont( wx.Font( 8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "" ) ) - self.sizer = wx.BoxSizer( wx.VERTICAL ) - self.pane.SetSizer( self.sizer ) - - def OnPaneChanged(self, event = None): - if event: - if ( event.Collapsed ): - event.GetEventObject().GetPane().Hide() - else: - event.GetEventObject().GetPane().Show() - parent = self.GetParent().Layout() - - -class PropertyPaneItemColour( PropertyPaneItem ): - def __init__( self, parent, name, cfront = None, cback = None ): - PropertyPaneItem.__init__(self, parent, name) - self.cback = cback - self.cfront = cfront - self.value = [0, 0, 0, 0] - self.scale = 255.0 - - self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGB ) - self.r = self.appendRowItemSlider( "red", 0, 255, cback = self.setRed ) - self.g = self.appendRowItemSlider( "green", 0, 255, cback = self.setGreen ) - self.b = self.appendRowItemSlider( "blue", 0, 255, cback = self.setBlue ) - self.a = self.appendRowItemSlider( "alpha", 0, 255, cback = self.setAlpha ) - - if self.cfront != None: - colour = self.cfront() - self.value = map(lambda x: x * self.scale, [colour[0], colour[1], colour[2], colour[3]] ) - self.applyValue( False ) - - def setRGB(self, value): - self.value[0:3] = value - self.applyValue() - def setRed(self, value): - self.value[0] = value - self.applyValue() - def setGreen(self, value): - self.value[1] = value - self.applyValue() - def setBlue(self, value): - self.value[2] = value - self.applyValue() - def setAlpha(self, value): - self.value[3] = value - self.applyValue() - - def applyValue(self, update = True ): - self.r.setValue( self.value[ 0 ] ) - self.g.setValue( self.value[ 1 ] ) - self.b.setValue( self.value[ 2 ] ) - self.a.setValue( self.value[ 3 ] ) - self.c.setValue( self.value ) - if update == True: - if self.cback != None: - 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) - PropertyGrid.__init__(self) - self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - #self.SetBackgroundColour( wx.Colour(200, 200, 200) ) - - self.pane = self - - def clean( self ): - self.sizer.Clear( True ) - self.sizer.Layout() - Deleted: branches/ogEditor/PythonOgreConfig.py =================================================================== --- branches/ogEditor/PythonOgreConfig.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/PythonOgreConfig.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# a single config file that is imported 'first' by the Python-Ogre demos -# this is primarly used to manage Linux demos when we have binaries in non standard (safe) locations - -import os,sys - -######################################################################### -### Override this setting if you are using non standard locations - -libpath = "/home/carsten/local/python-ogre.work/root/usr/lib" -libpathpyton = "/home/carsten/local/python-ogre.work/root/usr/lib64/" - -######################################################################### - -if os.name == 'nt': - libpath="" - libpathpyton="" - pythonpath = "" -else: - if libpathpyton == "" : # we need to find this ourselves - localpath = os.path.abspath(os.path.dirname(__file__) ) # assume that this module is in the ./demos directory - libpathpyton = os.path.abspath(os.path.join(localpath,'../lib')) # so in the binary release the lib is one path back up - if not os.path.exists ( libpathpyton ): #we must be running from the development environment - libpathpyton = os.path.abspath(os.path.join(localpath,'../../root/usr/lib')) - if not os.path.exists ( libpathpyton ): - ## should die here - print "**Problem finding libraries" - libpathpyton=localpath - - ## path to the Python-Ogre modules - pythonpath = os.path.abspath(os.path.join(libpathpyton, 'python2.5/site-packages') ) - ## and insert it into the system path - sys.path.insert(0,pythonpath) - - ## now we need to set the library path so the shared libraries can be found - try: - ldpath = os.environ['LD_LIBRARY_PATH'] - except: - ldpath="" - newldpath = libpath + ":" + ldpath - os.environ['LD_LIBRARY_PATH'] = newldpath - os.putenv('LD_LIBRARY_PATH', newldpath) - print "export LD_LIBRARY_PATH=%s" % os.environ['LD_LIBRARY_PATH'] Deleted: branches/ogEditor/ResourceTreePane.py =================================================================== --- branches/ogEditor/ResourceTreePane.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/ResourceTreePane.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,68 +0,0 @@ -import wx -import wx.lib.customtreectrl as CT -import ogre.renderer.OGRE as ogre - -class MyCustomTree( 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"): - CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle, validator, name) - - def OnInternalIdle(self): - wx.PyScrolledWindow.OnInternalIdle( self ) - CT.CustomTreeCtrl.OnInternalIdle( self ) - - -class ResourceTreePane( MyCustomTree ): - 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"): - 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 ) ) - - def OnInternalIdle(self): - wx.PyScrolledWindow.OnInternalIdle( self ) - CT.CustomTreeCtrl.OnInternalIdle( self ) - - def addItem( self, node, name, data ): - newNode = self.AppendItem( node, name ) - self.SetPyData( newNode, data ) - return newNode - - def buildResourceTree( self ): - root = self.AddRoot( "Ogre resources" ) - resManNode = self.AppendItem( root, "Resource manager" ) - - resManIter = ogre.ResourceGroupManager.getSingleton().getResourceManagerIterator() - while resManIter.hasMoreElements(): - resManNodeIter = self.addItem( resManNode, resManIter.peekNextKey(), resManIter.peekNextValue() ) - resIter = resManIter.peekNextValue().getResourceIterator() - while resIter.hasMoreElements(): - self.addItem( resManNodeIter, resIter.peekNextValue().getName(), resIter.peekNextValue() ) - resIter.getNext() - - resManIter.getNext() - - resGroupManNode = self.addItem( root, "Resource groups", ogre.ResourceGroupManager.getSingleton() ) - - resGroups = ogre.ResourceGroupManager.getSingleton().getResourceGroups( ) - for resGroupName in resGroups: - resGroupNode = self.addItem( resGroupManNode, resGroupName, None ) - - resLocNode = self.addItem( resGroupNode, "Resource locations", None ) - - resLocationList = ogre.ResourceGroupManager.getSingleton().getResourceDeclarationList( resGroupName ) - for resLocation in resLocationList: - print resLocation.resourceName - self.addItem( resLocNode, resLocation.resourceName, None ) - - resNameNode = self.addItem( resGroupNode, "Resources", None ) - resNameList = ogre.ResourceGroupManager.getSingleton().listResourceNames( resGroupName ) - for res in resNameList: - self.addItem( resNameNode, res, None ); - - # this fails ??? - #fileInfoList = ogre.ResourceGroupManager.getSingleton().findResourceFileInfo( "General", "*.png") - #fileNameList = ogre.ResourceGroupManager.getSingleton().listResourceFileInfo( resGroupName ) Added: branches/ogEditor/build.sh =================================================================== --- branches/ogEditor/build.sh (rev 0) +++ branches/ogEditor/build.sh 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ $OSTYPE = "msys" ]; then + echo "build for mingw" + python generate_code.py vector + bjam toolset=gcc +else + echo "build for linux gcc" + mkdir -p generated + MAKEOPTS=-j5 + make clean + sh build.wxogre_util.sh +# cp ./indexing_suite_v2/src/indexing/* generated/ + + if [ $# -lt 1 ]; then + python generate_code.py + make $MAKEOPTS + cp generated/opengate.so packages_2.5/opengate/OpenGate.so + + fi +fi Added: branches/ogEditor/environment.py =================================================================== --- branches/ogEditor/environment.py (rev 0) +++ branches/ogEditor/environment.py 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,49 @@ +#! /usr/bin/python +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import sys + +class settings: + module_name = 'OpenGate' + #opengate_path = '../../trunc/src/' + opengate_path = '/home/carsten/local/opengate/trunk/src/' + opengate_cache_file ='python_opengate.cache' + ogre_include_path = '' + ogreopcode_include_path = '' + boost_path = '' + boost_libs_path = '' + gccxml_path = '' + pygccxml_path = '' + pyplusplus_path = '' + python_libs_path = '' + python_include_path = '' + working_dir = '' + unittests_dir = '' + generated_files_dir = './generated' + opengate_defines = '' + def setup_environment(): + print settings.pygccxml_path + sys.path.append( settings.pygccxml_path ) + sys.path.append( settings.pyplusplus_path ) + setup_environment = staticmethod(setup_environment) + +if sys.platform == 'linux2': + settings.python_include_path = '/usr/include/python2.5' + settings.ogre_include_path = '/usr/include/OGRE' + settings.ogreopcode_include_path = '/usr/include/ogreopcode' + settings.gccxml_path = '/usr/bin' + settings.pygccxml_path = '/usr/lib64/python2.5/site-packages' + settings.pyplusplus_path = '/usr/lib64/python2.5/site-packages' + +elif sys.platform == 'win32': + settings.pygccxml_path = 'c:/python25/Lib/site-packages/' + settings.python_libs_path = 'c:/python25/libs' + settings.gccxml_path = 'c:/Programme/GCCXMLcomplete/bin' + settings.opengate_defines ='MINGW' +else: + raise RuntimeError( 'There is no configuration for "%s" platform.' % sys.platform ) + +settings.setup_environment() Added: branches/ogEditor/generate_code.py =================================================================== --- branches/ogEditor/generate_code.py (rev 0) +++ branches/ogEditor/generate_code.py 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,221 @@ +#! /usr/bin/python + +import os +import sys +import string +from environment import settings + +import hand_made_wrappers + +from pygccxml import parser +from pygccxml import declarations +from pygccxml.declarations import access_type_matcher_t +from pyplusplus import code_creators +from pyplusplus import module_builder +from pyplusplus.module_builder import call_policies + +import common_utils.ogre_properties as ogre_properties + +MAIN_NAMESPACE = 'OpenGate' + +def set_call_policies( mb ): +# + # Set the default policy to deal with pointer/reference return types to reference_existing object^M + # as this is the Ogre Default.^M + mem_funs = mb.calldefs () + mem_funs.create_with_signature = True #Generated code will not compile on^M + #MSVC 7.1 if function has throw modifier.^M + for mem_fun in mem_funs: + if mem_fun.call_policies: + continue + if declarations.is_pointer (mem_fun.return_type) or declarations.is_reference (mem_fun.return_type): + mem_fun.call_policies = call_policies.return_value_policy( call_policies.reference_existing_object ) + + +class decl_starts_with (object): + def __init__ (self, prefix): + self.prefix = prefix + def __call__ (self, decl): + return self.prefix in decl.name + +def excludeFreeFunctionsByReturn( mb, functs): + for funct in functs: + fun = mb.global_ns.free_functions( return_type=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeFreeFunctionsByName( mb, functs): + for funct in functs: + fun = mb.global_ns.free_functions( name=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeFreeOperatorsByReturn( mb, functs): + for funct in functs: + fun = mb.global_ns.free_operators( return_type=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeClass( mb, functs): + for funct in functs: + fun = mb.global_ns.class_( funct ) + print "exclude", fun + fun.exclude() + +def excludeMemberByReturn( mb, functs): + for funct in functs: + fun = mb.global_ns.member_functions( return_type=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def excludeMemberOperators( mb, functs): + for funct in functs: + fun = mb.global_ns.member_operators( symbol=funct, allow_empty=True ) + print "exclude", funct, len( fun ) + for f in fun: + f.exclude() + +def setMemberFunctionCallPolicieByReturn(mb, MemberRetRef, callPolicie ): + for ref in MemberRetRef: + memFuns = mb.global_ns.member_functions( return_type=ref, allow_empty=True ) + print ref, len(memFuns) + + for memFun in memFuns: + if memFun.call_policies: + continue + else: + memFun.call_policies = \ + call_policies.return_value_policy( callPolicie ) + +def generate( defined_symbols ): + xml_cached_fc = parser.create_cached_source_fc( os.path.join( r"python_opengate.h" ), + settings.opengate_cache_file ) + + print xml_cached_fc + + mb = module_builder.module_builder_t( [xml_cached_fc], + gccxml_path = settings.gccxml_path, + working_directory = settings.opengate_path, + include_paths = [settings.opengate_path, settings.python_include_path, + settings.ogreopcode_include_path, settings.ogre_include_path], + define_symbols = defined_symbols, + indexing_suite_version = 2 ) + + ## This module depends on Ogre + mb.register_module_dependency ( '/home/carsten/local/python-ogre/python-ogre/generated/ogre_1.4/' ) + + global_ns = mb.global_ns + global_ns.exclude() + + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + main_ns.include() + + global_ns.namespace( 'Ogre' ).class_('Vector3').include(already_exposed=True) + + hand_made_wrappers.apply( mb ) + + mb.BOOST_PYTHON_MAX_ARITY = 25 + mb.classes().always_expose_using_scope = True + + set_call_policies( mb.global_ns.namespace ('OpenGate') ) + set_call_policies( mb.global_ns.namespace ('Ogre') ) + + for cls in main_ns.classes(): + print cls + cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() ) + + + mb.calldefs( access_type_matcher_t( 'protected' ) ).exclude() + mb.calldefs( access_type_matcher_t( 'private' ) ).exclude() + + #mb.class_( '::std::set < ::std::string >' ).alias = 'stringSet'; + + excludeClass( mb, [ 'deletePtr' + ,'GameStateListener' + ,'GameStateManager' + ,'Message' + ,'MessageBodyBase' + ,'OpenALSoundSource' + ] ) + + # mb.class_( 'Vector<double>' ).alias = 'RVector' + + + #call_policies.return_value_policy( call_policies.reference_existing_object ) + #call_policies.return_value_policy( call_policies.copy_non_const_reference ) + #call_policies.return_value_policy( call_policies.copy_const_reference ) + + #excludeFreeFunctionsByName( mb, ['strReplaceBlankWithUnderscore' + #'toStr', 'toInt', 'toFloat', 'toDouble', + #'getRowSubstrings', 'getNonEmptyRow', 'getSubstrings' ] ) + + #excludeFreeFunctionsByReturn( mb, [ 'float *', 'float &' ] ) + + #excludeFreeOperatorsByReturn( mb, [ '::std::ostream &', '::std::istream &' ] ) + + #excludeMemberOperators( mb, ['++', '--', '*'] ) + + +## setMemberFunctionCallPolicie( mb, [''], call_policies.copy_non_const_reference ) + + ##setMemberFunctionCallPolicieByReturn( mb, ['::Ogre::Vector3' ], + ##call_policies.return_pointee_value ) + + #setMemberFunctionCallPolicieByReturn( mb, ['::std::string *', 'float *', 'double *'], + #call_policies.return_pointee_value ) + + #setMemberFunctionCallPolicieByReturn( mb, ['::std::string &', 'double &' ], + #call_policies.return_by_value ) + + + # exclude all that does not match any predefined callpolicie + excludeRest = True + + if excludeRest: + mem_funs = mb.calldefs () + + for mem_fun in mem_funs: + if mem_fun.call_policies: + continue + if not mem_fun.call_policies and \ + (declarations.is_reference( mem_fun.return_type ) or declarations.is_pointer (mem_fun.return_type) ): + #print mem_fun + mem_fun.exclude() + #mem_fun.call_policies = \ + #call_policies.return_value_policy( call_policies.reference_existing_object ) + #mem_fun.call_policies = \ + # call_policies.return_value_policy( call_policies.return_pointee_value ) + #mem_fun.call_policies = \ + # call_policies.return_value_policy( call_policies.return_opaque_pointer ) + #mem_fun.call_policies = \ + # call_policies.return_value_policy(call_policies.copy_non_const_reference) + + # mb.print_declarations( main_ns ) +#I can print declarations to see what is going on +#mb.print_declarations() + +#Now it is the time to give a name to our module + mb.build_code_creator( settings.module_name ) + +#It is common requirement in software world - each file should have license + #mb.code_creator.license = '//Boost Software License( http://boost.org/more/license_info.html )' + +#I don't want absolute includes within code + mb.code_creator.user_defined_directories.append( os.path.abspath('.') ) + + #And finally we can write code to the disk + mb.split_module( settings.generated_files_dir ) + #mb.write_module( os.path.join( settings.generated_files_dir, settings.module_name + '.cpp') ) + +if __name__ == '__main__': + + defined_symbols = ['OPENGATE'] + + generate( defined_symbols ) + print 'done' + + Added: branches/ogEditor/hand_made_wrappers.py =================================================================== --- branches/ogEditor/hand_made_wrappers.py (rev 0) +++ branches/ogEditor/hand_made_wrappers.py 2008-05-18 19:29:16 UTC (rev 899) @@ -0,0 +1,20 @@ +#! /usr/bin/python + +import os +import environment + +WRAPPER_DEFINITION_General = \ +""" +""" + +WRAPPER_REGISTRATION_General = [ + """ + """] + +def apply_reg ( class_, code ): + for c in code: + class_.add_registration_code ( c ) + +def apply( mb ): + mb.add_declaration_code( WRAPPER_DEFINITION_General ) + apply_reg( mb, WRAPPER_REGISTRATION_General ) \ No newline at end of file Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-14 21:50:43 UTC (rev 898) +++ branches/ogEditor/ogEditor.py 2008-05-18 19:29:16 UTC (rev 899) @@ -1,23 +1,32 @@ #!/usr/bin/env python -# -*- coding: ansi_x3.4-1968 -*- - import wxversion wxversion.ensureMinimal('2.8') +import sys import wx + +sys.path.append( './packages_2.5/' ) +sys.path.append( '../' ) +sys.path.append( './src/' ) + import wx.aui import wx.py as py import wx.lib.customtreectrl as CT -from OgreWindowWx import * + from ObjectInspectorPanels import * from ResourceTreePane import * +from OgreWindowWx import * + +import opengate as og + class OGView3D( OgreWindow ): def _PopulateScene(self): #automatic called by parent init # self.headE... [truncated message content] |
From: <spo...@us...> - 2008-05-24 17:26:34
|
Revision: 903 http://opengate.svn.sourceforge.net/opengate/?rev=903&view=rev Author: spom_spom Date: 2008-05-24 10:26:37 -0700 (Sat, 24 May 2008) Log Message: ----------- Add very basic ogre.material editor, properties can be changed on the fly but not yet stored. Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/propgridtest.py branches/ogEditor/src/ObjectInspectorPanels.py branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/PropertyGrid.py Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-21 20:04:57 UTC (rev 902) +++ branches/ogEditor/ogEditor.py 2008-05-24 17:26:37 UTC (rev 903) @@ -21,22 +21,11 @@ import opengate as og -#class OGView3D( OgreWindow ): - #def _PopulateScene(self): - ##automatic called by parent init -## self.headEnt = self.sceneManager.createEntity("ogreHead", "athene.mesh") - ##self.headEnt = self.sceneManager.createEntity("ogreHead", "ogrehead.mesh") - ###self.headEnt = self.sceneManager.createEntity("ogreHead", "Firefly.mesh") - ##self.headNode = self.sceneManager.getRootSceneNode().createChildSceneNode( ) - ##self.headNode.attachObject( self.headEnt ) - ##self.sceneManager.setAmbientLight( (0.0, 0.0, 1.0, 1.0) ) - #sector = og.Sector( self.sceneManager, None ) - ##sector.populate("testsector") - ID_MB_FILE_EXIT = wx.NewId() ID_MB_VIEW_SCENETREE = wx.NewId() ID_MB_VIEW_OBJECT = wx.NewId() ID_MB_VIEW_RESOURCE = wx.NewId() +ID_MB_VIEW_MATERIAL = wx.NewId() ID_MB_VIEW_PYCRUST = wx.NewId() ID_TB_EXIT = wx.NewId() ID_TB_TMP = wx.NewId() @@ -44,6 +33,7 @@ NAME_SCENETREE = "Scene tree" NAME_OBJECT = "Property inspector" NAME_RESOURCE = "Resource browser" +NAME_MATERIAL = "Material editor" NAME_PYCRUST = "PyCrust" class WorkSpace: @@ -54,11 +44,18 @@ class Opengate: resourceManager_ = None - def __init__( self, ): + def __init__( self, OgreWindow ): + self.resourceManager_ = og.ResourceManager() self.resourceManager_.logManager = og.LogManager() self.resourceManager_.entityManager = og.EntityManager( ) + self.resourceManager_.ogreRoot = OgreWindow.ogreRoot + self.resourceManager_.renderWindow = OgreWindow.renderWindow + for res in OgreWindow.resourceLocations: + self.resourceManager_.addResourceLocation( res[0], res[1] ) + + def initOpenGateResources_( self ): self.resourceManager_.loadGlobalIDs( "ids.xml" ) entityManager = self.resourceManager_.entityManager @@ -85,8 +82,16 @@ value = "Default", itemList = shaderSchemes, cback = vp.setMaterialScheme ) - +class OGEditorPane: + def __init__( self, ID, Name, mbShortcut, creator, defaultCheck ): + self.ID_ = ID + self.name_ = Name + self.mbItem_ = None + self.mbShortcut_ = mbShortcut + self.creator_ = creator + self.defaultCheck_ = defaultCheck + class MainFrame(wx.Frame): def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE @@ -95,14 +100,19 @@ global ws 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, False ) ) + 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_PYCRUST, NAME_PYCRUST , "\tF9", None, False ) ) - self.og = Opengate() - self.initMenuBar_() self.initToolBar_() self.initStatusBar_() self.initFrameManager_() + self.og = Opengate( self.ogreRenderWindow ) self.og.initOpenGateResources_(); self.og.sector = og.Sector( self.ogreRenderWindow.sceneManager, None ); @@ -117,24 +127,18 @@ self.mb.Append( self.mbFile, "&File" ) self.mbView = wx.Menu() - self.mbViewScenetree = wx.MenuItem( self.mbView, ID_MB_VIEW_SCENETREE, NAME_SCENETREE + "\tF1", "", wx.ITEM_CHECK) - self.mbViewObject = wx.MenuItem( self.mbView, ID_MB_VIEW_OBJECT, NAME_OBJECT + "\tF2", "", wx.ITEM_CHECK) - self.mbViewResource = wx.MenuItem( self.mbView, ID_MB_VIEW_RESOURCE, NAME_RESOURCE + "\tF3", "", wx.ITEM_CHECK) - self.mbViewPyCrust = wx.MenuItem( self.mbView, ID_MB_VIEW_PYCRUST, NAME_PYCRUST + "\tF9", "", wx.ITEM_CHECK) - self.mbView.AppendItem( self.mbViewScenetree ) - self.mbView.AppendItem( self.mbViewObject ) - self.mbView.AppendItem( self.mbViewResource ) - self.mbView.AppendItem( self.mbViewPyCrust ) + + for pane in self.allPanes: + pane.mbItem_ = wx.MenuItem( self.mbView, pane.ID_, pane.name_ + pane.mbShortcut_, "", wx.ITEM_CHECK) + self.mbView.AppendItem( pane.mbItem_ ) + self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = pane.ID_ ) + self.mb.Append( self.mbView, "&View") self.SetMenuBar( self.mb ) self.Bind( wx.EVT_MENU, self.doExit, id = wx.ID_EXIT ) - self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_SCENETREE) - self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_OBJECT) - self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_RESOURCE) - self.Bind( wx.EVT_MENU, self.doSwitchViewPane, id = ID_MB_VIEW_PYCRUST) - + def initToolBar_( self ): self.tb = wx.ToolBar(self, -1) self.SetToolBar( self.tb ) @@ -177,6 +181,11 @@ BestSize( wx.Size( 250, 200 ) ).MinSize( wx.Size( 250, 200 ) ). Left().Layer( 1 ).Position( 2 ).CloseButton(True).MaximizeButton(True)) + self.auiMgr.AddPane( self.createMaterialInspector_(), + wx.aui.AuiPaneInfo().Name( NAME_MATERIAL ).Caption( NAME_MATERIAL ). + BestSize( wx.Size( 250, 200 ) ).MinSize( wx.Size( 250, 200 ) ). + Left().Layer( 1 ).Position( 4 ).CloseButton(True).MaximizeButton(True)) + self.auiMgr.AddPane( self.createResourceInspector_(), wx.aui.AuiPaneInfo().Name( NAME_RESOURCE ).Caption( NAME_RESOURCE ). BestSize( wx.Size( 250, 200 ) ).MinSize( wx.Size( 250, 200 ) ). @@ -188,7 +197,7 @@ ################################################################################# def createRenderWindow_( self ): - self.ogreRenderWindow = OgreWindow( self, -1, ogResourceMan = self.og.resourceManager_ ) + self.ogreRenderWindow = OgreWindow( self, -1 ) return self.ogreRenderWindow def createCrustWindow_( self ): @@ -210,11 +219,17 @@ self.sceneTree.AssignImageList( il ) 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 return self.sceneTree def createObjectInspector_( self ): - self.objectInspector = ObjectInspectorPanel( self, -1, wx.Point(0, 0), wx.Size(160, 250) ) + self.objectInspector = ObjectInspectorPanel( self, self, -1, wx.Point(0, 0), wx.Size(160, 250) ) return self.objectInspector + + def createMaterialInspector_( self ): + self.materialInspector = MaterialInspectorPanel( self, self, -1, wx.Point(0, 0), wx.Size(160, 250) ) + return self.materialInspector def createResourceInspector_( self ): self.resourceTree = ResourceTreePane( self, -1, wx.Point( 0, 0 ), wx.Size( 160, 250 ), @@ -225,18 +240,13 @@ def setDefaultProperties_( self ): self.SetTitle("ogEditor") self.sb.SetStatusWidths([-1]) - - self.mbViewScenetree.Check( ) - self.auiMgr.GetPane( NAME_SCENETREE ).Show() - - self.mbViewObject.Check( ) - self.auiMgr.GetPane( NAME_OBJECT ).Show() - self.mbViewResource.Check( False ) - self.auiMgr.GetPane( NAME_RESOURCE ).Hide() - - self.mbViewPyCrust.Check( False ) - self.auiMgr.GetPane( NAME_PYCRUST ).Hide() + for pane in self.allPanes: + pane.mbItem_.Check( pane.defaultCheck_ ) + if pane.defaultCheck_: + self.auiMgr.GetPane( pane.name_ ).Show() + else: + self.auiMgr.GetPane( pane.name_ ).Hide() self.UpdateSceneGraphEvent( None ) self.resourceTree.buildResourceTree( ) @@ -251,29 +261,21 @@ def doClosePane( self, event ): caption = event.GetPane().caption - if caption == NAME_SCENETREE: - self.mb.Check( ID_MB_VIEW_SCENETREE, False ) - elif caption == NAME_OBJECT: - self.mb.Check( ID_MB_VIEW_OBJECT, False ) - elif caption == NAME_RESOURCE: - self.mb.Check( ID_MB_VIEW_RESOURCE, False ) - elif caption == NAME_PYCRUST: - self.mb.Check( ID_MB_VIEW_PYCRUST, False ) + for pane in self.allPanes: + if pane.name_ == caption: + self.mb.Check( pane.ID_, False ) + break def doSwitchViewPane( self, event ): - if event.GetId() == ID_MB_VIEW_SCENETREE: - pane = self.auiMgr.GetPane( NAME_SCENETREE ) - elif event.GetId() == ID_MB_VIEW_OBJECT: - pane = self.auiMgr.GetPane( NAME_OBJECT ) - elif event.GetId() == ID_MB_VIEW_RESOURCE: - pane = self.auiMgr.GetPane( NAME_RESOURCE ) - elif event.GetId() == ID_MB_VIEW_PYCRUST: - pane = self.auiMgr.GetPane( NAME_PYCRUST ) + for pane in self.allPanes: + if event.GetId() == pane.ID_: + auiPane = self.auiMgr.GetPane( pane.name_ ) + if event.IsChecked(): + auiPane.Show( ) + else: + auiPane.Hide() + break - if event.IsChecked(): - pane.Show( ) - else: - pane.Hide() self.auiMgr.Update() event.Skip() @@ -282,8 +284,12 @@ obj = event.GetEventObject().GetPyData( event.GetEventObject().GetSelection() ) if type( obj ) == ogre.SceneNode: self.ogreRenderWindow.camera.lookAt( obj.getWorldPosition() ) - self.objectInspector.showData( obj ); + if type( obj ) == ogre.Material: + self.materialInspector.showData( obj ); + else: + self.objectInspector.showData( obj ); + if ws.activeResource: if type( ws.activeResource ) == ogre.SceneNode: ws.activeResource.showBoundingBox( False ); @@ -294,6 +300,14 @@ ws.activeResource = obj event.Skip() + def doCheckTreeObject( self, event ): + obj = event.GetEventObject().GetPyData( event.GetItem() ) + checked = event.GetEventObject().IsItemChecked( event.GetItem() ); + obj.setVisible( checked ) + + event.GetEventObject().EnableChildren( event.GetItem(), checked) + event.Skip() + ################################################################################# # utils ################################################################################# @@ -345,11 +359,15 @@ object_it = scenenode.getAttachedObjectIterator() while object_it.hasMoreElements(): m = object_it.getNext() - item = self.sceneTree.AppendItem( treenode, m.getName() ) + item = self.sceneTree.AppendItem( treenode, m.getName(), 1 ) #item = self.sceneTree.AppendItem( treenode, m.getMovableType() + "-" + m.getName() ) if m.getMovableType() == "Entity": id = self.SceneEntityIconID + if m.getNumSubEntities() > 1: + for i in range( 0, m.getNumSubEntities() ): + subentNode = self.sceneTree.AppendItem( item, m.getSubEntity( i ).getMaterialName(), 1 ) + self.sceneTree.SetPyData( subentNode, m.getSubEntity( i ) ) else: id = self.SceneUnknownIconID Modified: branches/ogEditor/propgridtest.py =================================================================== --- branches/ogEditor/propgridtest.py 2008-05-21 20:04:57 UTC (rev 902) +++ branches/ogEditor/propgridtest.py 2008-05-24 17:26:37 UTC (rev 903) @@ -23,40 +23,61 @@ self.SetSize( wx.Size( 800, 600 ) ) self.propertyGrid = PropertyMainGrid( self, -1, wx.DefaultPosition, wx.DefaultSize ) - self.propertyGrid.appendRowItemName( "Main", "name" ) - self.propertyGrid.appendRowItemName( "float", value = 10.1, format = FORMAT_FLOAT, cback = test.printValue ) - self.propertyGrid.appendRowItemName( "int", value = 10, format = FORMAT_INT, cback = test.printValue ) + self.propertyGrid.appendRowItemName( "Main", "name", toolTip = "toolTip" ) + self.propertyGrid.appendRowItemName( "float", value = 10.1, format = FORMAT_FLOAT, cback = test.printValue, toolTip = "toolTip" ) + self.propertyGrid.appendRowItemName( "int", value = 10, format = FORMAT_INT, cback = test.printValue, toolTip = "toolTip" ) - self.propertyGrid.appendRowItemSlider( "slider", cback = test.printValue ) - self.propertyGrid.appendRowItemColourSelect( "Colour", cback = test.printValue ) + self.propertyGrid.appendRowItemSlider( "slider", cback = test.printValue, toolTip = "toolTip" ) + self.propertyGrid.appendRowItemColourSelect( "Colour", cback = test.printValue, toolTip = "toolTip" ) - pane = PropertyPaneItem( self.propertyGrid, "testPane " ) - self.propertyGrid.appendPane( pane ) + collpane = self.propertyGrid.createAndAppendPane( "Child 1", toolTip = "toolTip" ) + collpane.appendRowItemName( "Child 1 A", "name", toolTip = "toolTip" ) + collpane.appendRowItemName( "Child 1 B", "name", toolTip = "toolTip" ) + collpane.appendRowItemName( "Child 1 C", "name", toolTip = "toolTip" ) - text = PropertyRowItemName( pane.GetPane(), "Name", "Val") - pane.appendRow( text ) - pane.Layout() - pane.Show() + subPane = collpane.createAndAppendPane( "Child 1-1", toolTip = "toolTip" ) + subPane.appendRowItemName( "Child 1-1 A", "name", toolTip = "toolTip") + subPane.appendRowItemName( "Child 1-1 B", "name", toolTip = "toolTip") + subPane.appendRowItemName( "Child 1-1 C", "name", toolTip = "toolTip") + subPane.appendPaneColourSelect( "Colour", cback = test.printValue, toolTip = "toolTip" ); + + subPane = collpane.createAndAppendPane( "Child 1-2", toolTip = "toolTip" ) + subPane.appendRowItemName( "Child 1-2 A", "name", toolTip = "toolTip") + subPane.appendRowItemName( "Child 1-2 B", "name", toolTip = "toolTip") + subPane.appendRowItemName( "Child 1-2 C", "name", toolTip = "toolTip") + subPane.appendPaneColourSelect( "Colour", cback = test.printValue , toolTip = "toolTip"); + + collpane2 = self.propertyGrid.createAndAppendPane( "Child 2", toolTip = "toolTip" ) + collpane2.appendRowItemName( "Child 2 A", "name", toolTip = "toolTip" ) + collpane2.appendRowItemName( "Child 2 B", "name", toolTip = "toolTip" ) + collpane2.appendRowItemName( "Child 2 C", "name", toolTip = "toolTip" ) + + subPane2 = collpane2.createAndAppendPane( "Child 1-1", toolTip = "toolTip" ) + subPane2.appendRowItemName( "Child 2-1 A", "name", toolTip = "toolTip") + subPane2.appendRowItemName( "Child 2-1 B", "name", toolTip = "toolTip") + subPane2.appendRowItemName( "Child 2-1 C", "name", toolTip = "toolTip") + subPane2.appendRowItemColourSelect( "Colour", cback = test.printValue, toolTip = "toolTip" ); self.propertyGrid.appendRowItemSlider( "expDensity", 0.0001, 0.0002, format = FORMAT_LOG10, - cback = test.printValue ) + cback = test.printValue, toolTip = "toolTip" ) modes = ("one", "two", "three" ) self.propertyGrid.appendRowItemChoice( "Choice set", value = "one", - itemList = modes, cback = test.printValue ) + itemList = modes, cback = test.printValue , toolTip = "toolTip") dic = ( (1, "eins"), (2, "zwei"), (3, "drei")) self.propertyGrid.appendRowItemChoice( "Choice map", value = 1, - itemMap = dic, cback = test.printValue ) + itemMap = dic, cback = test.printValue , toolTip = "toolTip") - self.propertyGrid.appendRowItemFileSelect( "File", cback = test.printValue ) + self.propertyGrid.appendRowItemFileSelect( "File", cback = test.printValue, toolTip = "toolTip" ) self.propertyGrid.appendRowItemFileSelect( "Files", cback = test.printValue, - flag = wx.MULTIPLE ) + flag = wx.MULTIPLE, toolTip = "toolTip" ) - self.propertyGrid.appendRowItemButton( "Button", cback = test.printValue ) - self.propertyGrid.appendRowItemInfo( "here is a long an verbose text entry" ) + self.propertyGrid.appendRowItemButton( "Button", cback = test.printValue, toolTip = "toolTip" ) + self.propertyGrid.appendRowItemInfo( "here is a long an verbose text entry", toolTip = "toolTip" ) + self.propertyGrid.appendRowItemCheck( "Check button", cback = test.printValue , toolTip = "toolTip") if __name__ == "__main__": ogEditor = wx.PySimpleApp(0) Modified: branches/ogEditor/src/ObjectInspectorPanels.py =================================================================== --- branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-21 20:04:57 UTC (rev 902) +++ branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-24 17:26:37 UTC (rev 903) @@ -12,7 +12,24 @@ def toStr( vec ): return ("%g, %g, %g"%(vec.x, vec.y, vec.z)) + +ogreCompareFunctions = ((ogre.CMPF_ALWAYS_FAIL, "CMPF_ALWAYS_FAIL"), + (ogre.CMPF_ALWAYS_PASS, "CMPF_ALWAYS_PASS"), + (ogre.CMPF_LESS, "CMPF_LESS"), + (ogre.CMPF_LESS_EQUAL, "CMPF_LESS_EQUAL"), + (ogre.CMPF_EQUAL, "CMPF_EQUAL"), + (ogre.CMPF_NOT_EQUAL, "CMPF_NOT_EQUAL"), + (ogre.CMPF_GREATER_EQUAL, "CMPF_GREATER_EQUAL"), + (ogre.CMPF_GREATER, "CMPF_GREATER") ) +ogreCullingMode = (( ogre.CULL_NONE, "CULL_NONE"), # Hardware never culls triangles and renders everything it receives. + (ogre.CULL_CLOCKWISE, "CULL_CLOCKWISE" ), # Hardware culls triangles whose vertices are listed clockwise in the view (default). + (ogre.CULL_ANTICLOCKWISE, "CULL_ANTICLOCKWISE" ) )# Hardware culls triangles whose vertices are listed anticlockwise in the view. + +ogreShadeOptions = (( ogre.SO_FLAT , "SO_FLAT" ), + ( ogre.SO_GOURAUD, "SO_GOURAUD" ), + ( ogre.SO_PHONG, "SO_PHONG" ) ) + class PropertyCollapsibleOgreFogPane( PropertyPaneItem ): def __init__( self, parent, name, object = None ): PropertyPaneItem.__init__(self, parent, name) @@ -80,9 +97,10 @@ self.object.setFog(self.mode, col, self.expDensity, self.linearStart, self.linearEnd ) class ObjectInspectorPanel(wx.Panel): - def __init__(self, *args, **kwds): + def __init__(self, parent, *args, **kwds): kwds["style"] = wx.TAB_TRAVERSAL 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 ) @@ -121,6 +139,8 @@ self.showNone() if type( data ) == ogre.SceneNode: self.showSceneNode( data ) + elif type( data ) == ogre.SubEntity: + self.showSubEntity( data ) elif type( data ) == ogre.Entity: self.showEntity( data ) elif issubclass( type( data ), ogre.SceneManager): @@ -200,13 +220,20 @@ def showEntity( self, data ): self.typeStaticText.SetLabel( "ogre.Entity" ) self.showName( data ) + if data.getNumSubEntities() == 1: + self.propertyGrid.appendRowItemName( "Material", data.getSubEntity( 0 ).getMaterialName() ) + self.parent_.materialInspector.showData( data.getSubEntity( 0 ).getMaterial() ) + + def showSubEntity( self, data ): + self.typeStaticText.SetLabel( "ogre.SubEntity" ) + self.propertyGrid.appendRowItemName( "Material", data.getMaterialName() ) + self.parent_.materialInspector.showData( data.getMaterial() ) def showResource( self, data ): self.typeStaticText.SetLabel( "Resource: " + data.getCreator().getResourceType() ) self.showName( data ); self.propertyGrid.appendRowItemName( "Group", data.getGroup() ) self.propertyGrid.appendRowItemName( "Origin", data.getOrigin() ) - # params = data.getParameters() # if len( params ) > 0: # pane = self.propertyTree.createPane( "Parameters" ) @@ -216,7 +243,7 @@ # # if type( data ) == ogre.Texture: # print "Texture" - + def showMovableObject( self, data ): self.typeStaticText.SetLabel( "Movable object: " + data.getMovableType() ) self.showName( data ); @@ -233,5 +260,159 @@ # end of class ObjectInspectorPanel +class MaterialInspectorPanel( ObjectInspectorPanel ): + def showData( self, data ): + self.propertyGrid.clean() + if type( data ) == ogre.Material: + self.showMaterial( data ) + else: + print "data is no material", data + def showPass( self, data, parenpane ): + collpane = parenpane.createAndAppendPane( "Pass " + data.getName() ) + + collpane.appendRowItemInfo( "programmable %d" % data.isProgrammable(), + toolTip ="Returns true if this pass is programmable ie includes either a vertex or fragment program." ) + + collpane.appendRowItemInfo( "hasVertexProgram %d" % data.hasVertexProgram(), + toolTip ="Returns true if this pass uses a programmable vertex pipeline." ) + + collpane.appendRowItemInfo( "hasFragmentProgram %d" % data.hasFragmentProgram(), + toolTip ="Returns true if this pass uses a programmable fragment pipeline." ) + + + #Returns true if this pass uses a shadow caster vertex program. + #bool hasShadowCasterVertexProgram (void) const + + #Returns true if this pass uses a shadow receiver vertex program. + #bool hasShadowReceiverVertexProgram (void) const + + #Returns true if this pass uses a shadow receiver fragment program. + #bool hasShadowReceiverFragmentProgram (void) const + + collpane.appendPaneColourSelect( "setAmbient", cback = data.setAmbient, + toolTip = "Sets the ambient colour reflectance properties for every Pass in every Technique.") + + collpane.appendPaneColourSelect( "setDiffuse", cback = data.setDiffuse, + toolTip = "Sets the diffuse colour reflectance properties of every Pass in every Technique." ) + + collpane.appendPaneColourSelect( "setSpecular", cback = data.setSpecular, + toolTip = "Sets the specular colour reflectance properties of every Pass in every Technique." ) + + collpane.appendPaneColourSelect( "setSelfIllumination", cback = data.setSelfIllumination, + toolTip = "Sets the shininess properties of every Pass in every Technique." ) + + def showTechnique( self, data ): + collpane = self.propertyGrid.createAndAppendPane( "Technique " + data.getName() ) + + collpane.appendRowItemName( "scheme name ", cfront = data.getSchemeName, cback = data.setSchemeName, + toolTip = "Returns the scheme to which this technique is assigned." ) + collpane.appendRowItemInfo( "supported %d" % data.isSupported(), + toolTip ="Indicates if this technique is supported by the current graphics card." ) + + collpane.appendRowItemInfo( "transparent %d"% data.isTransparent(), + toolTip = "Indicates if this Technique involves transparency" ) + + collpane.appendRowItemInfo( "loaded %d"% data.isLoaded(), "technique.isLoaded()" ) + + collpane.appendPaneColourSelect( "setAmbient", cback = data.setAmbient, + toolTip = "Sets the ambient colour reflectance properties for every Pass in every Technique." ) + + collpane.appendPaneColourSelect( "setDiffuse", cback = data.setDiffuse, + toolTip = "Sets the diffuse colour reflectance properties of every Pass in every Technique." ) + + collpane.appendPaneColourSelect( "setSpecular", cback = data.setSpecular, + toolTip = "Sets the specular colour reflectance properties of every Pass in every Technique.") + + #void setShininess (Real val) + #Sets the shininess properties of every Pass in every Technique. + + collpane.appendPaneColourSelect( "setSelfIllumination", cback = data.setSelfIllumination, + toolTip = "Sets the shininess properties of every Pass in every Technique." ) + + collpane.appendRowItemCheck( "depth check", cfront = data.isDepthCheckEnabled, cback = data.setDepthCheckEnabled, + toolTip = "Sets whether or not each Pass renders with depth-buffer checking on or not." ) + + collpane.appendRowItemCheck( "depth write", cfront = data.isDepthWriteEnabled, cback = data.setDepthWriteEnabled, + toolTip = "Sets whether or not each Pass renders with depth-buffer writing on or not." ) + + collpane.appendRowItemChoice( "depth function", value = 1, itemMap = ogreCompareFunctions, cback = data.setDepthFunction, + toolTip = "Sets the function used to compare depth values when depth checking is on." ) + + collpane.appendRowItemChoice( "culling mode", value = 1, itemMap = ogreCullingMode, cback = data.setCullingMode, + toolTip = "Sets the culling mode for each pass based on the 'vertex winding'." ) + + collpane.appendRowItemCheck( "colour write", value = not data.hasColourWriteDisabled(), cback = data.setColourWriteEnabled, + toolTip = "Sets whether or not colour buffer writing is enabled for each Pass." ) + + collpane.appendRowItemCheck( "lighting", value = True, cback = data.setLightingEnabled, + toolTip = "Sets whether or not dynamic lighting is enabled for every Pass." ) + + collpane.appendRowItemChoice( "shading mode", value = 1, itemMap = ogreShadeOptions, cback = data.setShadingMode, + toolTip = "Sets the type of light shading required." ) + + #String _compile (bool autoManageTextureUnits) + #Internal compilation method; see Material::compile. + #void _compileIlluminationPasses (void) + #Internal method for splitting the passes into illumination passes. + #Pass * createPass (void) + #Creates a new Pass for this Technique. + #void removePass (unsigned short index) + #Removes the Pass with the given index. + #bool movePass (const unsigned short sourceIndex, const unsigned short destinationIndex) + #Move a pass from source index to destination index. + + #const IlluminationPassIterator getIlluminationPassIterator (void) + #Gets an iterator over the illumination-stage categorised passes. + + #void _notifyNeedsRecompile (void) + #Tells the technique that it needs recompilation. + #void setPointSize (Real ps) + #Sets the point size properties for every Pass in this Technique. + + #void setManualCullingMode (ManualCullingMode mode) + #Sets the manual culling mode, performed by CPU rather than hardware. + + #void setFog (bool overrideScene, FogMode mode=FOG_NONE, const ColourValue &colour=ColourValue::White, Real expDensity=0.001, Real linearStart=0.0, Real linearEnd=1.0) + #Sets the fogging mode applied to each pass. + #void setDepthBias (float constantBias, float slopeScaleBias) + #Sets the depth bias to be used for each Pass. + #void setTextureFiltering (TextureFilterOptions filterType) + #Set texture filtering for every texture unit in every Pass. + #void setTextureAnisotropy (unsigned int maxAniso) + #Sets the anisotropy level to be used for all textures. + #void setSceneBlending (const SceneBlendType sbt) + #Sets the kind of blending every pass has with the existing contents of the scene. + #void setSceneBlending (const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor) + #Allows very fine control of blending every Pass with the existing contents of the scene. + #void setLodIndex (unsigned short index) + #Assigns a level-of-detail (LOD) index to this Technique. + #unsigned short getLodIndex (void) const + #Gets the level-of-detail index assigned to this Technique. + + #void setSchemeName (const String &schemeName) + #Set the 'scheme name' for this technique. + #const String & getSchemeName (void) const + #Returns the scheme to which this technique is assigned. + #unsigned short _getSchemeIndex (void) const + #Internal method for getting the scheme index. + + #void setName (const String &name) + #Set the name of the technique. + #const String & getName (void) const + #Gets the name of the technique. + #bool applyTextureAliases (const AliasTextureNamePairList &aliasList, const bool apply=true) const + #Applies texture names to Texture Unit State with matching texture name aliases. + + + nPasses = data.getNumPasses() + for i in range(0,nPasses): + self.showPass( data.getPass( i ), collpane ) + + def showMaterial( self, data ): + self.showResource( data ) + self.typeStaticText.SetLabel( "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-21 20:04:57 UTC (rev 902) +++ branches/ogEditor/src/OgreWindowWx.py 2008-05-24 17:26:37 UTC (rev 903) @@ -44,10 +44,10 @@ #if you don't like the idea sceneEntities = Struct() - def __init__( self, parent, ID, size = wx.Size( 800, 600 ), renderSystem = "OpenGL", ogResourceMan = None, **kwargs ): + def __init__( self, parent, ID, size = wx.Size( 800, 600 ), renderSystem = "OpenGL", **kwargs ): self.parent = parent wx.PyWindow.__init__( self, parent, ID, size = size, **kwargs ) - self.ogResourceMan = ogResourceMan + #Event bindings self.Bind( wx.EVT_CLOSE, self._OnCloseWindow) self.Bind( wx.EVT_SIZE, self._OnSize) @@ -67,21 +67,22 @@ def _OgreInit(self,size,renderSystem): #Root creation self.ogreRoot = ogre.Root( getPluginPath(), "ogre.cfg" ) - if self.ogResourceMan: - self.ogResourceMan.ogreRoot = self.ogreRoot # setup resources config = ogre.ConfigFile() config.load( 'resources.cfg' ) + self.resourceLocations = [] section_iter = config.getSectionIterator() while section_iter.hasMoreElements(): section_name = section_iter.peekNextKey() settings = section_iter.getNext() for key, path in settings: ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section_name, False) - if self.ogResourceMan: - self.ogResourceMan.addResourceLocation( path, section_name ) + #if self.ogResourceMan: + #self.ogResourceMan.addResourceLocation( path, section_name ) + + self.resourceLocations.append( (path, section_name ) ) if os.path.exists( "ogre.cfg" ): self.ogreRoot.restoreConfig() @@ -140,9 +141,6 @@ renderWindow = self.ogreRoot.createRenderWindow('wxPython render window', size[ 0 ], size[ 1 ], False, renderParameters) renderWindow.active = True self.renderWindow = renderWindow - - if self.ogResourceMan: - self.ogResourceMan.renderWindow = renderWindow ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups() Modified: branches/ogEditor/src/PropertyGrid.py =================================================================== --- branches/ogEditor/src/PropertyGrid.py 2008-05-21 20:04:57 UTC (rev 902) +++ branches/ogEditor/src/PropertyGrid.py 2008-05-24 17:26:37 UTC (rev 903) @@ -200,19 +200,24 @@ return wx.combo.ComboPopup.LazyCreate(self) class PropertyRowItem( ): + cfront_ = None cback_ = None parent_ = None - size_ = None + sizer_ = None labelTextCtrl_ = None rowHeight_ = 10 - def __init__( self, parent, name, cback = None ): - self.cback_ = cback - self.parent_ = parent - self.sizer_ = wx.BoxSizer( wx.HORIZONTAL ) + def __init__( self, parent, name, cfront = None, cback = None, toolTip = None): + self.cfront_ = cfront + self.cback_ = cback + self.parent_ = parent + self.sizer_ = wx.BoxSizer( wx.HORIZONTAL ) self.labelTextCtrl_ = wx.TextCtrl( parent, -1, name, style = wx.NO_BORDER | wx.ALIGN_LEFT ) + if toolTip: + self.labelTextCtrl_.SetToolTip( wx.ToolTip( toolTip ) ) + self.rowHeight_ = self.labelTextCtrl_.GetSize()[ 1 ] self.labelTextCtrl_.SetEditable( False ) self.sizer_.Add( self.labelTextCtrl_, 0, wx.EXPAND | wx.ALIGN_RIGHT ) @@ -228,20 +233,25 @@ item.GetWindow().Enable( value ) class PropertyRowItemInfo( PropertyRowItem ): - def __init__( self, parent, name ): + def __init__( self, parent, name, toolTip = None ): self.sizer_ = wx.BoxSizer( wx.HORIZONTAL ) self.labelTextCtrl_ = wx.TextCtrl( parent, -1, name, style = wx.NO_BORDER | wx.ALIGN_LEFT ) + if toolTip: + self.labelTextCtrl_.SetToolTip( wx.ToolTip( toolTip ) ) + self.labelTextCtrl_.SetEditable( False ) self.sizer_.Add( self.labelTextCtrl_, 1, wx.EXPAND | wx.ALIGN_RIGHT ) class PropertyRowItemName( PropertyRowItem ): valueTextCtrl_ = None format_ = None - def __init__( self, parent, name, value = None, format = FORMAT_STRING, cback = None): - PropertyRowItem.__init__( self, parent, name, cback = cback ) + def __init__( self, parent, name, value = None, format = FORMAT_STRING, cfront = None, cback = None, toolTip = None ): + PropertyRowItem.__init__( self, parent, name, cfront = cfront, cback = cback, toolTip = toolTip ) self.format_ = format self.validator = MyValidator() + if cfront: + value = cfront() if format == FORMAT_INT: self.validator = MyValidator( DIGIT_ONLY ) @@ -250,6 +260,8 @@ size = wx.Size( 40, self.rowHeight_ ), style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND, validator = self.validator ) + if ( toolTip ): + self.valueTextCtrl_.SetToolTip( wx.ToolTip( toolTip ) ) if ( format == FORMAT_STRING ): self.valueTextCtrl_.SetValue( "%s" % value ); @@ -280,28 +292,33 @@ class PropertyRowItemButton( PropertyRowItem ): button_ = None - def __init__( self, parent, name, cback = None ): - PropertyRowItem.__init__( self, parent, name, cback = cback ) + def __init__( self, parent, name, cback = None, toolTip = None ): + PropertyRowItem.__init__( self, parent, name, cback = cback, toolTip = toolTip ) self.button_ = wx.Button( parent, -1, size = wx.Size( 40, self.rowHeight_ ), style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) + if ( toolTip ): + self.button_.SetToolTip( wx.ToolTip( toolTip ) ) + self.sizer_.AddSpacer( 1 ) self.sizer_.Add( self.button_, 1, wx.EXPAND | wx.ALIGN_LEFT ) self.button_.Bind( wx.EVT_BUTTON, self.cback_ ) class PropertyRowItemFileSelect( PropertyRowItem ): - def __init__( self, parent, name, value = "", cback = None, flag = 0, + def __init__( self, parent, name, value = "", cback = None, flag = 0, toolTip = None, wildcard = "All files (*.*)|*.*" ): - PropertyRowItem.__init__( self, parent, name, cback = cback ) + PropertyRowItem.__init__( self, parent, name, cback = cback, toolTip = toolTip ) self.value = value self.filename = self.value self.paths = [] self.wildcard = wildcard self.flag = flag if self.flag == wx.MULTIPLE: - self.choice = wx.combo.ComboCtrl( parent, -1, + self.choice = wx.combo.ComboCtrl( parent, -1,#shortHelp = "PropertyRowItem", size = wx.Size( 100, self.rowHeight_ ), style = wx.NO_BORDER | wx.NO_3D | wx.CB_READONLY ) + + self.popup = ListCtrlComboPopup( cback = self.setFilenameIdx ) self.popup.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.choice.SetPopupControl( self.popup ) @@ -364,10 +381,19 @@ self.cback_( self.filename ) class PropertyRowItemCheck( PropertyRowItem ): - def __init__( self, parent, name, value = False, cback = None): - PropertyRowItem.__init__( self, parent, name, cback = cback ) - self.isChecked = value + def __init__( self, parent, name, value = False, cfront = None, cback = None, toolTip = None ): + PropertyRowItem.__init__( self, parent, name, cfront = cfront, cback = cback, toolTip = toolTip ) + + if self.cfront_: + self.isChecked = self.cfront_() + else: + self.isChecked = value + self.checkbox = wx.CheckBox( parent, -1 ) + + if ( toolTip ): + self.checkbox.SetToolTip( wx.ToolTip( toolTip ) ) + self.sizer_.AddSpacer( 1 ) self.sizer_.Add( self.checkbox, 1, wx.EXPAND | wx.ALIGN_LEFT ) self.checkbox.Bind( wx.EVT_CHECKBOX, self.onChecked ) @@ -384,8 +410,8 @@ class PropertyRowItemSlider( PropertyRowItem ): def __init__( self, parent, name, value = 0, start = 0, end = 100, - format = FORMAT_INT, cback = None ): - PropertyRowItem.__init__( self, parent, name, cback = cback ) + format = FORMAT_INT, cback = None, toolTip = None ): + PropertyRowItem.__init__( self, parent, name, cback = cback, toolTip = toolTip ) self.format = format self.value = value self.start = start @@ -412,9 +438,12 @@ size = wx.Size( 40, self.rowHeight_ ), style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND, validator = self.validator) + + if ( toolTip ): + self.valueTextCtrl.SetToolTip( wx.ToolTip( toolTip ) ) - self.slider = wx.Slider( parent, -1, self.sliderValue, self.sliderStart, self.sliderEnd, - size = wx.Size( 100, self.rowHeight_ ), + self.slider = wx.Slider( parent, -1, self.sliderValue, self.sliderStart, self.sliderEnd, + size = wx.Size( 100, self.rowHeight_ ),#shortHelp = "PropertyRowItemSlider", style = wx.NO_BORDER | wx.NO_3D ) self.sizer_.AddSpacer( 1 ) @@ -460,8 +489,8 @@ self.cback_( self.value ) class PropertyRowItemChoice( PropertyRowItem ): - def __init__( self, parent, name, value = None, itemList = None, itemMap = None, cback = None): - PropertyRowItem.__init__( self, parent, name, cback = cback ) + def __init__( self, parent, name, value = None, itemList = None, itemMap = None, cback = None, toolTip = None): + PropertyRowItem.__init__( self, parent, name, cback = cback, toolTip = toolTip ) self.value = "" @@ -527,14 +556,18 @@ self.cback_( self.value ) class PropertyRowItemColourSelect( PropertyRowItemName ): - def __init__( self, parent, name, cback = None ): - PropertyRowItemName.__init__( self, parent, name, cback = cback ) + def __init__( self, parent, name, cback = None, toolTip = None ): + PropertyRowItemName.__init__( self, parent, name, cback = cback, toolTip = toolTip ) self.value = wx.Colour(0,0,0) self.colourButton = csel.ColourSelect( parent, -1, "", colour = self.value, size = wx.Size( self.rowHeight_, self.rowHeight_ ), - style = wx.NO_BORDER ) + style = wx.NO_BORDER ) + + if ( toolTip ): + self.colourButton.SetToolTip( wx.ToolTip( toolTip ) ) + self.sizer_.AddSpacer( 1 ) self.sizer_.Add( self.colourButton, 0, wx.EXPAND ) @@ -559,80 +592,97 @@ class PropertyGrid( ): def __init__(self): self.sizer_ = wx.BoxSizer( wx.VERTICAL ) - self.SetSizer( self.sizer_ ) self.widthCol0 = 50 self.widthCol2 = 24 self.xOffset = 17 def appendRow(self, row ): self.sizer_.AddSpacer(1) - self.sizer_.Add( row.sizer_, 0, wx.EXPAND ) + #self.sizer_.Add( row.sizer_, 0, wx.EXPAND ) - def appendRowItemInfo(self, name ): - item = PropertyRowItemInfo( self.pane, name ) + rowsizer = wx.BoxSizer( wx.HORIZONTAL ) + rowsizer.AddSpacer( 17 ) + rowsizer.Add( row.sizer_, 1, wx.EXPAND ) + self.sizer_.Add( rowsizer, 0, wx.EXPAND ) + + def appendRowItemInfo(self, name, toolTip = None): + item = PropertyRowItemInfo( self.pane, name, toolTip = toolTip ) self.appendRow( item ) return item - def appendRowItemName(self, name, value = None, format = FORMAT_STRING, cback = None ): - item = PropertyRowItemName( self.pane, name, value, format, cback ) + def appendRowItemName(self, name, value = None, format = FORMAT_STRING, cfront = None, cback = None, toolTip = None ): + item = PropertyRowItemName( self.pane, name, value, format, cfront = cfront, cback = cback, toolTip = toolTip ) self.appendRow( item ) return item - def appendRowItemButton(self, name, cback = None ): + def appendRowItemButton(self, name, cback = None, toolTip = None ): item = PropertyRowItemButton( self.pane, name, cback = cback) self.appendRow( item ) return item - def appendRowItemCheck(self, name, value = False, cback = None ): - item = PropertyRowItemCheck( self.pane, name, value, cback = cback) + def appendRowItemCheck(self, name, value = False, cfront = None, cback = None, toolTip = None ): + item = PropertyRowItemCheck( self.pane, name, value, cfront = cfront, cback = cback, toolTip = toolTip) self.appendRow( item ) return item - def appendRowItemChoice(self, name, value = None, itemList = None, itemMap = None, cback = None ): - item = PropertyRowItemChoice( self.pane, name = name , value = value, itemList = itemList, itemMap = itemMap, cback = cback ) + def appendRowItemChoice(self, name, value = None, itemList = None, itemMap = None, cback = None, toolTip = None ): + item = PropertyRowItemChoice( self.pane, name = name , value = value, itemList = itemList, itemMap = itemMap, + cback = cback, toolTip = toolTip ) self.appendRow( item ) return item - def appendRowItemFileSelect(self, name, value = "", cback = None, flag = 0, + def appendRowItemFileSelect(self, name, value = "", cback = None, flag = 0, toolTip = None, wildcard = "All files (*.*)|*.*" ): item = PropertyRowItemFileSelect( self.pane, name, value = value, - cback = cback, flag = flag, + cback = cback, flag = flag, toolTip = toolTip, wildcard = wildcard ) self.appendRow( item ) return item def appendRowItemSlider( self, name, value = 0, start = 0, end = 100, - format = FORMAT_INT, cback = None ): - item = PropertyRowItemSlider( self.pane, name, value, start, end, format, cback ) + format = FORMAT_INT, cback = None, toolTip = None ): + item = PropertyRowItemSlider( self.pane, name, value, start, end, format, cback = cback, toolTip = toolTip ) self.appendRow( item ) return item - def appendRowItemColourSelect( self, name, cback = None ): - item = PropertyRowItemColourSelect( self.pane, name, cback = cback ) + def appendRowItemColourSelect( self, name, cback = None, toolTip = None ): + item = PropertyRowItemColourSelect( self.pane, name, cback = cback, toolTip = toolTip ) self.appendRow( item ) return item + def createAndAppendPane( self, name, toolTip = None): + pane = PropertyPaneItem( self, name, toolTip = toolTip ) + return self.appendPane( pane ) + def appendPane(self, pane ): - self.sizer_.AddSpacer( 1 ) + rowsizer = wx.BoxSizer( wx.HORIZONTAL ) + rowsizer.AddSpacer( 13 ) + rowsizer.Add( pane, 1, wx.EXPAND ) + self.sizer_.Add( rowsizer, 0, wx.EXPAND ) + return pane + #self.sizer_.AddSpacer( 1 ) #self.sizer_.Add( pane, 0, wx.EXPAND ) - self.sizer_.Add( pane, 0, wx.EXPAND ) - def appendPaneColourSelect( self, name, cfront = None, cback = None ): - pane = PropertyPaneItemColour( self.pane, name, cfront, cback ) + def appendPaneColourSelect( self, name, cfront = None, cback = None, toolTip = None): + pane = PropertyPaneItemColour( self, name, cfront = cfront, cback = cback, toolTip = toolTip ) self.appendPane( pane ) return pane #class PropertyPaneItem( wx.Panel, PropertyGrid ): class PropertyPaneItem( wx.CollapsiblePane, PropertyGrid ): - def __init__(self, parent, name): + def __init__(self, parent, name, toolTip = None): self.parent_ = parent - - wx.CollapsiblePane.__init__( self, parent, -1, name, - style = wx.CP_DEFAULT_STYLE - | wx.CP_NO_TLW_RESIZE - ) + 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.Panel.__init__( self, parent, -1 ) + if toolTip: + self.SetToolTip( wx.ToolTip( toolTip ) ) + PropertyGrid.__init__( self ) self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) @@ -641,27 +691,22 @@ self.pane = self.GetPane() self.pane.SetFont( wx.Font( 8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "" ) ) - self.sizer_ = wx.BoxSizer( wx.VERTICAL ) self.pane.SetSizer( self.sizer_ ) #def GetPane( self ): #return self.pane def OnPaneChanged(self, event = None): - if event: - if ( event.Collapsed ): - event.GetEventObject().GetPane().Hide() - else: - event.GetEventObject().GetPane().Show() - #self.pane.Show() - #self.Layout() - #self.parent_.Layout() + if ( issubclass( type( self.parent_ ), PropertyPaneItem ) ): + self.parent_.Collapse( ) + self.parent_.Expand( ) + self.GetParent().Layout() class PropertyPaneItemColour( PropertyPaneItem ): - def __init__( self, parent, name, cfront = None, cback = None ): - PropertyPaneItem.__init__(self, parent, name) + def __init__( self, parent, name, cfront = None, cback = None, toolTip = None ): + PropertyPaneItem.__init__(self, parent, name, toolTip = toolTip) self.cback = cback self.cfront = cfront self.value = [0, 0, 0, 0] @@ -710,6 +755,8 @@ argv["style"] = wx.TAB_TRAVERSAL wx.Panel.__init__(self, *argc, **argv) 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) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-25 09:10:37
|
Revision: 904 http://opengate.svn.sourceforge.net/opengate/?rev=904&view=rev Author: spom_spom Date: 2008-05-25 02:10:42 -0700 (Sun, 25 May 2008) Log Message: ----------- separate opengate stuff from ogEditor base Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/plugins.cfg branches/ogEditor/resources.cfg branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/ResourceTreePane.py Added Paths: ----------- branches/ogEditor/opengate-resources.cfg Removed Paths: ------------- branches/ogEditor/ogEditor.sh branches/ogEditor/ogre.cfg Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-24 17:26:37 UTC (rev 903) +++ branches/ogEditor/ogEditor.py 2008-05-25 09:10:42 UTC (rev 904) @@ -19,7 +19,11 @@ from OgreWindowWx import * -import opengate as og +try: + import opengate as og +except: + haveOpenGatePlugin = False + pass ID_MB_FILE_EXIT = wx.NewId() ID_MB_VIEW_SCENETREE = wx.NewId() @@ -83,6 +87,24 @@ itemList = shaderSchemes, cback = vp.setMaterialScheme ) + def AddToResourcesTree( self, tree, node): + + if self.resourceManager_: + ogResManNode = tree.AppendItem( node, "OpenGate resource manager" ) + + if self.resourceManager_.entityManager: + ogEntityManagerNode = tree.AppendItem( ogResManNode, "Entity manager" ) + categories = self.resourceManager_.entityManager.categories(); + + for category in categories: + categoryNode = tree.AppendItem( ogEntityManagerNode, category ) + + + def AddToSceneGraph( self, tree, node ): + opengateNode = tree.AppendItem( node, "Opengate" ) + tree.SetPyData( opengateNode, self ) + + class OGEditorPane: def __init__( self, ID, Name, mbShortcut, creator, defaultCheck ): self.ID_ = ID @@ -102,7 +124,7 @@ 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, False ) ) + 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_PYCRUST, NAME_PYCRUST , "\tF9", None, False ) ) @@ -111,12 +133,21 @@ self.initToolBar_() self.initStatusBar_() self.initFrameManager_() + self.setDefaultProperties_(); - self.og = Opengate( self.ogreRenderWindow ) - self.og.initOpenGateResources_(); - self.og.sector = og.Sector( self.ogreRenderWindow.sceneManager, None ); + if haveOpenGatePlugin: + print "Found opengate plugin" + self.og = Opengate( self.ogreRenderWindow ) + self.og.initOpenGateResources_(); + self.og.sector = og.Sector( self.ogreRenderWindow.sceneManager, None ) + self.og.AddToSceneGraph( self.sceneTree, self.sceneTree.root_ ) + self.og.AddToResourcesTree( self.resourceTree, self.resourceTree.root_ ) + + else: + ohNode = self.createObject( "ogreMesh", "ogrehead.mesh" ) + ohNode.translate( ogre.Vector3( 0.0, 0.0, -100 ) ); - self.setDefaultProperties_(); + self.auiMgr.Update() def initMenuBar_( self ): @@ -145,7 +176,8 @@ self.tb.AddLabelTool( ID_TB_EXIT, "Exit", wx.ArtProvider_GetBitmap(wx.ART_QUIT), wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.tb.AddLabelTool( ID_TB_TMP, "Up", wx.ArtProvider_GetBitmap(wx.ART_QUESTION), - wx.NullBitmap, wx.ITEM_NORMAL, "", "") + wx.NullBitmap, wx.ITEM_NORMAL, "tempary tool button to force scenegraph update", "") + self.Bind( wx.EVT_TOOL, self.doExit, id = ID_TB_EXIT ) self.Bind( wx.EVT_TOOL, self.UpdateSceneGraphEvent, id = ID_TB_TMP ) @@ -299,6 +331,7 @@ ws.activeResource = obj event.Skip() + self.auiMgr.Update() def doCheckTreeObject( self, event ): obj = event.GetEventObject().GetPyData( event.GetItem() ) @@ -317,8 +350,10 @@ node = sceneManager.getRootSceneNode().createChildSceneNode( name ); entity = sceneManager.createEntity( name, meshname ); node.attachObject( entity ); + self.UpdateSceneGraphEvent(); + return node - def UpdateSceneGraphEvent(self, event): + def UpdateSceneGraphEvent(self, event = None): self.sceneTree.DeleteAllItems() root = self.sceneTree.AddRoot( "SceneManager" ) self.sceneTree.SetPyData( root, self.ogreRenderWindow.sceneManager ) @@ -330,9 +365,6 @@ self.dumpSceneNode_( rootSceneNodeTreeNode, rootSceneNode ) self.sceneTree.Expand( root ) - opengateNode = self.sceneTree.AppendItem( root, "Opengate" ) - self.sceneTree.SetPyData( opengateNode, self.og ) - if event != None: event.Skip() Deleted: branches/ogEditor/ogEditor.sh =================================================================== --- branches/ogEditor/ogEditor.sh 2008-05-24 17:26:37 UTC (rev 903) +++ branches/ogEditor/ogEditor.sh 2008-05-25 09:10:42 UTC (rev 904) @@ -1,3 +0,0 @@ -export LD_LIBRARY_PATH=~/local/python-ogre.work/root/usr/lib -export PYTHONPATH=/home/carsten/local/python-ogre.work/root/usr/lib64/python2.5/site-packages -python ogEditor.py Deleted: branches/ogEditor/ogre.cfg =================================================================== --- branches/ogEditor/ogre.cfg 2008-05-24 17:26:37 UTC (rev 903) +++ branches/ogEditor/ogre.cfg 2008-05-25 09:10:42 UTC (rev 904) @@ -1,7 +0,0 @@ -Render System=OpenGL Rendering Subsystem - -[OpenGL Rendering Subsystem] -FSAA=0 -Full Screen=Yes -RTT Preferred Mode=FBO -Video Mode=800 x 600 Added: branches/ogEditor/opengate-resources.cfg =================================================================== --- branches/ogEditor/opengate-resources.cfg (rev 0) +++ branches/ogEditor/opengate-resources.cfg 2008-05-25 09:10:42 UTC (rev 904) @@ -0,0 +1,33 @@ +[General] +FileSystem=../../trunk/data/ +FileSystem=../../trunk/data/capacitors +FileSystem=../../trunk/data/commodities +FileSystem=../../trunk/data/gui +FileSystem=../../trunk/data/gui/fonts +FileSystem=../../trunk/data/gui/layouts +FileSystem=../../trunk/data/gui/imagesets +FileSystem=../../trunk/data/gui/schemes +FileSystem=../../trunk/data/gui/looknfeel +FileSystem=../../trunk/data/gui/overlays +FileSystem=../../trunk/data/ecms +FileSystem=../../trunk/data/engines +FileSystem=../../trunk/data/guns +FileSystem=../../trunk/data/materials +FileSystem=../../trunk/data/asteroids +FileSystem=../../trunk/data/misc +FileSystem=../../trunk/data/missiles +FileSystem=../../trunk/data/power_plants +FileSystem=../../trunk/data/radars +FileSystem=../../trunk/data/shields +FileSystem=../../trunk/data/ships/octavius/apteryx +FileSystem=../../trunk/data/ships/quantar/storm +FileSystem=../../trunk/data/ships/squadrok/squid +FileSystem=../../trunk/data/ships/tauseti/lady_kickstart +FileSystem=../../trunk/data/skybox +FileSystem=../../trunk/data/stations +FileSystem=../../trunk/data/textures + +Zip=../../trunk/data/skybox/simpleSkybox.zip + +FileSystem=../../trunk/data/MediaFromOgre +FileSystem=../../trunk/data/MediaFromOgre/AdvancedMaterials Modified: branches/ogEditor/plugins.cfg =================================================================== --- branches/ogEditor/plugins.cfg 2008-05-24 17:26:37 UTC (rev 903) +++ branches/ogEditor/plugins.cfg 2008-05-25 09:10:42 UTC (rev 904) @@ -2,7 +2,6 @@ ## Use this for Windows # Define plugin folder -#PluginFolder=/home/carsten/local/python-ogre.work/root/usr/lib/OGRE PluginFolder=/usr/lib/OGRE #Plugin=RenderSystem_GL.dll #Plugin=RenderSystem_Direct3D9.dll Modified: branches/ogEditor/resources.cfg =================================================================== --- branches/ogEditor/resources.cfg 2008-05-24 17:26:37 UTC (rev 903) +++ branches/ogEditor/resources.cfg 2008-05-25 09:10:42 UTC (rev 904) @@ -1,38 +1,15 @@ [Bootstrap] -#Zip=../../../python-ogre/python-ogre/demos/media/packs/OgreCore.zip -FileSystem=../../trunk/data/startup +Zip=../../local/python-ogre/python-ogre/demos/media/packs/OgreCore.zip -# Resource locations to be added to the default path [General] -FileSystem=../../trunk/data/ -FileSystem=../../trunk/data/capacitors -FileSystem=../../trunk/data/commodities -FileSystem=../../trunk/data/gui -FileSystem=../../trunk/data/gui/fonts -FileSystem=../../trunk/data/gui/layouts -FileSystem=../../trunk/data/gui/imagesets -FileSystem=../../trunk/data/gui/schemes -FileSystem=../../trunk/data/gui/looknfeel -FileSystem=../../trunk/data/gui/overlays -FileSystem=../../trunk/data/ecms -FileSystem=../../trunk/data/engines -FileSystem=../../trunk/data/guns -FileSystem=../../trunk/data/materials -FileSystem=../../trunk/data/asteroids -FileSystem=../../trunk/data/misc -FileSystem=../../trunk/data/missiles -FileSystem=../../trunk/data/power_plants -FileSystem=../../trunk/data/radars -FileSystem=../../trunk/data/shields -FileSystem=../../trunk/data/ships/octavius/apteryx -FileSystem=../../trunk/data/ships/quantar/storm -FileSystem=../../trunk/data/ships/squadrok/squid -FileSystem=../../trunk/data/ships/tauseti/lady_kickstart -FileSystem=../../trunk/data/skybox -FileSystem=../../trunk/data/stations -FileSystem=../../trunk/data/textures +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 -Zip=../../trunk/data/skybox/simpleSkybox.zip - -FileSystem=../../trunk/data/MediaFromOgre -FileSystem=../../trunk/data/MediaFromOgre/AdvancedMaterials Modified: branches/ogEditor/src/OgreWindowWx.py =================================================================== --- branches/ogEditor/src/OgreWindowWx.py 2008-05-24 17:26:37 UTC (rev 903) +++ branches/ogEditor/src/OgreWindowWx.py 2008-05-25 09:10:42 UTC (rev 904) @@ -79,9 +79,6 @@ settings = section_iter.getNext() for key, path in settings: ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section_name, False) - #if self.ogResourceMan: - #self.ogResourceMan.addResourceLocation( path, section_name ) - self.resourceLocations.append( (path, section_name ) ) if os.path.exists( "ogre.cfg" ): @@ -141,7 +138,7 @@ renderWindow = self.ogreRoot.createRenderWindow('wxPython render window', size[ 0 ], size[ 1 ], False, renderParameters) renderWindow.active = True self.renderWindow = renderWindow - + ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups() def _OnSize(self, event): Modified: branches/ogEditor/src/ResourceTreePane.py =================================================================== --- branches/ogEditor/src/ResourceTreePane.py 2008-05-24 17:26:37 UTC (rev 903) +++ branches/ogEditor/src/ResourceTreePane.py 2008-05-25 09:10:42 UTC (rev 904) @@ -1,6 +1,5 @@ import wx import wx.lib.customtreectrl as CT -import opengate as og import ogre.renderer.OGRE as ogre @@ -34,13 +33,12 @@ return newNode def buildResourceTree( self ): - root = self.AddRoot( "Resources" ) + self.root_ = root = self.AddRoot( "Resources" ) resManNode = self.AppendItem( root, "Ogre resource manager" ) ## Insert resources group managers (Material, Mesh, Texture etc. ) ogreResourceGroupManager = ogre.ResourceGroupManager.getSingleton() - ogResourceManager = og.ResourceManager.getSingleton() resManIter = ogreResourceGroupManager.getResourceManagerIterator() while resManIter.hasMoreElements(): @@ -66,13 +64,14 @@ resGroupName = resGroups[ i ] resGroupNode = self.addItem( resGroupManNode, resGroupName, None ) - if ogResourceManager: - resLocNode = self.addItem( resGroupNode, "Resource group locations", None ) + #ogResourceManager = og.ResourceManager.getSingleton() + #if ogResourceManager: + #resLocNode = self.addItem( resGroupNode, "Resource group locations", None ) - if not resGroupName == "Autodetect" and not resGroupName == "Internal": - resLocationList = ogResourceManager.resourceLocations( resGroupName ) - for resLocation in resLocationList: - self.addItem( resLocNode, resLocation, None ) + #if not resGroupName == "Autodetect" and not resGroupName == "Internal": + #resLocationList = ogResourceManager.resourceLocations( resGroupName ) + #for resLocation in resLocationList: + #self.addItem( resLocNode, resLocation, None ) ## Insert resources for each groups resNameNode = self.addItem( resGroupNode, "Resources", None ) @@ -83,19 +82,8 @@ # insert Opengate specific resources - if ogResourceManager: - ogResManNode = self.AppendItem( root, "OpenGate resource manager" ) - - - if ogResourceManager.entityManager: - ogEntityManagerNode = self.AppendItem( ogResManNode, "Entity manager" ) - entityManager = ogResourceManager.entityManager - categories = entityManager.categories(); + - for category in categories: - categoryNode = self.AppendItem( ogEntityManagerNode, category ) - - ## Insert resources group managers (Material, Mesh, Texture etc. ) # this fails ??? #fileInfoList = ogre.ResourceGroupManager.getSingleton().findResourceFileInfo( "General", "*.png") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-25 14:21:19
|
Revision: 906 http://opengate.svn.sourceforge.net/opengate/?rev=906&view=rev Author: spom_spom Date: 2008-05-25 07:21:26 -0700 (Sun, 25 May 2008) Log Message: ----------- ogEditor: win compatibility commit, Propertygrid looks totally weird Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/plugins.cfg branches/ogEditor/propgridtest.py branches/ogEditor/resources.cfg branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/ResourceTreePane.py Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-25 11:51:13 UTC (rev 905) +++ branches/ogEditor/ogEditor.py 2008-05-25 14:21:26 UTC (rev 906) @@ -5,9 +5,9 @@ import sys import wx -sys.path.append( './packages_2.5/' ) +sys.path.append( './packages_2.5' ) sys.path.append( '../' ) -sys.path.append( './src/' ) +sys.path.append( './src' ) import wx.aui import wx.py as py @@ -150,6 +150,7 @@ self.og.AddToResourcesTree( self.resourceTree, self.resourceTree.root_ ) else: + print "no default plugin found: start fallback" ohNode = self.createObject( "ogreMesh", "ogrehead.mesh" ) ohNode.translate( ogre.Vector3( 0.0, 0.0, -100 ) ); @@ -247,7 +248,8 @@ style=wx.SUNKEN_BORDER | CT.TR_HAS_BUTTONS | 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.TR_DEFAULT_STYLE, wx.FONTWEIGHT_NORMAL ) ) + #self.sceneTree.SetFont( wx.Font( 8, 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 ) ) ) Modified: branches/ogEditor/plugins.cfg =================================================================== --- branches/ogEditor/plugins.cfg 2008-05-25 11:51:13 UTC (rev 905) +++ branches/ogEditor/plugins.cfg 2008-05-25 14:21:26 UTC (rev 906) @@ -2,18 +2,18 @@ ## Use this for Windows # Define plugin folder -PluginFolder=/usr/lib/OGRE -#Plugin=RenderSystem_GL.dll -#Plugin=RenderSystem_Direct3D9.dll -#Plugin=Plugin_ParticleFX.dll -#Plugin=Plugin_BSPSceneManager.dll -#Plugin=Plugin_OctreeSceneManager.dll -#Plugin=Plugin_CgProgramManager.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 + ## NOTE use this for MacOS or Linux -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 11:51:13 UTC (rev 905) +++ branches/ogEditor/propgridtest.py 2008-05-25 14:21:26 UTC (rev 906) @@ -4,8 +4,9 @@ import sys import wx -sys.path.append( './src/' ) +sys.path.append( './src' ) + from PropertyGrid import * @@ -24,8 +25,11 @@ self.propertyGrid = PropertyMainGrid( self, -1, wx.DefaultPosition, wx.DefaultSize ) self.propertyGrid.appendRowItemName( "Main", "name", toolTip = "toolTip" ) - self.propertyGrid.appendRowItemName( "float", value = 10.1, format = FORMAT_FLOAT, cback = test.printValue, toolTip = "toolTip" ) - self.propertyGrid.appendRowItemName( "int", value = 10, format = FORMAT_INT, cback = test.printValue, toolTip = "toolTip" ) + self.propertyGrid.appendRowItemName( "float", value = 10.1, format = FORMAT_FLOAT, + cback = test.printValue, toolTip = "toolTip" ) + + self.propertyGrid.appendRowItemName( "int", value = 10, format = FORMAT_INT, + cback = test.printValue, toolTip = "toolTip" ) self.propertyGrid.appendRowItemSlider( "slider", cback = test.printValue, toolTip = "toolTip" ) self.propertyGrid.appendRowItemColourSelect( "Colour", cback = test.printValue, toolTip = "toolTip" ) Modified: branches/ogEditor/resources.cfg =================================================================== --- branches/ogEditor/resources.cfg 2008-05-25 11:51:13 UTC (rev 905) +++ branches/ogEditor/resources.cfg 2008-05-25 14:21:26 UTC (rev 906) @@ -1,14 +1,28 @@ [Bootstrap] -Zip=../../../../local/python-ogre/python-ogre/demos/media/packs/OgreCore.zip +Zip=c:\PythonOgre/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=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 Modified: branches/ogEditor/src/OgreWindowWx.py =================================================================== --- branches/ogEditor/src/OgreWindowWx.py 2008-05-25 11:51:13 UTC (rev 905) +++ branches/ogEditor/src/OgreWindowWx.py 2008-05-25 14:21:26 UTC (rev 906) @@ -2,8 +2,12 @@ import ogre.renderer.OGRE as ogre import os import os.path +import string -import wxogre_util as wxHandle +try: + import wxogre_util as wxHandle +except: + pass #try : #import psyco #use psyco if available (JIT compiler) @@ -36,7 +40,7 @@ class OgreWindow( wx.PyWindow ): """wx.Frame subclass to embed an Ogre window in wxPython It is somewhat inspired from SampleFramework.py""" - + #all animation states included in this dictionary will be automatically updated at each render animStates = {} #the values have to be (AnimationState, SpeedFactor) tuples @@ -78,72 +82,65 @@ self.resourceLocations.append( (path, section_name ) ) def _OgreInit(self,size,renderSystem): - #Root creation + #Root creation + self.ogreRoot = ogre.Root( getPluginPath(), "ogre.cfg" ) - + # setup resources self.AddResources( "resources.cfg" ); - + + renList = self.ogreRoot.getAvailableRenderers() + + bFound = False + for r in renList: + print r.getName() + if string.find(r.getName(),renderSystem) != -1 and bFound==False: + self.ogreRoot.setRenderSystem ( r ) + bFound = True + if os.path.exists( "ogre.cfg" ): self.ogreRoot.restoreConfig() else: + print "create ogre.cfg" carryOn = self.ogreRoot.showConfigDialog() if not carryOn: sys.exit('Quit from Config Dialog') + - #The following section tries to avoid showing the configuration dilaog. -# rsList = root.getAvailableRenderers() #Gets the available RenderSystems -# rs = None -# CouldNotFindRequestedRenderer = False -# for i in rsList: -# print i - -# if renderSystem in i.name: #Tries to locate the requested render system -# rs=i -# if rs is not None : -# root.renderSystem=rs -# rs.setConfigOption("Full Screen","No") -# try : -# rs.setConfigOption("Video Mode","800 x 600 @ 16-bit colour") -# except : -# CouldNotFindRequestedRenderer=True -# else : -# CouldNotFindRequestedRenderer=True -# -# if CouldNotFindRequestedRenderer: #Calls Ogre's default Config dialog if failed -# carryOn = root.showConfigDialog() -# if not carryOn: -# sys.exit('Quit from Config Dialog') - -# carryOn = root.showConfigDialog() -# if not carryOn: -# sys.exit('Quit from Config Dialog') - #get the topmost window and make it visible, otherwise we cant get a valid windowhandle + self.ogreRoot.initialise(False) - lastValid = self.parent - parent = lastValid - while parent != None: - lastValid = parent - parent = lastValid.GetParent() - lastValid.Show( True ) + # tempory condition until code cleaning + tmpLinux = False; + if tmpLinux: + lastValid = self.parent + parent = lastValid + while parent != None: + lastValid = parent + parent = lastValid.GetParent() + lastValid.Show( True ) - self.ogreRoot.initialise(False) - renderParameters = ogre.NameValuePairList() - handle = wxHandle.get_window_handle_str( self ) - if handle == "No window found": - print handle - renderParameters = ogre.NameValuePairList(); + renderParameters = ogre.NameValuePairList() + handle = wxHandle.get_window_handle_str( self ) + if handle == "No window found": + print handle + renderParameters = ogre.NameValuePairList(); + else: + renderParameters['externalWindowHandle'] = handle + print handle, lastValid.GetHandle(), self.parent.GetHandle() else: - renderParameters['externalWindowHandle'] = handle - print handle, lastValid.GetHandle(), self.parent.GetHandle() + renderParameters = ogre.NameValuePairList() + renderParameters['externalWindowHandle'] = str(self.GetHandle()) + print str(self.GetHandle()) + #renderParameters['FSAA'] = "16" - renderWindow = self.ogreRoot.createRenderWindow('wxPython render window', size[ 0 ], size[ 1 ], False, renderParameters) - renderWindow.active = True - self.renderWindow = renderWindow - + self.renderWindow = self.ogreRoot.createRenderWindow('wxPython render window', size[ 0 ], + size[ 1 ], False, renderParameters) + self.renderWindow.active = True + ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups() - + print "start OgreWindow4" + def _OnSize(self, event): if getattr(self, 'ogreRoot', None): self.UpdateRender() Modified: branches/ogEditor/src/ResourceTreePane.py =================================================================== --- branches/ogEditor/src/ResourceTreePane.py 2008-05-25 11:51:13 UTC (rev 905) +++ branches/ogEditor/src/ResourceTreePane.py 2008-05-25 14:21:26 UTC (rev 906) @@ -21,7 +21,7 @@ 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.TR_DEFAULT_STYLE, wx.FONTWEIGHT_NORMAL ) ) def OnInternalIdle(self): wx.PyScrolledWindow.OnInternalIdle( self ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |