From 9560b540f09562b08da956cb0988791d36a41d33 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 30 Jun 2005 09:47:04 +0000 Subject: [PATCH] Start implementation of methods, manipulating view parameters (position, size, splitting); enclose GUI calls from engine into SALOME_Event; some other debug --- examples/VISU_Example_02.py | 5 + idl/VISU_Gen.idl | 113 +++++----- src/VISUGUI/VisuGUI.cxx | 46 ---- src/VISU_I/VISUConfig.cc | 6 +- src/VISU_I/VISU_Gen_i.cc | 24 +- src/VISU_I/VISU_Gen_i.hh | 2 - src/VISU_I/VISU_ViewManager_i.cc | 44 ++-- src/VISU_I/VISU_View_i.cc | 372 +++++++++++++++++++++++-------- src/VISU_I/VISU_View_i.hh | 4 + src/VISU_SWIG/visu_view3d.py | 12 +- 10 files changed, 399 insertions(+), 229 deletions(-) diff --git a/examples/VISU_Example_02.py b/examples/VISU_Example_02.py index a54f206d..a7f6ea3b 100644 --- a/examples/VISU_Example_02.py +++ b/examples/VISU_Example_02.py @@ -221,6 +221,8 @@ if str == None: file = str+'/VISU_005.hdf' salome.myStudyManager.SaveAs(file, salome.myStudy, 0) +study_id = salome.myStudy._get_StudyId() +#salome.sg.CloseStudy(study_id) #salome.myStudyManager.Close(salome.myStudy) #salome.myStudy.Close() print "OK" @@ -288,6 +290,9 @@ SObj = openedStudy.FindObject(aViewParamsName2) Builder.RemoveObject(SObj) print "OK" +SObjList2 = openedStudy.FindObjectByName(aViewParamsName1, "VISU") +print "FindObjectByName(aViewParamsName1, VISU) returned ", len(SObjList2), " objects" + print "Zooming trihedron.....................", aScale = myView.GetParallelScale() myView1.SetParallelScale(aScale*2) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index f27a904b..73c90136 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1135,6 +1135,17 @@ Creates a presentation form containing an array of references to the curves. boolean IsPartShown( in ViewRepresentation ViewRepr ); + /*! + * Horizontally split workarea of this view. This view is moved in a new right area. + */ + void SplitRight(); + + /*! + * Vertically split workarea of this view. This view is moved in a new bottom area. + */ + void SplitBottom(); + + // begin: old methods, they don't work now void SetViewWidth (in long Width); //setting width of view void SetViewHeight (in long Height); //setting height of view @@ -1151,70 +1162,72 @@ Creates a presentation form containing an array of references to the curves. void SetRelativePosition( in double x, in double y ); void SetRelativeSize( in double x, in double y ); -/*! -Sets the title of the %View frame. -\param theTitle String parameter defining the title of the %View frame. -*/ + // end: old methods, they don't work now + + /*! + Sets the title of the %View frame. + \param theTitle String parameter defining the title of the %View frame. + */ void SetTitle(in string theTitle); -/*! -Gets the title of the %View frame. -*/ + /*! + Gets the title of the %View frame. + */ string GetTitle(); -/*! -Sets background color of the %View frame. -\param theColor Background color defined in SALOMEDS::Color enumeration. -*/ + /*! + Sets background color of the %View frame. + \param theColor Background color defined in SALOMEDS::Color enumeration. + */ void SetBackground(in SALOMEDS::Color theColor); -/*! -Gets background color of the %View frame. -*/ + /*! + Gets background color of the %View frame. + */ SALOMEDS::Color GetBackground(); -/*! -Minimizes to the task bar or to the bottom of the Desktop the %View frame. -*/ + /*! + Minimizes to the task bar or to the bottom of the Desktop the %View frame. + */ void Minimize(); -/*! -Restores the %View frame. -*/ + /*! + Restores the %View frame. + */ void Restore(); -/*! -Maximizes the %View frame. -*/ + /*! + Maximizes the %View frame. + */ void Maximize(); -/*! -Removes all presentations (presentable objects) from the %view. -*/ + /*! + Removes all presentations (presentable objects) from the %view. + */ void EraseAll(); -/*! -Displays all presentations (presentable objects) in the %view. -*/ + /*! + Displays all presentations (presentable objects) in the %view. + */ void DisplayAll(); -/*! -Removes a definite presentation (presentable object) from the %view. -\param thePrsObj The presentation (presentable object) which should be deleted. -*/ + /*! + Removes a definite presentation (presentable object) from the %view. + \param thePrsObj The presentation (presentable object) which should be deleted. + */ void Erase(in PrsObject thePrsObj); -/*! -Displays a definite presentation (presentable object) in the %view. -\param thePrsObj The presentation (presentable object) which should be displayed. -*/ + /*! + Displays a definite presentation (presentable object) in the %view. + \param thePrsObj The presentation (presentable object) which should be displayed. + */ void Display(in PrsObject thePrsObj); -/*! -Allows to display only a definite presentation (presentable object) in the %view. -All other presentations are removed from the %view. -\param thePrsObj The presentation (presentable object) which should be displayed. -*/ + /*! + Allows to display only a definite presentation (presentable object) in the %view. + All other presentations are removed from the %view. + \param thePrsObj The presentation (presentable object) which should be displayed. + */ void DisplayOnly(in PrsObject thePrsObj); -/*! -Updates the view. -*/ + /*! + Updates the view. + */ void Update(); -/*! -Saves the view. -\param theFileName The name of the file where the view will be saved. -\return True, if the view have been saved successfully. -*/ + /*! + Saves the view. + \param theFileName The name of the file where the view will be saved. + \return True, if the view have been saved successfully. + */ boolean SavePicture(in string theFileName); }; diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 9504b6b4..5f73a5cc 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -267,52 +267,6 @@ OnExportTableToFile() if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()"); } -/*jfa tmp:void -VisuGUI:: -OnImportMedField() -{ - _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); - if (CheckLock(aCStudy)) - return; - - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - - SALOME_ListIteratorOfListIO It (aListIO); - QApplication::setOverrideCursor(Qt::waitCursor); - for (; It.More(); It.Next()) { - Handle(SALOME_InteractiveObject) anIO = It.Value(); - //SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); - _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry()); - //if (!aSObject->_is_nil()) { - if (aSObject) { - CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject); - if (!CORBA::is_nil(anObject)) { - SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); - if (!CORBA::is_nil(aMED.in())) - GetVisuGen(this)->ClientImportMed(aSObject); - SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); - if (!CORBA::is_nil(aField.in())) - GetVisuGen(this)->ImportMedField(aField); - } else { - //SALOMEDS::SObject_var aSFather = aSObject->GetFather(); - _PTR(SObject) aSFather = aSObject->GetFather(); - //SALOMEDS::GenericAttribute_var anAttr; - _PTR(GenericAttribute) anAttr; - aSFather->FindAttribute(anAttr, "AttributeName"); - //SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - _PTR(AttributeName) aName (anAttr); - std::string aValue = aName->Value(); - if (strcmp(aValue.c_str(), "MEDFIELD") == 0) - GetVisuGen(this)->ClientImportMed(aSObject); - } - } - } - updateObjBrowser(true); - QApplication::restoreOverrideCursor(); -}*/ - void VisuGUI:: OnImportMedField() diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 2194f55f..3d2174ba 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -386,8 +386,10 @@ namespace VISU{ SALOMEDS::Study_var GetDSStudy(_PTR(Study) theStudy) { - std::string aStudyName = theStudy->Name(); - return GetStudyManager()->GetStudyByName(aStudyName.c_str()); + //std::string aStudyName = theStudy->Name(); + //return GetStudyManager()->GetStudyByName(aStudyName.c_str()); + int aStudyID = theStudy->StudyId(); + return GetStudyManager()->GetStudyByID(aStudyID); } SALOMEDS::SObject_var GetSObject( _PTR(SObject) obj ) diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 4d7154ac..d71de33b 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -407,9 +407,9 @@ namespace VISU{ void VISU_Gen_i::SetCurrentStudy (SALOMEDS::Study_ptr theStudy) { class TEvent: public SALOME_Event { - QString myStudyName; + std::string myStudyName; public: - TEvent(const QString& theStudyName):myStudyName(theStudyName) + TEvent(const std::string theStudyName):myStudyName(theStudyName) {} virtual void Execute() { @@ -422,10 +422,13 @@ namespace VISU{ ++anIter; if (SUIT_Study* aSStudy = anApp->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { - MESSAGE("There is an application with active study : " << aStudy->studyName()); - if (myStudyName == aStudy->studyName()) { - isActive = true; - break; + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + MESSAGE("There is an application with active study : StudyId = " + << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'"); + if (myStudyName == aCStudy->Name()) { + isActive = true; + break; + } } } } @@ -442,7 +445,7 @@ namespace VISU{ if (!CORBA::is_nil(theStudy)) { CORBA::String_var aName = theStudy->Name(); - QString aStudyName (aName.in()); + std::string aStudyName (aName.in()); MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'"); myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); @@ -506,12 +509,6 @@ namespace VISU{ return aResult._retn(); } - Result_ptr VISU_Gen_i::ClientImportMed (_PTR(SObject) theMedSObject) - { - SALOMEDS::SObject_ptr aMedSObject = GetSObject(theMedSObject); - return ImportMed(aMedSObject); - } - Result_ptr VISU_Gen_i::ImportMed (SALOMEDS::SObject_ptr theMedSObject) { if (myStudyDocument->GetProperties()->IsLocked()) @@ -1049,5 +1046,4 @@ namespace VISU{ anIOR->SetValue(anIORValue); return aResultSO._retn(); } - } diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index edd59e26..77584d64 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -48,8 +48,6 @@ namespace VISU{ virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject); virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField); - Result_ptr ClientImportMed (_PTR(SObject) theMedSObject); - //Create Presentation Of Submeshes virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity); virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 9d037eb4..197bb660 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -64,12 +64,15 @@ namespace VISU { struct TNewViewManagerEvent: public SALOME_Event { - std::string myStudyName; + //std::string myStudyName; + int myStudyId; typedef SalomeApp_Application* TResult; TResult myResult; - TNewViewManagerEvent(const char* theStudyName): - myStudyName(theStudyName), + //TNewViewManagerEvent (const char* theStudyName): + // myStudyName(theStudyName), + TNewViewManagerEvent (const int theStudyId): + myStudyId(theStudyId), myResult(NULL) {} @@ -77,34 +80,29 @@ namespace VISU { void Execute() { - MESSAGE( "Find application for study : " << myStudyName ); - QString aStudyName( myStudyName.c_str() ); + //MESSAGE("Find application for study : " << myStudyName); + MESSAGE("Find application for study with id = : " << myStudyId); SUIT_Session* aSession = SUIT_Session::session(); QPtrList anApplications = aSession->applications(); QPtrListIterator anIter (anApplications); - //bool isAnyStudy = false; //jfa tmp - ////SUIT_Application* aFirstResult = NULL; //jfa tmp - //SUIT_Application* aFirstResult = anIter.current(); //jfa tmp while (SUIT_Application* anApp = anIter.current()) { ++anIter; if (SUIT_Study* aSStudy = anApp->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { - //isAnyStudy = true; //jfa tmp - ////aFirstResult = anApp; //jfa tmp - MESSAGE("There is an application with active study : " << aStudy->studyName()); - if (aStudyName == aStudy->studyName()) { - myResult = dynamic_cast(anApp); - break; + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + //if (myStudyName == aCStudy->Name()) { + if (myStudyId == aCStudy->StudyId()) { + myResult = dynamic_cast(anApp); + break; + } } } } } - if (!myResult) { //jfa tmp - MESSAGE("Error: application is not found for study : " << myStudyName); - ////if (isAnyStudy) { //jfa tmp - // myResult = dynamic_cast(aFirstResult); //jfa tmp - ////} //jfa tmp - } //jfa tmp + if (!myResult) { + //MESSAGE("Error: application is not found for study : " << myStudyName); + MESSAGE("Error: application is not found for study with id = : " << myStudyId); + } } }; @@ -113,8 +111,10 @@ namespace VISU { { if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i - "<Name(); - myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in())); + //CORBA::String_var aStudyName = theStudy->Name(); + //myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in())); + int aStudyID = theStudy->StudyId(); + myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyID)); } diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index 6615e8e4..5db38082 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -42,6 +42,7 @@ #include "SUIT_Tools.h" #include "STD_MDIDesktop.h" +#include "STD_TabDesktop.h" #include "SVTK_ViewWindow.h" #include "SVTK_ViewModel.h" @@ -54,6 +55,8 @@ #include "SalomeApp_Application.h" #include "SalomeApp_Study.h" +#include + #include #include @@ -67,21 +70,40 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -namespace VISU{ +namespace VISU { typedef TVoidMemFunEvent TFrameActionEvent; + struct TNewViewEvent: public SALOME_Event + { + SalomeApp_Application* myApplication; + typedef QWidget* TResult; + TResult myResult; + + TNewViewEvent (SalomeApp_Application* theApplication): + myApplication(theApplication), + myResult(NULL) + {} + + virtual + void + Execute() + { + if (STD_MDIDesktop* aDesktop = dynamic_cast(myApplication->desktop())) { + myResult = aDesktop->workspace(); + } + } + }; + View_i:: - View_i(SalomeApp_Application *theApplication, - SUIT_ViewManager* theViewManager): + View_i (SalomeApp_Application *theApplication, + SUIT_ViewManager* theViewManager): myApplication(theApplication), myWorkspace(NULL), myViewManager(theViewManager) { if(MYDEBUG) MESSAGE("View_i::View_i - "<(myApplication->desktop())){ - myWorkspace = aDesktop->workspace(); - } + myWorkspace = ProcessEvent(new TNewViewEvent(theApplication)); } View_i:: @@ -100,11 +122,10 @@ namespace VISU{ {} }; - void View_i:: - ShowPart(VISU::View::ViewRepresentation theViewRepresentation, - CORBA::Boolean theState) + ShowPart (VISU::View::ViewRepresentation theViewRepresentation, + CORBA::Boolean theState) { struct TEvent: public TApplicationEvent { @@ -145,7 +166,6 @@ namespace VISU{ ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState)); } - struct TPartShownEvent: public TApplicationEvent { VISU::View::ViewRepresentation myViewRepresentation; @@ -182,14 +202,76 @@ namespace VISU{ } }; - CORBA::Boolean View_i:: - IsPartShown(VISU::View::ViewRepresentation theViewRepresentation) + IsPartShown (VISU::View::ViewRepresentation theViewRepresentation) { return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation)); } + enum SplitSide {SPLIT_LEFT, SPLIT_RIGHT, SPLIT_TOP, SPLIT_BOTTOM}; + + struct TSplitEvent: public SALOME_Event + { + SalomeApp_Application * myApplication; + SUIT_ViewWindow * myViewWindow; + SplitSide mySplitSide; + + public: + TSplitEvent (SalomeApp_Application * theApplication, + SUIT_ViewWindow * theViewWindow, + SplitSide theSplitSide): + myApplication(theApplication), + myViewWindow(theViewWindow), + mySplitSide(theSplitSide) + {} + + virtual + void + Execute() + { + MESSAGE("TSplitEvent::Execute()"); + SUIT_Desktop* desk = myApplication->desktop(); + STD_TabDesktop* tabDesk = dynamic_cast(desk); + if (tabDesk) { + MESSAGE("TSplitEvent::Execute() - tabDesk"); + QtxWorkstack* workstack = tabDesk->workstack(); + if (workstack) { + MESSAGE("TSplitEvent::Execute() - workstack"); + QWidgetList vws = workstack->splitWindowList(); + if (vws.count() > 1) { + MESSAGE("TSplitEvent::Execute() - vws.count() > 1"); + //jfa tmp:workstack->windowActivated(myViewWindow); + //??? to do: set workarea of this vw as active area + switch (mySplitSide) { + case SPLIT_LEFT: + case SPLIT_RIGHT: + workstack->split(Qt::Horizontal); + break; + case SPLIT_TOP: + case SPLIT_BOTTOM: + workstack->split(Qt::Vertical); + break; + } + } + } + } + } + }; + + void + View_i:: + SplitRight() + { + ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,SPLIT_RIGHT)); + } + + void + View_i:: + SplitBottom() + { + ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,SPLIT_BOTTOM)); + } struct TSetViewSize: public SALOME_Event { @@ -219,7 +301,6 @@ namespace VISU{ } }; - void View_i:: SetViewWidth(CORBA::Long theWidth) @@ -227,7 +308,6 @@ namespace VISU{ ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth)); } - void View_i:: SetViewHeight(CORBA::Long theHeight) @@ -320,10 +400,10 @@ namespace VISU{ void View_i:: - SetViewPositionHorizontal(VISU::View::ViewPosition theViewPosition) + SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition) { - if(myWorkspace){ - switch(theViewPosition){ + if (myWorkspace) { + switch (theViewPosition) { case VISU::View::LEFT: ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft)); break; @@ -340,10 +420,10 @@ namespace VISU{ void View_i:: - SetViewPositionVertical(VISU::View::ViewPosition theViewPosition) + SetViewPositionVertical (VISU::View::ViewPosition theViewPosition) { - if(myWorkspace){ - switch(theViewPosition){ + if (myWorkspace) { + switch (theViewPosition) { case VISU::View::TOP: ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop)); break; @@ -377,7 +457,7 @@ namespace VISU{ void View_i:: - SetRelativePosition(CORBA::Double theX, CORBA::Double theY) + SetRelativePosition (CORBA::Double theX, CORBA::Double theY) { struct TEvent: public TXYEvent { @@ -398,13 +478,13 @@ namespace VISU{ } }; - if(myWorkspace) + if (myWorkspace) ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY)); } void View_i:: - SetRelativeSize(CORBA::Double theX, CORBA::Double theY) + SetRelativeSize (CORBA::Double theX, CORBA::Double theY) { struct TEvent: public TXYEvent { @@ -428,13 +508,13 @@ namespace VISU{ } }; - if(myWorkspace) + if (myWorkspace) ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY)); } void View_i:: - SetBackground(const SALOMEDS::Color& theColor) + SetBackground (const SALOMEDS::Color& theColor) { struct TEvent: public SALOME_Event { @@ -520,17 +600,17 @@ namespace VISU{ void View_i:: - Erase(PrsObject_ptr thePrsObj) + Erase (PrsObject_ptr thePrsObj) {} void View_i:: - Display(PrsObject_ptr thePrsObj) + Display (PrsObject_ptr thePrsObj) {} void View_i:: - DisplayOnly(PrsObject_ptr thePrsObj) + DisplayOnly (PrsObject_ptr thePrsObj) {} void @@ -583,10 +663,12 @@ namespace VISU{ { return ""; } + void View_i:: - ToStream(std::ostringstream& theStr) - {} + ToStream (std::ostringstream& theStr) + { + } //================= OLD CODE =================== @@ -609,35 +691,80 @@ namespace VISU{ // return aStudy; //} + template + struct TNewSpecViewEvent: public SALOME_Event + { + SalomeApp_Application* myApplication; + + typedef SUIT_ViewManager* TResult; + TResult myResult; + + TNewSpecViewEvent (SalomeApp_Application* theApplication): + myApplication(theApplication), + myResult(NULL) + {} + + virtual + void + Execute() + { + myResult = myApplication->getViewManager(TViewer::Type(), true); + } + }; + //=========================================================================== XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication) : View_i(theApplication, NULL) { if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i"); if (theApplication) { - myViewManager = theApplication->getViewManager(Plot2d_Viewer::Type(), true); + myViewManager = ProcessEvent(new TNewSpecViewEvent(theApplication)); } } - Storable* XYPlot_i::Create (int theNew) + + struct TCreatePlot2dViewEvent: public SALOME_Event { - if (theNew) { - myViewWindow = myViewManager->createViewWindow(); - } else { - myViewWindow = myViewManager->getActiveView(); - } - ////myView = dynamic_cast(myViewWindow->getRightFrame()->getViewFrame()); - //SPlot2d_Viewer* aView = dynamic_cast(myViewManager->getViewModel()); - //myView = aView->getActiveViewFrame(); - if (myViewWindow) { - Plot2d_ViewWindow* aPlot2dVW = dynamic_cast(myViewWindow); - if (aPlot2dVW) { - myView = aPlot2dVW->getViewFrame(); - if (myView) { - myView->Repaint(); + SUIT_ViewManager* myViewManager; + XYPlot_i * myPlot2dView; + int myNew; + + typedef Plot2d_ViewFrame* TResult; + TResult myResult; + + TCreatePlot2dViewEvent (SUIT_ViewManager* theViewManager, + XYPlot_i * thePlot2dView, + const int theNew): + myViewManager(theViewManager), + myPlot2dView(thePlot2dView), + myNew(theNew), + myResult(NULL) + {} + + virtual + void + Execute() + { + if (myNew) { + myPlot2dView->myViewWindow = myViewManager->createViewWindow(); + } else { + myPlot2dView->myViewWindow = myViewManager->getActiveView(); + } + if (myPlot2dView->myViewWindow) { + Plot2d_ViewWindow* aPlot2dVW = dynamic_cast(myPlot2dView->myViewWindow); + if (aPlot2dVW) { + myResult = aPlot2dVW->getViewFrame(); + if (myResult) { + myResult->Repaint(); + } } } } + }; + + Storable* XYPlot_i::Create (int theNew) + { + myView = ProcessEvent(new TCreatePlot2dViewEvent(myViewManager, this, theNew)); return this; } @@ -648,6 +775,7 @@ namespace VISU{ void XYPlot_i::Close() { + //jfa: may be need to be enclosed in SALOME_Event? myViewWindow->close(); } @@ -662,6 +790,7 @@ namespace VISU{ } char* XYPlot_i::GetTitle() { + //jfa: may be need to be enclosed in SALOME_Event? return CORBA::string_dup(myViewWindow->caption().latin1()); } @@ -673,6 +802,7 @@ namespace VISU{ char* XYPlot_i::GetSubTitle() { + //jfa: may be need to be enclosed in SALOME_Event? return CORBA::string_dup(myView->getTitle()); } @@ -684,6 +814,7 @@ namespace VISU{ VISU::XYPlot::CurveType XYPlot_i::GetCurveType() { + //jfa: may be need to be enclosed in SALOME_Event? return (VISU::XYPlot::CurveType)myView->getCurveType(); } @@ -695,6 +826,7 @@ namespace VISU{ CORBA::Long XYPlot_i::GetMarkerSize() { + //jfa: may be need to be enclosed in SALOME_Event? return myView->getMarkerSize(); } @@ -760,6 +892,7 @@ namespace VISU{ VISU::Scaling XYPlot_i::GetHorScaling() { + //jfa: may be need to be enclosed in SALOME_Event? return (VISU::Scaling)myView->getHorScaleMode(); } @@ -771,50 +904,43 @@ namespace VISU{ VISU::Scaling XYPlot_i::GetVerScaling() { + //jfa: may be need to be enclosed in SALOME_Event? return (VISU::Scaling)myView->getVerScaleMode(); } class TSetTitleEvent: public SALOME_Event { public: - //typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true); - typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, Plot2d_ViewFrame::ObjectType, bool = true); - //TSetTitleEvent (Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle): TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle): - //myView(theView), myFun(theFun), myTitle(theTitle) myView(theView), myType(theType), myTitle(theTitle) {} virtual void Execute() { - //(myView->*myFun)(true,myTitle,myType); myView->setTitle(true,myTitle,myType); } protected: Plot2d_ViewFrame* myView; - //TFun myFun; Plot2d_ViewFrame::ObjectType myType; const char* myTitle; }; void XYPlot_i::SetXTitle (const char* theTitle) { - //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setXTitle, theTitle)); ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle)); } char* XYPlot_i::GetXTitle() { - //return CORBA::string_dup(myView->getXTitle()); + //jfa: may be need to be enclosed in SALOME_Event? return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle)); } void XYPlot_i::SetYTitle (const char* theTitle) { - //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setYTitle, theTitle)); ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle)); } char* XYPlot_i::GetYTitle() { - //return CORBA::string_dup(myView->getYTitle()); + //jfa: may be need to be enclosed in SALOME_Event? return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle)); } @@ -912,11 +1038,6 @@ namespace VISU{ ProcessVoidEvent(new TVoidMemFunEvent (myView,&Plot2d_ViewFrame::fitAll)); } - //CORBA::Boolean XYPlot_i::SavePicture (const char* theFileName) - //{ - // return ProcessEvent(new TSavePictureEvent (myView->getViewWidget(),theFileName)); - //} - //=========================================================================== TableView_i::TableView_i (SalomeApp_Application* theApplication) @@ -924,31 +1045,57 @@ namespace VISU{ { } - Storable* TableView_i::Create (VISU::Table_ptr theTable) + struct TCreateTableViewEvent: public SALOME_Event { - if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil())); - if (!theTable->_is_nil()) { - VISU::Table_i* table = dynamic_cast(VISU::GetServant(theTable).in()); - if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table); - if (table != NULL) { + SalomeApp_Application* myApplication; + VISU::Table_i* myTable; + + typedef VisuGUI_TableDlg* TResult; + TResult myResult; + + TCreateTableViewEvent (SalomeApp_Application* theApplication, + VISU::Table_i* theTable): + myApplication(theApplication), + myTable(theTable), + myResult(NULL) + {} + + virtual + void + Execute() + { + if (myTable != NULL) { if (SUIT_Study* aSStudy = myApplication->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { - _PTR(SObject) aSObject = aCStudy->FindObjectID(table->GetObjectEntry()); + _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry()); if (aSObject) { - myView = new VisuGUI_TableDlg (myApplication->desktop(), - aSObject, - false, - VisuGUI_TableDlg::ttAuto, - Qt::Vertical); - myView->show(); - return this; + myResult = new VisuGUI_TableDlg (myApplication->desktop(), + aSObject, + false, + VisuGUI_TableDlg::ttAuto, + Qt::Vertical); + myResult->show(); } } } } } } + }; + + Storable* TableView_i::Create (VISU::Table_ptr theTable) + { + if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil())); + if (!theTable->_is_nil()) { + VISU::Table_i* table = + dynamic_cast(VISU::GetServant(theTable).in()); + if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table); + + myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table)); + if (myView) + return this; + } return NULL; } @@ -966,12 +1113,13 @@ namespace VISU{ char* TableView_i::GetTitle() { + //jfa: may be need to be enclosed in SALOME_Event? return CORBA::string_dup(myView->caption().latin1()); - return ""; } void TableView_i::Close() { + //jfa: may be need to be enclosed in SALOME_Event? myView->close(); } @@ -991,18 +1139,41 @@ namespace VISU{ { if (MYDEBUG) MESSAGE("View3D_i::View3D_i"); if (theApplication) { - myViewManager = theApplication->getViewManager(SVTK_Viewer::Type(), true); + myViewManager = ProcessEvent(new TNewSpecViewEvent(theApplication)); } } + struct TCreateView3dEvent: public SALOME_Event + { + SUIT_ViewManager* myViewManager; + int myNew; + + typedef SUIT_ViewWindow* TResult; + TResult myResult; + + TCreateView3dEvent (SUIT_ViewManager* theViewManager, + const int theNew): + myViewManager(theViewManager), + myNew(theNew), + myResult(NULL) + {} + + virtual + void + Execute() + { + if (myNew) { + myResult = myViewManager->createViewWindow(); + } else { + myResult = myViewManager->getActiveView(); + } + } + }; + Storable* View3D_i::Create (int theNew) { if (MYDEBUG) MESSAGE("View3D_i::Create"); - if (theNew) { - myViewWindow = myViewManager->createViewWindow(); - } else { - myViewWindow = myViewManager->getActiveView(); - } + myViewWindow = ProcessEvent(new TCreateView3dEvent(myViewManager, theNew)); return this; } @@ -1036,13 +1207,9 @@ namespace VISU{ ProcessVoidEvent(new TEvent(myViewWindow)); } - //CORBA::Boolean View3D_i::SavePicture (const char* theFileName) - //{ - // return ProcessEvent(new TSavePictureEvent(myViewWindow, theFileName)); - //} - bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName) { + MESSAGE("View3D_i::SaveViewParams()"); _PTR(Study) aCStudy; if (SUIT_Study* aSStudy = theViewManager->study()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { @@ -1078,9 +1245,28 @@ namespace VISU{ return true; } + class TSaveViewParamsEvent: public SALOME_Event + { + SUIT_ViewManager* myViewManager; + const char* myName; + public: + TSaveViewParamsEvent (SUIT_ViewManager* theViewManager, + const char* theName): + myViewManager(theViewManager), + myName(theName) + {} + + virtual void Execute() + { + myResult = View3D_i::SaveViewParams(myViewManager, myName); + } + typedef CORBA::Boolean TResult; + TResult myResult; + }; + CORBA::Boolean View3D_i::SaveViewParams (const char* theName) { - return SaveViewParams(myViewManager, theName); + return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName)); } bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName) @@ -1237,6 +1423,7 @@ namespace VISU{ void View3D_i::Close() { + //jfa: may be need to be enclosed in SALOME_Event? myViewWindow->close(); } @@ -1253,12 +1440,14 @@ namespace VISU{ char* View3D_i::GetTitle() { + //jfa: may be need to be enclosed in SALOME_Event? return CORBA::string_dup(myViewWindow->caption().latin1()); } void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame, const SALOMEDS::Color& theColor) { + //jfa: may be need to be enclosed in SALOME_Event? int aColor[3]; aColor[0] = int(255.0*theColor.R); aColor[1] = int(255.0*theColor.G); @@ -1269,6 +1458,7 @@ namespace VISU{ SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame) { + //jfa: may be need to be enclosed in SALOME_Event? SALOMEDS::Color aColor; float backint[3]; GetRenderer(theStudyFrame)->GetBackground(backint); @@ -1394,6 +1584,7 @@ namespace VISU{ void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame, const CORBA::Double thePosition[3]) { + //jfa: may be need to be enclosed in SALOME_Event? GetCamera(theStudyFrame)->SetPosition(thePosition); } @@ -1406,11 +1597,13 @@ namespace VISU{ void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame, CORBA::Double thePosition[3]) { + //jfa: may be need to be enclosed in SALOME_Event? GetCamera(theStudyFrame)->GetPosition(thePosition); } VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() { + //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView"); CORBA::Double aPosition[3]; GetPointOfView(myViewWindow,aPosition); @@ -1437,6 +1630,7 @@ namespace VISU{ VISU::View3D::XYZ_slice* View3D_i::GetViewUp() { + //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetViewUp"); CORBA::Double aViewUp[3]; GetCamera(myViewWindow)->GetViewUp(aViewUp); @@ -1464,6 +1658,7 @@ namespace VISU{ VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() { + //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint"); CORBA::Double aFocalPnt[3]; GetFocalPoint(myViewWindow,aFocalPnt); @@ -1510,6 +1705,7 @@ namespace VISU{ CORBA::Double View3D_i::GetParallelScale() { + //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale"); return GetParallelScale(myViewWindow); } diff --git a/src/VISU_I/VISU_View_i.hh b/src/VISU_I/VISU_View_i.hh index af96f2f4..67691d22 100644 --- a/src/VISU_I/VISU_View_i.hh +++ b/src/VISU_I/VISU_View_i.hh @@ -63,6 +63,10 @@ namespace VISU public: virtual void ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state ); virtual CORBA::Boolean IsPartShown( VISU::View::ViewRepresentation ViewRepr ); + + virtual void SplitRight(); + virtual void SplitBottom(); + virtual void SetViewWidth(CORBA::Long Width); virtual void SetViewHeight(CORBA::Long Height); virtual CORBA::Long GetViewWidth(); diff --git a/src/VISU_SWIG/visu_view3d.py b/src/VISU_SWIG/visu_view3d.py index 6300c24a..be807a71 100644 --- a/src/VISU_SWIG/visu_view3d.py +++ b/src/VISU_SWIG/visu_view3d.py @@ -94,16 +94,18 @@ myView.Update(); print "myView.FitAll()" myView.FitAll(); -aWidth = myView.GetViewWidth() -print "a View Width before = ", aWidth -myView.SetViewWidth(aWidth/2) -aWidth = myView.GetViewWidth() -print "a View Width after = ", aWidth +#aWidth = myView.GetViewWidth() +#print "a View Width before = ", aWidth +#myView.SetViewWidth(aWidth/2) +#aWidth = myView.GetViewWidth() +#print "a View Width after = ", aWidth myView = myViewManager.Create3DView(); myView.SetTitle("Here we will display CutPlanes") +myView.SplitRight() + print "myView.SetBackground(...)" aColor = SALOMEDS.Color(0.0,0.7,0.0) myView.SetBackground(aColor); -- 2.39.2