1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_View_i.cc
25 // Author : Alexey PETROV
28 #include "VISU_View_i.hh"
29 #include "VISU_Tools.h"
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Prs3d_i.hh"
33 #include "VISU_Table_i.hh"
34 #include "VISU_PointMap3d_i.hh"
35 #include "VISU_ScalarMap_i.hh"
36 #include "VISU_ViewManager_i.hh"
37 #include "VISU_TableDlg.h"
39 #include "VISU_Actor.h"
40 #include "VISU_ScalarMapAct.h"
41 #include "VISU_PointMap3dActor.h"
42 #include "VISU_DeformedGridPL.hxx"
44 #include "SALOME_Event.h"
46 #include "SUIT_ViewWindow.h"
47 #include "SUIT_ViewManager.h"
48 #include "SUIT_Tools.h"
50 #include "STD_MDIDesktop.h"
51 #include "STD_TabDesktop.h"
53 #include "SVTK_ViewWindow.h"
54 #include "SVTK_ViewModel.h"
55 #include "VTKViewer_Algorithm.h"
57 #include "SPlot2d_ViewModel.h"
58 #include "Plot2d_ViewFrame.h"
60 #include "SalomeApp_Application.h"
61 #include "SalomeApp_Study.h"
63 #include <QtxWorkstack.h>
64 #include <QtxWorkspace.h>
69 #include <vtkCamera.h>
70 #include <vtkRenderer.h>
76 static int MYDEBUG = 0;
78 static int MYDEBUG = 0;
83 typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
85 struct TNewViewEvent: public SALOME_Event
87 SalomeApp_Application* myApplication;
88 typedef QWidget* TResult;
91 TNewViewEvent (SalomeApp_Application* theApplication):
92 myApplication(theApplication),
100 if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
101 myResult = aDesktop->workspace();
107 View_i (SalomeApp_Application *theApplication,
108 SUIT_ViewManager* theViewManager):
109 myApplication(theApplication),
111 myViewManager(theViewManager)
113 if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
114 myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
120 if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
124 struct TApplicationEvent: public SALOME_Event
126 SalomeApp_Application* myApplication;
128 TApplicationEvent(SalomeApp_Application* theApplication):
129 myApplication(theApplication)
135 ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
136 CORBA::Boolean theState)
138 struct TEvent: public TApplicationEvent
140 VISU::View::ViewRepresentation myViewRepresentation;
141 CORBA::Boolean myState;
143 TEvent(SalomeApp_Application* theApplication,
144 VISU::View::ViewRepresentation theViewRepresentation,
145 CORBA::Boolean theState):
146 TApplicationEvent(theApplication),
147 myViewRepresentation(theViewRepresentation),
155 switch(myViewRepresentation){
156 case VISU::View::OBJECTBROWSER:
157 myApplication->getWindow( SalomeApp_Application::WT_ObjectBrowser )->setVisible( myState );
159 case VISU::View::PYTHON:
160 myApplication->getWindow( SalomeApp_Application::WT_PyConsole )->setVisible( myState );
162 case VISU::View::MESSAGES:
163 myApplication->getWindow( SalomeApp_Application::WT_LogWindow )->setVisible( myState );
165 case VISU::View::VIEWER:
167 ViewManagerList mgrs = myApplication->viewManagers();
168 ViewManagerList::const_iterator anIt = mgrs.begin(), aLast = mgrs.end();
169 for( ; anIt!=aLast; anIt++ )
171 const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
172 for( int i=0; i<views.count(); i++ )
173 views[i]->setShown( myState );
180 ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
183 struct TPartShownEvent: public TApplicationEvent
185 VISU::View::ViewRepresentation myViewRepresentation;
186 typedef bool TResult;
189 TPartShownEvent(SalomeApp_Application* theApplication,
190 VISU::View::ViewRepresentation theViewRepresentation):
191 TApplicationEvent(theApplication),
192 myViewRepresentation(theViewRepresentation),
200 switch(myViewRepresentation){
201 case VISU::View::OBJECTBROWSER:
202 myResult = myApplication->dockWindow( SalomeApp_Application::WT_ObjectBrowser )->isVisible();
204 case VISU::View::PYTHON:
205 myResult = myApplication->dockWindow( SalomeApp_Application::WT_PyConsole )->isVisible();
207 case VISU::View::MESSAGES:
208 myResult = myApplication->dockWindow( SalomeApp_Application::WT_LogWindow )->isVisible();
210 case VISU::View::VIEWER:{
211 ViewManagerList aViewManagerList = myApplication->viewManagers();
212 ViewManagerList::const_iterator anIt = aViewManagerList.begin();
213 for( ; anIt != aViewManagerList.end(); anIt++ )
215 const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
216 for( int i=0; i<views.count(); i++ ) {
217 myResult = views[i]->isVisible();
229 IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
231 return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
234 // Begin: New methods for view parameters management
235 struct TSplitEvent: public SALOME_Event
237 SalomeApp_Application * myApplication;
238 SUIT_ViewWindow * myVW;
239 Qt::Orientation myOrientation;
240 QtxWorkstack::SplitType mySplitType;
243 TSplitEvent (SalomeApp_Application * theApplication,
244 SUIT_ViewWindow * theViewWindow,
245 Qt::Orientation theOrientation,
246 QtxWorkstack::SplitType theSplitType):
247 myApplication(theApplication),
249 myOrientation(theOrientation),
250 mySplitType(theSplitType)
253 virtual void Execute()
255 SUIT_Desktop* desk = myApplication->desktop();
256 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
258 QtxWorkstack* workstack = tabDesk->workstack();
260 workstack->Split(myVW, myOrientation, mySplitType);
270 SUIT_ViewWindow* aVW = GetViewWindow();
272 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
273 Qt::Horizontal, QtxWorkstack::SplitMove));
280 SUIT_ViewWindow* aVW = GetViewWindow();
282 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
283 Qt::Horizontal, QtxWorkstack::SplitStay));
290 SUIT_ViewWindow* aVW = GetViewWindow();
292 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
293 Qt::Vertical, QtxWorkstack::SplitMove));
300 SUIT_ViewWindow* aVW = GetViewWindow();
302 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
303 Qt::Vertical, QtxWorkstack::SplitStay));
310 struct TOnTopEvent: public SALOME_Event
312 SUIT_ViewWindow * myVW;
315 TOnTopEvent (SUIT_ViewWindow * theViewWindow):
319 virtual void Execute()
327 SUIT_ViewWindow* aVW = GetViewWindow();
329 ProcessVoidEvent(new TOnTopEvent(aVW));
332 struct TAttractEvent: public SALOME_Event
334 SalomeApp_Application * myApplication;
335 SUIT_ViewWindow * myVW1;
336 SUIT_ViewWindow * myVW2;
340 TAttractEvent (SalomeApp_Application * theApplication,
341 SUIT_ViewWindow * theViewWindow1,
342 SUIT_ViewWindow * theViewWindow2,
344 myApplication(theApplication),
345 myVW1(theViewWindow1),
346 myVW2(theViewWindow2),
347 myAttractAll(theAttractAll)
350 virtual void Execute()
352 SUIT_Desktop* desk = myApplication->desktop();
353 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
355 QtxWorkstack* workstack = tabDesk->workstack();
357 workstack->Attract(myVW1, myVW2, myAttractAll);
365 Attract (VISU::View_ptr theView)
367 if (!CORBA::is_nil(theView)) {
368 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
370 SUIT_ViewWindow* aVW1 = GetViewWindow();
371 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
373 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, false));
381 AttractAll (VISU::View_ptr theView)
383 if (!CORBA::is_nil(theView)) {
384 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
386 SUIT_ViewWindow* aVW1 = GetViewWindow();
387 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
389 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, true));
395 struct TSizePositionEvent: public SALOME_Event
397 SalomeApp_Application * myApplication;
398 SUIT_ViewWindow * myVW;
403 TSizePositionEvent (SalomeApp_Application * theApplication,
404 SUIT_ViewWindow * theViewWindow,
407 myApplication(theApplication),
413 virtual void Execute()
415 MESSAGE("TSizePositionEvent::Execute()");
416 SUIT_Desktop* desk = myApplication->desktop();
417 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
419 QtxWorkstack* workstack = tabDesk->workstack();
422 //jfa to do:workstack->SetRelativeSizeInSplitter(myVW, myValue);
424 workstack->SetRelativePositionInSplitter(myVW, myValue);
433 SetRelativePositionInSplitter (CORBA::Double thePosition)
435 if (thePosition < 0.0 || 1.0 < thePosition) {
438 SUIT_ViewWindow* aVW = GetViewWindow();
440 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, thePosition, false));
445 SetRelativeSizeInSplitter (CORBA::Double theSize)
447 if (theSize < 0.0 || 1.0 < theSize) {
450 SUIT_ViewWindow* aVW = GetViewWindow();
452 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, theSize, true));
455 struct TWSSizePositionEvent: public SALOME_Event
457 SalomeApp_Application * myApplication;
458 SUIT_ViewWindow * myVW;
459 Qt::Orientation myOrientation;
464 TWSSizePositionEvent (SalomeApp_Application * theApplication,
465 SUIT_ViewWindow * theViewWindow,
466 Qt::Orientation theOrientation,
469 myApplication(theApplication),
471 myOrientation(theOrientation),
476 virtual void Execute()
478 MESSAGE("TWSSizePositionEvent::Execute()");
479 SUIT_Desktop* desk = myApplication->desktop();
480 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
482 QtxWorkstack* workstack = tabDesk->workstack();
485 //jfa to do:workstack->SetRelativeSize(myVW, myOrientation, myValue);
487 workstack->SetRelativePosition(myVW, myOrientation, myValue);
496 SetRelativePositionX (CORBA::Double thePosition)
498 if (thePosition < 0.0 || 1.0 < thePosition) {
501 SUIT_ViewWindow* aVW = GetViewWindow();
503 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
504 Qt::Horizontal, thePosition, false));
509 SetRelativePositionY (CORBA::Double thePosition)
511 if (thePosition < 0.0 || 1.0 < thePosition) {
514 SUIT_ViewWindow* aVW = GetViewWindow();
516 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
517 Qt::Vertical, thePosition, false));
522 SetRelativeSizeX (CORBA::Double theSize)
524 if (theSize < 0.0 || 1.0 < theSize) {
527 SUIT_ViewWindow* aVW = GetViewWindow();
529 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
530 Qt::Horizontal, theSize, true));
535 SetRelativeSizeY (CORBA::Double theSize)
537 if (theSize < 0.0 || 1.0 < theSize) {
540 SUIT_ViewWindow* aVW = GetViewWindow();
542 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
543 Qt::Vertical, theSize, true));
545 // End: New methods for view parameters management
547 // Begin: Old methods for view parameters management, they don't work now
548 struct TSetViewSize: public SALOME_Event
550 SUIT_ViewWindow* myVW;
551 typedef void (QRect::* TAction)(int);
556 TSetViewSize(SUIT_ViewWindow* theViewWindow,
558 CORBA::Long theSize):
568 if (QWidget* aParent = myVW->parentWidget()) {
569 QRect aQRect = aParent->frameGeometry();
570 (aQRect.*myAction)(mySize);
571 aParent->setGeometry(aQRect);
578 SetViewWidth(CORBA::Long theWidth)
580 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
585 SetViewHeight(CORBA::Long theHeight)
587 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
591 struct TGetViewSize: public SALOME_Event
593 SUIT_ViewWindow* myVW;
595 typedef int (QRect::* TAction)() const;
598 typedef CORBA::Long TResult;
602 TGetViewSize(SUIT_ViewWindow* theViewWindow,
612 if(QWidget* aParent = myVW->parentWidget()){
613 QRect aQRect = aParent->frameGeometry();
614 myResult = (aQRect.*myAction)();
624 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
631 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
635 class TWorkspaceEvent: public SALOME_Event
639 QWidget* myWorkspace;
642 TWorkspaceEvent(QWidget* theViewWindow,
643 QWidget* theWorkspace):
645 myWorkspace(theWorkspace)
650 class TAlignEvent: public TWorkspaceEvent
653 Qt::AlignmentFlag myAligment;
656 TAlignEvent(QWidget* theViewWindow,
657 QWidget* theWorkspace,
658 Qt::AlignmentFlag theAligment):
659 TWorkspaceEvent(theViewWindow,theWorkspace),
660 myAligment(theAligment)
667 if(QWidget* aParent = myVW->parentWidget())
668 SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
675 SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
678 switch (theViewPosition) {
679 case VISU::View::LEFT:
680 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
682 case VISU::View::CENTER:
683 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
685 case VISU::View::RIGHT:
686 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
695 SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
698 switch (theViewPosition) {
699 case VISU::View::TOP:
700 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
702 case VISU::View::CENTER:
703 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
705 case VISU::View::BOTTOM:
706 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
713 class TXYEvent: public TWorkspaceEvent
716 CORBA::Double myX, myY;
719 TXYEvent(QWidget* theViewWindow,
720 QWidget* theWorkspace,
723 TWorkspaceEvent(theViewWindow,theWorkspace),
732 SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
734 struct TEvent: public TXYEvent
737 TEvent(QWidget* theViewWindow,
738 QWidget* theWorkspace,
741 TXYEvent(theViewWindow,theWorkspace,theX,theY)
748 if(QWidget* aParent = myVW->parentWidget())
749 aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
754 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
759 SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
761 struct TEvent: public TXYEvent
764 TEvent(QWidget* theViewWindow,
765 QWidget* theWorkspace,
768 TXYEvent(theViewWindow,theWorkspace,theX,theY)
775 if(QWidget* aParent = myVW->parentWidget())
776 aParent->setGeometry(aParent->x(),
778 int(myX*myWorkspace->width()),
779 int(myY*myWorkspace->height()));
784 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
786 // End: Old methods for view parameters management, they don't work now
790 SetBackground (const SALOMEDS::Color& theColor)
792 struct TEvent: public SALOME_Event
794 SVTK_ViewWindow* myVW;
795 SALOMEDS::Color myColor;
797 TEvent(SVTK_ViewWindow* theViewWindow,
798 const SALOMEDS::Color& theColor):
802 virtual void Execute(){
804 aColor[0] = int(255.0*myColor.R);
805 aColor[1] = int(255.0*myColor.G);
806 aColor[2] = int(255.0*myColor.B);
807 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
808 myVW->setBackgroundColor(aNewColor);
812 SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
814 ProcessVoidEvent(new TEvent(aVW, theColor));
818 struct TBackgroundEvent: public SALOME_Event
820 SVTK_ViewWindow* myVW;
821 typedef SALOMEDS::Color TResult;
824 TBackgroundEvent(SVTK_ViewWindow* theViewWindow):
832 vtkFloatingPointType backint[3];
833 GetRenderer(myVW)->GetBackground(backint);
834 myResult.R = backint[0];
835 myResult.G = backint[1];
836 myResult.B = backint[2];
844 SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
846 return ProcessEvent(new TBackgroundEvent(aVW));
848 SALOMEDS::Color aBlack;
859 SUIT_ViewWindow* aVW = GetViewWindow();
861 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMinimized));
868 SUIT_ViewWindow* aVW = GetViewWindow();
870 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showNormal));
877 SUIT_ViewWindow* aVW = GetViewWindow();
879 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMaximized));
894 Erase (PrsObject_ptr thePrsObj)
899 Display (PrsObject_ptr thePrsObj)
904 DisplayOnly (PrsObject_ptr thePrsObj)
912 class TSavePictureEvent: public SALOME_Event
914 SUIT_ViewWindow * myVW;
915 const char * myFileName;
917 typedef CORBA::Boolean TResult;
919 TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
920 : myVW(theViewWindow),
921 myFileName(theFileName),
926 virtual void Execute()
929 QImage img = myVW->dumpView();
931 QString fileName (myFileName);
932 if (!fileName.isEmpty()) {
933 QString fmt = SUIT_Tools::extension(fileName).toUpper();
934 if (fmt.isEmpty()) fmt = QString("BMP"); // default format
935 if (fmt == "JPG" ) fmt = "JPEG";
936 //QApplication::setOverrideCursor(Qt::waitCursor);
937 img.save(fileName, fmt.toLatin1().data());
939 //QApplication::restoreOverrideCursor();
947 View_i::SavePicture(const char* theFileName)
949 return ProcessEvent(new TSavePictureEvent (GetViewWindow(), theFileName));
953 View_i::GetComment() const
960 ToStream (std::ostringstream& theStr)
964 SUIT_ViewWindow* View_i::GetViewWindow()
967 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
968 int aPos = aViews.indexOf(myViewWindow);
975 void View_i::SetViewWindow(SUIT_ViewWindow* theViewWindow)
977 myViewWindow = theViewWindow;
981 //===========================================================================
982 XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
983 : View_i(theApplication, NULL)
985 if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
988 struct TCreatePlot2dViewEvent: public SALOME_Event
990 XYPlot_i * myPlot2dView;
993 typedef Plot2d_ViewFrame* TResult;
996 TCreatePlot2dViewEvent (XYPlot_i * thePlot2dView,
998 myPlot2dView(thePlot2dView),
1007 if (!myPlot2dView->myApplication)
1010 SUIT_ViewManager* aViewMgr =
1011 myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), false);
1012 SUIT_ViewWindow* aVW = NULL;
1016 aVW = aViewMgr->createViewWindow();
1018 aVW = aViewMgr->getActiveView();
1021 aViewMgr = myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), true);
1022 aVW = aViewMgr->getActiveView();
1024 return; // there are no current Plot2d view
1029 Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(aVW);
1031 myResult = aPlot2dVW->getViewFrame();
1033 myResult->Repaint();
1036 myPlot2dView->myViewManager = aViewMgr;
1037 myPlot2dView->SetViewWindow(aVW);
1043 Storable* XYPlot_i::Create (int theNew)
1045 myView = ProcessEvent(new TCreatePlot2dViewEvent(this, theNew));
1051 void XYPlot_i::Update()
1053 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
1056 struct TCloseViewEvent: public SALOME_Event
1058 SUIT_ViewWindow* myView;
1059 TCloseViewEvent (SUIT_ViewWindow* theView):
1063 virtual void Execute()
1065 if ( myView ) myView->close();
1069 void XYPlot_i::Close()
1071 ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
1072 QApplication::sendPostedEvents();
1075 XYPlot_i::~XYPlot_i() {
1076 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1079 void XYPlot_i::SetTitle (const char* theTitle)
1081 SUIT_ViewWindow* aVW = GetViewWindow();
1083 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1084 (aVW, &SUIT_ViewWindow::setWindowTitle, QString(theTitle)));
1086 char* XYPlot_i::GetTitle()
1088 SUIT_ViewWindow* aVW = GetViewWindow();
1090 return CORBA::string_dup( aVW->windowTitle().toLatin1().data());
1091 return CORBA::string_dup("");
1094 void XYPlot_i::SetSubTitle (const char* theTitle)
1096 if (GetViewWindow())
1097 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1098 (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1101 char* XYPlot_i::GetSubTitle()
1103 if (GetViewWindow())
1104 return CORBA::string_dup(myView->getTitle().toLatin1().data());
1105 return CORBA::string_dup("");
1108 void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1110 if (GetViewWindow())
1111 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1112 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1115 VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1117 if (GetViewWindow())
1118 return (VISU::XYPlot::CurveType)myView->getCurveType();
1119 return VISU::XYPlot::POINTS;
1122 void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1124 if (GetViewWindow())
1125 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1126 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1129 CORBA::Long XYPlot_i::GetMarkerSize()
1131 if (GetViewWindow())
1132 return myView->getMarkerSize();
1136 void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1137 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1139 class TEvent: public SALOME_Event
1142 TEvent (Plot2d_ViewFrame* theView,
1143 CORBA::Boolean theMajor,
1144 CORBA::Long theNumMajor,
1145 CORBA::Boolean theMinor,
1146 CORBA::Long theNumMinor):
1149 myNumMajor(theNumMajor),
1151 myNumMinor(theNumMinor)
1154 virtual void Execute()
1156 myView->setXGrid( myMajor, myNumMajor, myMinor, myNumMinor );
1159 Plot2d_ViewFrame* myView;
1160 CORBA::Boolean myMajor, myMinor;
1161 CORBA::Long myNumMajor, myNumMinor;
1164 if ( GetViewWindow() )
1165 ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor ) );
1167 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
1168 CORBA::Long theNumMajor,
1169 CORBA::Boolean theMinor,
1170 CORBA::Long theNumMinor)
1172 this->EnableYGrid( theMajor, theNumMajor, theMinor, theNumMinor, false, 0, false, 0 );
1175 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
1176 CORBA::Long theNumMajor,
1177 CORBA::Boolean theMinor,
1178 CORBA::Long theNumMinor,
1179 CORBA::Boolean the2Major,
1180 CORBA::Long the2NumMajor,
1181 CORBA::Boolean the2Minor,
1182 CORBA::Long the2NumMinor)
1184 class TEvent: public SALOME_Event
1187 TEvent (Plot2d_ViewFrame* theView,
1188 CORBA::Boolean theMajor,
1189 CORBA::Long theNumMajor,
1190 CORBA::Boolean theMinor,
1191 CORBA::Long theNumMinor,
1192 CORBA::Boolean the2Major,
1193 CORBA::Long the2NumMajor,
1194 CORBA::Boolean the2Minor,
1195 CORBA::Long the2NumMinor):
1198 myNumMajor(theNumMajor),
1200 myNumMinor(theNumMinor),
1201 my2Major(the2Major),
1202 my2NumMajor(the2NumMajor),
1203 my2Minor(the2Minor),
1204 my2NumMinor(the2NumMinor)
1207 virtual void Execute()
1209 myView->setYGrid( myMajor, myNumMajor, myMinor, myNumMinor,
1210 my2Major, my2NumMajor, my2Minor, my2NumMinor);
1213 Plot2d_ViewFrame* myView;
1214 CORBA::Boolean myMajor, myMinor, my2Major, my2Minor;
1215 CORBA::Long myNumMajor, myNumMinor, my2NumMajor, my2NumMinor;
1218 if (GetViewWindow())
1219 ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor,
1220 the2Major, the2NumMajor, the2Minor, the2NumMinor ) );
1223 class TSetScaleModeEvent: public SALOME_Event
1226 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1227 TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1228 myView(theView), myFun(theFun), myScaling(theScaling)
1231 virtual void Execute()
1233 (myView->*myFun)(myScaling,true);
1236 Plot2d_ViewFrame* myView;
1241 void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1243 if (GetViewWindow())
1244 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1245 theScaling == VISU::LOGARITHMIC));
1248 VISU::Scaling XYPlot_i::GetHorScaling()
1250 //jfa: may be need to be enclosed in SALOME_Event?
1251 if (GetViewWindow())
1252 return (VISU::Scaling)myView->getHorScaleMode();
1253 return VISU::LINEAR;
1256 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1258 if (GetViewWindow())
1259 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1260 theScaling == VISU::LOGARITHMIC));
1263 VISU::Scaling XYPlot_i::GetVerScaling()
1265 if (GetViewWindow())
1266 return (VISU::Scaling)myView->getVerScaleMode();
1267 return VISU::LINEAR;
1270 class TSetTitleEvent: public SALOME_Event
1273 TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1274 myView(theView), myType(theType), myTitle(theTitle)
1276 virtual void Execute()
1278 myView->setTitle(true,myTitle,myType);
1281 Plot2d_ViewFrame* myView;
1282 Plot2d_ViewFrame::ObjectType myType;
1283 const char* myTitle;
1286 void XYPlot_i::SetXTitle (const char* theTitle)
1288 if (GetViewWindow())
1289 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1291 char* XYPlot_i::GetXTitle()
1293 if (GetViewWindow())
1294 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle).toLatin1().data());
1295 return CORBA::string_dup("");
1298 void XYPlot_i::SetYTitle (const char* theTitle)
1300 if (GetViewWindow())
1301 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1303 char* XYPlot_i::GetYTitle()
1305 if (GetViewWindow())
1306 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle).toLatin1().data());
1307 return CORBA::string_dup("");
1310 void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1312 if (GetViewWindow())
1313 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1314 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1317 class TXYPlotViewEvent: public SALOME_Event
1319 SalomeApp_Application* myApplication;
1320 Plot2d_ViewFrame* myView;
1321 PrsObject_ptr myPrsObj;
1325 TXYPlotViewEvent(SalomeApp_Application* theApplication,
1326 Plot2d_ViewFrame* theView,
1327 PrsObject_ptr thePrsObj,
1329 : myApplication(theApplication),
1331 myPrsObj(thePrsObj),
1332 myDisplaing(theDisplaing)
1336 virtual void Execute()
1338 Qtx::VisibilityState state = (myDisplaing == eDisplay ||myDisplaing == eDisplayOnly) ?
1339 Qtx::ShownState : Qtx::HiddenState;
1341 if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1342 UpdatePlot2d(aCurve,myDisplaing,myView);
1343 VISU::SetVisibilityState(aCurve->GetEntry(),state);
1344 VISU::CurveVisibilityChanged(aCurve, myDisplaing , false, true, true);
1346 // is it Container ?
1347 if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1348 VISU::SetVisibilityState(aContainer->GetEntry(),state);
1349 int nbCurves = aContainer->GetNbCurves();
1350 for ( int i = 1; i <= nbCurves; i++ ) {
1351 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1352 if ( aCurve && aCurve->IsValid() ) {
1353 UpdatePlot2d(aCurve,myDisplaing,myView);
1354 VISU::CurveVisibilityChanged(aCurve, myDisplaing , true, true, true);
1360 if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1361 _PTR(Study) aCStudy;
1362 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1363 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1364 aCStudy = aStudy->studyDS();
1367 if (!aCStudy) return;
1368 _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry());
1370 _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1371 for (; Iter->More(); Iter->Next()) {
1372 CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1373 if (!CORBA::is_nil(childObject)) {
1374 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1375 if (!CORBA::is_nil(aCurve)) {
1376 Curve_i* crv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1377 UpdatePlot2d(crv, myDisplaing, myView);
1378 VISU::CurveVisibilityChanged(crv, myDisplaing , true, false, true);
1383 VISU::SetVisibilityState(aTable->GetEntry(),state);
1389 void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1391 if (GetViewWindow())
1392 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1395 void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1397 if (GetViewWindow())
1398 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1401 void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1403 if (GetViewWindow())
1404 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1407 void XYPlot_i::EraseAll()
1409 if (GetViewWindow())
1410 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1413 void XYPlot_i::FitAll()
1415 if (GetViewWindow())
1416 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1419 class TFitRangeEvent: public SALOME_Event
1422 TFitRangeEvent (Plot2d_ViewFrame* theView,
1424 const double xMin, const double xMax,
1425 const double yMin, const double yMax):
1428 myXMin(xMin),myXMax(xMax),
1429 myYMin(yMin),myYMax(yMax)
1431 virtual void Execute()
1433 myView->fitData(myMode,myXMin,myXMax,myYMin,myYMax);
1437 const double myXMin;
1438 const double myXMax;
1439 const double myYMin;
1440 const double myYMax;
1441 Plot2d_ViewFrame* myView;
1444 void XYPlot_i::FitXRange(const CORBA::Double xMin,const CORBA::Double xMax)
1446 const CORBA::Long mode = 1;
1447 const CORBA::Double yMin = 0.0;
1448 const CORBA::Double yMax = 0.0;
1449 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1452 void XYPlot_i::FitYRange(const CORBA::Double yMin,const CORBA::Double yMax)
1454 const CORBA::Long mode = 2;
1455 const CORBA::Double xMin = 0.0;
1456 const CORBA::Double xMax = 0.0;
1457 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1460 void XYPlot_i::FitRange(const CORBA::Double xMin,const CORBA::Double xMax,
1461 const CORBA::Double yMin,const CORBA::Double yMax)
1463 const CORBA::Long mode = 0;
1464 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1467 void XYPlot_i::GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax)
1470 myView->getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
1473 //===========================================================================
1474 TableView_i::TableView_i (SalomeApp_Application* theApplication)
1475 : View_i(theApplication, NULL)
1479 struct TCreateTableViewEvent: public SALOME_Event
1481 SalomeApp_Application* myApplication;
1482 VISU::Table_i* myTable;
1484 typedef VISU_TableDlg* TResult;
1487 TCreateTableViewEvent (SalomeApp_Application* theApplication,
1488 VISU::Table_i* theTable):
1489 myApplication(theApplication),
1498 if (myTable != NULL) {
1499 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1500 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1501 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1502 myResult = new VISU_TableDlg (myApplication->desktop(),
1506 VISU_TableDlg::ttAuto,
1516 Storable* TableView_i::Create (VISU::Table_ptr theTable)
1518 if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1519 if (!theTable->_is_nil()) {
1520 VISU::Table_i* table =
1521 dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1522 if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1524 myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1531 TableView_i::~TableView_i()
1533 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1537 void TableView_i::SetTitle (const char* theTitle)
1539 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TableDlg,const QString&,QString>
1540 (myView, &VISU_TableDlg::setWindowTitle, QString(theTitle)));
1543 char* TableView_i::GetTitle()
1545 //jfa: may be need to be enclosed in SALOME_Event?
1546 return CORBA::string_dup(myView->windowTitle().toLatin1().data());
1549 void TableView_i::Close()
1551 //jfa: may be need to be enclosed in SALOME_Event?
1556 //===========================================================================
1557 int View3D_i::myNbViewParams = 0;
1558 const string View3D_i::myComment = "VIEW3D";
1559 const char* View3D_i::GetComment() const { return myComment.c_str();}
1561 QString View3D_i::GenerateViewParamsName()
1563 return VISU::GenerateName("ViewParams", ++myNbViewParams);
1566 View3D_i::View3D_i (SalomeApp_Application* theApplication)
1567 : View_i(theApplication, NULL)
1569 if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1572 struct TCreateView3dEvent: public SALOME_Event
1574 SalomeApp_Application *myApplication;
1575 View3D_i * myView3D;
1578 typedef SUIT_ViewWindow* TResult;
1581 TCreateView3dEvent (SalomeApp_Application *theApplication,
1582 View3D_i * theView3D,
1584 myApplication(theApplication),
1585 myView3D(theView3D),
1598 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1599 myResult = aViewManager->createViewWindow();
1600 myView3D->myViewManager = aViewManager;
1602 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),true)){
1603 myResult = aViewManager->getActiveView();
1604 myView3D->myViewManager = aViewManager;
1608 if(SUIT_ViewManager* aViewManager = myApplication->activeViewManager()){
1609 if(SUIT_ViewWindow* aView = aViewManager->getActiveView()){
1610 if(dynamic_cast<SVTK_ViewWindow*>(aView)){
1611 myView3D->myViewManager = aViewManager;
1612 myResult = aViewManager->getActiveView();
1616 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1617 myView3D->myViewManager = aViewManager;
1618 myResult = aViewManager->getActiveView();
1625 Storable* View3D_i::Create (int theNew)
1627 if (MYDEBUG) MESSAGE("View3D_i::Create");
1628 SUIT_ViewWindow* aVW = ProcessEvent(new TCreateView3dEvent(myApplication, this, theNew));
1636 void View3D_i::Update()
1638 class TEvent: public SALOME_Event
1640 SUIT_ViewWindow* myViewWindow;
1642 TEvent(SUIT_ViewWindow* theViewWindow):
1643 myViewWindow(theViewWindow)
1645 virtual void Execute()
1647 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myViewWindow);
1648 vtkRenderer* aRenderer = aViewWindow->getRenderer();
1649 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1650 vtkActorCollection* anActors = aCopy.GetActors();
1651 anActors->InitTraversal();
1652 while (vtkActor *anAct = anActors->GetNextActor()) {
1653 if (VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(anAct)) {
1654 if (anActor->GetVisibility())
1655 anActor->UpdateFromFactory();
1658 RepaintView(myViewWindow);
1662 if (SUIT_ViewWindow* aViewWindow = GetViewWindow())
1663 ProcessVoidEvent(new TEvent(aViewWindow));
1666 bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1668 MESSAGE("View3D_i::SaveViewParams()");
1670 if (!theViewManager || theName == "")
1673 _PTR(Study) aCStudy;
1674 if (SUIT_Study* aSStudy = theViewManager->study()) {
1675 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1676 aCStudy = aStudy->studyDS();
1682 if (theName != "") {
1683 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU");
1684 _PTR(GenericAttribute) anAttr;
1685 int iEnd = aList.size();
1686 for (int i = 0; i < iEnd; i++) {
1687 _PTR(SObject) anObj = aList[i];
1688 string anEntry = anObj->GetID();
1689 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1690 if (anObj->FindAttribute(anAttr, "AttributeString")) {
1691 _PTR(AttributeString) aCmnt (anAttr);
1692 string aComm (aCmnt->Value());
1693 if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1694 if (aComm.compare(View3D_i::myComment) >= 0) {
1695 aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1701 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1702 string aSComponentEntry = aSComponent->GetID();
1703 string anEntry = CreateAttributes(aCStudy,
1704 aSComponentEntry.c_str(),
1709 ToString(theViewManager->getActiveView()).c_str());
1713 class TSaveViewParamsEvent: public SALOME_Event
1715 SUIT_ViewManager* myViewMgr;
1718 TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1719 const std::string& theName):
1720 myViewMgr(theViewManager),
1724 virtual void Execute()
1726 myResult = View3D_i::SaveViewParams(myViewMgr, myName);
1728 typedef CORBA::Boolean TResult;
1732 CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName)
1734 return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName));
1737 bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1739 _PTR(Study) aCStudy;
1740 if (SUIT_Study* aSStudy = theViewManager->study()) {
1741 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1742 aCStudy = aStudy->studyDS();
1748 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1749 _PTR(GenericAttribute) anAttr;
1750 int iEnd = aList.size();
1751 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1752 for (int i = 0; i < iEnd; i++) {
1753 _PTR(SObject) anObj = aList[i];
1754 string anEntry = anObj->GetID();
1755 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1756 Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj);
1757 if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) {
1758 Restore(theViewManager->getActiveView(), aMap);
1765 class TRestoreViewParamsEvent: public SALOME_Event
1767 SUIT_ViewManager* myViewMgr;
1770 TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1771 const std::string& theName):
1772 myViewMgr(theViewManager),
1776 virtual void Execute()
1778 myResult = View3D_i::RestoreViewParams(myViewMgr, myName);
1780 typedef CORBA::Boolean TResult;
1784 CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName)
1786 return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName));
1789 void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
1790 const Storable::TRestoringMap& theMap)
1792 SALOMEDS::Color aColor;
1793 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1794 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1795 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1797 double aPosition[3];
1798 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1799 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1800 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1802 double aFocalPnt[3];
1803 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1804 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1805 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1808 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1809 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1810 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1812 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1814 double aScaleFactor[3];
1815 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1816 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1817 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1819 SetBackground(theViewWindow,aColor);
1820 SetPointOfView(theViewWindow,aPosition);
1821 SetViewUp(theViewWindow,aViewUp);
1822 SetFocalPoint(theViewWindow,aFocalPnt);
1823 SetParallelScale(theViewWindow,aParallelScale);
1824 ScaleView(theViewWindow,VISU::View3D::XAxis,aScaleFactor[0]);
1825 ScaleView(theViewWindow,VISU::View3D::YAxis,aScaleFactor[1]);
1826 ScaleView(theViewWindow,VISU::View3D::ZAxis,aScaleFactor[2]);
1830 string View3D_i::ToString (SUIT_ViewWindow* theViewWindow)
1832 ostringstream strOut;
1833 Storable::DataToStream(strOut, "myComment", myComment.c_str());
1834 ToStream(theViewWindow, strOut);
1836 if(MYDEBUG) MESSAGE("View3D_i::ToString - " << strOut.str());
1837 return strOut.str();
1840 void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr)
1842 vtkFloatingPointType backint[3];
1843 GetRenderer(theViewWindow)->GetBackground(backint);
1844 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1845 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1846 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1848 double aPosition[3];
1849 GetPointOfView(theViewWindow,aPosition);
1850 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1851 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1852 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1854 double aFocalPnt[3];
1855 GetFocalPoint(theViewWindow,aFocalPnt);
1856 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1857 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1858 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1861 GetCamera(theViewWindow)->GetViewUp(aViewUp);
1862 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1863 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1864 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1866 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theViewWindow));
1868 double aScaleFactor[3];
1869 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->GetScale(aScaleFactor);
1870 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1871 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1872 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1875 void View3D_i::ToStream(std::ostringstream& theStr)
1877 SUIT_ViewWindow* aVW = GetViewWindow();
1879 ToStream(aVW, theStr);
1882 void View3D_i::Close()
1884 ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
1885 QApplication::sendPostedEvents();
1888 View3D_i::~View3D_i()
1890 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1893 void View3D_i::SetTitle (const char* theTitle)
1895 SUIT_ViewWindow* aVW = GetViewWindow();
1897 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1898 (aVW,&SUIT_ViewWindow::setWindowTitle,QString(theTitle)));
1901 char* View3D_i::GetTitle()
1903 SUIT_ViewWindow* aVW = GetViewWindow();
1905 return CORBA::string_dup(aVW->windowTitle().toLatin1().data());
1906 return CORBA::string_dup("");
1909 void View3D_i::SetBackground (SUIT_ViewWindow* theViewWindow,
1910 const SALOMEDS::Color& theColor)
1912 //jfa: may be need to be enclosed in SALOME_Event?
1914 aColor[0] = int(255.0*theColor.R);
1915 aColor[1] = int(255.0*theColor.G);
1916 aColor[2] = int(255.0*theColor.B);
1917 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
1918 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->setBackgroundColor(aNewColor);
1921 SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow)
1923 SALOMEDS::Color aColor;
1924 vtkFloatingPointType backint[3];
1925 GetRenderer(theViewWindow)->GetBackground(backint);
1926 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1930 class TUpdateViewerEvent: public SALOME_Event
1932 SUIT_ViewWindow* myVW;
1936 TUpdateViewerEvent(SUIT_ViewWindow* theViewWindow,
1939 myVW(theViewWindow),
1941 myDisplaing(theDisplaing)
1943 virtual void Execute(){
1944 UpdateViewer(myVW, myDisplaing, myPrs3d);
1948 class TDisplayTableEvent: public SALOME_Event
1950 SUIT_ViewWindow* myVW;
1951 PointMap3d_i* myTable;
1954 TDisplayTableEvent( SUIT_ViewWindow* theView,
1955 PointMap3d_i* theTable,
1956 int theDisplaying ) :
1959 myDisplaying (theDisplaying)
1961 virtual void Execute() {
1962 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myVW);
1963 VISU_PointMap3dActor* anActor = myTable->CreateActor();
1964 myTable->UpdateActor( anActor );
1965 aViewWindow->AddActor( anActor );
1969 void View3D_i::EraseAll()
1971 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1972 SUIT_ViewWindow* aVW = GetViewWindow();
1974 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eEraseAll));
1977 void View3D_i::DisplayAll()
1979 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1980 SUIT_ViewWindow* aVW = GetViewWindow();
1982 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eDisplayAll));
1985 void View3D_i::Erase (PrsObject_ptr thePrsObj)
1987 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1988 SUIT_ViewWindow* aVW = GetViewWindow();
1989 CORBA::Object_ptr anObj = thePrsObj;
1990 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1992 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eErase));
1995 void View3D_i::Display (PrsObject_ptr thePrsObj)
1997 if(MYDEBUG) MESSAGE("View3D_i::Display");
1998 SUIT_ViewWindow* aVW = GetViewWindow();
1999 CORBA::Object_ptr anObj = thePrsObj;
2000 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
2002 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay));
2003 else if (aVW && !aPrs) {
2004 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
2006 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay));
2010 void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
2012 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
2013 SUIT_ViewWindow* aVW = GetViewWindow();
2014 CORBA::Object_ptr anObj = thePrsObj;
2015 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
2017 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly));
2018 else if (aVW && !aPrs) {
2019 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
2021 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly));
2025 void View3D_i::FitAll()
2027 SUIT_ViewWindow* aVW = GetViewWindow();
2029 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2030 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFitAll));
2035 void View3D_i::SetView (VISU::View3D::ViewType theType)
2037 SUIT_ViewWindow* aVW = GetViewWindow();
2042 case VISU::View3D::FRONT :
2043 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2044 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFrontView));
2046 case VISU::View3D::BACK :
2047 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2048 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onBackView));
2050 case VISU::View3D::LEFT :
2051 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2052 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onLeftView));
2054 case VISU::View3D::RIGHT :
2055 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2056 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onRightView));
2058 case VISU::View3D::TOP :
2059 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2060 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onTopView));
2062 case VISU::View3D::BOTTOM :
2063 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2064 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onBottomView));
2070 class TSet3DViewParamEvent: public SALOME_Event
2073 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]);
2074 TSet3DViewParamEvent (TFun theFun,
2075 SUIT_ViewWindow* theViewWindow,
2076 const CORBA::Double theParam[3]):
2078 myVW(theViewWindow),
2081 virtual void Execute() {
2082 myFun(myVW,myParam);
2086 SUIT_ViewWindow* myVW;
2087 const CORBA::Double* myParam;
2090 void View3D_i::SetPointOfView (SUIT_ViewWindow* theViewWindow,
2091 const CORBA::Double thePosition[3])
2093 //jfa: may be need to be enclosed in SALOME_Event?
2094 GetCamera(theViewWindow)->SetPosition(thePosition);
2097 void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
2099 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
2100 SUIT_ViewWindow* aVW = GetViewWindow();
2102 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetPointOfView,aVW,thePosition));
2105 void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow,
2106 CORBA::Double thePosition[3])
2108 GetCamera(theViewWindow)->GetPosition(thePosition);
2111 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
2113 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
2114 CORBA::Double aPosition[3];
2115 SUIT_ViewWindow* aVW = GetViewWindow();
2117 GetPointOfView(aVW,aPosition);
2118 return VISU::View3D::XYZ_dup(aPosition);
2121 void View3D_i::SetViewUp (SUIT_ViewWindow* theViewWindow,
2122 const CORBA::Double theViewUp[3])
2124 GetCamera(theViewWindow)->SetViewUp(theViewUp);
2127 void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
2129 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
2130 SUIT_ViewWindow* aVW = GetViewWindow();
2132 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetViewUp,aVW,theViewUp));
2135 void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow,
2136 CORBA::Double theViewUp[3])
2138 GetCamera(theViewWindow)->GetViewUp(theViewUp);
2141 VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
2143 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
2144 CORBA::Double aViewUp[3];
2145 SUIT_ViewWindow* aVW = GetViewWindow();
2147 GetCamera(aVW)->GetViewUp(aViewUp);
2148 return VISU::View3D::XYZ_dup(aViewUp);
2151 void View3D_i::SetFocalPoint (SUIT_ViewWindow* theViewWindow,
2152 const CORBA::Double theFocalPnt[3])
2154 GetCamera(theViewWindow)->SetFocalPoint(theFocalPnt);
2157 void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
2159 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
2160 SUIT_ViewWindow* aVW = GetViewWindow();
2162 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetFocalPoint,aVW,theCoord));
2166 void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow,
2167 CORBA::Double theFocalPnt[3])
2169 GetCamera(theViewWindow)->GetFocalPoint(theFocalPnt);
2172 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
2174 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
2175 CORBA::Double aFocalPnt[3];
2176 SUIT_ViewWindow* aVW = GetViewWindow();
2178 GetFocalPoint(aVW,aFocalPnt);
2179 return VISU::View3D::XYZ_dup(aFocalPnt);
2182 class TSetViewParamEvent: public SALOME_Event
2185 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, CORBA::Double theParam);
2186 TSetViewParamEvent (TFun theFun,
2187 SUIT_ViewWindow* theViewWindow,
2188 CORBA::Double theParam):
2190 myVW(theViewWindow),
2193 virtual void Execute()
2195 myFun(myVW,myParam);
2199 SUIT_ViewWindow* myVW;
2200 CORBA::Double myParam;
2203 void View3D_i::SetParallelScale (SUIT_ViewWindow* theViewWindow,
2204 CORBA::Double theScale)
2206 GetCamera(theViewWindow)->SetParallelScale(theScale);
2209 void View3D_i::SetParallelScale (CORBA::Double theScale)
2211 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
2212 SUIT_ViewWindow* aVW = GetViewWindow();
2214 ProcessVoidEvent(new TSetViewParamEvent(&View3D_i::SetParallelScale,aVW,theScale));
2217 CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow)
2219 return GetCamera(theViewWindow)->GetParallelScale();
2222 CORBA::Double View3D_i::GetParallelScale()
2224 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
2225 SUIT_ViewWindow* aVW = GetViewWindow();
2227 return GetParallelScale(aVW);
2231 void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow,
2232 VISU::View3D::Axis theAxis, CORBA::Double theParam)
2234 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
2235 double aScaleFactor[3];
2236 aViewWindow->GetScale(aScaleFactor);
2237 aScaleFactor[theAxis] = theParam;
2238 aViewWindow->SetScale(aScaleFactor);
2241 void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3])
2243 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
2244 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->SetScale(aScale);
2247 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
2249 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
2250 SUIT_ViewWindow* aVW = GetViewWindow();
2253 (dynamic_cast<SVTK_ViewWindow*>(aVW))->GetScale(aScale);
2254 aScale[theAxis] = theParam;
2255 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2259 void View3D_i::RemoveScale()
2261 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
2262 SUIT_ViewWindow* aVW = GetViewWindow();
2264 double aScale[3] = {1.0, 1.0, 1.0};
2265 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2269 //================================================
2270 // Certain presentation view parameters management
2271 //================================================
2272 class TPrsManageEvent: public SALOME_Event
2276 ScalarMap_ptr myPrs;
2279 TPrsManageEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2280 myView3D(theView3D),
2281 myPrs(ScalarMap::_duplicate(thePrs)),
2282 myError("Unknown error occured")
2284 VISU_Actor* GetMyActor()
2286 SUIT_ViewWindow* aVW = myView3D->GetViewWindow();
2287 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aVW);
2289 myError = "Corrupted view window";
2291 ScalarMap_i* aPrs = dynamic_cast<ScalarMap_i*>(VISU::GetServant(myPrs).in());
2293 myError = "Corrupted presentation";
2295 VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
2297 myError = "No actor found. Display the presentation at first.";
2309 class TGetPrsTypeEvent: public TPrsManageEvent {
2311 typedef VISU::PresentationType TResult;
2313 TGetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2314 TPrsManageEvent(theView3D, thePrs), myResult(VISU::SHRINK) {}
2315 virtual void Execute() {
2316 if (VISU_Actor* anActor = GetMyActor())
2317 myResult = (VISU::PresentationType)anActor->GetRepresentation();
2321 class TGetShrinkedEvent: public TPrsManageEvent {
2323 typedef bool TResult;
2325 TGetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2326 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2327 virtual void Execute() {
2328 if (VISU_Actor* anActor = GetMyActor()) {
2329 if (anActor->IsShrunkable())
2330 myResult = anActor->IsShrunk();
2337 class TGetShadedEvent: public TPrsManageEvent {
2339 typedef bool TResult;
2341 TGetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2342 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2343 virtual void Execute() {
2344 if (VISU_Actor* anActor = GetMyActor())
2345 if (VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor))
2346 myResult = aScalarMapActor->IsShading();
2350 class TGetOpacityEvent: public TPrsManageEvent {
2352 typedef double TResult;
2354 TGetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2355 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2356 virtual void Execute() {
2357 if (VISU_Actor* anActor = GetMyActor()) {
2358 vtkFloatingPointType oldvalue = anActor->GetOpacity();
2359 myResult = (double)oldvalue;
2364 class TGetLineWidthEvent: public TPrsManageEvent {
2366 typedef double TResult;
2368 TGetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2369 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2370 virtual void Execute() {
2371 if (VISU_Actor* anActor = GetMyActor()) {
2372 vtkFloatingPointType oldvalue = anActor->GetLineWidth();
2373 myResult = (double)oldvalue;
2379 class TSetPrsTypeEvent: public TPrsManageEvent {
2381 PresentationType myPrsType;
2383 typedef string TResult;
2385 TSetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, PresentationType thePrsType):
2386 TPrsManageEvent(theView3D, thePrs), myPrsType(thePrsType),
2387 myResult("Unknown error occured")
2389 virtual void Execute() {
2390 VISU::VISUType aType = myPrs->GetType();
2391 switch (myPrsType) {
2392 case VISU::INSIDEFRAME:
2394 if (aType != VISU::TSCALARMAP &&
2395 aType != VISU::TDEFORMEDSHAPE &&
2396 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2397 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2398 myResult = "Insideframe representation is not available for this type of presentations.";
2403 case VISU::SURFACEFRAME:
2405 if (aType != VISU::TSCALARMAP &&
2406 aType != VISU::TDEFORMEDSHAPE &&
2407 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2408 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP &&
2409 aType != VISU::TCUTPLANES &&
2410 aType != VISU::TISOSURFACES &&
2411 aType != VISU::TPLOT3D) {
2412 myResult = "Surfaceframe representation is not available for this type of presentations.";
2418 myResult = "Use SetShrinked() method to shrink/unshrink presentation.";
2423 if (VISU_Actor* anActor = GetMyActor()) {
2424 anActor->SetRepresentation((int)myPrsType);
2425 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2434 class TSetShrinkedEvent: public TPrsManageEvent {
2438 typedef string TResult;
2440 TSetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2441 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2442 myResult("Unknown error occured")
2444 virtual void Execute() {
2445 VISU::VISUType aType = myPrs->GetType();
2446 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2447 myResult = "Shrinked representation is not available for this type of presentations.";
2449 if (VISU_Actor* anActor = GetMyActor()) {
2450 if (anActor->IsShrunkable()) {
2451 if (myIsOn) anActor->SetShrink();
2452 else anActor->UnShrink();
2453 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2457 myResult = "This presentation is not shrunkable.";
2466 class TSetShadedEvent: public TPrsManageEvent {
2470 typedef string TResult;
2472 TSetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2473 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2474 myResult("Unknown error occured")
2476 virtual void Execute() {
2477 if (VISU_Actor* anActor = GetMyActor()) {
2478 if (VISU_ScalarMapAct* aScalarMapActor =
2479 dynamic_cast<VISU_ScalarMapAct*>(anActor)) {
2480 aScalarMapActor->SetShading(myIsOn);
2481 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2485 myResult = "Corrupted actor";
2493 class TSetOpacityEvent: public TPrsManageEvent {
2497 typedef string TResult;
2499 TSetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theOpacity):
2500 TPrsManageEvent(theView3D, thePrs), myOpacity(theOpacity),
2501 myResult("Unknown error occured")
2503 virtual void Execute() {
2504 VISU::VISUType aType = myPrs->GetType();
2505 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2506 myResult = "Opacity is meaningless for this type of presentations.";
2509 if (VISU_Actor* anActor = GetMyActor()) {
2510 anActor->SetOpacity((vtkFloatingPointType)myOpacity);
2511 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2520 class TSetLineWidthEvent: public TPrsManageEvent {
2524 typedef string TResult;
2526 TSetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theLineWidth):
2527 TPrsManageEvent(theView3D, thePrs), myLineWidth(theLineWidth),
2528 myResult("Unknown error occured")
2530 virtual void Execute() {
2531 if (myPrs->GetType() == VISU::TVECTORS) {
2532 myResult = "Line Width is meaningless for Vectors presentation.";
2535 if (VISU_Actor* anActor = GetMyActor()) {
2536 anActor->SetLineWidth((vtkFloatingPointType)myLineWidth);
2537 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2546 class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2548 Quadratic2DPresentationType myPrsType;
2550 typedef string TResult;
2552 TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D,
2553 ScalarMap_ptr thePrs,
2554 Quadratic2DPresentationType theType):
2555 TPrsManageEvent(theView3D, thePrs), myPrsType(theType),
2556 myResult("Unknown error occured")
2558 virtual void Execute()
2560 VISU::VISUType aType = myPrs->GetType();
2561 if (aType != VISU::TSCALARMAP &&
2562 aType != VISU::TDEFORMEDSHAPE &&
2563 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2564 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2565 myResult = "2D Quadratic element representation is not available for this type of presentations.";
2568 if (VISU_Actor* anActor = GetMyActor()) {
2569 if(myPrsType == VISU::LINES)
2570 anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
2571 else if(myPrsType == VISU::ARCS)
2572 anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
2574 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2583 class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2585 typedef VISU::Quadratic2DPresentationType TResult;
2587 TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2588 TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {}
2589 virtual void Execute() {
2590 if (VISU_Actor* anActor = GetMyActor()) {
2591 if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines)
2592 myResult = VISU::LINES;
2593 else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs)
2594 myResult = VISU::ARCS;
2599 PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs)
2601 return ProcessEvent(new TGetPrsTypeEvent(this,thePrs));
2603 CORBA::Boolean View3D_i::IsShrinked(ScalarMap_ptr thePrs)
2605 return ProcessEvent(new TGetShrinkedEvent(this,thePrs));
2607 CORBA::Boolean View3D_i::IsShaded(ScalarMap_ptr thePrs)
2609 return ProcessEvent(new TGetShadedEvent(this,thePrs));
2611 CORBA::Double View3D_i::GetOpacity(ScalarMap_ptr thePrs)
2613 return ProcessEvent(new TGetOpacityEvent(this,thePrs));
2615 CORBA::Double View3D_i::GetLineWidth(ScalarMap_ptr thePrs)
2617 return ProcessEvent(new TGetLineWidthEvent(this,thePrs));
2620 Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs)
2622 return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs));
2625 char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType)
2627 string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType));
2628 return CORBA::string_dup(aRet.c_str());
2630 char* View3D_i::SetShrinked(ScalarMap_ptr thePrs, CORBA::Boolean isShrinked)
2632 string aRet = ProcessEvent(new TSetShrinkedEvent(this,thePrs,isShrinked));
2633 return CORBA::string_dup(aRet.c_str());
2635 char* View3D_i::SetShaded(ScalarMap_ptr thePrs, CORBA::Boolean isShaded)
2637 string aRet = ProcessEvent(new TSetShadedEvent(this,thePrs,isShaded));
2638 return CORBA::string_dup(aRet.c_str());
2640 char* View3D_i::SetOpacity(ScalarMap_ptr thePrs, CORBA::Double theOpacity)
2642 string aRet = ProcessEvent(new TSetOpacityEvent(this,thePrs,theOpacity));
2643 return CORBA::string_dup(aRet.c_str());
2645 char* View3D_i::SetLineWidth(ScalarMap_ptr thePrs, CORBA::Double theLineWidth)
2647 string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth));
2648 return CORBA::string_dup(aRet.c_str());
2651 char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType)
2653 string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType));
2654 return CORBA::string_dup(aRet.c_str());