X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISU_I%2FVISU_View_i.cc;h=d80850e79a849f5cf9f1cfc9a0927115c42cbaa2;hb=ba9e93f27d47a0ac9eaa884a753b5676da4e7168;hp=ae5bf27ccce8c9149c12e89275d32ae465da459d;hpb=3f4152dedc1ae968267cfb8a079f261ec0088ed0;p=modules%2Fvisu.git diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index ae5bf27c..d80850e7 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -1,6 +1,6 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or @@ -17,27 +17,31 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// VISU OBJECT : interactive object for VISU entities implementation // File : VISU_View_i.cc // Author : Alexey PETROV // Module : VISU - +// #include "VISU_View_i.hh" +#include "VISU_Tools.h" #include "VISU_Gen_i.hh" #include "VISU_Prs3d_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" #include "VISU_ScalarMap_i.hh" #include "VISU_ViewManager_i.hh" - -#include "VisuGUI_TableDlg.h" +#include "VISU_TableDlg.h" #include "VISU_Actor.h" #include "VISU_ScalarMapAct.h" +#include "VISU_PointMap3dActor.h" +#include "VISU_DeformedGridPL.hxx" -#include "SALOME_Event.hxx" +#include "SALOME_Event.h" #include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" @@ -48,6 +52,7 @@ #include "SVTK_ViewWindow.h" #include "SVTK_ViewModel.h" +#include "VTKViewer_Algorithm.h" #include "SPlot2d_ViewModel.h" #include "Plot2d_ViewFrame.h" @@ -56,12 +61,14 @@ #include "SalomeApp_Study.h" #include +#include -#include -#include +#include +#include #include #include +#include using namespace std; @@ -147,18 +154,24 @@ namespace VISU { { switch(myViewRepresentation){ case VISU::View::OBJECTBROWSER: - myApplication->setWindowShown(SalomeApp_Application::WT_ObjectBrowser,myState); + myApplication->getWindow( SalomeApp_Application::WT_ObjectBrowser )->setVisible( myState ); break; case VISU::View::PYTHON: - myApplication->setWindowShown(SalomeApp_Application::WT_PyConsole,myState); + myApplication->getWindow( SalomeApp_Application::WT_PyConsole )->setVisible( myState ); break; case VISU::View::MESSAGES: - myApplication->setWindowShown(SalomeApp_Application::WT_LogWindow,myState); + myApplication->getWindow( SalomeApp_Application::WT_LogWindow )->setVisible( myState ); break; - case VISU::View::VIEWER:{ - ViewManagerList aViewManagerList = myApplication->viewManagers(); - // to do something - // ... + case VISU::View::VIEWER: + { + ViewManagerList mgrs = myApplication->viewManagers(); + ViewManagerList::const_iterator anIt = mgrs.begin(), aLast = mgrs.end(); + for( ; anIt!=aLast; anIt++ ) + { + const QVector& views = (*anIt)->getViews(); + for( int i=0; isetShown( myState ); + } break; }} } @@ -186,18 +199,26 @@ namespace VISU { { switch(myViewRepresentation){ case VISU::View::OBJECTBROWSER: - myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_ObjectBrowser); + myResult = myApplication->dockWindow( SalomeApp_Application::WT_ObjectBrowser )->isVisible(); break; case VISU::View::PYTHON: - myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_PyConsole); + myResult = myApplication->dockWindow( SalomeApp_Application::WT_PyConsole )->isVisible(); break; case VISU::View::MESSAGES: - myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_LogWindow); + myResult = myApplication->dockWindow( SalomeApp_Application::WT_LogWindow )->isVisible(); break; case VISU::View::VIEWER:{ ViewManagerList aViewManagerList = myApplication->viewManagers(); - // to do something - // ... + ViewManagerList::const_iterator anIt = aViewManagerList.begin(); + for( ; anIt != aViewManagerList.end(); anIt++ ) + { + const QVector& views = (*anIt)->getViews(); + for( int i=0; iisVisible(); + return; + } + } + myResult = false; break; }} } @@ -249,7 +270,7 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) ProcessVoidEvent(new TSplitEvent(myApplication, aVW, - Qt::Horizontal, QtxWorkstack::SPLIT_MOVE)); + Qt::Horizontal, QtxWorkstack::SplitMove)); } void @@ -259,7 +280,7 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) ProcessVoidEvent(new TSplitEvent(myApplication, aVW, - Qt::Horizontal, QtxWorkstack::SPLIT_STAY)); + Qt::Horizontal, QtxWorkstack::SplitStay)); } void @@ -269,7 +290,7 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) ProcessVoidEvent(new TSplitEvent(myApplication, aVW, - Qt::Vertical, QtxWorkstack::SPLIT_MOVE)); + Qt::Vertical, QtxWorkstack::SplitMove)); } void @@ -279,7 +300,7 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) ProcessVoidEvent(new TSplitEvent(myApplication, aVW, - Qt::Vertical, QtxWorkstack::SPLIT_STAY)); + Qt::Vertical, QtxWorkstack::SplitStay)); } void @@ -544,7 +565,7 @@ namespace VISU { void Execute() { - if (QWidget* aParent = myVW->parentWidget(true)) { + if (QWidget* aParent = myVW->parentWidget()) { QRect aQRect = aParent->frameGeometry(); (aQRect.*myAction)(mySize); aParent->setGeometry(aQRect); @@ -588,7 +609,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myVW->parentWidget(true)){ + if(QWidget* aParent = myVW->parentWidget()){ QRect aQRect = aParent->frameGeometry(); myResult = (aQRect.*myAction)(); } @@ -629,12 +650,12 @@ namespace VISU { class TAlignEvent: public TWorkspaceEvent { protected: - Qt::AlignmentFlags myAligment; + Qt::AlignmentFlag myAligment; public: TAlignEvent(QWidget* theViewWindow, QWidget* theWorkspace, - Qt::AlignmentFlags theAligment): + Qt::AlignmentFlag theAligment): TWorkspaceEvent(theViewWindow,theWorkspace), myAligment(theAligment) {} @@ -643,7 +664,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myVW->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget()) SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment); } }; @@ -724,7 +745,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myVW->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget()) aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height())); } }; @@ -751,7 +772,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myVW->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget()) aParent->setGeometry(aParent->x(), aParent->y(), int(myX*myWorkspace->width()), @@ -770,12 +791,12 @@ namespace VISU { { struct TEvent: public SALOME_Event { - QWidget* myWidget; + SVTK_ViewWindow* myVW; SALOMEDS::Color myColor; public: - TEvent(QWidget* theWidget, + TEvent(SVTK_ViewWindow* theViewWindow, const SALOMEDS::Color& theColor): - myWidget(theWidget), + myVW(theViewWindow), myColor(theColor) {} virtual void Execute(){ @@ -783,11 +804,12 @@ namespace VISU { aColor[0] = int(255.0*myColor.R); aColor[1] = int(255.0*myColor.G); aColor[2] = int(255.0*myColor.B); - myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2])); + QColor aNewColor (aColor[0],aColor[1],aColor[2]); + myVW->setBackgroundColor(aNewColor); } }; - - SUIT_ViewWindow* aVW = GetViewWindow(); + + SVTK_ViewWindow* aVW = dynamic_cast(GetViewWindow()); if (aVW) ProcessVoidEvent(new TEvent(aVW, theColor)); } @@ -795,22 +817,23 @@ namespace VISU { struct TBackgroundEvent: public SALOME_Event { - QWidget* myWidget; + SVTK_ViewWindow* myVW; typedef SALOMEDS::Color TResult; TResult myResult; - TBackgroundEvent(QWidget* theWidget): - myWidget(theWidget) + TBackgroundEvent(SVTK_ViewWindow* theViewWindow): + myVW(theViewWindow) {} virtual void Execute() { - const QColor& aColor = myWidget->backgroundColor(); - myResult.R = aColor.red()/255.0; - myResult.G = aColor.green()/255.0; - myResult.B = aColor.blue()/255.0; + vtkFloatingPointType backint[3]; + GetRenderer(myVW)->GetBackground(backint); + myResult.R = backint[0]; + myResult.G = backint[1]; + myResult.B = backint[2]; } }; @@ -818,7 +841,7 @@ namespace VISU { View_i:: GetBackground() { - SUIT_ViewWindow* aVW = GetViewWindow(); + SVTK_ViewWindow* aVW = dynamic_cast(GetViewWindow()); if (aVW) return ProcessEvent(new TBackgroundEvent(aVW)); @@ -907,11 +930,11 @@ namespace VISU { if (!img.isNull()) { QString fileName (myFileName); if (!fileName.isEmpty()) { - QString fmt = SUIT_Tools::extension(fileName).upper(); + QString fmt = SUIT_Tools::extension(fileName).toUpper(); if (fmt.isEmpty()) fmt = QString("BMP"); // default format if (fmt == "JPG" ) fmt = "JPEG"; //QApplication::setOverrideCursor(Qt::waitCursor); - img.save(fileName, fmt.latin1()); + img.save(fileName, fmt.toLatin1().data()); myResult = true; //QApplication::restoreOverrideCursor(); } @@ -941,8 +964,8 @@ namespace VISU { SUIT_ViewWindow* View_i::GetViewWindow() { if (myViewWindow) { - QPtrVector aViews = myViewManager->getViews(); - int aPos = aViews.find(myViewWindow); + QVector aViews = myViewManager->getViews(); + int aPos = aViews.indexOf(myViewWindow); if (aPos < 0) myViewWindow = NULL; } @@ -1030,16 +1053,23 @@ namespace VISU { ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::Repaint)); } + struct TCloseViewEvent: public SALOME_Event + { + SUIT_ViewWindow* myView; + TCloseViewEvent (SUIT_ViewWindow* theView): + myView(theView) + {} + + virtual void Execute() + { + if ( myView ) myView->close(); + } + }; + void XYPlot_i::Close() { - //jfa: may be need to be enclosed in SALOME_Event? - SUIT_ViewWindow* aVW = GetViewWindow(); - if (aVW) - aVW->close(); - //QPtrVector aViews = myViewManager->getViews(); - //int aPos = aViews.find(myViewWindow); - //if (aPos >= 0) - // myViewWindow->close(); + ProcessVoidEvent(new TCloseViewEvent(GetViewWindow())); + QApplication::sendPostedEvents(); } XYPlot_i::~XYPlot_i() { @@ -1051,13 +1081,13 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) ProcessVoidEvent(new TVoidMemFun1ArgEvent - (aVW, &SUIT_ViewWindow::setCaption, QString(theTitle))); + (aVW, &SUIT_ViewWindow::setWindowTitle, QString(theTitle))); } char* XYPlot_i::GetTitle() { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) - return CORBA::string_dup(aVW->caption().latin1()); + return CORBA::string_dup( aVW->windowTitle().toLatin1().data()); return CORBA::string_dup(""); } @@ -1071,7 +1101,7 @@ namespace VISU { char* XYPlot_i::GetSubTitle() { if (GetViewWindow()) - return CORBA::string_dup(myView->getTitle()); + return CORBA::string_dup(myView->getTitle().toLatin1().data()); return CORBA::string_dup(""); } @@ -1103,45 +1133,93 @@ namespace VISU { return -1; } - class TEnableGridEvent: public SALOME_Event - { - public: - typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool); - TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun, - CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor): - myView(theView), myFun(theFun), - myMajor(theMajor), myNumMajor(theNumMajor), - myMinor(theMinor), myNumMinor(theNumMinor) - {} - - virtual void Execute() - { - (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true); - } - protected: - Plot2d_ViewFrame* myView; - TFun myFun; - CORBA::Boolean myMajor, myMinor; - CORBA::Long myNumMajor, myNumMinor; - }; - void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor, CORBA::Boolean theMinor, CORBA::Long theNumMinor) { - if (GetViewWindow()) - ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid, - theMajor,theNumMajor,theMinor,theNumMinor)); + class TEvent: public SALOME_Event + { + public: + TEvent (Plot2d_ViewFrame* theView, + CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor): + myView(theView), + myMajor(theMajor), + myNumMajor(theNumMajor), + myMinor(theMinor), + myNumMinor(theNumMinor) + {} + + virtual void Execute() + { + myView->setXGrid( myMajor, myNumMajor, myMinor, myNumMinor ); + } + protected: + Plot2d_ViewFrame* myView; + CORBA::Boolean myMajor, myMinor; + CORBA::Long myNumMajor, myNumMinor; + }; + + if ( GetViewWindow() ) + ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor ) ); } - void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor) + void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor) { - //asl: Plot2d_ViewFrame::setYGrid has more parameters - //if (GetViewWindow()) - // ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid, - // theMajor,theNumMajor,theMinor,theNumMinor)); + this->EnableYGrid( theMajor, theNumMajor, theMinor, theNumMinor, false, 0, false, 0 ); } + void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor, + CORBA::Boolean the2Major, + CORBA::Long the2NumMajor, + CORBA::Boolean the2Minor, + CORBA::Long the2NumMinor) + { + class TEvent: public SALOME_Event + { + public: + TEvent (Plot2d_ViewFrame* theView, + CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor, + CORBA::Boolean the2Major, + CORBA::Long the2NumMajor, + CORBA::Boolean the2Minor, + CORBA::Long the2NumMinor): + myView(theView), + myMajor(theMajor), + myNumMajor(theNumMajor), + myMinor(theMinor), + myNumMinor(theNumMinor), + my2Major(the2Major), + my2NumMajor(the2NumMajor), + my2Minor(the2Minor), + my2NumMinor(the2NumMinor) + {} + + virtual void Execute() + { + myView->setYGrid( myMajor, myNumMajor, myMinor, myNumMinor, + my2Major, my2NumMajor, my2Minor, my2NumMinor); + } + protected: + Plot2d_ViewFrame* myView; + CORBA::Boolean myMajor, myMinor, my2Major, my2Minor; + CORBA::Long myNumMajor, myNumMinor, my2NumMajor, my2NumMinor; + }; + + if (GetViewWindow()) + ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor, + the2Major, the2NumMajor, the2Minor, the2NumMinor ) ); + } + class TSetScaleModeEvent: public SALOME_Event { public: @@ -1213,7 +1291,7 @@ namespace VISU { char* XYPlot_i::GetXTitle() { if (GetViewWindow()) - return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle)); + return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle).toLatin1().data()); return CORBA::string_dup(""); } @@ -1225,7 +1303,7 @@ namespace VISU { char* XYPlot_i::GetYTitle() { if (GetViewWindow()) - return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle)); + return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle).toLatin1().data()); return CORBA::string_dup(""); } @@ -1257,17 +1335,23 @@ namespace VISU { virtual void Execute() { + Qtx::VisibilityState state = (myDisplaing == eDisplay ||myDisplaing == eDisplayOnly) ? + Qtx::ShownState : Qtx::HiddenState; // is it Curve ? if (Curve_i* aCurve = dynamic_cast(VISU::GetServant(myPrsObj).in())) { - UpdatePlot2d(myView,myDisplaing,aCurve); + UpdatePlot2d(aCurve,myDisplaing,myView); + VISU::SetVisibilityState(aCurve->GetEntry(),state); + VISU::CurveVisibilityChanged(aCurve, myDisplaing , false, true, true); } // is it Container ? if (Container_i* aContainer = dynamic_cast(VISU::GetServant(myPrsObj).in())) { + VISU::SetVisibilityState(aContainer->GetEntry(),state); int nbCurves = aContainer->GetNbCurves(); for ( int i = 1; i <= nbCurves; i++ ) { VISU::Curve_i* aCurve = aContainer->GetCurve( i ); if ( aCurve && aCurve->IsValid() ) { - UpdatePlot2d(myView,myDisplaing,aCurve); + UpdatePlot2d(aCurve,myDisplaing,myView); + VISU::CurveVisibilityChanged(aCurve, myDisplaing , true, true, true); } } myView->Repaint(); @@ -1281,19 +1365,22 @@ namespace VISU { } } if (!aCStudy) return; - _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1()); + _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry()); if (TableSO) { _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO); for (; Iter->More(); Iter->Next()) { CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value()); if (!CORBA::is_nil(childObject)) { CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject); - if (!CORBA::is_nil(aCurve)) - UpdatePlot2d(myView, myDisplaing, - dynamic_cast(VISU::GetServant(aCurve).in())); + if (!CORBA::is_nil(aCurve)) { + Curve_i* crv = dynamic_cast(VISU::GetServant(aCurve).in()); + UpdatePlot2d(crv, myDisplaing, myView); + VISU::CurveVisibilityChanged(crv, myDisplaing , true, false, true); + } } } myView->Repaint(); + VISU::SetVisibilityState(aTable->GetEntry(),state); } } } @@ -1394,7 +1481,7 @@ namespace VISU { SalomeApp_Application* myApplication; VISU::Table_i* myTable; - typedef VisuGUI_TableDlg* TResult; + typedef VISU_TableDlg* TResult; TResult myResult; TCreateTableViewEvent (SalomeApp_Application* theApplication, @@ -1412,15 +1499,13 @@ namespace VISU { if (SUIT_Study* aSStudy = myApplication->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { - _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry()); - if (aSObject) { - myResult = new VisuGUI_TableDlg (myApplication->desktop(), - aSObject, - false, - VisuGUI_TableDlg::ttAuto, - Qt::Vertical); - myResult->show(); - } + myResult = new VISU_TableDlg (myApplication->desktop(), + aCStudy, + myTable, + false, + VISU_TableDlg::ttAuto, + Qt::Vertical); + myResult->show(); } } } @@ -1451,14 +1536,14 @@ namespace VISU { void TableView_i::SetTitle (const char* theTitle) { - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle))); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myView, &VISU_TableDlg::setWindowTitle, QString(theTitle))); } char* TableView_i::GetTitle() { //jfa: may be need to be enclosed in SALOME_Event? - return CORBA::string_dup(myView->caption().latin1()); + return CORBA::string_dup(myView->windowTitle().toLatin1().data()); } void TableView_i::Close() @@ -1552,40 +1637,37 @@ namespace VISU { { class TEvent: public SALOME_Event { - SUIT_ViewWindow* myVW; + SUIT_ViewWindow* myViewWindow; public: TEvent(SUIT_ViewWindow* theViewWindow): - myVW(theViewWindow) + myViewWindow(theViewWindow) {} virtual void Execute() { - SVTK_ViewWindow* vf = dynamic_cast(myVW); - vtkRenderer* Renderer = vf->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - while (vtkActor *anAct = theActors->GetNextActor()) { - if (VISU_Actor* anActor = dynamic_cast(anAct)) { - VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d(); - if (anActor->GetVisibility() && aPrs3d) { - aPrs3d->Update(); - aPrs3d->UpdateActor(anActor); - } + SVTK_ViewWindow* aViewWindow = dynamic_cast(myViewWindow); + vtkRenderer* aRenderer = aViewWindow->getRenderer(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection* anActors = aCopy.GetActors(); + anActors->InitTraversal(); + while (vtkActor *anAct = anActors->GetNextActor()) { + if (VISU_ActorBase* anActor = dynamic_cast(anAct)) { + if (anActor->GetVisibility()) + anActor->UpdateFromFactory(); } } - RepaintView(myVW); + RepaintView(myViewWindow); } }; - SUIT_ViewWindow* aVW = GetViewWindow(); - if (aVW) - ProcessVoidEvent(new TEvent(aVW)); + if (SUIT_ViewWindow* aViewWindow = GetViewWindow()) + ProcessVoidEvent(new TEvent(aViewWindow)); } - bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName) + bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName) { MESSAGE("View3D_i::SaveViewParams()"); - if (!theViewManager || !theName) + if (!theViewManager || theName == "") return false; _PTR(Study) aCStudy; @@ -1597,16 +1679,16 @@ namespace VISU { if (!aCStudy) return false; - if (strcmp(theName, "") != 0) { - std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU"); + if (theName != "") { + std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU"); _PTR(GenericAttribute) anAttr; int iEnd = aList.size(); for (int i = 0; i < iEnd; i++) { _PTR(SObject) anObj = aList[i]; string anEntry = anObj->GetID(); if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry); - if (anObj->FindAttribute(anAttr, "AttributeComment")) { - _PTR(AttributeComment) aCmnt (anAttr); + if (anObj->FindAttribute(anAttr, "AttributeString")) { + _PTR(AttributeString) aCmnt (anAttr); string aComm (aCmnt->Value()); if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm); if (aComm.compare(View3D_i::myComment) >= 0) { @@ -1618,7 +1700,12 @@ namespace VISU { } _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy); string aSComponentEntry = aSComponent->GetID(); - string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "", + string anEntry = CreateAttributes(aCStudy, + aSComponentEntry.c_str(), + "", + "", + theName, + "", ToString(theViewManager->getActiveView()).c_str()); return true; } @@ -1626,10 +1713,10 @@ namespace VISU { class TSaveViewParamsEvent: public SALOME_Event { SUIT_ViewManager* myViewMgr; - const char* myName; + std::string myName; public: TSaveViewParamsEvent (SUIT_ViewManager* theViewManager, - const char* theName): + const std::string& theName): myViewMgr(theViewManager), myName(theName) {} @@ -1642,12 +1729,12 @@ namespace VISU { TResult myResult; }; - CORBA::Boolean View3D_i::SaveViewParams (const char* theName) + CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName) { - return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName)); + return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName)); } - bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName) + bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName) { _PTR(Study) aCStudy; if (SUIT_Study* aSStudy = theViewManager->study()) { @@ -1666,17 +1753,10 @@ namespace VISU { _PTR(SObject) anObj = aList[i]; string anEntry = anObj->GetID(); if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry); - if (anObj->FindAttribute(anAttr, "AttributeComment")) { - _PTR(AttributeComment) aCmnt (anAttr); - QString strIn(aCmnt->Value().c_str()); - Storable::TRestoringMap aMap; - Storable::StrToMap(strIn, aMap); - if (Storable::FindValue(aMap, "myComment").compare - (View3D_i::myComment.c_str()) >= 0) { - if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn); - Restore(theViewManager->getActiveView(), aMap); - return true; - } + Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj); + if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) { + Restore(theViewManager->getActiveView(), aMap); + return true; } } return false; @@ -1685,10 +1765,10 @@ namespace VISU { class TRestoreViewParamsEvent: public SALOME_Event { SUIT_ViewManager* myViewMgr; - const char* myName; + std::string myName; public: TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager, - const char* theName): + const std::string& theName): myViewMgr(theViewManager), myName(theName) {} @@ -1701,9 +1781,9 @@ namespace VISU { TResult myResult; }; - CORBA::Boolean View3D_i::RestoreViewParams (const char* theName) + CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName) { - return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName)); + return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName)); } void View3D_i::Restore (SUIT_ViewWindow* theViewWindow, @@ -1759,8 +1839,6 @@ namespace VISU { void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr) { - Storable::DataToStream(theStr,"myType",VISU::TVIEW3D); - vtkFloatingPointType backint[3]; GetRenderer(theViewWindow)->GetBackground(backint); Storable::DataToStream(theStr,"myColor.R",backint[0]); @@ -1803,16 +1881,10 @@ namespace VISU { void View3D_i::Close() { - //jfa: may be need to be enclosed in SALOME_Event? - SUIT_ViewWindow* aVW = GetViewWindow(); - if (aVW) - aVW->close(); - //QPtrVector aViews = myViewManager->getViews(); - //int aPos = aViews.find(myViewWindow); - //if (aPos >= 0) - // myViewWindow->close(); + ProcessVoidEvent(new TCloseViewEvent(GetViewWindow())); + QApplication::sendPostedEvents(); } - + View3D_i::~View3D_i() { if(MYDEBUG) MESSAGE("View3D_i::~View3D_i"); @@ -1823,14 +1895,14 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) ProcessVoidEvent(new TVoidMemFun1ArgEvent - (aVW,&SUIT_ViewWindow::setCaption,QString(theTitle))); + (aVW,&SUIT_ViewWindow::setWindowTitle,QString(theTitle))); } char* View3D_i::GetTitle() { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) - return CORBA::string_dup(aVW->caption().latin1()); + return CORBA::string_dup(aVW->windowTitle().toLatin1().data()); return CORBA::string_dup(""); } @@ -1873,6 +1945,27 @@ namespace VISU { } }; + class TDisplayTableEvent: public SALOME_Event + { + SUIT_ViewWindow* myVW; + PointMap3d_i* myTable; + int myDisplaying; + public: + TDisplayTableEvent( SUIT_ViewWindow* theView, + PointMap3d_i* theTable, + int theDisplaying ) : + myVW (theView), + myTable (theTable), + myDisplaying (theDisplaying) + {} + virtual void Execute() { + SVTK_ViewWindow* aViewWindow = dynamic_cast(myVW); + VISU_PointMap3dActor* anActor = myTable->CreateActor(); + myTable->UpdateActor( anActor ); + aViewWindow->AddActor( anActor ); + } + }; + void View3D_i::EraseAll() { if(MYDEBUG) MESSAGE("View3D_i::EraseAll"); @@ -1904,9 +1997,14 @@ namespace VISU { if(MYDEBUG) MESSAGE("View3D_i::Display"); SUIT_ViewWindow* aVW = GetViewWindow(); CORBA::Object_ptr anObj = thePrsObj; - Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); + Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); if (aVW && aPrs) ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay)); + else if (aVW && !aPrs) { + PointMap3d_i* aTable = dynamic_cast(VISU::GetServant(anObj).in()); + if (aTable) + ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay)); + } } void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj) @@ -1917,6 +2015,11 @@ namespace VISU { Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); if (aVW && aPrs) ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly)); + else if (aVW && !aPrs) { + PointMap3d_i* aTable = dynamic_cast(VISU::GetServant(anObj).in()); + if (aTable) + ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly)); + } } void View3D_i::FitAll() @@ -1996,7 +2099,7 @@ namespace VISU { if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView"); SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) - ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,aVW,thePosition)); + ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetPointOfView,aVW,thePosition)); } void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow, @@ -2026,7 +2129,7 @@ namespace VISU { if(MYDEBUG) MESSAGE("View3D_i::SetViewUp"); SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) - ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,aVW,theViewUp)); + ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetViewUp,aVW,theViewUp)); } void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow, @@ -2056,7 +2159,7 @@ namespace VISU { if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint"); SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) - ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,aVW,theCoord)); + ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetFocalPoint,aVW,theCoord)); } @@ -2108,7 +2211,7 @@ namespace VISU { if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale"); SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) - ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,aVW,theScale)); + ProcessVoidEvent(new TSetViewParamEvent(&View3D_i::SetParallelScale,aVW,theScale)); } CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow) @@ -2189,7 +2292,7 @@ namespace VISU { if (!aPrs) { myError = "Corrupted presentation"; } else { - VISU_Actor* anActor = VISU::GetActor(aPrs, vw); + VISU_Actor* anActor = VISU::FindActor(vw, aPrs); if (!anActor) { myError = "No actor found. Display the presentation at first."; } else { @@ -2284,21 +2387,33 @@ namespace VISU { myResult("Unknown error occured") {} virtual void Execute() { + VISU::VISUType aType = myPrs->GetType(); switch (myPrsType) { case VISU::INSIDEFRAME: { - VISU::VISUType aType = myPrs->GetType(); if (aType != VISU::TSCALARMAP && aType != VISU::TDEFORMEDSHAPE && - aType != VISU::TSCALARMAPONDEFORMEDSHAPE) { + aType != VISU::TSCALARMAPONDEFORMEDSHAPE && + aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) { myResult = "Insideframe representation is not available for this type of presentations."; return; } } break; case VISU::SURFACEFRAME: - myResult = "Surfaceframe representation is available only for mesh presentation."; - return; + { + if (aType != VISU::TSCALARMAP && + aType != VISU::TDEFORMEDSHAPE && + aType != VISU::TSCALARMAPONDEFORMEDSHAPE && + aType != VISU::TDEFORMEDSHAPEANDSCALARMAP && + aType != VISU::TCUTPLANES && + aType != VISU::TISOSURFACES && + aType != VISU::TPLOT3D) { + myResult = "Surfaceframe representation is not available for this type of presentations."; + return; + } + } + break; case VISU::SHRINK: myResult = "Use SetShrinked() method to shrink/unshrink presentation."; return; @@ -2428,6 +2543,59 @@ namespace VISU { } }; + class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent { + private: + Quadratic2DPresentationType myPrsType; + public: + typedef string TResult; + TResult myResult; + TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, + ScalarMap_ptr thePrs, + Quadratic2DPresentationType theType): + TPrsManageEvent(theView3D, thePrs), myPrsType(theType), + myResult("Unknown error occured") + {} + virtual void Execute() + { + VISU::VISUType aType = myPrs->GetType(); + if (aType != VISU::TSCALARMAP && + aType != VISU::TDEFORMEDSHAPE && + aType != VISU::TSCALARMAPONDEFORMEDSHAPE && + aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) { + myResult = "2D Quadratic element representation is not available for this type of presentations."; + return; + } + if (VISU_Actor* anActor = GetMyActor()) { + if(myPrsType == VISU::LINES) + anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines); + else if(myPrsType == VISU::ARCS) + anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs); + + SVTK_ViewWindow* vw = dynamic_cast(myView3D->GetViewWindow()); + vw->Repaint(); + myResult = ""; + } else { + myResult = myError; + } + } + }; + + class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent { + public: + typedef VISU::Quadratic2DPresentationType TResult; + TResult myResult; + TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) { + if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines) + myResult = VISU::LINES; + else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs) + myResult = VISU::ARCS; + } + } + }; + PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs) { return ProcessEvent(new TGetPrsTypeEvent(this,thePrs)); @@ -2449,6 +2617,11 @@ namespace VISU { return ProcessEvent(new TGetLineWidthEvent(this,thePrs)); } + Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs) + { + return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs)); + } + char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType) { string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType)); @@ -2474,4 +2647,12 @@ namespace VISU { string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth)); return CORBA::string_dup(aRet.c_str()); } + + char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType) + { + string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType)); + return CORBA::string_dup(aRet.c_str()); + } } + +