From: san Date: Wed, 14 Sep 2005 08:31:21 +0000 (+0000) Subject: Rolling back incorrect integration X-Git-Tag: V3_1_0a1~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=00fccccb22ad6dde8640fa5347c4b0d8127b7cfc;p=modules%2Fgui.git Rolling back incorrect integration --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index d20e26ad7..4f276dfa8 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -482,11 +482,11 @@ void CAM_Application::createEmptyStudy() STD_Application::createEmptyStudy(); - //SUIT_Study* newStudy = activeStudy(); - //if ( study != newStudy ) - //{ - // CAM_Study* camStudy = dynamic_cast( newStudy ); - // for ( ModuleListIterator it( myModules ); it.current(); ++it ) - // camStudy->insertDataModel( it.current()->dataModel() ); - //} + SUIT_Study* newStudy = activeStudy(); + if ( study != newStudy ) + { + CAM_Study* camStudy = dynamic_cast( newStudy ); + for ( ModuleListIterator it( myModules ); it.current(); ++it ) + camStudy->insertDataModel( it.current()->dataModel() ); + } } diff --git a/src/GLViewer/Makefile.in b/src/GLViewer/Makefile.in index 28bb5bf76..d921dd294 100644 --- a/src/GLViewer/Makefile.in +++ b/src/GLViewer/Makefile.in @@ -98,6 +98,6 @@ CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) LDFLAGS+=$(QT_MT_LIBS) $(CAS_KERNEL) -LIBS+= -L${GUI_ROOT_DIR}/lib/salome -lsuit -lqtx -L/usr/X11R6/lib -lGLU +LIBS+= -L${GUI_ROOT_DIR}/lib/salome -lsuit -L/usr/X11R6/lib -lGLU @CONCLUDE@ diff --git a/src/Makefile.in b/src/Makefile.in index 9d6a17933..e1899da8d 100755 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -34,6 +34,6 @@ VPATH=.:@srcdir@ SUBDIRS = Qtx SUIT STD CAF CAM SUITApp VTKViewer OCCViewer GLViewer \ LogWindow Event OBJECT Prs PyInterp PythonConsole ObjBrowser \ - RegistryDisplay Plot2d TOOLSGUI SOCC SVTK SPlot2d LightApp Session SalomeApp SALOME_SWIG SALOME_PY SUPERVGraph SALOME_PYQT Style ResExporter + RegistryDisplay Plot2d TOOLSGUI SOCC SVTK SPlot2d Session SalomeApp SALOME_SWIG SALOME_PY SUPERVGraph SALOME_PYQT Style ResExporter @MODULE@ diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index 9bcbc4cec..b6dfae0e1 100755 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -52,7 +52,7 @@ LIB_CLIENT_IDL = BIN = BIN_SRC = -CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QT_INCLUDES) $(OGL_INCLUDES) +CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QT_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+= $(PYTHON_LIBS) $(VTK_LIBS) $(QT_LIBS) $(OGL_LIBS) $(CAS_LDPATH) -lTKV3d -lVTKViewer -lsuit diff --git a/src/Plot2d/Makefile.in b/src/Plot2d/Makefile.in index ef3d4742b..65ccacd41 100755 --- a/src/Plot2d/Makefile.in +++ b/src/Plot2d/Makefile.in @@ -66,9 +66,9 @@ plot2d_settings.png \ plot2d_splines.png \ plot2d_zoom.png -CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) -I$(KERNEL_ROOT_DIR)/include/salome -LDFLAGS+=$(QWT_LIBS) $(QT_MT_LIBS) -lsuit +LDFLAGS+=$(QWT_LIBS) $(QT_MT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lsuit @CONCLUDE@ diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 7b1da6225..03540eabd 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -12,6 +12,8 @@ #include "SUIT_ResourceMgr.h" #include "SUIT_Application.h" +//#include "utilities.h" + #include "qapplication.h" #include #include @@ -379,6 +381,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) if ( xmark-2 == pnt.x() ) { xCoord = majXmark; xFound = true; +// MESSAGE("Plot2d_ViewFrame::getInfo : close maj X mark("< color.blue() ) cols[ "blue-min" ] = color.blue(); } + for (IList::Iterator it = mars.begin(); it != mars.end(); ++it) + MESSAGE("markers( " << it.key() << ") = " << it.data() ); + for (IList::Iterator it = lins.begin(); it != lins.end(); ++it) + MESSAGE("lines( " << it.key() << ") = " << it.data() ); + for (SList::Iterator it = cols.begin(); it != cols.end(); ++it) + MESSAGE("colors( " << it.key() << ") = " << it.data() ); #endif Plot2d_SetupViewDlg* dlg = new Plot2d_SetupViewDlg( this, true, mySecondY ); diff --git a/src/Prs/Makefile.in b/src/Prs/Makefile.in index 73133a3e6..2ca3c38c5 100755 --- a/src/Prs/Makefile.in +++ b/src/Prs/Makefile.in @@ -20,7 +20,7 @@ LIB_CLIENT_IDL = BIN = BIN_SRC = -CPPFLAGS+= +CPPFLAGS+= -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+= diff --git a/src/PyInterp/Makefile.in b/src/PyInterp/Makefile.in index 1672f5ada..15e6ba005 100755 --- a/src/PyInterp/Makefile.in +++ b/src/PyInterp/Makefile.in @@ -44,7 +44,7 @@ LIB_SRC= PyInterp_base.cxx \ LIB_MOC = PyInterp_Watcher.h -CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_INCLUDES) +CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_INCLUDES) -I$(KERNEL_ROOT_DIR)/include/salome LDFLAGS+= $(PYTHON_LIBS) $(QT_MT_LIBS) diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx index e9fdcb259..4c427d7ef 100644 --- a/src/PyInterp/PyInterp_base.cxx +++ b/src/PyInterp/PyInterp_base.cxx @@ -14,29 +14,46 @@ #include #include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! +#include #include +#include + + using namespace std; + +//#ifdef _DEBUG_ +//static int MYDEBUG = 1; +//static int MYPYDEBUG = 1; +//#else +//static int MYDEBUG = 0; +//static int MYPYDEBUG = 0; +//#endif + + PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): myThreadState(theThreadState), - mySaveThreadState(0) + mySaveThreadState(KERNEL_PYTHON::_gtstate) { PyEval_AcquireLock(); mySaveThreadState = PyThreadState_Swap(myThreadState); // store previous current in save, // set local in current +// if(MYDEBUG) MESSAGE(" PyLockWrapper "< #include -class LightApp_SelectionMgr; +class SalomeApp_SelectionMgr; class SalomeApp_Application; class QMenuBar; class QPopupMenu; @@ -40,7 +40,7 @@ private slots: void onSelMgrDestroyed(); private: - LightApp_SelectionMgr* mySelMgr; + SalomeApp_SelectionMgr* mySelMgr; SALOME_Selection( QObject* ); }; diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx index c4c2382c4..088c576eb 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx @@ -36,7 +36,7 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Module.h" #include "SalomeApp_DataObject.h" -#include "LightApp_SelectionMgr.h" +#include "SalomeApp_SelectionMgr.h" #include "SALOME_Prs.h" #include "SOCC_ViewModel.h" #include "SVTK_ViewModel.h" @@ -241,8 +241,8 @@ public: TSelectedCountEvent() : myResult( 0 ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; aSelMgr->selectedObjects( anIOList ); @@ -268,8 +268,8 @@ public: TGetSelectedEvent( int theIndex ) : myIndex( theIndex ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; aSelMgr->selectedObjects( anIOList ); @@ -305,8 +305,8 @@ void SALOMEGUI_Swig::AddIObject( const char* theEntry ) TEvent( const char* theEntry ) : myEntry( theEntry ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; anIOList.Append( new SALOME_InteractiveObject( myEntry, "", "" ) ); @@ -329,11 +329,11 @@ void SALOMEGUI_Swig::RemoveIObject( const char* theEntry ) TEvent( const char* theEntry ) : myEntry( theEntry ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; - // VSR: temporary solution, until LightApp_SelectionMgr::unsetSelectedObjects() method appears + // VSR: temporary solution, until SalomeApp_SelectionMgr::unsetSelectedObjects() method appears // Lately this should be replaced by the following: // anIOList.Append( new SALOME_InteractiveObject( myEntry, "", "" ) ); // aSelMgr->unsetSelectedObjects( anIOList ); @@ -364,8 +364,8 @@ void SALOMEGUI_Swig::ClearIObjects() TEvent() {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) aSelMgr->clearSelected(); } diff --git a/src/SOCC/Makefile.in b/src/SOCC/Makefile.in index 36b2aa697..9ae919a0a 100755 --- a/src/SOCC/Makefile.in +++ b/src/SOCC/Makefile.in @@ -27,9 +27,14 @@ LIB_SRC= SOCC_ViewModel.cxx \ LIB_MOC = SOCC_ViewModel.h \ SOCC_ViewWindow.h -CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(BOOST_CPPFLAGS) +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOME_Exception.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_GenericObj.idl -LDFLAGS+=$(QT_MT_LIBS) -LIBS+= -lsuit -lSalomeObject -lSalomePrs -lOCCViewer +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome + +LDFLAGS+=$(QT_MT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome +LIBS+= -lsuit -lSalomeObject -lSalomePrs -lOCCViewer -lOpUtil @CONCLUDE@ diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index dd9ebd70f..b78328d7f 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -8,11 +8,8 @@ #include "ToolsGUI.h" -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//#include -//#include CORBA_CLIENT_HEADER(SALOMEDS) +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) #include #include @@ -20,16 +17,13 @@ #include #include -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//#include -//#include -//#include -//#include +#include +#include +#include +#include -//#include "SALOMEDSClient.hxx" -//#include "SALOMEDS_StudyManager.hxx" +#include "SALOMEDSClient.hxx" +#include "SALOMEDS_StudyManager.hxx" #include @@ -37,24 +31,21 @@ // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from // SALOMEDS::StudyManager - no linkage with SalomeApp. -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//static _PTR(Study) getStudyDS() -//{ -// SALOMEDSClient_Study* aStudy = NULL; -// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); +static _PTR(Study) getStudyDS() +{ + SALOMEDSClient_Study* aStudy = NULL; + _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); // get id of SUIT_Study, if it's a SalomeApp_Study, it will return // id of its underlying SALOMEDS::Study -// SUIT_Application* app = SUIT_Session::session()->activeApplication(); -// if ( !app ) return _PTR(Study)(aStudy); -// SUIT_Study* stud = app->activeStudy(); -// if ( !stud ) return _PTR(Study)(aStudy); -// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( !app ) return _PTR(Study)(aStudy); + SUIT_Study* stud = app->activeStudy(); + if ( !stud ) return _PTR(Study)(aStudy); + const int id = stud->id(); // virtual method, must return SALOMEDS_Study id // get SALOMEDS_Study with this id from StudyMgr -// return aMgr->GetStudyByID( id ); -//} + return aMgr->GetStudyByID( id ); +} SOCC_Viewer::SOCC_Viewer( bool DisplayTrihedron ) : OCCViewer_Viewer( DisplayTrihedron ) @@ -253,10 +244,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) return; // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); + _PTR(Study) study(getStudyDS()); // get context Handle (AIS_InteractiveContext) ic = getAISContext(); @@ -315,16 +303,14 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) bDisplayed = true; // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - //if ( !anObj.IsNull() && anObj->hasEntry() ) - //{ - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - //} + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + if ( !anObj.IsNull() && anObj->hasEntry() ) + { + if ( study ) + ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + } + break; } } @@ -343,16 +329,13 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) ic->Display( anAIS, false ); // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - //if ( !anObj.IsNull() && anObj->hasEntry() ) - //{ - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - //} + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + if ( !anObj.IsNull() && anObj->hasEntry() ) + { + if ( study ) + ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + } // Deactivate object if necessary if ( !anOCCPrs->ToActivate() ) @@ -373,10 +356,7 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) return; // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); + _PTR(Study) study(getStudyDS()); // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -393,19 +373,16 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) ic->Erase( anAIS, false, forced ? false : true ); // Set visibility flag if necessary - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //if ( !forced ) - //{ - // Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - // if ( !anObj.IsNull() && anObj->hasEntry() ) - // { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - // } - //} + if ( !forced ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + if ( !anObj.IsNull() && anObj->hasEntry() ) + { + if ( study ) + ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + } + } } } } @@ -417,10 +394,7 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) void SOCC_Viewer::EraseAll( const bool forced ) { // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); + _PTR(Study) study(getStudyDS()); // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -441,18 +415,15 @@ void SOCC_Viewer::EraseAll( const bool forced ) ic->Erase( anIO, false, forced ? false : true ); // Set visibility flag if necessary - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //if ( !forced ) { - // Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); - - // if ( !anObj.IsNull() && anObj->hasEntry() ) { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - // } - //} + if ( !forced ) { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() ) { + if ( study ) + ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + } + } } // display trihedron if necessary diff --git a/src/SVTK/Makefile.in b/src/SVTK/Makefile.in index 928dfd5eb..e41cfb610 100755 --- a/src/SVTK/Makefile.in +++ b/src/SVTK/Makefile.in @@ -48,9 +48,14 @@ LIB_MOC = SVTK_RenderWindowInteractor.h \ SVTK_ViewModel.h \ SVTK_ViewManager.h -CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOME_Exception.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_GenericObj.idl -LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) -LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome + +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome +LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer -lOpUtil @CONCLUDE@ diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index c958f2852..1ec5fa4b1 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -31,6 +31,8 @@ #include #include +//#include "utilities.h" + using namespace std; #ifdef _DEBUG_ diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 6564c0007..0a5e19f49 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -29,6 +29,8 @@ #include "SVTK_InteractorStyle.h" +#include "utilities.h" + #include "VTKViewer_CellRectPicker.h" #include "VTKViewer_Utilities.h" #include "VTKViewer_RectPicker.h" @@ -72,6 +74,12 @@ using namespace std; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + namespace { int @@ -139,6 +147,7 @@ SVTK_InteractorStyle SVTK_InteractorStyle ::~SVTK_InteractorStyle() { + if(MYDEBUG) INFOS("SVTK_InteractorStyle::~SVTK_InteractorStyle()"); myViewWindow->RemoveActor(myPreSelectionActor); } @@ -902,6 +911,7 @@ SVTK_InteractorStyle Handle(SALOME_InteractiveObject) anIO = aSActor->getIO(); if(aSelectionMode != EdgeOfCellSelection) { if(CheckDimensionId(aSelectionMode,aSActor,anObjId)){ + if(MYDEBUG) INFOS(" CellId : "<IsSelected(anIO)) { // This IO is already in the selection GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState); @@ -921,6 +931,7 @@ SVTK_InteractorStyle } int anEdgeId = GetEdgeId(picker,aSActor,anObjId); if (anEdgeId >= 0) { + if(MYDEBUG) INFOS(" CellId : "<AddOrRemoveIndex(anIO,anObjId,false); GetSelector()->AddOrRemoveIndex(anIO,-anEdgeId-1,true); GetSelector()->AddIObject(aSActor); @@ -946,6 +957,7 @@ SVTK_InteractorStyle this->HighlightProp( NULL ); GetSelector()->ClearIObjects(); } + if(MYDEBUG) INFOS(" PointId : "<AddOrRemoveIndex(anIO,anObjId,myShiftState); GetSelector()->AddIObject(aSActor); } @@ -1075,6 +1087,7 @@ SVTK_InteractorStyle continue; VTKViewer_CellDataSet cellList = picker->GetCellData(aActor); if ( !cellList.empty() ) { + if(MYDEBUG) INFOS ( " NAME Actor : " << aSActor->getName() ); TColStd_MapOfInteger anIndexes; VTKViewer_CellDataSet::iterator it; for ( it = cellList.begin(); it != cellList.end(); ++it ) { @@ -1260,6 +1273,7 @@ SVTK_InteractorStyle if(aResult){ mySelectedActor = aSActor; myElemId = anObjId; + if(MYDEBUG) INFOS(" CellId : "<setCellData(anObjId,aSActor,myPreSelectionActor); } } @@ -1274,6 +1288,7 @@ SVTK_InteractorStyle mySelectedActor = aSActor; myEdgeId = anEdgeId; myElemId = anObjId; + if(MYDEBUG) INFOS(" CellId : "<setEdgeData(anObjId,aSActor,-anEdgeId-1,myPreSelectionActor); } } @@ -1294,6 +1309,7 @@ SVTK_InteractorStyle if(!anIsSameObjId) { mySelectedActor = aSActor; myNodeId = anObjId; + if(MYDEBUG) INFOS(" PointId : "<setPointData(anObjId,aSActor,myPreSelectionActor); } myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index 55dd794e7..a80733492 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -54,8 +54,17 @@ #include +#include "utilities.h" + using namespace std; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + SVTK_RenderWindowInteractor* SVTK_RenderWindowInteractor ::New() @@ -104,6 +113,8 @@ SVTK_RenderWindowInteractor SVTK_RenderWindowInteractor ::~SVTK_RenderWindowInteractor() { + if(MYDEBUG) INFOS("SVTK_RenderWindowInteractor::~SVTK_RenderWindowInteractor()"); + delete mTimer ; myViewWindow->RemoveActor(myCellActor); diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index 7a18425d5..96690603e 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -36,6 +36,7 @@ #include "SVTK_ViewWindow.h" #include "SVTK_SelectorDef.h" +#include "utilities.h" SVTK_SelectorDef ::SVTK_SelectorDef() diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 02bdb6d64..17f0ac85c 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -20,38 +20,33 @@ #include "SALOME_Actor.h" #include "SALOME_InteractiveObject.hxx" -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//#include "Utils_ORB_INIT.hxx" -//#include "Utils_SINGLETON.hxx" -//#include "SALOME_ModuleCatalog_impl.hxx" -//#include "SALOME_NamingService.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "SALOME_ModuleCatalog_impl.hxx" +#include "SALOME_NamingService.hxx" -//#include "SALOMEDSClient.hxx" -//#include "SALOMEDS_StudyManager.hxx" +#include "SALOMEDSClient.hxx" +#include "SALOMEDS_StudyManager.hxx" // in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from // SALOMEDS::StudyManager - no linkage with SalomeApp. -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//static _PTR(Study) getStudyDS() -//{ -// SALOMEDSClient_Study* aStudy = NULL; -// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); +static _PTR(Study) getStudyDS() +{ + SALOMEDSClient_Study* aStudy = NULL; + _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); + // get id of SUIT_Study, if it's a SalomeApp_Study, it will return // id of its underlying SALOMEDS::Study -// SUIT_Application* app = SUIT_Session::session()->activeApplication(); -// if ( !app ) return _PTR(Study)(aStudy); -// SUIT_Study* stud = app->activeStudy(); -// if ( !stud ) return _PTR(Study)(aStudy); -// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( !app ) return _PTR(Study)(aStudy); + SUIT_Study* stud = app->activeStudy(); + if ( !stud ) return _PTR(Study)(aStudy); + const int id = stud->id(); // virtual method, must return SALOMEDS_Study id // get SALOMEDS_Study with this id from StudyMgr -// return aMgr->GetStudyByID( id ); -//} + return aMgr->GetStudyByID( id ); +} //========================================================== SVTK_Viewer::SVTK_Viewer() @@ -259,21 +254,15 @@ SVTK_Viewer return; if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) aStudy(getStudyDS()); + _PTR(Study) aStudy(getStudyDS()); anActorCollection->InitTraversal(); while(vtkActor* anActor = anActorCollection->GetNextActor()){ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this); - //} + Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ + ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this); + } // just display the object QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ @@ -306,21 +295,15 @@ SVTK_Viewer return; if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //_PTR(Study) aStudy(getStudyDS()); + _PTR(Study) aStudy(getStudyDS()); anActorCollection->InitTraversal(); while(vtkActor* anActor = anActorCollection->GetNextActor()) if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); - //} + Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ + ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + } // just display the object QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ @@ -342,10 +325,7 @@ void SVTK_Viewer ::EraseAll( const bool forced ) { - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //_PTR(Study) aStudy(getStudyDS()); + _PTR(Study) aStudy(getStudyDS()); QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ @@ -356,12 +336,9 @@ SVTK_Viewer while(vtkActor* anActor = anActorCollection->GetNextActor()){ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy) - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + if(!anObj.IsNull() && anObj->hasEntry() && aStudy) + ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); if(forced) aRenderer->RemoveActor(anAct); else{ diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index e7214a93a..fb914ced0 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -13,17 +13,32 @@ VPATH=.:@srcdir@:@srcdir@/resources # header files EXPORT_HEADERS= SalomeApp.h \ + SalomeApp_AboutDlg.h \ SalomeApp_Application.h \ SalomeApp_DataModel.h \ SalomeApp_DataObject.h \ + SalomeApp_DataOwner.h \ + SalomeApp_OCCSelector.h \ + SalomeApp_VTKSelector.h \ + SalomeApp_OBSelector.h \ + SalomeApp_GLSelector.h \ SalomeApp_Module.h \ SalomeApp_Study.h \ + SalomeApp_WidgetContainer.h \ SalomeApp_ExceptionHandler.h \ + SalomeApp_RootObject.h \ + SalomeApp_SelectionMgr.h \ SalomeApp_EventFilter.h \ + SalomeApp_Preferences.h \ + SalomeApp_PreferencesDlg.h \ SalomeApp_Tools.h \ + SalomeApp_NameDlg.h \ SalomeApp_ImportOperation.h \ + SalomeApp_DataSubOwner.h \ + SalomeApp_Selection.h \ SalomeApp_Filter.h \ SalomeApp_TypeFilter.h \ + SalomeApp_OBFilter.h \ SalomeApp_StudyPropertiesDlg.h \ SalomeApp_CheckFileDlg.h \ SalomeApp_Operation.h \ @@ -39,17 +54,32 @@ PO_FILES = SalomeApp_images.po \ LIB = libSalomeApp.la LIB_SRC= SalomeApp_Module.cxx \ + SalomeApp_AboutDlg.cxx \ SalomeApp_Application.cxx \ SalomeApp_DataModel.cxx \ SalomeApp_DataObject.cxx \ + SalomeApp_DataOwner.cxx \ + SalomeApp_OCCSelector.cxx \ + SalomeApp_VTKSelector.cxx \ + SalomeApp_OBSelector.cxx \ + SalomeApp_GLSelector.cxx \ SalomeApp_Study.cxx \ + SalomeApp_WidgetContainer.cxx \ SalomeApp_ExceptionHandler.cxx \ + SalomeApp_SelectionMgr.cxx \ SalomeApp_EventFilter.cxx \ + SalomeApp_Preferences.cxx \ + SalomeApp_PreferencesDlg.cxx \ SalomeApp_PyInterp.cxx \ SalomeApp_Tools.cxx \ + SalomeApp_NameDlg.cxx \ SalomeApp_ImportOperation.cxx \ + SalomeApp_DataSubOwner.cxx \ + SalomeApp_ModuleDlg.cxx \ + SalomeApp_Selection.cxx \ SalomeApp_Filter.cxx \ SalomeApp_TypeFilter.cxx \ + SalomeApp_OBFilter.cxx \ SalomeApp_StudyPropertiesDlg.cxx \ SalomeApp_ListView.cxx \ SalomeApp_CheckFileDlg.cxx \ @@ -57,10 +87,21 @@ LIB_SRC= SalomeApp_Module.cxx \ SalomeApp_Dialog.cxx \ SalomeApp_SwitchOp.cxx -LIB_MOC = SalomeApp_Application.h \ +LIB_MOC = SalomeApp_AboutDlg.h \ + SalomeApp_Application.h \ SalomeApp_DataModel.h \ + SalomeApp_OBSelector.h \ + SalomeApp_OCCSelector.h \ + SalomeApp_VTKSelector.h \ + SalomeApp_GLSelector.h \ SalomeApp_Module.h \ SalomeApp_Study.h \ + SalomeApp_SelectionMgr.h \ + SalomeApp_WidgetContainer.h \ + SalomeApp_Preferences.h \ + SalomeApp_PreferencesDlg.h \ + SalomeApp_NameDlg.h \ + SalomeApp_ModuleDlg.h \ SalomeApp_StudyPropertiesDlg.h \ SalomeApp_ListView.h \ SalomeApp_CheckFileDlg.h \ @@ -72,14 +113,19 @@ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_Exception.idl \ SALOME_GenericObj.idl -RESOURCES_FILES = icon_select.png \ +RESOURCES_FILES = icon_about.png \ + icon_applogo.png \ + icon_default.png \ + icon_module.png \ + icon_module_big.png \ + icon_select.png \ SalomeApp.ini \ SalomeApp.xml CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) -LIBS+= -lsuit -lstd -lCAM -lObjBrowser -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lLightApp -lSalomeContainer -lToolsGUI +LIBS+= -lsuit -lstd -lCAM -lObjBrowser -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lSalomeContainer -lToolsGUI @CONCLUDE@ diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 57370698c..16b7ab939 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -9,23 +9,51 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Module.h" +#include "SalomeApp_OBFilter.h" #include "SalomeApp_DataModel.h" #include "SalomeApp_DataObject.h" #include "SalomeApp_EventFilter.h" +#include "SalomeApp_WidgetContainer.h" +#include "SalomeApp_AboutDlg.h" +#include "SalomeApp_ModuleDlg.h" +#include "SalomeApp_Preferences.h" +#include "SalomeApp_PreferencesDlg.h" #include "SalomeApp_StudyPropertiesDlg.h" - #include "SalomeApp_CheckFileDlg.h" -#include "LightApp_Application.h" -#include "LightApp_Preferences.h" -#include "LightApp_WidgetContainer.h" -#include "LightApp_SelectionMgr.h" +#include "SalomeApp_GLSelector.h" +#include "SalomeApp_OBSelector.h" +#include "SalomeApp_OCCSelector.h" +#include "SalomeApp_VTKSelector.h" +#include "SalomeApp_SelectionMgr.h" + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include #include "STD_LoadStudiesDlg.h" #include #include +#include + +#include +#include +#include +#include #include @@ -42,13 +70,18 @@ #include #include +#include +#include +#include #include +#include #include +#include +#include #include #include #include "SALOMEDS_StudyManager.hxx" -#include "SALOMEDS_SObject.hxx" #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIO.hxx" @@ -58,50 +91,252 @@ #define OBJECT_BROWSER_WIDTH 300 +/*!Image for empty icon.*/ +static const char* imageEmptyIcon[] = { +"20 20 1 1", +". c None", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"....................", +"...................."}; + /*!Create new instance of SalomeApp_Application.*/ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() { return new SalomeApp_Application(); } +SalomeApp_Preferences* SalomeApp_Application::_prefs_ = 0; + /* Class : SalomeApp_Application Description : Application containing SalomeApp module */ +/*!Constructor.*/ SalomeApp_Application::SalomeApp_Application() -: LightApp_Application() +: CAM_Application( false ), +myPrefs( 0 ) { + STD_TabDesktop* desk = new STD_TabDesktop(); + + setDesktop( desk ); + + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false ); + + desktop()->setIcon( aLogo ); + desktop()->setDockableMenuBar( true ); + desktop()->setDockableStatusBar( false ); + + // base logo (salome itself) + desktop()->addLogo( "_app_base", aResMgr->loadPixmap( "SalomeApp", tr( "APP_BASE_LOGO" ), false ) ); + // extra logo (salome-based application) + desktop()->addLogo( "_app_extra", aResMgr->loadPixmap( "SalomeApp", tr( "APP_EXTRA_LOGO" ), false ) ); + + clearViewManagers(); + + mySelMgr = new SalomeApp_SelectionMgr( this ); + + myAccel = new SUIT_Accel( desktop() ); + myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, OCCViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, VTKViewer_Viewer::Type() ); + myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, VTKViewer_Viewer::Type() ); + + connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ), + this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) ); + + connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) ); } /*!Destructor. + *\li Save window geometry. + *\li Save desktop geometry. + *\li Save resource maneger. + *\li Delete selection manager. *\li Destroy event filter. */ SalomeApp_Application::~SalomeApp_Application() { + saveWindowsGeometry(); + + if ( resourceMgr() ) + { + if ( desktop() ) + desktop()->saveGeometry( resourceMgr(), "desktop" ); + resourceMgr()->save(); + } + + delete mySelMgr; + SalomeApp_EventFilter::Destroy(); } /*!Start application.*/ void SalomeApp_Application::start() { - LightApp_Application::start(); + if ( desktop() ) + desktop()->loadGeometry( resourceMgr(), "desktop" ); + + CAM_Application::start(); + + QAction* a = action( ViewWindowsId ); + if ( a && a->inherits( "QtxDockAction" ) ) + ((QtxDockAction*)a)->setAutoPlace( true ); SalomeApp_EventFilter::Init(); + + updateWindows(); + updateViewManagers(); + + putInfo( "" ); +} + +/*!Gets application name.*/ +QString SalomeApp_Application::applicationName() const +{ + return tr( "APP_NAME" ); +} + +/*!Gets application version.*/ +QString SalomeApp_Application::applicationVersion() const +{ + static QString _app_version; + + if ( _app_version.isEmpty() ) + { + QString resVersion = tr( "APP_VERSION" ); + if ( resVersion != "APP_VERSION" ) + { + _app_version = resVersion; + } + else + { + QString path( ::getenv( "GUI_ROOT_DIR" ) ); + if ( !path.isEmpty() ) + path += QDir::separator(); + path += QString( "bin/salome/VERSION" ); + + QFile vf( path ); + if ( vf.open( IO_ReadOnly ) ) + { + QString line; + vf.readLine( line, 1024 ); + vf.close(); + + if ( !line.isEmpty() ) + { + while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) ) + line.remove( line.length() - 1, 1 ); + + int idx = line.findRev( ":" ); + if ( idx != -1 ) + _app_version = line.mid( idx + 1 ).stripWhiteSpace(); + } + } + } + } + return _app_version; +} + +/*!Load module by \a name.*/ +CAM_Module* SalomeApp_Application::loadModule( const QString& name ) +{ + CAM_Module* mod = CAM_Application::loadModule( name ); + if ( mod ) + { + connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) ); + connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) ); + connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) ); + } + return mod; +} + +/*!Activate module by \a modName*/ +bool SalomeApp_Application::activateModule( const QString& modName ) +{ + QString actName; + CAM_Module* prevMod = activeModule(); + + if ( prevMod ) + actName = prevMod->moduleName(); + + if ( actName == modName ) + return true; + + putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) ); + + saveWindowsGeometry(); + + bool status = CAM_Application::activateModule( modName ); + + updateModuleActions(); + + putInfo( "" ); + + if ( !status ) + return false; + + updateWindows(); + updateViewManagers(); + + return true; +} + +/*!Gets selection manager.*/ +SalomeApp_SelectionMgr* SalomeApp_Application::selectionMgr() const +{ + return mySelMgr; } /*!Create actions:*/ void SalomeApp_Application::createActions() { - LightApp_Application::createActions(); + STD_Application::createActions(); SUIT_Desktop* desk = desktop(); - + SUIT_ResourceMgr* resMgr = resourceMgr(); + //! Dump study createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(), tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ), 0, desk, false, this, SLOT( onDumpStudy() ) ); - + //! Load script createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(), tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ), @@ -112,6 +347,11 @@ void SalomeApp_Application::createActions() tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ), 0, desk, false, this, SLOT( onProperties() ) ); + //! Preferences + createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(), + tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ), + CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) ); + //! Catalog Generator createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIconSet(), tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ), @@ -122,7 +362,93 @@ void SalomeApp_Application::createActions() tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ), 0, desk, false, this, SLOT( onRegDisplay() ) ); - int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); + //! MRU + QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk ); + connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) ); + registerAction( MRUId, mru ); + + //! default icon for neutral point ('SALOME' module) + QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false ); + if ( defIcon.isNull() ) + defIcon = QPixmap( imageEmptyIcon ); + + //! default icon for any module + QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ), false ); + if ( modIcon.isNull() ) + modIcon = QPixmap( imageEmptyIcon ); + + QToolBar* modTBar = new QtxToolBar( true, desk ); + modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) ); + + QActionGroup* modGroup = new QActionGroup( this ); + modGroup->setExclusive( true ); + modGroup->setUsesDropDown( true ); + + QAction* a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ), + tr( "PRP_APP_MODULE" ), 0, desk, true ); + modGroup->add( a ); + myActions.insert( QString(), a ); + + QMap iconMap; + moduleIconNames( iconMap ); + + const int iconSize = 20; + + modGroup->addTo( modTBar ); + modTBar->addSeparator(); + + QStringList modList; + modules( modList, false ); + + for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it ) + { + if ( (*it).isEmpty() ) + continue; + + QString iconName; + if ( iconMap.contains( *it ) ) + iconName = iconMap[*it]; + + QString modName = moduleName( *it ); + + QPixmap icon = resMgr->loadPixmap( modName, iconName, false ); + if ( icon.isNull() ) + icon = modIcon; + + icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) ); + + QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true ); + a->addTo( modTBar ); + modGroup->add( a ); + + myActions.insert( *it, a ); + } + + SUIT_Tools::simplifySeparators( modTBar ); + + //! New window + + int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 ); + int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 ); + createMenu( separator(), windowMenu, -1, 1 ); + + QMap accelMap; + accelMap[NewGLViewId] = ALT+Key_G; + accelMap[NewPlot2dId] = ALT+Key_P; + accelMap[NewOCCViewId] = ALT+Key_O; + accelMap[NewVTKViewId] = ALT+Key_K; + + for ( int id = NewGLViewId; id <= NewVTKViewId; id++ ) + { + QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(), + tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), + tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), + accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) ); + createMenu( a, newWinMenu, -1 ); + } + connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) ); + + int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); createMenu( DumpStudyId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 15, -1 ); @@ -130,11 +456,156 @@ void SalomeApp_Application::createActions() createMenu( separator(), fileMenu, -1, 15, -1 ); createMenu( PropertiesId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 15, -1 ); + createMenu( PreferencesId, fileMenu, 15, -1 ); + createMenu( separator(), fileMenu, -1, 15, -1 ); int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 50 ); createMenu( CatalogGenId, toolsMenu, 10, -1 ); createMenu( RegDisplayId, toolsMenu, 10, -1 ); createMenu( separator(), toolsMenu, -1, 15, -1 ); + + /* + createMenu( separator(), fileMenu, -1, 100, -1 ); + createMenu( MRUId, fileMenu, 100, -1 ); + createMenu( separator(), fileMenu, -1, 100, -1 ); + */ +} + +/*!On module activation action.*/ +void SalomeApp_Application::onModuleActivation( QAction* a ) +{ + if ( !a ) + return; + + QString modName = a->menuText(); + if ( modName == tr( "APP_NAME" ) ) + modName = QString::null; + + // Force user to create/open a study before module activation + QMap iconMap; + moduleIconNames( iconMap ); + QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false ); + if ( icon.isNull() ) + icon = resourceMgr()->loadPixmap( "SalomeApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module + + bool cancelled = false; + while ( !modName.isEmpty() && !activeStudy() && !cancelled ){ + SalomeApp_ModuleDlg aDlg( desktop(), modName, icon ); + int res = aDlg.exec(); + + switch ( res ){ + case 1: + onNewDoc(); + break; + case 2: + onOpenDoc(); + break; + case 3: + //onLoadStudy(); + //break; + case 0: + default: + putInfo( tr("INF_CANCELLED") ); + myActions[QString()]->setOn( true ); + cancelled = true; + } + } + + if ( !cancelled ) + activateModule( modName ); +} + +/*!Default module activation.*/ +QString SalomeApp_Application::defaultModule() const +{ + QStringList aModuleNames; + modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration + //! If there's the one and only module --> activate it automatically + //! TODO: Possible improvement - default module can be taken from preferences + return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" ); +} + +/*!On new window slot.*/ +void SalomeApp_Application::onNewWindow() +{ + const QObject* obj = sender(); + if ( !obj || !obj->inherits( "QAction" ) ) + return; + + QString type; + int id = actionId( (QAction*)obj ); + switch ( id ) + { + case NewGLViewId: + type = GLViewer_Viewer::Type(); + break; + case NewPlot2dId: + type = Plot2d_Viewer::Type(); + break; + case NewOCCViewId: + type = OCCViewer_Viewer::Type(); + break; + case NewVTKViewId: + type = VTKViewer_Viewer::Type(); + break; + } + + if ( !type.isEmpty() ) + createViewManager( type ); +} + +//======================================================================= +// name : onNewDoc +/*! Purpose : SLOT. Create new document*/ +//======================================================================= +void SalomeApp_Application::onNewDoc() +{ + SUIT_Study* study = activeStudy(); + + saveWindowsGeometry(); + + CAM_Application::onNewDoc(); + + if ( !study ) // new study will be create in THIS application + { + updateWindows(); + updateViewManagers(); + } +} + +//======================================================================= +// name : onOpenDoc +/*! Purpose : SLOT. Open new document*/ +//======================================================================= +void SalomeApp_Application::onOpenDoc() +{ + SUIT_Study* study = activeStudy(); + saveWindowsGeometry(); + + CAM_Application::onOpenDoc(); + + if ( !study ) // new study will be create in THIS application + { + updateWindows(); + updateViewManagers(); + } +} + +/*! Purpose : SLOT. Open new document with \a aName.*/ +bool SalomeApp_Application::onOpenDoc( const QString& aName ) +{ + bool res = CAM_Application::onOpenDoc( aName ); + + QAction* a = action( MRUId ); + if ( a && a->inherits( "QtxMRUAction" ) ) + { + QtxMRUAction* mru = (QtxMRUAction*)a; + if ( res ) + mru->insert( aName ); + else + mru->remove( aName ); + } + return res; } /*!SLOT. Load document.*/ @@ -176,28 +647,54 @@ void SalomeApp_Application::onLoadDoc() name = studyname; name.replace( QRegExp(":"), "/" ); - if (LightApp_Application::onLoadDoc(name)) - { + if(onLoadDoc(name)) { updateWindows(); updateViewManagers(); updateObjectBrowser(true); } } + +/*!SLOT. Load document with \a aName.*/ +bool SalomeApp_Application::onLoadDoc( const QString& aName ) +{ + bool res = CAM_Application::onLoadDoc( aName ); + + /*jfa tmp:QAction* a = action( MRUId ); + if ( a && a->inherits( "QtxMRUAction" ) ) + { + QtxMRUAction* mru = (QtxMRUAction*)a; + if ( res ) + mru->insert( aName ); + else + mru->remove( aName ); + }*/ + return res; +} + +/*!Private SLOT. Selection.*/ +void SalomeApp_Application::onSelection() +{ + onSelectionChanged(); + + if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) ) + ((SalomeApp_Module*)activeModule())->selectionChanged(); +} + /*!SLOT. Copy objects to study maneger from selection maneger..*/ -void SalomeApp_Application::onCopy() +void SalomeApp_Application::onCopy() { SALOME_ListIO list; - LightApp_SelectionMgr* mgr = selectionMgr(); + SalomeApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(list); - + SalomeApp_Study* study = dynamic_cast(activeStudy()); - if(study == NULL) return; - + if(study == NULL) return; + _PTR(Study) stdDS = study->studyDS(); if(!stdDS) return; - SALOME_ListIteratorOfListIO it( list ); + SALOME_ListIteratorOfListIO it( list ); if(it.More()) { _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); @@ -211,26 +708,26 @@ void SalomeApp_Application::onCopy() } /*!SLOT. Paste objects to study maneger from selection manager.*/ -void SalomeApp_Application::onPaste() +void SalomeApp_Application::onPaste() { SALOME_ListIO list; - LightApp_SelectionMgr* mgr = selectionMgr(); + SalomeApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(list); - + SalomeApp_Study* study = dynamic_cast(activeStudy()); if(study == NULL) return; - + _PTR(Study) stdDS = study->studyDS(); if(!stdDS) return; - - SALOME_ListIteratorOfListIO it( list ); + + SALOME_ListIteratorOfListIO it( list ); if(it.More()) { _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); try { studyMgr()->Paste(so); updateObjectBrowser( true ); - updateActions(); //SRN: BugID IPAL9377, case 3 + updateActions(); //SRN: BugID IPAL9377, case 3 } catch(...) { } @@ -241,43 +738,49 @@ void SalomeApp_Application::onPaste() void SalomeApp_Application::onSelectionChanged() { SALOME_ListIO list; - LightApp_SelectionMgr* mgr = selectionMgr(); + SalomeApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(list); - + SalomeApp_Study* study = dynamic_cast(activeStudy()); if(study == NULL) return; - + _PTR(Study) stdDS = study->studyDS(); if(!stdDS) return; - - QAction* qaction; - SALOME_ListIteratorOfListIO it( list ); + QAction* qaction; + + SALOME_ListIteratorOfListIO it( list ); if(it.More() && list.Extent() == 1) { _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); + qaction = action(EditCopyId); - SALOMEDS_SObject* aSO = dynamic_cast(so.get()); - if(aSO && studyMgr()->CanCopy(so) ) qaction->setEnabled(true); - else qaction->setEnabled(false); - + if(studyMgr()->CanCopy(so) ) qaction->setEnabled(true); + else qaction->setEnabled(false); + qaction = action(EditPasteId); - if( aSO && studyMgr()->CanPaste(so) ) qaction->setEnabled(true); + if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true); else qaction->setEnabled(false); } else { - qaction = action(EditCopyId); - qaction->setEnabled(false); + qaction = action(EditCopyId); + qaction->setEnabled(false); qaction = action(EditPasteId); qaction->setEnabled(false); } } +/*!Update object browser.*/ +void SalomeApp_Application::onRefresh() +{ + updateObjectBrowser( true ); +} + /*!Delete references.*/ void SalomeApp_Application::onDeleteReferences() { SALOME_ListIO aList; - LightApp_SelectionMgr* mgr = selectionMgr(); + SalomeApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(aList); if (aList.Extent() < 1) return; @@ -300,6 +803,47 @@ void SalomeApp_Application::onDeleteReferences() updateObjectBrowser(); } +/*!Private SLOT. */ +void SalomeApp_Application::onOpenWith() +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + SALOME_ListIO aList; + SalomeApp_SelectionMgr* mgr = selectionMgr(); + mgr->selectedObjects(aList); + if (aList.Extent() != 1) + { + QApplication::restoreOverrideCursor(); + return; + } + Handle(SALOME_InteractiveObject) aIObj = aList.First(); + QString aModuleName(aIObj->getComponentDataType()); + QString aModuleTitle = moduleTitle(aModuleName); + activateModule(aModuleTitle); + QApplication::restoreOverrideCursor(); +} + +bool SalomeApp_Application::useStudy(const QString& theName) +{ + createEmptyStudy(); + SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); + bool res = false; + if (aStudy) + res = aStudy->loadDocument( theName ); + updateDesktopTitle(); + updateCommandsStatus(); + return res; +} + +/*!Set active study. + *\param study - SUIT_Study. + */ +void SalomeApp_Application::setActiveStudy( SUIT_Study* study ) +{ + CAM_Application::setActiveStudy( study ); + + activateWindows(); +} + //======================================================================= // name : createNewStudy /*! Purpose : Create new study*/ @@ -318,12 +862,19 @@ SUIT_Study* SalomeApp_Application::createNewStudy() } //======================================================================= -// name : updateCommandsStatus +// name : createNewStudy /*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/ //======================================================================= void SalomeApp_Application::updateCommandsStatus() { - LightApp_Application::updateCommandsStatus(); + CAM_Application::updateCommandsStatus(); + + for ( int id = NewGLViewId; id <= NewVTKViewId; id++ ) + { + QAction* a = action( id ); + if ( a ) + a->setEnabled( activeStudy() ); + } // Dump study menu QAction* a = action( DumpStudyId ); @@ -334,134 +885,814 @@ void SalomeApp_Application::updateCommandsStatus() a = action( LoadScriptId ); if ( a ) a->setEnabled( activeStudy() ); - + a = action( PropertiesId ); if( a ) a->setEnabled( activeStudy() ); - + a = action(EditCopyId); - a->setEnabled(false); + a->setEnabled(false); a = action(EditPasteId); - a->setEnabled(false); + a->setEnabled(false); } -/*!Private SLOT. On dump study.*/ -void SalomeApp_Application::onDumpStudy( ) +//======================================================================= +// name : onHelpAbout +/*! Purpose : SLOT. Display "About" message box*/ +//======================================================================= +void SalomeApp_Application::onHelpAbout() { - SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); - if ( !appStudy ) return; - _PTR(Study) aStudy = appStudy->studyDS(); - - QStringList aFilters; - aFilters.append( tr( "PYTHON_FILES_FILTER" ) ); + SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() ); + dlg->exec(); + delete dlg; +} - SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true); - fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); - fd->setFilters( aFilters ); - fd->SetChecked(true); - fd->exec(); - QString aFileName = fd->selectedFile(); - bool toPublish = fd->IsChecked(); - delete fd; +QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const +{ + QWidget* wid = 0; - if(!aFileName.isEmpty()) { - QFileInfo aFileInfo(aFileName); - aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish ); + int sId = studyId; + if ( sId < 0 ) + { + if ( !activeStudy() ) + return 0; + else + sId = activeStudy()->id(); } + + if ( myWindows.contains( flag ) ) + wid = myWindows[flag]->widget( sId ); + + return wid; } -/*!Private SLOT. On load script.*/ -void SalomeApp_Application::onLoadScript( ) +/*!Adds window to application. + *\param wid - QWidget + *\param flag - key wor window + *\param studyId - study id + * Flag used how identificator of window in windows list. + */ +void SalomeApp_Application::addWindow( QWidget* wid, const int flag, const int studyId ) { - SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); - if ( !appStudy ) return; - _PTR(Study) aStudy = appStudy->studyDS(); - - if ( aStudy->GetProperties()->IsLocked() ) { - SUIT_MessageBox::warn1 ( desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK") ); + if ( !wid ) return; - } - QStringList filtersList; - filtersList.append(tr("PYTHON_FILES_FILTER")); - filtersList.append(tr("ALL_FILES_FILTER")); - - QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true ); + int sId = studyId; + if ( sId < 0 ) + { + if ( !activeStudy() ) + return; + else + sId = activeStudy()->id(); + } - if ( !aFile.isEmpty() ) + if ( !myWindows.contains( flag ) ) { - QString command = QString("execfile(\"%1\")").arg(aFile); + QMap winMap; + currentWindows( winMap ); - PythonConsole* pyConsole = pythonConsole(); + myWindows.insert( flag, new SalomeApp_WidgetContainer( flag, desktop() ) ); + if ( winMap.contains( flag ) ) + desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] ); - if ( pyConsole ) - pyConsole->exec( command ); + myWindows[flag]->setResizeEnabled( true ); + myWindows[flag]->setCloseMode( QDockWindow::Always ); + myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) ); } -} -/*!Gets file filter. - *\retval QString "(*.hdf)" + QFont f; + if( wid->inherits( "PythonConsole" ) ) + f = ( ( PythonConsole* )wid )->font(); + else + f = wid->font(); + + myWindows[flag]->insert( sId, wid ); + wid->setFont( f ); + + setWindowShown( flag, !myWindows[flag]->isEmpty() ); +} + +/*!Remove window from application. + *\param flag - key wor window + *\param studyId - study id + * Flag used how identificator of window in windows list. + */ +void SalomeApp_Application::removeWindow( const int flag, const int studyId ) +{ + if ( !myWindows.contains( flag ) ) + return; + + int sId = studyId; + if ( sId < 0 ) + { + if ( !activeStudy() ) + return; + else + sId = activeStudy()->id(); + } + + QWidget* wid = myWindows[flag]->widget( sId ); + myWindows[flag]->remove( sId ); + delete wid; + + setWindowShown( flag, !myWindows[flag]->isEmpty() ); +} + +/*!Gets window. + *\param flag - key wor window + *\param studyId - study id + * Flag used how identificator of window in windows list. + */ +QWidget* SalomeApp_Application::getWindow( const int flag, const int studyId ) +{ + QWidget* wid = window( flag, studyId ); + if ( !wid ) + addWindow( wid = createWindow( flag ), flag, studyId ); + + return wid; +} + +/*!Check is window visible?(with identificator \a type)*/ +bool SalomeApp_Application::isWindowVisible( const int type ) const +{ + bool res = false; + if ( myWindows.contains( type ) ) + { + SUIT_Desktop* desk = ((SalomeApp_Application*)this)->desktop(); + res = desk && desk->appropriate( myWindows[type] ); + } + return res; +} + +/*!Sets window show or hide. + *\param type - window identificator. + *\param on - true/false (window show/hide) + */ +void SalomeApp_Application::setWindowShown( const int type, const bool on ) +{ + if ( !desktop() || !myWindows.contains( type ) ) + return; + + QDockWindow* dw = myWindows[type]; + desktop()->setAppropriate( dw, on ); + on ? dw->show() : dw->hide(); +} + +OB_Browser* SalomeApp_Application::objectBrowser() +{ + OB_Browser* ob = 0; + QWidget* wid = getWindow( WT_ObjectBrowser ); + if ( wid->inherits( "OB_Browser" ) ) + ob = (OB_Browser*)wid; + return ob; +} + +/*!Gets "LogWindow".*/ +LogWindow* SalomeApp_Application::logWindow() +{ + LogWindow* lw = 0; + QWidget* wid = getWindow( WT_LogWindow ); + if ( wid->inherits( "LogWindow" ) ) + lw = (LogWindow*)wid; + return lw; +} + +/*!Get "PythonConsole"*/ +PythonConsole* SalomeApp_Application::pythonConsole() +{ + PythonConsole* console = 0; + QWidget* wid = getWindow( WT_PyConsole ); + if ( wid->inherits( "PythonConsole" ) ) + console = (PythonConsole*)wid; + return console; +} + +/*!Gets preferences.*/ +SalomeApp_Preferences* SalomeApp_Application::preferences() const +{ + return preferences( false ); +} + +/*!Gets view manager*/ +SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create ) +{ + SUIT_ViewManager* aVM = viewManager( vmType ); + SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager(); + + if ( anActiveVM && anActiveVM->getType() == vmType ) + aVM = anActiveVM; + + if ( aVM && create ) + { + if ( !aVM->getActiveView() ) + aVM->createView(); + else + aVM->getActiveView()->setFocus(); + } + else if ( create ) + aVM = createViewManager( vmType ); + + return aVM; +} + +/*!Create view manager.*/ +SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType ) +{ + SUIT_ResourceMgr* resMgr = resourceMgr(); + + SUIT_ViewManager* viewMgr = 0; + if ( vmType == GLViewer_Viewer::Type() ) + { + viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() ); + new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr ); + } + else if ( vmType == Plot2d_Viewer::Type() ) + { + viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() ); + viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface + } + else if ( vmType == OCCViewer_Viewer::Type() ) + { + viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() ); + SOCC_Viewer* vm = new SOCC_Viewer(); + vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) ); + vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) ); + int u( 1 ), v( 1 ); + vm->isos( u, v ); + u = resMgr->integerValue( "OCCViewer", "iso_number_u", u ); + v = resMgr->integerValue( "OCCViewer", "iso_number_v", v ); + vm->setIsos( u, v ); + viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface + new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr ); + } + else if ( vmType == SVTK_Viewer::Type() ) + { + viewMgr = new SVTK_ViewManager( activeStudy(), desktop() ); + SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel(); + vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) ); + vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) ); + new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr); + } + + if ( !viewMgr ) + return 0; + + addViewManager( viewMgr ); + SUIT_ViewWindow* viewWin = viewMgr->createViewWindow(); + + if ( viewWin && desktop() ) + viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) ); + + connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + this, SLOT( onCloseView( SUIT_ViewManager* ) ) ); + + return viewMgr; +} + +void SalomeApp_Application::onCloseView( SUIT_ViewManager* theVM ) +{ + removeViewManager( theVM ); +} + +/*!Private SLOT. On study created.*/ +void SalomeApp_Application::onStudyCreated( SUIT_Study* theStudy ) +{ + SUIT_DataObject* aRoot = 0; + if ( theStudy && theStudy->root() ) + { + aRoot = theStudy->root(); + //aRoot->setName( tr( "DATA_MODELS" ) ); + } + if ( objectBrowser() != 0 ) + objectBrowser()->setRootObject( aRoot ); + + activateModule( defaultModule() ); + + activateWindows(); +} + +/*!Private SLOT. On study opened.*/ +void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy ) +{ + SUIT_DataObject* aRoot = 0; + if ( theStudy && theStudy->root() ) + { + aRoot = theStudy->root(); + //aRoot->dump(); + } + if ( objectBrowser() != 0 ) { + objectBrowser()->setRootObject( aRoot ); + } + + activateModule( defaultModule() ); + + activateWindows(); + + emit studyOpened(); +} + +void SalomeApp_Application::onStudySaved( SUIT_Study* ) +{ + emit studySaved(); +} + +/*!Private SLOT. On study closed.*/ +void SalomeApp_Application::onStudyClosed( SUIT_Study* ) +{ + emit studyClosed(); + + activateModule( "" ); + + saveWindowsGeometry(); +} + +/*!Private SLOT. On dump study.*/ +void SalomeApp_Application::onDumpStudy( ) +{ + SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); + if ( !appStudy ) return; + _PTR(Study) aStudy = appStudy->studyDS(); + + QStringList aFilters; + aFilters.append( tr( "PYTHON_FILES_FILTER" ) ); + + SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true); + fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); + fd->setFilters( aFilters ); + fd->SetChecked(true); + fd->exec(); + QString aFileName = fd->selectedFile(); + bool toPublish = fd->IsChecked(); + delete fd; + + if(!aFileName.isEmpty()) { + QFileInfo aFileInfo(aFileName); + aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish ); + } +} + +/*!Private SLOT. On load script.*/ +void SalomeApp_Application::onLoadScript( ) +{ + SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); + if ( !appStudy ) return; + _PTR(Study) aStudy = appStudy->studyDS(); + + if ( aStudy->GetProperties()->IsLocked() ) { + SUIT_MessageBox::warn1 ( desktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return; + } + + QStringList filtersList; + filtersList.append(tr("PYTHON_FILES_FILTER")); + filtersList.append(tr("ALL_FILES_FILTER")); + + QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true ); + + if ( !aFile.isEmpty() ) + { + QString command = QString("execfile(\"%1\")").arg(aFile); + + PythonConsole* pyConsole = pythonConsole(); + + if ( pyConsole ) + pyConsole->exec( command ); + } +} + +/*!Private SLOT. On preferences.*/ +void SalomeApp_Application::onPreferences() +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + + SalomeApp_PreferencesDlg* prefDlg = new SalomeApp_PreferencesDlg( preferences( true ), desktop()); + + QApplication::restoreOverrideCursor(); + + if ( !prefDlg ) + return; + + prefDlg->exec(); + + delete prefDlg; +} + +/*!Private SLOT. On open document with name \a aName.*/ +void SalomeApp_Application::onMRUActivated( QString aName ) +{ + onOpenDoc( aName ); +} + +/*!Private SLOT. On preferences changed.*/ +void SalomeApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param ) +{ + SalomeApp_Module* sMod = 0; + CAM_Module* mod = module( modName ); + if ( mod && mod->inherits( "SalomeApp_Module" ) ) + sMod = (SalomeApp_Module*)mod; + + if ( sMod ) + sMod->preferencesChanged( section, param ); + else + preferencesChanged( section, param ); +} + +/*!Gets file filter. + *\retval QString "(*.hdf)" */ QString SalomeApp_Application::getFileFilter() const { return "(*.hdf)"; } +/*!Remove all windows from study.*/ +void SalomeApp_Application::beforeCloseDoc( SUIT_Study* s ) +{ + CAM_Application::beforeCloseDoc( s ); + + for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr ) + removeWindow( itr.key(), s->id() ); +} + +/*!Update actions.*/ +void SalomeApp_Application::updateActions() +{ + updateCommandsStatus(); +} + /*!Create window.*/ QWidget* SalomeApp_Application::createWindow( const int flag ) { - QWidget* wid = LightApp_Application::createWindow(flag); + QWidget* wid = 0; + SUIT_ResourceMgr* resMgr = resourceMgr(); if ( flag == WT_ObjectBrowser ) { - OB_Browser* ob = (OB_Browser*)wid; + OB_Browser* ob = new OB_Browser( desktop() ); + ob->setAutoUpdate( true ); + ob->setAutoOpenLevel( 1 ); + ob->setCaption( tr( "OBJECT_BROWSER" ) ); + ob->resize( OBJECT_BROWSER_WIDTH, ob->height() ); + ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) ); + + ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) ); + bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ); - if ( ob != 0 ) { - for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ ) - { - ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i ); - ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser", - QString().sprintf( "visibility_column_%d", i ), true ) ); - } + for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ ) + { + ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i ); + ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser", + QString().sprintf( "visibility_column_%d", i ), true ) ); } ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual ); + + // Create OBSelector + new SalomeApp_OBSelector( ob, mySelMgr ); + + wid = ob; + + ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } - else if ( flag == WT_PyConsole ) + else if ( flag == WT_PyConsole ) { - delete wid; - wid = 0; PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() ); pyCons->setCaption( tr( "PYTHON_CONSOLE" ) ); + pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) ); wid = pyCons; + // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } + else if ( flag == WT_LogWindow ) + { + LogWindow* logWin = new LogWindow( desktop() ); + logWin->setCaption( tr( "LOG_WINDOW" ) ); + wid = logWin; + + logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); + } + return wid; } -/*!Create preferences.*/ -void SalomeApp_Application::createPreferences( LightApp_Preferences* pref ) +/*!Default windows(Object Browser, Python Console). + * Adds to map \a aMap. + */ +void SalomeApp_Application::defaultWindows( QMap& aMap ) const { - LightApp_Application::createPreferences(pref); + aMap.insert( WT_ObjectBrowser, Qt::DockLeft ); + aMap.insert( WT_PyConsole, Qt::DockBottom ); + // aMap.insert( WT_LogWindow, Qt::DockBottom ); +} + +/*!Default view manager.*/ +void SalomeApp_Application::defaultViewManagers( QStringList& ) const +{ + /*!Do nothing.*/ +} + +/*!Gets preferences. + * Create preferences, if \a crt = true. + */ +SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const +{ + if ( myPrefs ) + return myPrefs; + + SalomeApp_Application* that = (SalomeApp_Application*)this; + + if ( !_prefs_ && crt ) + { + _prefs_ = new SalomeApp_Preferences( resourceMgr() ); + that->createPreferences( _prefs_ ); + } + that->myPrefs = _prefs_; + + QPtrList appList = SUIT_Session::session()->applications(); + for ( QPtrListIterator appIt ( appList ); appIt.current(); ++appIt ) + { + if ( !appIt.current()->inherits( "SalomeApp_Application" ) ) + continue; + + SalomeApp_Application* app = (SalomeApp_Application*)appIt.current(); + + QStringList modNameList; + app->modules( modNameList, false ); + for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it ) + { + int id = _prefs_->addPreference( *it ); + _prefs_->setItemProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) ); + } + + ModuleList modList; + app->modules( modList ); + for ( ModuleListIterator itr( modList ); itr.current(); ++itr ) + { + SalomeApp_Module* mod = 0; + if ( itr.current()->inherits( "SalomeApp_Module" ) ) + mod = (SalomeApp_Module*)itr.current(); + + if ( mod && !_prefs_->hasModule( mod->moduleName() ) ) + { + int modCat = _prefs_->addPreference( mod->moduleName() ); + _prefs_->setItemProperty( modCat, "info", QString::null ); + mod->createPreferences(); + } + } + } + + connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ), + this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) ); + + return myPrefs; +} + +/*!Add new module to application.*/ +void SalomeApp_Application::moduleAdded( CAM_Module* mod ) +{ + CAM_Application::moduleAdded( mod ); + + SalomeApp_Module* salomeMod = 0; + if ( mod && mod->inherits( "SalomeApp_Module" ) ) + salomeMod = (SalomeApp_Module*)mod; + + if ( myPrefs && salomeMod && !myPrefs->hasModule( salomeMod->moduleName() ) ) + { + int modCat = myPrefs->addPreference( mod->moduleName() ); + myPrefs->setItemProperty( modCat, "info", QString::null ); + salomeMod->createPreferences(); + } +} + +/*!Create preferences.*/ +void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref ) +{ if ( !pref ) return; int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) ); + + int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat ); + int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab ); + pref->setItemProperty( studyGroup, "columns", 1 ); + + pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, SalomeApp_Preferences::Bool, "Study", "multi_file" ); + pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, SalomeApp_Preferences::Bool, "Study", "ascii_file" ); + int undoPref = pref->addPreference( tr( "PREF_UNDO_LEVEL" ), studyGroup, SalomeApp_Preferences::IntSpin, "Study", "undo_level" ); + pref->setItemProperty( undoPref, "min", 1 ); + pref->setItemProperty( undoPref, "max", 100 ); + + int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); + pref->setItemProperty( extgroup, "columns", 1 ); + int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, SalomeApp_Preferences::File, "ExternalBrowser", "application" ); + pref->setItemProperty( apppref, "existing", true ); + pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser ); + + pref->addPreference( tr( "PREF_PARAM" ), extgroup, SalomeApp_Preferences::String, "ExternalBrowser", "parameters" ); + + int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab ); + pref->setItemProperty( pythonConsoleGroup, "columns", 1 ); + pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, SalomeApp_Preferences::Font, "PyConsole", "font" ); + + + int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat ); int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab ); for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ ) { pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), defCols, - LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) ); + SalomeApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) ); } pref->setItemProperty( defCols, "columns", 1 ); int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab ); - pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool, "ObjectBrowser", "auto_size" ); + pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, SalomeApp_Preferences::Bool, "ObjectBrowser", "auto_size" ); + + int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat ); + + int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab ); + + int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab ); + + int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), viewTab ); + + pref->setItemProperty( occGroup, "columns", 1 ); + pref->setItemProperty( vtkGroup, "columns", 1 ); + pref->setItemProperty( plot2dGroup, "columns", 1 ); + + int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup, + SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" ); + pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, + SalomeApp_Preferences::Color, "OCCViewer", "background" ); + + pref->setItemProperty( occTS, "min", 1 ); + pref->setItemProperty( occTS, "max", 150 ); + + int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup, + SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" ); + int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup, + SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" ); + + pref->setItemProperty( isoU, "min", 0 ); + pref->setItemProperty( isoU, "max", 100000 ); + + pref->setItemProperty( isoV, "min", 0 ); + pref->setItemProperty( isoV, "max", 100000 ); + + int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup, + SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" ); + pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup, + SalomeApp_Preferences::Color, "VTKViewer", "background" ); + + pref->setItemProperty( vtkTS, "min", 1 ); + pref->setItemProperty( vtkTS, "max", 150 ); + + pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup, + SalomeApp_Preferences::Bool, "Plot2d", "ShowLegend" ); + + int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup, + SalomeApp_Preferences::Selector, "Plot2d", "LegendPos" ); + QStringList aLegendPosList; + aLegendPosList.append( tr("PREF_LEFT") ); + aLegendPosList.append( tr("PREF_RIGHT") ); + aLegendPosList.append( tr("PREF_TOP") ); + aLegendPosList.append( tr("PREF_BOTTOM") ); + + QValueList anIndexesList; + anIndexesList.append(0); + anIndexesList.append(1); + anIndexesList.append(2); + anIndexesList.append(3); + + pref->setItemProperty( legendPosition, "strings", aLegendPosList ); + pref->setItemProperty( legendPosition, "indexes", anIndexesList ); + + int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup, + SalomeApp_Preferences::Selector, "Plot2d", "CurveType" ); + QStringList aCurveTypesList; + aCurveTypesList.append( tr("PREF_POINTS") ); + aCurveTypesList.append( tr("PREF_LINES") ); + aCurveTypesList.append( tr("PREF_SPLINE") ); + + anIndexesList.clear(); + anIndexesList.append(0); + anIndexesList.append(1); + anIndexesList.append(2); + + pref->setItemProperty( curveType, "strings", aCurveTypesList ); + pref->setItemProperty( curveType, "indexes", anIndexesList ); + + int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup, + SalomeApp_Preferences::IntSpin, "Plot2d", "MarkerSize" ); + + pref->setItemProperty( markerSize, "min", 0 ); + pref->setItemProperty( markerSize, "max", 100 ); + + QStringList aScaleModesList; + aScaleModesList.append( tr("PREF_LINEAR") ); + aScaleModesList.append( tr("PREF_LOGARITHMIC") ); + + anIndexesList.clear(); + anIndexesList.append(0); + anIndexesList.append(1); + + int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup, + SalomeApp_Preferences::Selector, "Plot2d", "HorScaleMode" ); + + pref->setItemProperty( horScale, "strings", aScaleModesList ); + pref->setItemProperty( horScale, "indexes", anIndexesList ); + + int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup, + SalomeApp_Preferences::Selector, "Plot2d", "VerScaleMode" ); + + pref->setItemProperty( verScale, "strings", aScaleModesList ); + pref->setItemProperty( verScale, "indexes", anIndexesList ); + + pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup, + SalomeApp_Preferences::Color, "Plot2d", "Background" ); + + int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat ); + int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab ); + pref->setItemProperty( dirGroup, "columns", 1 ); + pref->addPreference( tr( "" ), dirGroup, + SalomeApp_Preferences::DirList, "FileDlg", "QuickDirList" ); +} + +void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param ) +{ + SUIT_ResourceMgr* resMgr = resourceMgr(); + if ( !resMgr ) + return; + + if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) ) + { + int sz = resMgr->integerValue( sec, param, -1 ); + QPtrList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + for ( QPtrListIterator it( lst ); it.current() && sz >= 0; ++it ) + { + SUIT_ViewModel* vm = it.current()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setTrihedronSize( sz ); + occVM->getAISContext()->UpdateCurrentViewer(); + } + } + + if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) ) + { + int sz = resMgr->integerValue( sec, param, -1 ); + QPtrList lst; + viewManagers( SVTK_Viewer::Type(), lst ); + for ( QPtrListIterator it( lst ); it.current() && sz >= 0; ++it ) + { + SUIT_ViewModel* vm = it.current()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = (SVTK_Viewer*)vm; + vtkVM->setTrihedronSize( sz ); + vtkVM->Repaint(); + } + } + + if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) ) + { + QPtrList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + int u = resMgr->integerValue( sec, "iso_number_u" ); + int v = resMgr->integerValue( sec, "iso_number_v" ); + for ( QPtrListIterator it( lst ); it.current(); ++it ) + ((OCCViewer_Viewer*)it.current())->setIsos( u, v ); + } + + if( sec=="ObjectBrowser" ) + { + if( param=="auto_size" ) + { + OB_Browser* ob = objectBrowser(); + if( !ob ) + return; + + bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ); + ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual ); + + updateObjectBrowser( false ); + } + } + + if( sec=="PyConsole" ) + { + if( param=="font" ) + if( pythonConsole() ) + pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) ); + } } /*!Update desktop title.*/ @@ -476,15 +1707,13 @@ void SalomeApp_Application::updateDesktopTitle() { QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false ); if ( !sName.isEmpty() ) { SalomeApp_Study* study = dynamic_cast(activeStudy()); - if ( study ) { - _PTR(Study) stdDS = study->studyDS(); - if(stdDS) { - if ( stdDS->GetProperties()->IsLocked() ) { - aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) ); - } else { - aTitle += QString( " - [%1]" ).arg( sName ); - } - } + _PTR(Study) stdDS = study->studyDS(); + if(stdDS) { + if ( stdDS->GetProperties()->IsLocked() ) { + aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) ); + } else { + aTitle += QString( " - [%1]" ).arg( sName ); + } } } } @@ -492,6 +1721,14 @@ void SalomeApp_Application::updateDesktopTitle() { desktop()->setCaption( aTitle ); } +/*!Update windows after close document.*/ +void SalomeApp_Application::afterCloseDoc() +{ + updateWindows(); + + CAM_Application::afterCloseDoc(); +} + /*!Gets CORBA::ORB_var*/ CORBA::ORB_var SalomeApp_Application::orb() { @@ -531,6 +1768,158 @@ QString SalomeApp_Application::defaultEngineIOR() return anIOR; } +/*!Adds icon names for modules.*/ +void SalomeApp_Application::moduleIconNames( QMap& iconMap ) const +{ + iconMap.clear(); + + SUIT_ResourceMgr* resMgr = resourceMgr(); + if ( !resMgr ) + return; + + QStringList modList; + modules( modList, false ); + + for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it ) + { + QString modName = *it; + QString modIntr = moduleName( modName ); + QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null ); + + if ( modIcon.isEmpty() ) + continue; + + if ( SUIT_Tools::extension( modIcon ).isEmpty() ) + modIcon += QString( ".png" ); + + iconMap.insert( modName, modIcon ); + } +} + +/*!Update module action.*/ +void SalomeApp_Application::updateModuleActions() +{ + QString modName; + if ( activeModule() ) + modName = activeModule()->moduleName(); + + if ( myActions.contains( modName ) ) + myActions[modName]->setOn( true ); +} + +/*!Gets current windows. + *\param winMap - output current windows map. + */ +void SalomeApp_Application::currentWindows( QMap& winMap ) const +{ + winMap.clear(); + if ( !activeStudy() ) + return; + + if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) ) + ((SalomeApp_Module*)activeModule())->windows( winMap ); + else + defaultWindows( winMap ); +} + +/*!Gets current view managers. + *\param lst - output current view managers list. + */ +void SalomeApp_Application::currentViewManagers( QStringList& lst ) const +{ + lst.clear(); + if ( !activeStudy() ) + return; + + if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) ) + ((SalomeApp_Module*)activeModule())->viewManagers( lst ); + else + defaultViewManagers( lst ); +} + +/*!Update windows.*/ +void SalomeApp_Application::updateWindows() +{ + QMap winMap; + currentWindows( winMap ); + + for ( QMap::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) + getWindow( it.key() ); + + loadWindowsGeometry(); + + for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) + setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) ); +} + +/*!Update view managers.*/ +void SalomeApp_Application::updateViewManagers() +{ + QStringList lst; + currentViewManagers( lst ); + + for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it ) + getViewManager( *it, true ); +} + +/*!Load windows geometry.*/ +void SalomeApp_Application::loadWindowsGeometry() +{ + QtxDockAction* dockMgr = 0; + + QAction* a = action( ViewWindowsId ); + if ( a && a->inherits( "QtxDockAction" ) ) + dockMgr = (QtxDockAction*)a; + + if ( !dockMgr ) + return; + + QString modName; + if ( activeModule() ) + modName = moduleLibrary( activeModule()->moduleName(), false ); + + QString section = QString( "windows_geometry" ); + if ( !modName.isEmpty() ) + section += QString( "." ) + modName; + + dockMgr->loadGeometry( resourceMgr(), section, false ); + dockMgr->restoreGeometry(); +} + +/*!Save windows geometry.*/ +void SalomeApp_Application::saveWindowsGeometry() +{ + QtxDockAction* dockMgr = 0; + + QAction* a = action( ViewWindowsId ); + if ( a && a->inherits( "QtxDockAction" ) ) + dockMgr = (QtxDockAction*)a; + + if ( !dockMgr ) + return; + + QString modName; + if ( activeModule() ) + modName = moduleLibrary( activeModule()->moduleName(), false ); + + QString section = QString( "windows_geometry" ); + if ( !modName.isEmpty() ) + section += QString( "." ) + modName; + + dockMgr->storeGeometry(); + dockMgr->saveGeometry( resourceMgr(), section, false ); +} + +/*!Activate windows.*/ +void SalomeApp_Application::activateWindows() +{ + if ( activeStudy() ) + { + for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) + itr.data()->activate( activeStudy()->id() ); + } +} + /*!Private SLOT. On preferences.*/ void SalomeApp_Application::onProperties() { @@ -552,18 +1941,49 @@ void SalomeApp_Application::onProperties() updateDesktopTitle(); } +/*!*/ +QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters, + const QString& caption, QWidget* parent ) +{ + if ( !parent ) + parent = desktop(); + QStringList fls = QStringList::split( ";;", filters, false ); + return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true ); +} + +/*!*/ +QString SalomeApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent ) +{ + if ( !parent ) + parent = desktop(); + return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true ); +} + +/*!*/ +QStringList SalomeApp_Application::getOpenFileNames( const QString& initial, const QString& filters, + const QString& caption, QWidget* parent ) +{ + if ( !parent ) + parent = desktop(); + QStringList fls = QStringList::split( ";;", filters, false ); + return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true ); +} + /*!*/ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title ) { - LightApp_Application::contextMenuPopup( type, thePopup, title ); + CAM_Application::contextMenuPopup( type, thePopup, title ); OB_Browser* ob = objectBrowser(); if ( !ob || type != ob->popupClientType() ) return; + thePopup->insertSeparator(); + thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) ); + // Get selected objects SALOME_ListIO aList; - LightApp_SelectionMgr* mgr = selectionMgr(); + SalomeApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(aList); // "Delete reference" item should appear only for invalid references @@ -578,16 +1998,15 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t { SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); _PTR(Study) aStudyDS = aStudy->studyDS(); - _PTR(SObject) anObj; + _PTR(SObject) anObj; + for ( SALOME_ListIteratorOfListIO it( aList ); it.More() && isInvalidRefs; it.Next() ) { if ( it.Value()->hasEntry() ) { _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ); - SALOMEDS_SObject* aSO = dynamic_cast(aSObject.get()); - if( aSO ) - if ( aSObject->ReferencedObject(anObj) == false || !QString(anObj->GetName().c_str()).isEmpty() ) - isInvalidRefs = false; + if ( aSObject->ReferencedObject(anObj) == false || !QString(anObj->GetName().c_str()).isEmpty() ) + isInvalidRefs = false; } } } @@ -610,30 +2029,72 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t if (currentModule && currentModule->moduleName() == aModuleTitle) return; thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) ); + } /*!Update obect browser*/ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) { + // update existing data models (already loaded SComponents) + if ( updateModels ) + { + for ( ModuleListIterator it = modules(); it.current(); ++it ) + { + CAM_DataModel* camDM = it.current()->dataModel(); + if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) ) + ((SalomeApp_DataModel*)camDM)->update(); + } + } // update "non-existing" (not loaded yet) data models SalomeApp_Study* study = dynamic_cast(activeStudy()); - if ( study ) + if ( study ) { _PTR(Study) stdDS = study->studyDS(); - if( stdDS ) + if( stdDS ) { - for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() ) + for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() ) { - _PTR(SComponent) aComponent ( it->Value() ); + _PTR(SComponent) aComponent ( it->Value() ); if ( aComponent->ComponentDataType() == "Interface Applicative" ) continue; // skip the magic "Interface Applicative" component - + SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true ); } } } - LightApp_Application::updateObjectBrowser(updateModels); + + if ( objectBrowser() ) + { + objectBrowser()->updateGeometry(); + objectBrowser()->updateTree(); + } +} + +/*!Protected SLOT.On desktop activated.*/ +void SalomeApp_Application::onDesktopActivated() +{ + CAM_Application::onDesktopActivated(); + SalomeApp_Module* aModule = dynamic_cast(activeModule()); + if(aModule) + aModule->studyActivated(); +} + +/*!Create empty study.*/ +void SalomeApp_Application::createEmptyStudy() +{ + CAM_Application::createEmptyStudy(); + if ( objectBrowser() ) + objectBrowser()->updateTree(); +} + +/*!Activate module \a mod.*/ +bool SalomeApp_Application::activateModule( CAM_Module* mod ) +{ + bool res = CAM_Application::activateModule( mod ); + if ( objectBrowser() ) + objectBrowser()->updateTree(); + return res; } /*!Display Catalog Genenerator dialog */ @@ -653,21 +2114,8 @@ void SalomeApp_Application::onRegDisplay() regWnd->setActiveWindow(); } -/*!Private SLOT. */ -void SalomeApp_Application::onOpenWith() +/*!return keyborad accelerators manager object */ +SUIT_Accel* SalomeApp_Application::accel() const { - QApplication::setOverrideCursor( Qt::waitCursor ); - SALOME_ListIO aList; - LightApp_SelectionMgr* mgr = selectionMgr(); - mgr->selectedObjects(aList); - if (aList.Extent() != 1) - { - QApplication::restoreOverrideCursor(); - return; - } - Handle(SALOME_InteractiveObject) aIObj = aList.First(); - QString aModuleName(aIObj->getComponentDataType()); - QString aModuleTitle = moduleTitle(aModuleName); - activateModule(aModuleTitle); - QApplication::restoreOverrideCursor(); + return myAccel; } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 0cad762f5..969d54890 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -11,7 +11,7 @@ #endif // _MSC_VER > 1000 #include "SalomeApp.h" -#include +#include #include @@ -25,8 +25,14 @@ class QAction; class QComboBox; class QDockWindow; -class LightApp_Preferences; +class LogWindow; +class OB_Browser; +class PythonConsole; class SalomeApp_Module; +class SalomeApp_Preferences; +class SalomeApp_SelectionMgr; +class SalomeApp_WidgetContainer; +class SUIT_Accel; class SALOME_LifeCycleCORBA; @@ -38,58 +44,176 @@ class SALOME_LifeCycleCORBA; Description : Application containing SalomeApp module */ -class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application +class SALOMEAPP_EXPORT SalomeApp_Application : public CAM_Application { Q_OBJECT public: - enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId, - CatalogGenId, RegDisplayId, UserID }; + typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes; + + enum { ModulesListId = STD_Application::UserID, NewGLViewId, + NewPlot2dId, NewOCCViewId, NewVTKViewId, DumpStudyId, + LoadScriptId, PropertiesId, PreferencesId, MRUId, + CatalogGenId, RegDisplayId, UserID }; public: SalomeApp_Application(); virtual ~SalomeApp_Application(); + + virtual QString applicationName() const; + virtual QString applicationVersion() const; + + virtual CAM_Module* loadModule( const QString& ); + virtual bool activateModule( const QString& ); + + virtual bool useStudy( const QString& ); + + SalomeApp_SelectionMgr* selectionMgr() const; + + LogWindow* logWindow(); + OB_Browser* objectBrowser(); + PythonConsole* pythonConsole(); - virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); virtual void updateObjectBrowser( const bool = true ); + SalomeApp_Preferences* preferences() const; + virtual QString getFileFilter() const; + virtual QString getFileName( bool open, const QString& initial, const QString& filters, + const QString& caption, QWidget* parent ); + virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ); + virtual QStringList getOpenFileNames( const QString& initial, const QString& filters, + const QString& caption, QWidget* parent ); SUIT_ViewManager* getViewManager( const QString&, const bool ); + void updateActions(); + + QWidget* getWindow( const int, const int = -1 ); + + QWidget* window( const int, const int = -1 ) const; + void addWindow( QWidget*, const int, const int = -1 ); + void removeWindow( const int, const int = -1 ); + + bool isWindowVisible( const int ) const; + void setWindowShown( const int, const bool ); + virtual void start(); + virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); + + virtual void createEmptyStudy(); + + SUIT_Accel* accel() const; + static CORBA::ORB_var orb(); static SALOMEDSClient_StudyManager* studyMgr(); static SALOME_NamingService* namingService(); static SALOME_LifeCycleCORBA* lcc(); static QString defaultEngineIOR(); +signals: + void studyOpened(); + void studySaved(); + void studyClosed(); + public slots: + virtual void onNewDoc(); + virtual void onOpenDoc(); + virtual void onHelpAbout(); + virtual bool onOpenDoc( const QString& ); virtual void onLoadDoc(); + virtual bool onLoadDoc( const QString& ); virtual void onCopy(); virtual void onPaste(); +private slots: + void onSelection(); + void onRefresh(); + void onDeleteReferences(); + protected: virtual void createActions(); virtual SUIT_Study* createNewStudy(); virtual QWidget* createWindow( const int ); + virtual void defaultWindows( QMap& ) const; + virtual void defaultViewManagers( QStringList& ) const; + + virtual void setActiveStudy( SUIT_Study* ); virtual void updateCommandsStatus(); + virtual void onSelectionChanged(); - virtual void createPreferences( LightApp_Preferences* ); + virtual void beforeCloseDoc( SUIT_Study* ); + virtual void afterCloseDoc(); + + virtual void moduleAdded( CAM_Module* ); + virtual bool activateModule( CAM_Module* = 0 ); + + SalomeApp_Preferences* preferences( const bool ) const; + + virtual void createPreferences( SalomeApp_Preferences* ); + virtual void preferencesChanged( const QString&, const QString& ); virtual void updateDesktopTitle(); +protected slots: + virtual void onDesktopActivated(); + private slots: - void onDeleteReferences(); + void onNewWindow(); + void onModuleActivation( QAction* ); + void onCloseView( SUIT_ViewManager* ); + + void onStudyCreated( SUIT_Study* ); + void onStudyOpened( SUIT_Study* ); + void onStudySaved( SUIT_Study* ); + void onStudyClosed( SUIT_Study* ); + void onProperties(); void onDumpStudy(); void onLoadScript(); + void onPreferences(); + void onMRUActivated( QString ); + void onCatalogGen(); void onRegDisplay(); + + void onPreferenceChanged( QString&, QString&, QString& ); void onOpenWith(); + +private: + void updateWindows(); + void updateViewManagers(); + void updateModuleActions(); + + void loadWindowsGeometry(); + void saveWindowsGeometry(); + + void updatePreference( const QString&, const QString&, const QString& ); + + QString defaultModule() const; + void currentWindows( QMap& ) const; + void currentViewManagers( QStringList& ) const; + SUIT_ViewManager* createViewManager( const QString& vmType ); + void moduleIconNames( QMap& ) const; + + void activateWindows(); + +private: + typedef QMap ActionMap; + typedef QMap WindowMap; + +private: + SalomeApp_Preferences* myPrefs; + SalomeApp_SelectionMgr* mySelMgr; + ActionMap myActions; + WindowMap myWindows; + + SUIT_Accel* myAccel; + + static SalomeApp_Preferences* _prefs_; }; #ifdef WIN32 diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 3c63e644b..e2b9fbef2 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -5,13 +5,13 @@ #include "SalomeApp_DataModel.h" #include "SalomeApp_Study.h" +#include "SalomeApp_RootObject.h" #include "SalomeApp_DataObject.h" #include "SalomeApp_Module.h" #include "SalomeApp_Application.h" +#include "SalomeApp_SelectionMgr.h" #include "SalomeApp_Engine_i.hxx" -#include "LightApp_RootObject.h" - #include #include @@ -51,11 +51,12 @@ SUIT_DataObject* SalomeApp_DataModel::BuildTree( const _PTR(SObject)& obj, for ( DataObjectListIterator it( allComponents ); it.current(); ++it ) { SUIT_DataObject* componentObj = it.current(); if ( componentObj->name() == aSName ) { - //mkr : modifications for update already published in - //object browser, but not loaded yet component - LightApp_Application* anApp = dynamic_cast - ( SUIT_Session::session()->activeApplication() ); - // asv : corresponding DataObjects are DELETED before update (so they are re-built). + // mkr : modifications for update of already published in + // object browser, but not loaded yet components + CAM_Application* anApp = dynamic_cast + (SUIT_Session::session()->activeApplication()); + + // asv : corresponding DataObjects are DELETED before update (so they are re-built). if (anApp && !anApp->module(aSName)) { // if module is not loaded, delete it's DataObject // jfa: remove children before DataObject deletion DataObjectList chilren = componentObj->children(/*recursive=*/true); @@ -92,7 +93,7 @@ SUIT_DataObject* SalomeApp_DataModel::BuildTree( const _PTR(SObject)& obj, /*!Purpose : Constructor*/ //======================================================================= SalomeApp_DataModel::SalomeApp_DataModel( CAM_Module* theModule ) -: LightApp_DataModel( theModule ) +: CAM_DataModel( theModule ) { } @@ -108,7 +109,7 @@ SalomeApp_DataModel::~SalomeApp_DataModel() // Function : open /*! Purpose : Open data model*/ //================================================================ -bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study ) +bool SalomeApp_DataModel::open( const QString&, CAM_Study* study ) { SalomeApp_Study* aDoc = dynamic_cast( study ); if ( !aDoc ) @@ -118,12 +119,72 @@ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study ) if ( anId.isEmpty() ) return true; // Probably nothing to load + QString anEngine = getModule()->engineIOR(); + if ( anEngine == "-1" ) { + // Module doesn't have a CORBA engine and doesn't use + // a default one -> SALOMEDS persistence cannot be used + return false; + } + + if ( anEngine.isEmpty() ) { + // Module use a default engine + //TODO: deside, if the below code has to be copyed in a light data model to avoid bulding of data tree twice + anEngine = SalomeApp_Application::defaultEngineIOR(); + } + _PTR(Study) aStudy ( aDoc->studyDS() ); // shared_ptr cannot be used here _PTR(SComponent) aSComp ( aStudy->FindComponentID( std::string( anId.latin1() ) ) ); - if ( aSComp ) - buildTree( aSComp, 0, aDoc ); - LightApp_DataModel::open(name, study); + if ( aSComp ) { + _PTR(StudyBuilder) aBuilder( aStudy->NewBuilder() ); + if ( aBuilder ) { + try { + aBuilder->LoadWith( aSComp, std::string( anEngine.latin1() ) ); + } + catch( const SALOME::SALOME_Exception& ) { + // Oops, something went wrong while loading -> return an error + return false; + } + + // Something has been read -> create data model tree + buildTree( aSComp, 0, aDoc ); + } + } else { + // Don't return false here, for there might be no data + // for a given component in the study yet + } + + emit opened(); //TODO: is it really needed? to be removed maybe... + return true; +} + +//================================================================ +// Function : save +/*! Purpose : Emit saved()*/ +//================================================================ +bool SalomeApp_DataModel::save() +{ + emit saved(); + return true; +} + +//================================================================ +// Function : saveAs +/*! Purpose : Emit saved() */ +//================================================================ +bool SalomeApp_DataModel::saveAs( const QString&, CAM_Study* ) +{ + emit saved(); + return true; +} + +//================================================================ +// Function : close +/*! Purpose : Emit closed()*/ +//================================================================ +bool SalomeApp_DataModel::close() +{ + emit closed(); return true; } @@ -131,42 +192,33 @@ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study ) // Function : update /*! Purpose : Update application.*/ //================================================================ -void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) +void SalomeApp_DataModel::update( SalomeApp_DataObject*, SalomeApp_Study* study ) { - SalomeApp_Study* aSStudy = 0; - LightApp_RootObject* studyRoot = 0; + SalomeApp_RootObject* studyRoot = 0; _PTR(SObject) sobj; SalomeApp_DataObject* modelRoot = dynamic_cast( root() ); if ( !modelRoot ){ // not yet connected to a study -> try using argument - aSStudy = dynamic_cast( study ); - if ( !aSStudy ) - aSStudy = dynamic_cast( getModule()->getApp()->activeStudy() ); - if ( aSStudy ){ - studyRoot = dynamic_cast( aSStudy->root() ); - if ( studyRoot ) { - QString anId = getRootEntry( aSStudy ); - if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing - _PTR(Study) aStudy ( aSStudy->studyDS() ); - sobj = aStudy->FindComponentID( std::string( anId.latin1() ) ); - } + if ( !study ) + study = dynamic_cast( getModule()->getApp()->activeStudy() ); + + if ( study ){ + studyRoot = dynamic_cast( study->root() ); + QString anId = getRootEntry( study ); + if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing + _PTR(Study) aStudy ( study->studyDS() ); + sobj = aStudy->FindComponentID( std::string( anId.latin1() ) ); } } } else{ - studyRoot = dynamic_cast( modelRoot->root() ); - if ( studyRoot ) { - aSStudy = dynamic_cast( study ); - if ( aSStudy ) { - aSStudy = dynamic_cast( studyRoot->study() ); // value should not change here theoretically, but just to make sure - if ( aSStudy ) { - _PTR(Study) aStudy ( aSStudy->studyDS() ); - // modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon - sobj = aStudy->FindComponentID( std::string( modelRoot->entry().latin1() ) ); - } - } - } + studyRoot = dynamic_cast( modelRoot->root() ); + study = studyRoot->study(); // value should not change here theoretically, but just to make sure + _PTR(Study) aStudy ( study->studyDS() ); + + // modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon + sobj = aStudy->FindComponentID( std::string( modelRoot->entry().latin1() ) ); } - buildTree( sobj, studyRoot, aSStudy ); + buildTree( sobj, studyRoot, study ); } //================================================================ @@ -205,13 +257,10 @@ SalomeApp_Module* SalomeApp_DataModel::getModule() const SalomeApp_Study* SalomeApp_DataModel::getStudy() const { if(!root()) return 0; - LightApp_RootObject* aRoot = dynamic_cast( root()->root() ); + SalomeApp_RootObject* aRoot = dynamic_cast( root()->root() ); if ( !aRoot ) return 0; - SalomeApp_Study* aStudy = dynamic_cast( aRoot->study() ); - if ( !aStudy ) - return 0; - return aStudy; + return aRoot->study(); } //================================================================ @@ -233,3 +282,99 @@ QString SalomeApp_DataModel::getRootEntry( SalomeApp_Study* study ) const } return anEntry; } + +//================================================================ +// Function : isModified +/*! Purpose : default implementation, always returns false so as not to mask study's isModified()*/ +//================================================================ +bool SalomeApp_DataModel::isModified() const +{ + return false; +} + +//================================================================ +// Function : isSaved +/*! Purpose : default implementation, always returns true so as not to mask study's isSaved()*/ +//================================================================ +bool SalomeApp_DataModel::isSaved() const +{ + return true; +} + +// BEGIN: methods to be used by CORBAless modules + +//================================================================ +// Function : GetListOfFiles +/*! Purpose : to be used by CORBAless modules*/ +//================================================================ +std::vector SalomeApp_DataModel::GetListOfFiles() const + //(const int theStudyId, const char* theComponentName) const +{ + SUIT_Study* anActiveStudy = getModule()->getApp()->activeStudy(); + if (anActiveStudy) { + int aStudyId = anActiveStudy->id(); + SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance(); + if (aDefaultEngine) { + return aDefaultEngine->GetListOfFiles(aStudyId, module()->name()); + } + } + + std::vector aListOfFiles; + return aListOfFiles; +} + +//================================================================ +// Function : SetListOfFiles +/*! Purpose : to be used by CORBAless modules*/ +//================================================================ +void SalomeApp_DataModel::SetListOfFiles (const std::vector theListOfFiles) + //(const std::vector theListOfFiles, + // const int theStudyId, + // const char* theComponentName) +{ + SUIT_Study* anActiveStudy = getModule()->getApp()->activeStudy(); + if (anActiveStudy) { + int aStudyId = anActiveStudy->id(); + SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance(); + if (aDefaultEngine) { + aDefaultEngine->SetListOfFiles(theListOfFiles, aStudyId, module()->name()); + } + } +} + +//================================================================ +// Function : GetTmpDir +/*! Purpose : Static method. To be used by CORBAless modules*/ +//================================================================ +std::string SalomeApp_DataModel::GetTmpDir (const char* theURL, + const bool isMultiFile) +{ + std::string anURLDir = SALOMEDS_Tool::GetDirFromPath(theURL); + std::string aTmpDir = isMultiFile ? anURLDir : SALOMEDS_Tool::GetTmpDir(); + return aTmpDir; +} + +//================================================================ +// Function : RemoveTemporaryFiles +/*! Purpose : to be used by CORBAless modules*/ +//================================================================ +void SalomeApp_DataModel::RemoveTemporaryFiles (const bool isMultiFile) const +{ + if (isMultiFile) + return; + + std::vector aListOfFiles = GetListOfFiles(); + if (aListOfFiles.size() > 0) { + std::string aTmpDir = aListOfFiles[0]; + + const int n = aListOfFiles.size() - 1; + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(n); + for (int i = 0; i < n; i++) + aSeq[i] = CORBA::string_dup(aListOfFiles[i + 1].c_str()); + + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); + } +} + +// END: methods to be used by CORBAless modules diff --git a/src/SalomeApp/SalomeApp_DataModel.h b/src/SalomeApp/SalomeApp_DataModel.h index 7ef34b088..3f7d5f664 100644 --- a/src/SalomeApp/SalomeApp_DataModel.h +++ b/src/SalomeApp/SalomeApp_DataModel.h @@ -11,17 +11,18 @@ #endif // _MSC_VER > 1000 #include "SalomeApp.h" -#include "LightApp_DataModel.h" +#include "CAM_DataModel.h" #include "SALOMEDSClient.hxx" class SalomeApp_Module; class SalomeApp_Study; class SalomeApp_DataObject; +class SalomeApp_SelectionMgr; // Class : SalomeApp_DataModel /// Description : Base class of data model -class SALOMEAPP_EXPORT SalomeApp_DataModel : public LightApp_DataModel +class SALOMEAPP_EXPORT SalomeApp_DataModel : public CAM_DataModel { Q_OBJECT @@ -34,16 +35,44 @@ public: SalomeApp_DataModel ( CAM_Module* theModule ); virtual ~SalomeApp_DataModel(); + /** @name These methods should be redefined in successors.*/ + //@{ virtual bool open( const QString&, CAM_Study* ); - virtual void update( LightApp_DataObject* = 0, LightApp_Study* = 0 ); + virtual bool save(); + virtual bool saveAs( const QString&, CAM_Study* ); + virtual bool close(); - QString getRootEntry( SalomeApp_Study* ) const; - SalomeApp_Module* getModule() const; + virtual void update( SalomeApp_DataObject* = 0, SalomeApp_Study* = 0 ); + + virtual bool isModified() const; + virtual bool isSaved() const; + //@} + +signals: + void opened(); + void saved(); + void closed(); protected: + SalomeApp_Module* getModule() const; SalomeApp_Study* getStudy() const; virtual void buildTree(const _PTR(SObject)&, SUIT_DataObject*, SalomeApp_Study* ); + + /** @name methods to be used by CORBAless modules*/ + //@{ + std::vector GetListOfFiles () const; + void SetListOfFiles (const std::vector theListOfFiles); + + static std::string GetTmpDir (const char* theURL, + const bool isMultiFile); + + void RemoveTemporaryFiles (const bool isMultiFile) const; + //@} + // END: methods to be used by CORBAless modules + +private: + QString getRootEntry( SalomeApp_Study* ) const; }; #endif diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 62cb0add7..0e9866fa9 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -1,7 +1,7 @@ #include "SalomeApp_DataObject.h" #include "SalomeApp_Study.h" -#include "LightApp_RootObject.h" +#include "SalomeApp_RootObject.h" #include #include @@ -15,21 +15,62 @@ #include #include +/*! + Class: SalomeApp_DataObject::Key + Level: Internal +*/ +class SalomeApp_DataObject::Key : public SUIT_DataObjectKey +{ +public: + Key( const QString& ); + virtual ~Key(); + + virtual bool isLess( const SUIT_DataObjectKey* ) const; + virtual bool isEqual( const SUIT_DataObjectKey* ) const; + +private: + QString myEntry; +}; + +/*!Constructor. Initialize by \a entry.*/ +SalomeApp_DataObject::Key::Key( const QString& entry ) +: SUIT_DataObjectKey(), + myEntry( entry ) +{ +} + +/*!Destructor. Do nothing.*/ +SalomeApp_DataObject::Key::~Key() +{ +} + +/*!Checks: Is current key less than \a other.*/ +bool SalomeApp_DataObject::Key::isLess( const SUIT_DataObjectKey* other ) const +{ + Key* that = (Key*)other; + return myEntry < that->myEntry; +} + +/*!Checks: Is current key equal with \a other.*/ +bool SalomeApp_DataObject::Key::isEqual( const SUIT_DataObjectKey* other ) const +{ + Key* that = (Key*)other; + return myEntry == that->myEntry; +} + /* Class: SalomeApp_DataObject Level: Public */ /*!Constructor. Initialize by \a parent*/ SalomeApp_DataObject::SalomeApp_DataObject( SUIT_DataObject* parent ) -: LightApp_DataObject( parent ), - CAM_DataObject( parent ) +: CAM_DataObject( parent ) { } /*!Constructor. Initialize by \a parent and SObject*/ SalomeApp_DataObject::SalomeApp_DataObject( const _PTR(SObject)& sobj, SUIT_DataObject* parent ) -: LightApp_DataObject( parent ), - CAM_DataObject( parent ) +: CAM_DataObject( parent ) { myObject = sobj; } @@ -49,6 +90,13 @@ QString SalomeApp_DataObject::entry() const return QString::null; } +/*!Create and return new key object.*/ +SUIT_DataObjectKey* SalomeApp_DataObject::key() const +{ + QString str = entry(); + return new Key( str ); +} + /*!Gets name of object.*/ QString SalomeApp_DataObject::name() const { @@ -83,7 +131,7 @@ QPixmap SalomeApp_DataObject::icon() const _PTR(AttributePixMap) aPixAttr ( anAttr ); if ( aPixAttr->HasPixMap() ){ QString pixmapName = QObject::tr( aPixAttr->GetPixMap().c_str() ); - LightApp_RootObject* aRoot = dynamic_cast( root() ); + SalomeApp_RootObject* aRoot = dynamic_cast( root() ); if ( aRoot && aRoot->study() ) { QPixmap pixmap = aRoot->study()->application()->resourceMgr()->loadPixmap( componentDataType(), pixmapName, false ); return pixmap; @@ -178,6 +226,25 @@ QString SalomeApp_DataObject::toolTip() const return QString( "Object \'%1\', module \'%2\', ID=%3" ).arg( name() ).arg( componentDataType() ).arg( entry() ); } +/*!Gets component object. + *\retval SUIT_DataObject. + */ +SUIT_DataObject* SalomeApp_DataObject::componentObject() const +{ + SUIT_DataObject* compObj = 0; // for root object (invisible SALOME_ROOT_OBJECT) + + if ( parent() && parent() == root() ) + compObj = (SUIT_DataObject*)this; // for component-level objects + else + { + compObj = parent(); // for lower level objects + while ( compObj && compObj->parent() != root() ) + compObj = compObj->parent(); + } + + return compObj; +} + /*!Get component type.*/ QString SalomeApp_DataObject::componentDataType() const { diff --git a/src/SalomeApp/SalomeApp_DataObject.h b/src/SalomeApp/SalomeApp_DataObject.h index 34042162d..434f96baa 100644 --- a/src/SalomeApp/SalomeApp_DataObject.h +++ b/src/SalomeApp/SalomeApp_DataObject.h @@ -3,15 +3,16 @@ #include "SalomeApp.h" -#include "LightApp_DataObject.h" +#include "CAM_DataObject.h" #include "CAM_RootObject.h" #include "SALOMEDSClient.hxx" class SalomeApp_Study; -class SALOMEAPP_EXPORT SalomeApp_DataObject : public LightApp_DataObject +class SALOMEAPP_EXPORT SalomeApp_DataObject : public virtual CAM_DataObject { + class Key; public: enum { CT_Value, CT_Entry, CT_IOR, CT_RefEntry }; @@ -28,6 +29,7 @@ public: virtual QString text( const int ) const; virtual QColor color( const ColorRole ) const; + virtual SUIT_DataObjectKey* key() const; virtual QString entry() const; /*! location of corresponding SALOMEDS::SObject */ @@ -36,6 +38,7 @@ public: bool isReference() const; _PTR(SObject) referencedObject() const; + SUIT_DataObject* componentObject() const; /*! GEOM, SMESH, VISU, etc.*/ QString componentDataType() const; diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 9123d76f7..f62a3eca4 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -8,19 +8,19 @@ #include "SalomeApp_Study.h" #include "SalomeApp_DataModel.h" #include "SalomeApp_Application.h" - -#include "LightApp_Preferences.h" +#include "SalomeApp_Preferences.h" #include "SalomeApp_UpdateFlags.h" #include "SalomeApp_Operation.h" #include "SalomeApp_SwitchOp.h" -#include "SUIT_Operation.h" -#include "CAM_DataModel.h" +#include + +#include -#include "OB_Browser.h" +#include +#include -#include -#include +#include #include #include @@ -31,7 +31,8 @@ /*!Constructor.*/ SalomeApp_Module::SalomeApp_Module( const QString& name ) -: LightApp_Module( name ), +: CAM_Module( name ), +myPopupMgr( 0 ), mySwitchOp( 0 ) { } @@ -43,32 +44,105 @@ SalomeApp_Module::~SalomeApp_Module() delete mySwitchOp; } -/*!Gets application.*/ -SalomeApp_Application* SalomeApp_Module::getApp() const +/*!Initialize module.*/ +void SalomeApp_Module::initialize( CAM_Application* app ) { - return (SalomeApp_Application*)application(); + CAM_Module::initialize( app ); + + SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0; + if ( resMgr ) + resMgr->raiseTranslators( name() ); } /*!Activate module.*/ bool SalomeApp_Module::activateModule( SUIT_Study* study ) { - bool res = LightApp_Module::activateModule( study ); + bool res = CAM_Module::activateModule( study ); + + if ( res && application() && application()->resourceMgr() ) + application()->resourceMgr()->raiseTranslators( name() ); if ( mySwitchOp == 0 ) mySwitchOp = new SalomeApp_SwitchOp( this ); - + return res; } /*!Deactivate module.*/ -bool SalomeApp_Module::deactivateModule( SUIT_Study* study ) +bool SalomeApp_Module::deactivateModule( SUIT_Study* ) { - bool res = LightApp_Module::deactivateModule( study ); - delete mySwitchOp; mySwitchOp = 0; + + return true; +} - return res; +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::selectionChanged() +{ +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::MenuItem() +{ +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::windows( QMap& ) const +{ +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::viewManagers( QStringList& ) const +{ +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::createPreferences() +{ +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::preferencesChanged( const QString&, const QString& ) +{ +} + +/*!Gets application.*/ +SalomeApp_Application* SalomeApp_Module::getApp() const +{ + return (SalomeApp_Application*)application(); +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::onModelOpened() +{ +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::onModelSaved() +{ +} + +/*!NOT IMPLEMENTED*/ +void SalomeApp_Module::onModelClosed() +{ +} + +/*!Gets popup manager.(create if not exist)*/ +QtxPopupMgr* SalomeApp_Module::popupMgr() +{ + if ( !myPopupMgr ) + myPopupMgr = new QtxPopupMgr( 0, this ); + return myPopupMgr; +} + +/*!Gets preferences.*/ +SalomeApp_Preferences* SalomeApp_Module::preferences() const +{ + SalomeApp_Preferences* pref = 0; + if ( getApp() ) + pref = getApp()->preferences(); + return pref; } /*!Create new instance of data model and return it.*/ @@ -77,6 +151,75 @@ CAM_DataModel* SalomeApp_Module::createDataModel() return new SalomeApp_DataModel(this); } +/*!Update object browser.*/ +void SalomeApp_Module::updateObjBrowser( bool updateDataModel, SUIT_DataObject* root ) +{ + if( updateDataModel ) + if( CAM_DataModel* aDataModel = dataModel() ) + if( SalomeApp_DataModel* aModel = dynamic_cast( aDataModel ) ) + aModel->update( 0, dynamic_cast( getApp()->activeStudy() ) ); + getApp()->objectBrowser()->updateTree( root ); +} + +/*!Context menu popup.*/ +void SalomeApp_Module::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ ) +{ + SalomeApp_Selection* sel = createSelection(); + sel->init( client, getApp()->selectionMgr() ); + popupMgr()->updatePopup( menu, sel ); + delete sel; +} + +/*!Create and return instance of SalomeApp_Selection.*/ +SalomeApp_Selection* SalomeApp_Module::createSelection() const +{ + return new SalomeApp_Selection(); +} + +/*!Add preference to preferences.*/ +int SalomeApp_Module::addPreference( const QString& label ) +{ + SalomeApp_Preferences* pref = preferences(); + if ( !pref ) + return -1; + + int catId = pref->addPreference( moduleName(), -1 ); + if ( catId == -1 ) + return -1; + + return pref->addPreference( label, catId ); +} + +/*!Add preference to preferences.*/ +int SalomeApp_Module::addPreference( const QString& label, const int pId, const int type, + const QString& section, const QString& param ) +{ + SalomeApp_Preferences* pref = preferences(); + if ( !pref ) + return -1; + + return pref->addPreference( moduleName(), label, pId, type, section, param ); +} + +/*!Gets property of preferences.*/ +QVariant SalomeApp_Module::preferenceProperty( const int id, const QString& prop ) const +{ + QVariant var; + SalomeApp_Preferences* pref = preferences(); + if ( pref ) + var = pref->itemProperty( id, prop ); + return var; +} + + +/*!Set property of preferences.*/ +void SalomeApp_Module::setPreferenceProperty( const int id, const QString& prop, const QVariant& var ) +{ + SalomeApp_Preferences* pref = preferences(); + if ( pref ) + pref->setItemProperty( id, prop, var ); +} + /*! * \brief Update something in accordance with update flags * \param theFlags - update flags @@ -90,11 +233,8 @@ void SalomeApp_Module::update( const int theFlags ) if ( theFlags & UF_Model ) { if( CAM_DataModel* aDataModel = dataModel() ) - if( SalomeApp_DataModel* aModel = dynamic_cast( aDataModel ) ) { - SalomeApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); - if (aStudy) - aModel->update( 0, aStudy ); - } + if( SalomeApp_DataModel* aModel = dynamic_cast( aDataModel ) ) + aModel->update( 0, dynamic_cast( getApp()->activeStudy() ) ); } if ( theFlags & UF_ObjBrowser ) getApp()->objectBrowser()->updateTree( 0 ); diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index 436548415..644608c5d 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -7,23 +7,34 @@ #define SALOMEAPP_MODULE_H #include "SalomeApp.h" +#include "SalomeApp_Selection.h" -#include +#include #include -class CAM_DataModel; -class SUIT_DataObject; +class QDockWindow; + +class CAM_Study; + +class QtxPopupMgr; + class SUIT_Operation; -class SalomeApp_Application; +class SUIT_Convertor; +class SUIT_ViewModel; +class SUIT_DataObject; +class SalomeApp_DataModel; +class SalomeApp_Application; +class SalomeApp_Preferences; +class SalomeApp_SelectionManager; class SalomeApp_Operation; class SalomeApp_SwitchOp; /*! * \brief Base class for all salome modules */ -class SALOMEAPP_EXPORT SalomeApp_Module : public LightApp_Module +class SALOMEAPP_EXPORT SalomeApp_Module : public CAM_Module { Q_OBJECT @@ -31,6 +42,10 @@ public: SalomeApp_Module( const QString& ); virtual ~SalomeApp_Module(); + virtual void initialize( CAM_Application* ); + virtual void windows( QMap& ) const; + virtual void viewManagers( QStringList& ) const; + /*! engineIOR() should be a pure virtual method, to avoid logical errors!\n * Implementation in derived classes can return the following values:\n * module`s engine IOR - means that this is a standard SALOME module with a CORBA engine @@ -38,6 +53,10 @@ public: * \li "-1" - means that this is a light module, SALOMEDS persistence is not used at all\n */ virtual QString engineIOR() const = 0; + + virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); + + virtual void createPreferences(); /*! Convenient shortcuts*/ @@ -48,17 +67,34 @@ public: // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method // for their own purposes + void updateObjBrowser( bool = true, SUIT_DataObject* = 0 ); + // Update object bropwser ( for updating model or whole object browser use update() method + // can be used ) + + virtual void selectionChanged(); + virtual void preferencesChanged( const QString&, const QString& ); + + virtual void studyActivated() {}; + public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* ); + void MenuItem(); + protected slots: + virtual void onModelSaved(); + virtual void onModelOpened(); + virtual void onModelClosed(); virtual void onOperationStopped( SUIT_Operation* ); virtual void onOperationDestroyed(); - protected: - virtual CAM_DataModel* createDataModel(); +protected: + QtxPopupMgr* popupMgr(); + SalomeApp_Preferences* preferences() const; + virtual CAM_DataModel* createDataModel(); + virtual SalomeApp_Selection* createSelection() const; virtual void updateControls(); /*! Module stores operations in map. This method starts operation by id. @@ -72,12 +108,20 @@ protected slots: */ virtual SalomeApp_Operation* createOperation( const int ) const; + int addPreference( const QString& label ); + int addPreference( const QString& label, const int pId, const int = -1, + const QString& section = QString::null, + const QString& param = QString::null ); + QVariant preferenceProperty( const int, const QString& ) const; + void setPreferenceProperty( const int, const QString&, const QVariant& ); + private: typedef QMap MapOfOperation; private: + QtxPopupMgr* myPopupMgr; MapOfOperation myOperations; - SalomeApp_SwitchOp* mySwitchOp; + SalomeApp_SwitchOp* mySwitchOp; }; #endif diff --git a/src/SalomeApp/SalomeApp_Operation.cxx b/src/SalomeApp/SalomeApp_Operation.cxx index bb794a8bc..267229156 100755 --- a/src/SalomeApp/SalomeApp_Operation.cxx +++ b/src/SalomeApp/SalomeApp_Operation.cxx @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -209,7 +209,7 @@ SUIT_Operation* SalomeApp_Operation::activeOperation() const * * This method provided for convinience calls SalomeApp_Application::selectionMgr() one */ -LightApp_SelectionMgr* SalomeApp_Operation::selectionMgr() const +SalomeApp_SelectionMgr* SalomeApp_Operation::selectionMgr() const { SUIT_Application* app = application(); if ( app != 0 && app->inherits( "SalomeApp_Application" ) ) diff --git a/src/SalomeApp/SalomeApp_Operation.h b/src/SalomeApp/SalomeApp_Operation.h index 274f8e553..39c0ca6e9 100755 --- a/src/SalomeApp/SalomeApp_Operation.h +++ b/src/SalomeApp/SalomeApp_Operation.h @@ -17,7 +17,7 @@ class SalomeApp_Module; class SalomeApp_Application; class SalomeApp_Operation; -class LightApp_SelectionMgr; +class SalomeApp_SelectionMgr; class SalomeApp_Dialog; class SUIT_Desktop; @@ -67,7 +67,7 @@ protected: SUIT_Desktop* desktop() const; SUIT_Operation* activeOperation() const; - LightApp_SelectionMgr* selectionMgr() const; + SalomeApp_SelectionMgr* selectionMgr() const; void update( const int ); void setAutoResumed( const bool ); diff --git a/src/SalomeApp/SalomeApp_PyInterp.cxx b/src/SalomeApp/SalomeApp_PyInterp.cxx index a6549f646..7cf6ce66d 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.cxx +++ b/src/SalomeApp/SalomeApp_PyInterp.cxx @@ -30,13 +30,11 @@ #include #include - -#include -#include - -#include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! - -#include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif /*! * constructor : multi Python interpreter, one per SALOME study. @@ -109,23 +107,3 @@ bool SalomeApp_PyInterp::initContext() return true; } - -void SalomeApp_PyInterp::init_python() -{ - /* - * Initialize the main state (_gtstate) if not already done - * The lock is released on init_python output - * It is the caller responsability to acquire it if needed - */ - MESSAGE("PyInterp_base::init_python"); - ASSERT(KERNEL_PYTHON::_gtstate); // initialisation in main - SCRUTE(KERNEL_PYTHON::_gtstate); -// if(!_gtstate){ -// PyReleaseLock aReleaseLock; -// Py_Initialize(); // Initialize the interpreter -// PyEval_InitThreads(); // Initialize and acquire the global interpreter lock -// PySys_SetArgv(_argc,_argv); // initialize sys.argv -// _gtstate = PyThreadState_Get(); -// } -} - diff --git a/src/SalomeApp/SalomeApp_PyInterp.h b/src/SalomeApp/SalomeApp_PyInterp.h index a15b3767f..065f8efd0 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.h +++ b/src/SalomeApp/SalomeApp_PyInterp.h @@ -37,8 +37,6 @@ public: SalomeApp_PyInterp(); virtual ~SalomeApp_PyInterp(); - virtual void init_python(); - protected: virtual bool initContext(); }; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 97be8db88..e1065c9fe 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -2,31 +2,21 @@ #include "SalomeApp_Module.h" #include "SalomeApp_DataModel.h" -#include "LightApp_RootObject.h" +#include "SalomeApp_RootObject.h" #include "SalomeApp_DataObject.h" #include "SalomeApp_Application.h" -#include "SalomeApp_Engine_i.hxx" #include #include -#include - #include "utilities.h" -#include "string.h" -#include "vector.h" - -#include "SALOMEDS_Tool.hxx" - -#include -#include CORBA_SERVER_HEADER(SALOME_Exception) /*! Constructor. */ SalomeApp_Study::SalomeApp_Study( SUIT_Application* app ) -: LightApp_Study( app ) +: CAM_Study( app ) { } @@ -72,7 +62,12 @@ void SalomeApp_Study::createDocument() setStudyDS( study ); setStudyName( aName ); - LightApp_Study::createDocument(); + // create myRoot + setRoot( new SalomeApp_RootObject( this ) ); + + CAM_Study::createDocument(); + + emit created( this ); } //======================================================================= @@ -90,8 +85,22 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) setStudyDS( study ); - bool res = LightApp_Study::openDocument( theFileName ); - + setRoot( new SalomeApp_RootObject( this ) ); // create myRoot + + // update loaded data models: call open() and update() on them. + ModelList dm_s; + dataModels( dm_s ); + for ( ModelListIterator it( dm_s ); it.current(); ++it ) + openDataModel( studyName(), it.current() ); + + // this will build a SUIT_DataObject-s tree under myRoot member field + // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step + // but tree that corresponds to not-loaded data models will be updated any way. + ((SalomeApp_Application*)application())->updateObjectBrowser( false ); + + bool res = CAM_Study::openDocument( theFileName ); + emit opened( this ); + return res; } @@ -110,56 +119,95 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) setStudyDS( study ); - bool res = LightApp_Study::loadDocument( theStudyName ); + setRoot( new SalomeApp_RootObject( this ) ); // create myRoot + + //SRN: BugID IPAL9021, put there the same code as in a method openDocument + + // update loaded data models: call open() and update() on them. + ModelList dm_s; + dataModels( dm_s ); + for ( ModelListIterator it( dm_s ); it.current(); ++it ) + openDataModel( studyName(), it.current() ); + + // this will build a SUIT_DataObject-s tree under myRoot member field + // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step + // but tree that corresponds to not-loaded data models will be updated any way. + ((SalomeApp_Application*)application())->updateObjectBrowser( false ); + + bool res = CAM_Study::openDocument( theStudyName ); + emit opened( this ); + + //SRN: BugID IPAL9021: End return res; } //======================================================================= // name : saveDocumentAs -/*! Purpose : Save document*/ +/*! Purpose : Save document */ //======================================================================= bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) { + ModelList list; dataModels( list ); + + SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) + aModel->saveAs( theFileName, this ); + // save SALOMEDS document SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if( !resMgr ) return false; - bool res = LightApp_Study::saveDocumentAs( theFileName ); //SRN: BugID IPAL9377, removed usage of uninitialized variable bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ), isAscii = resMgr->booleanValue( "Study", "ascii_file", true ); isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) : SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile ); + bool res = CAM_Study::saveDocumentAs( theFileName ); //SRN: BugID IPAL9377, removed usage of uninitialized variable + + if ( res ) + emit saved( this ); + return res; } //======================================================================= // name : saveDocument -/*! Purpose : Save document*/ +/*! Purpose : Save document */ //======================================================================= void SalomeApp_Study::saveDocument() { + ModelList list; dataModels( list ); + + SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) + aModel->save(); + + CAM_Study::saveDocument(); + // save SALOMEDS document SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if( !resMgr ) return; - LightApp_Study::saveDocument(); bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ), isAscii = resMgr->booleanValue( "Study", "ascii_file", true ); isAscii ? SalomeApp_Application::studyMgr()->SaveASCII( studyDS(), isMultiFile ) : SalomeApp_Application::studyMgr()->Save ( studyDS(), isMultiFile ); + + emit saved( this ); } //================================================================ // Function : closeDocument -/*! Purpose : Close document*/ +/*! Purpose : Close document */ //================================================================ void SalomeApp_Study::closeDocument(bool permanently) { - LightApp_Study::closeDocument(permanently); + // Inform everybody that this study is going to close when it's most safe to, + // i.e. in the very beginning + emit closed( this ); // close SALOMEDS document _PTR(Study) studyPtr = studyDS(); @@ -169,18 +217,25 @@ void SalomeApp_Study::closeDocument(bool permanently) SALOMEDSClient_Study* aStudy = 0; setStudyDS( _PTR(Study)(aStudy) ); } + + CAM_Study::closeDocument(permanently); } //================================================================ // Function : isModified -// Purpose : +/*! Purpose : Check data model on modifications.*/ //================================================================ bool SalomeApp_Study::isModified() const { bool isAnyChanged = studyDS() && studyDS()->IsModified(); - if (!isAnyChanged) - isAnyChanged = LightApp_Study::isModified(); + ModelList list; dataModels( list ); + SalomeApp_DataModel* aModel = 0; + for ( QPtrListIterator it( list ); it.current() && !isAnyChanged; ++it ){ + aModel = dynamic_cast( it.current() ); + if ( aModel ) + isAnyChanged = aModel->isModified(); + } return isAnyChanged; } @@ -191,9 +246,14 @@ bool SalomeApp_Study::isModified() const bool SalomeApp_Study::isSaved() const { bool isAllSaved = studyDS() && studyDS()->GetPersistentReference().size(); - if (!isAllSaved) - isAllSaved = LightApp_Study::isModified(); + ModelList list; dataModels( list ); + SalomeApp_DataModel* aModel = 0; + for ( QPtrListIterator it( list ); it.current() && isAllSaved; ++it ){ + aModel = dynamic_cast( it.current() ); + if ( aModel ) + isAllSaved = aModel->isSaved(); + } return isAllSaved; } @@ -215,23 +275,20 @@ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm) CAM_Study::dataModelInserted(dm); // Create SComponent for module, using default engine (CORBAless) - // SalomeApp_Module* aModule = (SalomeApp_Module*)(dm->module()); - SalomeApp_Module* aModule = dynamic_cast( dm->module() ); - // 1. aModule == 0 means that this is a light module (no CORBA enigine) - // 2. engineIOR == "" means this is a full module but without CORBA engine - if (!aModule || aModule->engineIOR().isEmpty()) { - // Check SComponent existance - _PTR(Study) aStudy = studyDS(); - if (!aStudy) - return; - _PTR(SComponent) aComp = aStudy->FindComponent(dm->module()->name()); - if (!aComp) { - // Create SComponent - _PTR(StudyBuilder) aBuilder = studyDS()->NewBuilder(); - aComp = aBuilder->NewComponent(dm->module()->name()); - - // Set default engine IOR - aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1()); + SalomeApp_Module* aModule = (SalomeApp_Module*)(dm->module()); + if (aModule) { + QString anEngineIOR = aModule->engineIOR(); + if (anEngineIOR.isEmpty()) { // CORBAless module + // Check SComponent existance + _PTR(SComponent) aComp = studyDS()->FindComponent(dm->module()->name()); + if (!aComp) { + // Create SComponent + _PTR(StudyBuilder) aBuilder = studyDS()->NewBuilder(); + aComp = aBuilder->NewComponent(dm->module()->name()); + + // Set default engine IOR + aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1()); + } } } } @@ -244,64 +301,13 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm if (!dm) return false; - // SalomeApp_DataModel* aDM = (SalomeApp_DataModel*)(dm); - SalomeApp_Module* aModule = dynamic_cast( dm->module() ); - _PTR(Study) aStudy = studyDS(); // shared_ptr cannot be used here - _PTR(SComponent) aSComp; - QString anEngine; - // 1. aModule == 0 means that this is a light module (no CORBA enigine) - // 2. engineIOR == "" means this is a full module but without CORBA engine - if (!aModule || aModule->engineIOR().isEmpty()) { - anEngine = SalomeApp_Application::defaultEngineIOR(); - aSComp = aStudy->FindComponent(dm->module()->name()); - } - else { - SalomeApp_DataModel* aDM = dynamic_cast( dm ); - if ( aDM ) { - QString anId = aDM->getRootEntry( this ); - if ( anId.isEmpty() ) - return true; // Probably nothing to load - - if ( aDM ) { - anEngine = aDM->getModule()->engineIOR(); - if ( anEngine == "-1" ) { - // Module doesn't have a CORBA engine and doesn't use - // a default one -> SALOMEDS persistence cannot be used - return false; - } - } - if ( anEngine.isEmpty() ) { - // Module use a default engine - //TODO: deside, if the below code has to be copyed in a light data model to avoid bulding of data tree twice - anEngine = SalomeApp_Application::defaultEngineIOR(); - } - aSComp = aStudy->FindComponentID( std::string( anId.latin1() ) ); - } - } - if ( aSComp ) { - _PTR(StudyBuilder) aBuilder( aStudy->NewBuilder() ); - if ( aBuilder ) { - try { - aBuilder->LoadWith( aSComp, std::string( anEngine.latin1() ) ); - } - catch( const SALOME::SALOME_Exception& ) { - // Oops, something went wrong while loading -> return an error - return false; - } - // Something has been read -> create data model tree - // aDM->buildTree( aSComp, 0, this ); - } - } else { - // Don't return false here, for there might be no data - // for a given component in the study yet - } - if (dm && dm->open(studyName, this)) { + SalomeApp_DataModel* aDM = (SalomeApp_DataModel*)(dm); + if (aDM && aDM->open(studyName, this)) { // Something has been read -> create data model tree - LightApp_DataModel* aDM = dynamic_cast( dm ); - if ( aDM ) - aDM->update(NULL, this); + aDM->update(NULL, this); return true; } + return false; } @@ -327,72 +333,6 @@ QString SalomeApp_Study::newStudyName() const return newName; } -//================================================================ -// Function : GetListOfFiles -/*! Purpose : to be used by CORBAless modules*/ -//================================================================ -std::vector SalomeApp_Study::GetListOfFiles() const -{ - SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance(); - if (aDefaultEngine) { - const char* aName = ((CAM_Application*)application())->activeModule()->name(); - return aDefaultEngine->GetListOfFiles(id(), aName); - } - - std::vector aListOfFiles; - return aListOfFiles; -} - -//================================================================ -// Function : SetListOfFiles -/*! Purpose : to be used by CORBAless modules*/ -//================================================================ -void SalomeApp_Study::SetListOfFiles (const std::vector theListOfFiles) -{ - SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance(); - if (aDefaultEngine) { - const char* aName = ((CAM_Application*)application())->activeModule()->name(); - aDefaultEngine->SetListOfFiles(theListOfFiles, id(), aName); - } -} - -//================================================================ -// Function : GetTmpDir -/*! Purpose : to be used by CORBAless modules*/ -//================================================================ -std::string SalomeApp_Study::GetTmpDir (const char* theURL, - const bool isMultiFile) -{ - std::string anURLDir = SALOMEDS_Tool::GetDirFromPath(theURL); - std::string aTmpDir = isMultiFile ? anURLDir : SALOMEDS_Tool::GetTmpDir(); - return aTmpDir; -} - -//================================================================ -// Function : RemoveTemporaryFiles -/*! Purpose : to be used by CORBAless modules*/ -//================================================================ -void SalomeApp_Study::RemoveTemporaryFiles (const bool isMultiFile) const -{ - if (isMultiFile) - return; - - std::vector aListOfFiles = GetListOfFiles(); - if (aListOfFiles.size() > 0) { - std::string aTmpDir = aListOfFiles[0]; - - const int n = aListOfFiles.size() - 1; - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(n); - for (int i = 0; i < n; i++) - aSeq[i] = CORBA::string_dup(aListOfFiles[i + 1].c_str()); - - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); - } -} - -// END: methods to be used by CORBAless modules - void SalomeApp_Study::deleteReferencesTo( _PTR( SObject ) obj ) { _PTR(StudyBuilder) sb = studyDS()->NewBuilder(); @@ -407,4 +347,3 @@ void SalomeApp_Study::deleteReferencesTo( _PTR( SObject ) obj ) } } } - diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index b75dd4f08..1404446f4 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -3,7 +3,7 @@ #include "SalomeApp.h" -#include +#include #ifdef WIN32 #pragma warning( disable:4251 ) @@ -11,7 +11,7 @@ #include "SALOMEDSClient.hxx" -class SALOMEAPP_EXPORT SalomeApp_Study : public LightApp_Study +class SALOMEAPP_EXPORT SalomeApp_Study : public CAM_Study { Q_OBJECT @@ -35,15 +35,15 @@ public: _PTR(Study) studyDS() const; - virtual std::vector GetListOfFiles () const; - virtual void SetListOfFiles (const std::vector theListOfFiles); - virtual std::string GetTmpDir (const char* theURL, - const bool isMultiFile); - virtual void RemoveTemporaryFiles (const bool isMultiFile) const; - // to delete all references to object, whose have the same component void deleteReferencesTo( _PTR( SObject ) ); +signals: + void saved( SUIT_Study* ); + void opened( SUIT_Study* ); + void closed( SUIT_Study* ); + void created( SUIT_Study* ); + protected: virtual void dataModelInserted( const CAM_DataModel* ); virtual bool openDataModel( const QString&, CAM_DataModel* ); @@ -56,6 +56,7 @@ private: _PTR(Study) myStudyDS; }; + #ifdef WIN32 #pragma warning( default:4251 ) #endif diff --git a/src/SalomeApp/SalomeApp_TypeFilter.cxx b/src/SalomeApp/SalomeApp_TypeFilter.cxx index 445ec3f9d..92216b667 100644 --- a/src/SalomeApp/SalomeApp_TypeFilter.cxx +++ b/src/SalomeApp/SalomeApp_TypeFilter.cxx @@ -1,6 +1,6 @@ #include "SalomeApp_TypeFilter.h" -#include "LightApp_DataOwner.h" +#include "SalomeApp_DataOwner.h" #include "SalomeApp_Study.h" #include @@ -26,7 +26,7 @@ SalomeApp_TypeFilter::~SalomeApp_TypeFilter() */ bool SalomeApp_TypeFilter::isOk( const SUIT_DataOwner* sOwner ) const { - const LightApp_DataOwner* owner = dynamic_cast ( sOwner ); + const SalomeApp_DataOwner* owner = dynamic_cast ( sOwner ); SalomeApp_Study* aDoc = getStudy(); if (owner && aDoc && aDoc->studyDS()) diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 540f9bcc6..15a0583bc 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -16,7 +16,7 @@ - + @@ -36,9 +36,7 @@ - - @@ -53,10 +51,6 @@ -
- - -
@@ -80,7 +74,7 @@
- + diff --git a/src/SalomeApp/resources/SalomeApp_images.po b/src/SalomeApp/resources/SalomeApp_images.po index c085ad512..2a15df463 100644 --- a/src/SalomeApp/resources/SalomeApp_images.po +++ b/src/SalomeApp/resources/SalomeApp_images.po @@ -11,6 +11,24 @@ msgstr "" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" +msgid "ABOUT" +msgstr "icon_about.png" + +msgid "ABOUT_SPLASH" +msgstr "icon_about.png" + +msgid "APP_DEFAULT_ICO" +msgstr "icon_default.png" + +msgid "APP_MODULE_ICO" +msgstr "icon_module.png" + +msgid "APP_MODULE_BIG_ICO" +msgstr "icon_module_big.png" + msgid "ICON_SELECT" msgstr "icon_select.png" +msgid "APP_BASE_LOGO" +msgstr "icon_applogo.png" + diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index 907f8f73f..ad917a2ce 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -47,9 +47,30 @@ msgstr "GNU LGPL" //======================================================================================= +msgid "SalomeApp_Application::OBJECT_BROWSER" +msgstr "Object Browser" + msgid "SalomeApp_Application::PYTHON_CONSOLE" msgstr "Python Console" +msgid "SalomeApp_Application::LOG_WINDOW" +msgstr "Message Window" + +msgid "SalomeApp_Application::DATA_MODELS" +msgstr "Data models" + +msgid "SalomeApp_Application::NEW_WINDOW_0" +msgstr "GL view" + +msgid "SalomeApp_Application::NEW_WINDOW_1" +msgstr "Plot2d view" + +msgid "SalomeApp_Application::NEW_WINDOW_2" +msgstr "OCC view" + +msgid "SalomeApp_Application::NEW_WINDOW_3" +msgstr "VTK view" + msgid "SalomeApp_Application::TOT_DESK_FILE_DUMP_STUDY" msgstr "Dump study" @@ -71,6 +92,12 @@ msgstr "Loads python script from file" msgid "SalomeApp_Application::TOT_FILE_DESK_PREFERENCES" msgstr "Preferences" +msgid "SalomeApp_Application::MEN_DESK_PREFERENCES" +msgstr "Preferences..." + +msgid "SalomeApp_Application::PRP_DESK_PREFERENCES" +msgstr "Allow to change the preferences" + msgid "SalomeApp_Application::MEN_DESK_TOOLS" msgstr "Tools" @@ -107,14 +134,11 @@ msgstr "Properties..." msgid "SalomeApp_Application::PRP_DESK_PROPERTIES" msgstr "Edits study properties" -msgid "SalomeApp_Application::PREF_CATEGORY_SALOME" -msgstr "SALOME" - -msgid "SalomeApp_Application::PREF_TAB_OBJBROWSER" -msgstr "Object browser" +msgid "SalomeApp_Application::MEN_REFRESH" +msgstr "Refresh" msgid "SalomeApp_Application::MEN_OPENWITH" -msgstr "Activate module" +msgstr "Activate Module" msgid "SalomeApp_Application::MEN_DELETE_REFERENCE" msgstr "Delete Reference" @@ -127,8 +151,44 @@ msgstr "New window" msgid "SalomeApp_Application::MEN_VIEW_WNDS" msgstr "Windows" +msgid "SalomeApp_Application::PRP_MODULE" +msgstr "Switch to the module \"%1\"" + +msgid "SalomeApp_Application::PRP_APP_MODULE" +msgstr "Switch to SALOME platform neutral point" + +msgid "SalomeApp_Application::INF_TOOLBAR_MODULES" +msgstr "Modules" + +msgid "SalomeApp_Application::INF_CANCELLED" +msgstr "Module activation cancelled" + //======================================================================================= +msgid "SalomeApp_Application::PREFERENCES_NOT_LOADED" +msgstr "Preferences for module \"%1\" will be available when the module will be loaded" + +msgid "SalomeApp_Application::PREF_FONT" +msgstr "Font" + +msgid "SalomeApp_Application::PREF_CATEGORY_SALOME" +msgstr "SALOME" + +msgid "SalomeApp_Application::PREF_TAB_GENERAL" +msgstr "General" + +msgid "SalomeApp_Application::PREF_TAB_OBJBROWSER" +msgstr "Object browser" + +msgid "SalomeApp_Application::PREF_GROUP_EXT_BROWSER" +msgstr "External browser" + +msgid "SalomeApp_Application::PREF_APP" +msgstr "Application" + +msgid "SalomeApp_Application::PREF_PARAM" +msgstr "Parameters" + msgid "SalomeApp_Application::PREF_GROUP_DEF_COLUMNS" msgstr "Default columns" @@ -138,6 +198,99 @@ msgstr "Settings" msgid "SalomeApp_Application::PREF_AUTO_SIZE" msgstr "Auto size columns" +msgid "SalomeApp_Application::PREF_GROUP_STUDY" +msgstr "Study properties" + +msgid "SalomeApp_Application::PREF_GROUP_PY_CONSOLE" +msgstr "Python console properties" + +msgid "SalomeApp_Application::PREF_TAB_VIEWERS" +msgstr "Viewers" + +msgid "SalomeApp_Application::PREF_GROUP_OCCVIEWER" +msgstr "OCC Viewer 3d" + +msgid "SalomeApp_Application::PREF_MULTI_FILE" +msgstr "Multi file save" + +msgid "SalomeApp_Application::PREF_ASCII_FILE" +msgstr "ASCII save" + +msgid "SalomeApp_Application::PREF_UNDO_LEVEL" +msgstr "Undo level" + +msgid "SalomeApp_Application::PREF_GROUP_VTKVIEWER" +msgstr "VTK Viewer 3d" + +msgid "SalomeApp_Application::PREF_VIEWER_BACKGROUND" +msgstr "Background color" + +msgid "SalomeApp_Application::PREF_TRIHEDRON_SIZE" +msgstr "Trihedron size" + +msgid "SalomeApp_Application::PREF_ISOS_U" +msgstr "Number of isolines along U" + +msgid "SalomeApp_Application::PREF_ISOS_V" +msgstr "Number of isolines along V" + +msgid "SalomeApp_Application::PREF_TRIHEDRON_SHOW" +msgstr "Show trihedron" + +msgid "SalomeApp_Application::PREF_GROUP_PLOT2DVIEWER" +msgstr "Plot2d Viewer" + +msgid "SalomeApp_Application::PREF_SHOW_LEGEND" +msgstr "Show legend" + +msgid "SalomeApp_Application::PREF_LEGEND_POSITION" +msgstr "Legend position:" + +msgid "SalomeApp_Application::PREF_LEFT" +msgstr "Left" + +msgid "SalomeApp_Application::PREF_RIGHT" +msgstr "Right" + +msgid "SalomeApp_Application::PREF_TOP" +msgstr "Top" + +msgid "SalomeApp_Application::PREF_BOTTOM" +msgstr "Bottom" + +msgid "SalomeApp_Application::PREF_CURVE_TYPE" +msgstr "Curve type:" + +msgid "SalomeApp_Application::PREF_POINTS" +msgstr "Points" + +msgid "SalomeApp_Application::PREF_LINES" +msgstr "Lines" + +msgid "SalomeApp_Application::PREF_SPLINE" +msgstr "Spline" + +msgid "SalomeApp_Application::PREF_MARKER_SIZE" +msgstr "Marker size:" + +msgid "SalomeApp_Application::PREF_LINEAR" +msgstr "Linear" + +msgid "SalomeApp_Application::PREF_LOGARITHMIC" +msgstr "Logarithmic" + +msgid "SalomeApp_Application::PREF_HOR_AXIS_SCALE" +msgstr "Horizontal axis scale:" + +msgid "SalomeApp_Application::PREF_VERT_AXIS_SCALE" +msgstr "Vertical axis scale:" + +msgid "SalomeApp_Application::PREF_TAB_DIRECTORIES" +msgstr "Directories" + +msgid "SalomeApp_Application::PREF_GROUP_DIRECTORIES" +msgstr "Quick directory list" + //======================================================================================= msgid "SalomeApp_Application::OBJ_BROWSER_NAME" @@ -166,6 +319,31 @@ msgstr "LOCKED" //======================================================================================= +msgid "SalomeApp_ModuleDlg::CAPTION" +msgstr "Activate module" + +msgid "SalomeApp_ModuleDlg::NEW" +msgstr "&New" + +msgid "SalomeApp_ModuleDlg::OPEN" +msgstr "&Open" + +msgid "SalomeApp_ModuleDlg::LOAD" +msgstr "&Load" + +msgid "SalomeApp_ModuleDlg::CANCEL" +msgstr "&Cancel" + +msgid "SalomeApp_ModuleDlg::ActivateComponent_DESCRIPTION" +msgstr "Create, open or load study." + +//======================================================================================= + +msgid "SalomeApp_PreferencesDlg::CAPTION" +msgstr "Preferences" + +//======================================================================================= + msgid "SalomeApp_StudyPropertiesDlg::PRP_MODE_FROM_SCRATCH" msgstr "from scratch" @@ -204,3 +382,6 @@ msgstr "No" msgid "SalomeApp_Application::PUBLISH_IN_STUDY" msgstr "Publish in study" +msgid "SalomeApp_Application::ACTIVATING_MODULE" +msgstr "Trying to activate module \"%1\"" + diff --git a/src/SalomeApp/resources/icon_about.png b/src/SalomeApp/resources/icon_about.png new file mode 100755 index 000000000..287b4f766 Binary files /dev/null and b/src/SalomeApp/resources/icon_about.png differ diff --git a/src/SalomeApp/resources/icon_applogo.png b/src/SalomeApp/resources/icon_applogo.png new file mode 100755 index 000000000..bb1265280 Binary files /dev/null and b/src/SalomeApp/resources/icon_applogo.png differ diff --git a/src/SalomeApp/resources/icon_default.png b/src/SalomeApp/resources/icon_default.png new file mode 100644 index 000000000..0140a6667 Binary files /dev/null and b/src/SalomeApp/resources/icon_default.png differ diff --git a/src/SalomeApp/resources/icon_module.png b/src/SalomeApp/resources/icon_module.png new file mode 100644 index 000000000..9fdd5fb01 Binary files /dev/null and b/src/SalomeApp/resources/icon_module.png differ diff --git a/src/SalomeApp/resources/icon_module_big.png b/src/SalomeApp/resources/icon_module_big.png new file mode 100755 index 000000000..99e10b1ff Binary files /dev/null and b/src/SalomeApp/resources/icon_module_big.png differ diff --git a/src/VTKViewer/VTKViewer_InteractorStyle.cxx b/src/VTKViewer/VTKViewer_InteractorStyle.cxx index fa407641d..18a496089 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyle.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyle.cxx @@ -64,6 +64,12 @@ using namespace std; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + /* static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){ int anEdgeId = -1; @@ -111,6 +117,7 @@ VTKViewer_InteractorStyle::VTKViewer_InteractorStyle() /*!Destructor.*/ VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle() { +// if(MYDEBUG) INFOS("VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle()"); m_ViewWnd->RemoveActor(myPreSelectionActor); } @@ -892,6 +899,7 @@ void VTKViewer_InteractorStyle::onFinishOperation() Handle(SALOME_InteractiveObject) IO = SActor->getIO(); if(aSelectionMode != EdgeOfCellSelection) { if(CheckDimensionId(aSelectionMode,SActor,anObjId)){ + if(MYDEBUG) INFOS(" CellId : "<AddOrRemoveIndex( IO, anObjId, myShiftState, false ); @@ -911,6 +919,7 @@ void VTKViewer_InteractorStyle::onFinishOperation() } int anEdgeId = GetEdgeId(picker,SActor,anObjId); if (anEdgeId >= 0) { + if(MYDEBUG) INFOS(" CellId : "<AddOrRemoveIndex( IO, anObjId, true, false); aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true ); aSel->AddIObject( IO, false ); @@ -936,6 +945,7 @@ void VTKViewer_InteractorStyle::onFinishOperation() this->HighlightProp( NULL ); aSel->ClearIObjects(); } + if(MYDEBUG) INFOS(" PointId : "<AddOrRemoveIndex( IO, anObjId, myShiftState, false ); aSel->AddIObject( IO, false ); } @@ -1066,6 +1076,7 @@ void VTKViewer_InteractorStyle::onFinishOperation() continue; VTKViewer_CellDataSet cellList = picker->GetCellData(aActor); if ( !cellList.empty() ) { + if(MYDEBUG) INFOS ( " NAME Actor : " << aSActor->getName() ); SALOME_Selection::TContainerOfId anIndexes; VTKViewer_CellDataSet::iterator it; for ( it = cellList.begin(); it != cellList.end(); ++it ) { @@ -1249,6 +1260,7 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { if(aResult){ mySelectedActor = SActor; myElemId = anObjId; + if(MYDEBUG) INFOS(" CellId : "<setCellData(anObjId,SActor,myPreSelectionActor); } } @@ -1263,6 +1275,7 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { mySelectedActor = SActor; myEdgeId = anEdgeId; myElemId = anObjId; + if(MYDEBUG) INFOS(" CellId : "<setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor); } } @@ -1283,6 +1296,7 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { if(!anIsSameObjId) { mySelectedActor = SActor; myNodeId = anObjId; + if(MYDEBUG) INFOS(" PointId : "<setPointData(anObjId,SActor,myPreSelectionActor); } myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); @@ -1314,6 +1328,7 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { } } } + //if(MYDEBUG) INFOS ( " NAME PREVIEW " << SActor->getName() ); } } } diff --git a/src/VTKViewer/VTKViewer_ShrinkFilter.cxx b/src/VTKViewer/VTKViewer_ShrinkFilter.cxx index c65699a9a..f980b5c0d 100755 --- a/src/VTKViewer/VTKViewer_ShrinkFilter.cxx +++ b/src/VTKViewer/VTKViewer_ShrinkFilter.cxx @@ -35,6 +35,14 @@ #include #include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#else +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#endif + vtkCxxRevisionMacro(VTKViewer_ShrinkFilter, "$Revision$"); vtkStandardNewMacro(VTKViewer_ShrinkFilter);