1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_View_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_View_i.hh"
29 #include "VISU_Gen_i.hh"
30 #include "VISU_Prs3d_i.hh"
31 #include "VISU_Table_i.hh"
32 #include "VISU_ViewManager_i.hh"
34 #include "VisuGUI_TableDlg.h"
36 #include "VISU_Actor.h"
38 #include "SALOME_Event.hxx"
40 #include "SUIT_ViewWindow.h"
41 #include "SUIT_ViewManager.h"
42 #include "SUIT_Tools.h"
44 #include "STD_MDIDesktop.h"
45 #include "STD_TabDesktop.h"
47 #include "SVTK_ViewWindow.h"
48 #include "SVTK_ViewModel.h"
49 #include "SVTK_RenderWindow.h"
51 #include "SPlot2d_ViewModel.h"
52 #include "Plot2d_ViewFrame.h"
54 #include "SalomeApp_Application.h"
55 #include "SalomeApp_Study.h"
57 #include <QtxWorkstack.h>
59 #include <qworkspace.h>
61 #include <vtkCamera.h>
62 #include <vtkRenderer.h>
67 static int MYDEBUG = 0;
69 static int MYDEBUG = 0;
74 typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
76 struct TNewViewEvent: public SALOME_Event
78 SalomeApp_Application* myApplication;
79 typedef QWidget* TResult;
82 TNewViewEvent (SalomeApp_Application* theApplication):
83 myApplication(theApplication),
91 if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
92 myResult = aDesktop->workspace();
98 View_i (SalomeApp_Application *theApplication,
99 SUIT_ViewManager* theViewManager):
100 myApplication(theApplication),
102 myViewManager(theViewManager)
104 if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
105 myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
111 if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
115 struct TApplicationEvent: public SALOME_Event
117 SalomeApp_Application* myApplication;
119 TApplicationEvent(SalomeApp_Application* theApplication):
120 myApplication(theApplication)
126 ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
127 CORBA::Boolean theState)
129 struct TEvent: public TApplicationEvent
131 VISU::View::ViewRepresentation myViewRepresentation;
132 CORBA::Boolean myState;
134 TEvent(SalomeApp_Application* theApplication,
135 VISU::View::ViewRepresentation theViewRepresentation,
136 CORBA::Boolean theState):
137 TApplicationEvent(theApplication),
138 myViewRepresentation(theViewRepresentation),
146 switch(myViewRepresentation){
147 case VISU::View::OBJECTBROWSER:
148 myApplication->setWindowShown(SalomeApp_Application::WT_ObjectBrowser,myState);
150 case VISU::View::PYTHON:
151 myApplication->setWindowShown(SalomeApp_Application::WT_PyConsole,myState);
153 case VISU::View::MESSAGES:
154 myApplication->setWindowShown(SalomeApp_Application::WT_LogWindow,myState);
156 case VISU::View::VIEWER:{
157 ViewManagerList aViewManagerList = myApplication->viewManagers();
165 ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
168 struct TPartShownEvent: public TApplicationEvent
170 VISU::View::ViewRepresentation myViewRepresentation;
171 typedef bool TResult;
174 TPartShownEvent(SalomeApp_Application* theApplication,
175 VISU::View::ViewRepresentation theViewRepresentation):
176 TApplicationEvent(theApplication),
177 myViewRepresentation(theViewRepresentation),
185 switch(myViewRepresentation){
186 case VISU::View::OBJECTBROWSER:
187 myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_ObjectBrowser);
189 case VISU::View::PYTHON:
190 myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_PyConsole);
192 case VISU::View::MESSAGES:
193 myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_LogWindow);
195 case VISU::View::VIEWER:{
196 ViewManagerList aViewManagerList = myApplication->viewManagers();
206 IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
208 return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
211 // Begin: New methods for view parameters management
212 struct TSplitEvent: public SALOME_Event
214 SalomeApp_Application * myApplication;
215 SUIT_ViewWindow * myVW;
216 Qt::Orientation myOrientation;
217 QtxWorkstack::SplitType mySplitType;
220 TSplitEvent (SalomeApp_Application * theApplication,
221 SUIT_ViewWindow * theViewWindow,
222 Qt::Orientation theOrientation,
223 QtxWorkstack::SplitType theSplitType):
224 myApplication(theApplication),
226 myOrientation(theOrientation),
227 mySplitType(theSplitType)
230 virtual void Execute()
232 SUIT_Desktop* desk = myApplication->desktop();
233 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
235 QtxWorkstack* workstack = tabDesk->workstack();
237 workstack->Split(myVW, myOrientation, mySplitType);
247 SUIT_ViewWindow* aVW = GetViewWindow();
249 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
250 Qt::Horizontal, QtxWorkstack::SPLIT_MOVE));
257 SUIT_ViewWindow* aVW = GetViewWindow();
259 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
260 Qt::Horizontal, QtxWorkstack::SPLIT_STAY));
267 SUIT_ViewWindow* aVW = GetViewWindow();
269 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
270 Qt::Vertical, QtxWorkstack::SPLIT_MOVE));
277 SUIT_ViewWindow* aVW = GetViewWindow();
279 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
280 Qt::Vertical, QtxWorkstack::SPLIT_STAY));
287 struct TOnTopEvent: public SALOME_Event
289 SUIT_ViewWindow * myVW;
292 TOnTopEvent (SUIT_ViewWindow * theViewWindow):
296 virtual void Execute()
304 SUIT_ViewWindow* aVW = GetViewWindow();
306 ProcessVoidEvent(new TOnTopEvent(aVW));
309 struct TAttractEvent: public SALOME_Event
311 SalomeApp_Application * myApplication;
312 SUIT_ViewWindow * myVW1;
313 SUIT_ViewWindow * myVW2;
317 TAttractEvent (SalomeApp_Application * theApplication,
318 SUIT_ViewWindow * theViewWindow1,
319 SUIT_ViewWindow * theViewWindow2,
321 myApplication(theApplication),
322 myVW1(theViewWindow1),
323 myVW2(theViewWindow2),
324 myAttractAll(theAttractAll)
327 virtual void Execute()
329 SUIT_Desktop* desk = myApplication->desktop();
330 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
332 QtxWorkstack* workstack = tabDesk->workstack();
334 workstack->Attract(myVW1, myVW2, myAttractAll);
342 Attract (VISU::View_ptr theView)
344 if (!CORBA::is_nil(theView)) {
345 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
347 SUIT_ViewWindow* aVW1 = GetViewWindow();
348 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
350 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, false));
358 AttractAll (VISU::View_ptr theView)
360 if (!CORBA::is_nil(theView)) {
361 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
363 SUIT_ViewWindow* aVW1 = GetViewWindow();
364 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
366 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, true));
372 struct TSizePositionEvent: public SALOME_Event
374 SalomeApp_Application * myApplication;
375 SUIT_ViewWindow * myVW;
380 TSizePositionEvent (SalomeApp_Application * theApplication,
381 SUIT_ViewWindow * theViewWindow,
384 myApplication(theApplication),
390 virtual void Execute()
392 MESSAGE("TSizePositionEvent::Execute()");
393 SUIT_Desktop* desk = myApplication->desktop();
394 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
396 QtxWorkstack* workstack = tabDesk->workstack();
399 //jfa to do:workstack->SetRelativeSizeInSplitter(myVW, myValue);
401 workstack->SetRelativePositionInSplitter(myVW, myValue);
410 SetRelativePositionInSplitter (CORBA::Double thePosition)
412 if (thePosition < 0.0 || 1.0 < thePosition) {
415 SUIT_ViewWindow* aVW = GetViewWindow();
417 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, thePosition, false));
422 SetRelativeSizeInSplitter (CORBA::Double theSize)
424 if (theSize < 0.0 || 1.0 < theSize) {
427 SUIT_ViewWindow* aVW = GetViewWindow();
429 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, theSize, true));
432 struct TWSSizePositionEvent: public SALOME_Event
434 SalomeApp_Application * myApplication;
435 SUIT_ViewWindow * myVW;
436 Qt::Orientation myOrientation;
441 TWSSizePositionEvent (SalomeApp_Application * theApplication,
442 SUIT_ViewWindow * theViewWindow,
443 Qt::Orientation theOrientation,
446 myApplication(theApplication),
448 myOrientation(theOrientation),
453 virtual void Execute()
455 MESSAGE("TWSSizePositionEvent::Execute()");
456 SUIT_Desktop* desk = myApplication->desktop();
457 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
459 QtxWorkstack* workstack = tabDesk->workstack();
462 //jfa to do:workstack->SetRelativeSize(myVW, myOrientation, myValue);
464 workstack->SetRelativePosition(myVW, myOrientation, myValue);
473 SetRelativePositionX (CORBA::Double thePosition)
475 if (thePosition < 0.0 || 1.0 < thePosition) {
478 SUIT_ViewWindow* aVW = GetViewWindow();
480 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
481 Qt::Horizontal, thePosition, false));
486 SetRelativePositionY (CORBA::Double thePosition)
488 if (thePosition < 0.0 || 1.0 < thePosition) {
491 SUIT_ViewWindow* aVW = GetViewWindow();
493 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
494 Qt::Vertical, thePosition, false));
499 SetRelativeSizeX (CORBA::Double theSize)
501 if (theSize < 0.0 || 1.0 < theSize) {
504 SUIT_ViewWindow* aVW = GetViewWindow();
506 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
507 Qt::Horizontal, theSize, true));
512 SetRelativeSizeY (CORBA::Double theSize)
514 if (theSize < 0.0 || 1.0 < theSize) {
517 SUIT_ViewWindow* aVW = GetViewWindow();
519 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
520 Qt::Vertical, theSize, true));
522 // End: New methods for view parameters management
524 // Begin: Old methods for view parameters management, they don't work now
525 struct TSetViewSize: public SALOME_Event
527 SUIT_ViewWindow* myVW;
528 typedef void (QRect::* TAction)(int);
533 TSetViewSize(SUIT_ViewWindow* theViewWindow,
535 CORBA::Long theSize):
545 if (QWidget* aParent = myVW->parentWidget(true)) {
546 QRect aQRect = aParent->frameGeometry();
547 (aQRect.*myAction)(mySize);
548 aParent->setGeometry(aQRect);
555 SetViewWidth(CORBA::Long theWidth)
557 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
562 SetViewHeight(CORBA::Long theHeight)
564 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
568 struct TGetViewSize: public SALOME_Event
570 SUIT_ViewWindow* myVW;
572 typedef int (QRect::* TAction)() const;
575 typedef CORBA::Long TResult;
579 TGetViewSize(SUIT_ViewWindow* theViewWindow,
589 if(QWidget* aParent = myVW->parentWidget(true)){
590 QRect aQRect = aParent->frameGeometry();
591 myResult = (aQRect.*myAction)();
601 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
608 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
612 class TWorkspaceEvent: public SALOME_Event
616 QWidget* myWorkspace;
619 TWorkspaceEvent(QWidget* theViewWindow,
620 QWidget* theWorkspace):
622 myWorkspace(theWorkspace)
627 class TAlignEvent: public TWorkspaceEvent
630 Qt::AlignmentFlags myAligment;
633 TAlignEvent(QWidget* theViewWindow,
634 QWidget* theWorkspace,
635 Qt::AlignmentFlags theAligment):
636 TWorkspaceEvent(theViewWindow,theWorkspace),
637 myAligment(theAligment)
644 if(QWidget* aParent = myVW->parentWidget(true))
645 SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
652 SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
655 switch (theViewPosition) {
656 case VISU::View::LEFT:
657 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
659 case VISU::View::CENTER:
660 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
662 case VISU::View::RIGHT:
663 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
672 SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
675 switch (theViewPosition) {
676 case VISU::View::TOP:
677 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
679 case VISU::View::CENTER:
680 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
682 case VISU::View::BOTTOM:
683 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
690 class TXYEvent: public TWorkspaceEvent
693 CORBA::Double myX, myY;
696 TXYEvent(QWidget* theViewWindow,
697 QWidget* theWorkspace,
700 TWorkspaceEvent(theViewWindow,theWorkspace),
709 SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
711 struct TEvent: public TXYEvent
714 TEvent(QWidget* theViewWindow,
715 QWidget* theWorkspace,
718 TXYEvent(theViewWindow,theWorkspace,theX,theY)
725 if(QWidget* aParent = myVW->parentWidget(true))
726 aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
731 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
736 SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
738 struct TEvent: public TXYEvent
741 TEvent(QWidget* theViewWindow,
742 QWidget* theWorkspace,
745 TXYEvent(theViewWindow,theWorkspace,theX,theY)
752 if(QWidget* aParent = myVW->parentWidget(true))
753 aParent->setGeometry(aParent->x(),
755 int(myX*myWorkspace->width()),
756 int(myY*myWorkspace->height()));
761 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
763 // End: Old methods for view parameters management, they don't work now
767 SetBackground (const SALOMEDS::Color& theColor)
769 struct TEvent: public SALOME_Event
772 SALOMEDS::Color myColor;
774 TEvent(QWidget* theWidget,
775 const SALOMEDS::Color& theColor):
779 virtual void Execute(){
781 aColor[0] = int(255.0*myColor.R);
782 aColor[1] = int(255.0*myColor.G);
783 aColor[2] = int(255.0*myColor.B);
784 myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2]));
788 SUIT_ViewWindow* aVW = GetViewWindow();
790 ProcessVoidEvent(new TEvent(aVW, theColor));
794 struct TBackgroundEvent: public SALOME_Event
797 typedef SALOMEDS::Color TResult;
800 TBackgroundEvent(QWidget* theWidget):
808 const QColor& aColor = myWidget->backgroundColor();
809 myResult.R = aColor.red()/255.0;
810 myResult.G = aColor.green()/255.0;
811 myResult.B = aColor.blue()/255.0;
819 SUIT_ViewWindow* aVW = GetViewWindow();
821 return ProcessEvent(new TBackgroundEvent(aVW));
823 SALOMEDS::Color aBlack;
834 SUIT_ViewWindow* aVW = GetViewWindow();
836 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMinimized));
843 SUIT_ViewWindow* aVW = GetViewWindow();
845 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showNormal));
852 SUIT_ViewWindow* aVW = GetViewWindow();
854 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMaximized));
869 Erase (PrsObject_ptr thePrsObj)
874 Display (PrsObject_ptr thePrsObj)
879 DisplayOnly (PrsObject_ptr thePrsObj)
887 class TSavePictureEvent: public SALOME_Event
889 SUIT_ViewWindow * myVW;
890 const char * myFileName;
892 typedef CORBA::Boolean TResult;
894 TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
895 : myVW(theViewWindow),
896 myFileName(theFileName),
901 virtual void Execute()
904 QImage img = myVW->dumpView();
906 QString fileName (myFileName);
907 if (!fileName.isEmpty()) {
908 QString fmt = SUIT_Tools::extension(fileName).upper();
909 if (fmt.isEmpty()) fmt = QString("BMP"); // default format
910 if (fmt == "JPG" ) fmt = "JPEG";
911 //QApplication::setOverrideCursor(Qt::waitCursor);
912 img.save(fileName, fmt.latin1());
914 //QApplication::restoreOverrideCursor();
922 View_i::SavePicture(const char* theFileName)
924 return ProcessEvent(new TSavePictureEvent (GetViewWindow(), theFileName));
928 View_i::GetComment() const
935 ToStream (std::ostringstream& theStr)
939 SUIT_ViewWindow* View_i::GetViewWindow()
942 QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
943 int aPos = aViews.find(myViewWindow);
950 void View_i::SetViewWindow(SUIT_ViewWindow* theViewWindow)
952 myViewWindow = theViewWindow;
956 //===========================================================================
957 XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
958 : View_i(theApplication, NULL)
960 if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
963 struct TCreatePlot2dViewEvent: public SALOME_Event
965 XYPlot_i * myPlot2dView;
968 typedef Plot2d_ViewFrame* TResult;
971 TCreatePlot2dViewEvent (XYPlot_i * thePlot2dView,
973 myPlot2dView(thePlot2dView),
982 if (!myPlot2dView->myApplication)
985 SUIT_ViewManager* aViewMgr =
986 myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), false);
987 SUIT_ViewWindow* aVW = NULL;
991 aVW = aViewMgr->createViewWindow();
993 aVW = aViewMgr->getActiveView();
996 aViewMgr = myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), true);
997 aVW = aViewMgr->getActiveView();
999 return; // there are no current Plot2d view
1004 Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(aVW);
1006 myResult = aPlot2dVW->getViewFrame();
1008 myResult->Repaint();
1011 myPlot2dView->myViewManager = aViewMgr;
1012 myPlot2dView->SetViewWindow(aVW);
1018 Storable* XYPlot_i::Create (int theNew)
1020 myView = ProcessEvent(new TCreatePlot2dViewEvent(this, theNew));
1026 void XYPlot_i::Update()
1028 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
1031 void XYPlot_i::Close()
1033 //jfa: may be need to be enclosed in SALOME_Event?
1034 SUIT_ViewWindow* aVW = GetViewWindow();
1037 //QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
1038 //int aPos = aViews.find(myViewWindow);
1040 // myViewWindow->close();
1043 XYPlot_i::~XYPlot_i() {
1044 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1047 void XYPlot_i::SetTitle (const char* theTitle)
1049 SUIT_ViewWindow* aVW = GetViewWindow();
1051 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1052 (aVW, &SUIT_ViewWindow::setCaption, QString(theTitle)));
1054 char* XYPlot_i::GetTitle()
1056 SUIT_ViewWindow* aVW = GetViewWindow();
1058 return CORBA::string_dup(aVW->caption().latin1());
1059 return CORBA::string_dup("");
1062 void XYPlot_i::SetSubTitle (const char* theTitle)
1064 if (GetViewWindow())
1065 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1066 (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1069 char* XYPlot_i::GetSubTitle()
1071 if (GetViewWindow())
1072 return CORBA::string_dup(myView->getTitle());
1073 return CORBA::string_dup("");
1076 void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1078 if (GetViewWindow())
1079 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1080 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1083 VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1085 if (GetViewWindow())
1086 return (VISU::XYPlot::CurveType)myView->getCurveType();
1087 return VISU::XYPlot::POINTS;
1090 void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1092 if (GetViewWindow())
1093 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1094 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1097 CORBA::Long XYPlot_i::GetMarkerSize()
1099 if (GetViewWindow())
1100 return myView->getMarkerSize();
1104 class TEnableGridEvent: public SALOME_Event
1107 typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool);
1108 TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun,
1109 CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1110 CORBA::Boolean theMinor, CORBA::Long theNumMinor):
1111 myView(theView), myFun(theFun),
1112 myMajor(theMajor), myNumMajor(theNumMajor),
1113 myMinor(theMinor), myNumMinor(theNumMinor)
1116 virtual void Execute()
1118 (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true);
1121 Plot2d_ViewFrame* myView;
1123 CORBA::Boolean myMajor, myMinor;
1124 CORBA::Long myNumMajor, myNumMinor;
1127 void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1128 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1130 if (GetViewWindow())
1131 ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
1132 theMajor,theNumMajor,theMinor,theNumMinor));
1134 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1135 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1137 //asl: Plot2d_ViewFrame::setYGrid has more parameters
1138 //if (GetViewWindow())
1139 // ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
1140 // theMajor,theNumMajor,theMinor,theNumMinor));
1143 class TSetScaleModeEvent: public SALOME_Event
1146 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1147 TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1148 myView(theView), myFun(theFun), myScaling(theScaling)
1151 virtual void Execute()
1153 (myView->*myFun)(myScaling,true);
1156 Plot2d_ViewFrame* myView;
1161 void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1163 if (GetViewWindow())
1164 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1165 theScaling == VISU::LOGARITHMIC));
1168 VISU::Scaling XYPlot_i::GetHorScaling()
1170 //jfa: may be need to be enclosed in SALOME_Event?
1171 if (GetViewWindow())
1172 return (VISU::Scaling)myView->getHorScaleMode();
1173 return VISU::LINEAR;
1176 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1178 if (GetViewWindow())
1179 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1180 theScaling == VISU::LOGARITHMIC));
1183 VISU::Scaling XYPlot_i::GetVerScaling()
1185 if (GetViewWindow())
1186 return (VISU::Scaling)myView->getVerScaleMode();
1187 return VISU::LINEAR;
1190 class TSetTitleEvent: public SALOME_Event
1193 TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1194 myView(theView), myType(theType), myTitle(theTitle)
1196 virtual void Execute()
1198 myView->setTitle(true,myTitle,myType);
1201 Plot2d_ViewFrame* myView;
1202 Plot2d_ViewFrame::ObjectType myType;
1203 const char* myTitle;
1206 void XYPlot_i::SetXTitle (const char* theTitle)
1208 if (GetViewWindow())
1209 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1211 char* XYPlot_i::GetXTitle()
1213 if (GetViewWindow())
1214 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
1215 return CORBA::string_dup("");
1218 void XYPlot_i::SetYTitle (const char* theTitle)
1220 if (GetViewWindow())
1221 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1223 char* XYPlot_i::GetYTitle()
1225 if (GetViewWindow())
1226 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
1227 return CORBA::string_dup("");
1230 void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1232 if (GetViewWindow())
1233 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1234 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1237 class TXYPlotViewEvent: public SALOME_Event
1239 SalomeApp_Application* myApplication;
1240 Plot2d_ViewFrame* myView;
1241 PrsObject_ptr myPrsObj;
1245 TXYPlotViewEvent(SalomeApp_Application* theApplication,
1246 Plot2d_ViewFrame* theView,
1247 PrsObject_ptr thePrsObj,
1249 : myApplication(theApplication),
1251 myPrsObj(thePrsObj),
1252 myDisplaing(theDisplaing)
1256 virtual void Execute()
1259 if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1260 UpdatePlot2d(myView,myDisplaing,aCurve);
1262 // is it Container ?
1263 if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1264 int nbCurves = aContainer->GetNbCurves();
1265 for ( int i = 1; i <= nbCurves; i++ ) {
1266 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1267 if ( aCurve && aCurve->IsValid() ) {
1268 UpdatePlot2d(myView,myDisplaing,aCurve);
1274 if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1275 _PTR(Study) aCStudy;
1276 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1277 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1278 aCStudy = aStudy->studyDS();
1281 if (!aCStudy) return;
1282 _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
1284 _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1285 for (; Iter->More(); Iter->Next()) {
1286 CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1287 if (!CORBA::is_nil(childObject)) {
1288 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1289 if (!CORBA::is_nil(aCurve))
1290 UpdatePlot2d(myView, myDisplaing,
1291 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
1300 void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1302 if (GetViewWindow())
1303 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1306 void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1308 if (GetViewWindow())
1309 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1312 void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1314 if (GetViewWindow())
1315 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1318 void XYPlot_i::EraseAll()
1320 if (GetViewWindow())
1321 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1324 void XYPlot_i::FitAll()
1326 if (GetViewWindow())
1327 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1330 class TFitRangeEvent: public SALOME_Event
1333 TFitRangeEvent (Plot2d_ViewFrame* theView,
1335 const double xMin, const double xMax,
1336 const double yMin, const double yMax):
1339 myXMin(xMin),myXMax(xMax),
1340 myYMin(yMin),myYMax(yMax)
1342 virtual void Execute()
1344 myView->fitData(myMode,myXMin,myXMax,myYMin,myYMax);
1348 const double myXMin;
1349 const double myXMax;
1350 const double myYMin;
1351 const double myYMax;
1352 Plot2d_ViewFrame* myView;
1355 void XYPlot_i::FitXRange(const CORBA::Double xMin,const CORBA::Double xMax)
1357 const CORBA::Long mode = 1;
1358 const CORBA::Double yMin = 0.0;
1359 const CORBA::Double yMax = 0.0;
1360 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1363 void XYPlot_i::FitYRange(const CORBA::Double yMin,const CORBA::Double yMax)
1365 const CORBA::Long mode = 2;
1366 const CORBA::Double xMin = 0.0;
1367 const CORBA::Double xMax = 0.0;
1368 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1371 void XYPlot_i::FitRange(const CORBA::Double xMin,const CORBA::Double xMax,
1372 const CORBA::Double yMin,const CORBA::Double yMax)
1374 const CORBA::Long mode = 0;
1375 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1378 void XYPlot_i::GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax)
1381 myView->getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
1384 //===========================================================================
1385 TableView_i::TableView_i (SalomeApp_Application* theApplication)
1386 : View_i(theApplication, NULL)
1390 struct TCreateTableViewEvent: public SALOME_Event
1392 SalomeApp_Application* myApplication;
1393 VISU::Table_i* myTable;
1395 typedef VisuGUI_TableDlg* TResult;
1398 TCreateTableViewEvent (SalomeApp_Application* theApplication,
1399 VISU::Table_i* theTable):
1400 myApplication(theApplication),
1409 if (myTable != NULL) {
1410 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1411 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1412 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1413 _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
1415 myResult = new VisuGUI_TableDlg (myApplication->desktop(),
1418 VisuGUI_TableDlg::ttAuto,
1429 Storable* TableView_i::Create (VISU::Table_ptr theTable)
1431 if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1432 if (!theTable->_is_nil()) {
1433 VISU::Table_i* table =
1434 dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1435 if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1437 myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1444 TableView_i::~TableView_i()
1446 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1450 void TableView_i::SetTitle (const char* theTitle)
1452 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
1453 (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
1456 char* TableView_i::GetTitle()
1458 //jfa: may be need to be enclosed in SALOME_Event?
1459 return CORBA::string_dup(myView->caption().latin1());
1462 void TableView_i::Close()
1464 //jfa: may be need to be enclosed in SALOME_Event?
1469 //===========================================================================
1470 int View3D_i::myNbViewParams = 0;
1471 const string View3D_i::myComment = "VIEW3D";
1472 const char* View3D_i::GetComment() const { return myComment.c_str();}
1474 QString View3D_i::GenerateViewParamsName()
1476 return VISU::GenerateName("ViewParams", ++myNbViewParams);
1479 View3D_i::View3D_i (SalomeApp_Application* theApplication)
1480 : View_i(theApplication, NULL)
1482 if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1485 struct TCreateView3dEvent: public SALOME_Event
1487 View3D_i * myView3D;
1490 typedef SUIT_ViewWindow* TResult;
1493 TCreateView3dEvent (View3D_i * theView3D,
1495 myView3D(theView3D),
1504 if (!myView3D->myApplication)
1507 SUIT_ViewManager * aViewMgr =
1508 myView3D->myApplication->getViewManager(SVTK_Viewer::Type(), false);
1512 myResult = aViewMgr->createViewWindow();
1514 myResult = aViewMgr->getActiveView();
1518 aViewMgr = myView3D->myApplication->getViewManager(SVTK_Viewer::Type(), true);
1519 myResult = aViewMgr->getActiveView();
1521 return; // there are no current 3D view
1525 myView3D->myViewManager = aViewMgr;
1529 Storable* View3D_i::Create (int theNew)
1531 if (MYDEBUG) MESSAGE("View3D_i::Create");
1532 SUIT_ViewWindow* aVW = ProcessEvent(new TCreateView3dEvent(this, theNew));
1540 void View3D_i::Update()
1542 class TEvent: public SALOME_Event
1544 SUIT_ViewWindow* myVW;
1546 TEvent(SUIT_ViewWindow* theViewWindow):
1549 virtual void Execute()
1551 SVTK_ViewWindow* vf = VISU::GetViewWindow(myVW);
1552 vtkRenderer* Renderer = vf->getRenderer();
1553 vtkActorCollection* theActors = Renderer->GetActors();
1554 theActors->InitTraversal();
1555 while (vtkActor *anAct = theActors->GetNextActor()) {
1556 if (VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)) {
1557 VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
1558 if (anActor->GetVisibility() && aPrs3d) {
1560 aPrs3d->UpdateActor(anActor);
1568 SUIT_ViewWindow* aVW = GetViewWindow();
1570 ProcessVoidEvent(new TEvent(aVW));
1573 bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1575 MESSAGE("View3D_i::SaveViewParams()");
1577 if (!theViewManager || !theName)
1580 _PTR(Study) aCStudy;
1581 if (SUIT_Study* aSStudy = theViewManager->study()) {
1582 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1583 aCStudy = aStudy->studyDS();
1589 if (strcmp(theName, "") != 0) {
1590 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1591 _PTR(GenericAttribute) anAttr;
1592 int iEnd = aList.size();
1593 for (int i = 0; i < iEnd; i++) {
1594 _PTR(SObject) anObj = aList[i];
1595 string anEntry = anObj->GetID();
1596 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1597 if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1598 _PTR(AttributeComment) aCmnt (anAttr);
1599 string aComm (aCmnt->Value());
1600 if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1601 if (aComm.compare(View3D_i::myComment) >= 0) {
1602 aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1608 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1609 string aSComponentEntry = aSComponent->GetID();
1610 string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
1611 ToString(theViewManager->getActiveView()).c_str());
1615 class TSaveViewParamsEvent: public SALOME_Event
1617 SUIT_ViewManager* myViewMgr;
1620 TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1621 const char* theName):
1622 myViewMgr(theViewManager),
1626 virtual void Execute()
1628 myResult = View3D_i::SaveViewParams(myViewMgr, myName);
1630 typedef CORBA::Boolean TResult;
1634 CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
1636 return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName));
1639 bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1641 _PTR(Study) aCStudy;
1642 if (SUIT_Study* aSStudy = theViewManager->study()) {
1643 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1644 aCStudy = aStudy->studyDS();
1650 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1651 _PTR(GenericAttribute) anAttr;
1652 int iEnd = aList.size();
1653 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1654 for (int i = 0; i < iEnd; i++) {
1655 _PTR(SObject) anObj = aList[i];
1656 string anEntry = anObj->GetID();
1657 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1658 if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1659 _PTR(AttributeComment) aCmnt (anAttr);
1660 QString strIn(aCmnt->Value().c_str());
1661 Storable::TRestoringMap aMap;
1662 Storable::StrToMap(strIn, aMap);
1663 if (Storable::FindValue(aMap, "myComment").compare
1664 (View3D_i::myComment.c_str()) >= 0) {
1665 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn);
1666 Restore(theViewManager->getActiveView(), aMap);
1674 class TRestoreViewParamsEvent: public SALOME_Event
1676 SUIT_ViewManager* myViewMgr;
1679 TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1680 const char* theName):
1681 myViewMgr(theViewManager),
1685 virtual void Execute()
1687 myResult = View3D_i::RestoreViewParams(myViewMgr, myName);
1689 typedef CORBA::Boolean TResult;
1693 CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
1695 return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
1698 void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
1699 const Storable::TRestoringMap& theMap)
1701 SALOMEDS::Color aColor;
1702 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1703 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1704 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1706 double aPosition[3];
1707 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1708 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1709 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1711 double aFocalPnt[3];
1712 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1713 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1714 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1717 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1718 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1719 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1721 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1723 double aScaleFactor[3];
1724 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1725 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1726 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1728 SetBackground(theViewWindow,aColor);
1729 SetPointOfView(theViewWindow,aPosition);
1730 SetViewUp(theViewWindow,aViewUp);
1731 SetFocalPoint(theViewWindow,aFocalPnt);
1732 SetParallelScale(theViewWindow,aParallelScale);
1733 SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theViewWindow);
1734 aViewWindow->SetScale(aScaleFactor);
1738 string View3D_i::ToString (SUIT_ViewWindow* theViewWindow)
1740 ostringstream strOut;
1741 Storable::DataToStream(strOut, "myComment", myComment.c_str());
1742 ToStream(theViewWindow, strOut);
1744 if(MYDEBUG) MESSAGE("View3D_i::ToString - " << strOut.str());
1745 return strOut.str();
1748 void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr)
1750 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1753 GetRenderer(theViewWindow)->GetBackground(backint);
1754 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1755 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1756 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1758 double aPosition[3];
1759 GetPointOfView(theViewWindow,aPosition);
1760 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1761 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1762 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1764 double aFocalPnt[3];
1765 GetFocalPoint(theViewWindow,aFocalPnt);
1766 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1767 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1768 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1771 GetCamera(theViewWindow)->GetViewUp(aViewUp);
1772 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1773 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1774 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1776 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theViewWindow));
1778 double aScaleFactor[3];
1779 VISU::GetViewWindow(theViewWindow)->GetScale(aScaleFactor);
1780 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1781 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1782 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1785 void View3D_i::ToStream(std::ostringstream& theStr)
1787 SUIT_ViewWindow* aVW = GetViewWindow();
1789 ToStream(aVW, theStr);
1792 void View3D_i::Close()
1794 //jfa: may be need to be enclosed in SALOME_Event?
1795 SUIT_ViewWindow* aVW = GetViewWindow();
1798 //QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
1799 //int aPos = aViews.find(myViewWindow);
1801 // myViewWindow->close();
1804 View3D_i::~View3D_i()
1806 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1809 void View3D_i::SetTitle (const char* theTitle)
1811 SUIT_ViewWindow* aVW = GetViewWindow();
1813 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1814 (aVW,&SUIT_ViewWindow::setCaption,QString(theTitle)));
1817 char* View3D_i::GetTitle()
1819 SUIT_ViewWindow* aVW = GetViewWindow();
1821 return CORBA::string_dup(aVW->caption().latin1());
1822 return CORBA::string_dup("");
1825 void View3D_i::SetBackground (SUIT_ViewWindow* theViewWindow,
1826 const SALOMEDS::Color& theColor)
1828 //jfa: may be need to be enclosed in SALOME_Event?
1830 aColor[0] = int(255.0*theColor.R);
1831 aColor[1] = int(255.0*theColor.G);
1832 aColor[2] = int(255.0*theColor.B);
1833 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
1834 VISU::GetViewWindow(theViewWindow)->setBackgroundColor(aNewColor);
1837 SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow)
1839 SALOMEDS::Color aColor;
1841 GetRenderer(theViewWindow)->GetBackground(backint);
1842 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1846 class TUpdateViewerEvent: public SALOME_Event
1848 SUIT_ViewWindow* myVW;
1852 TUpdateViewerEvent(SUIT_ViewWindow* theViewWindow,
1855 myVW(theViewWindow),
1857 myDisplaing(theDisplaing)
1859 virtual void Execute(){
1860 UpdateViewer(myVW, myDisplaing, myPrs3d);
1864 void View3D_i::EraseAll()
1866 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1867 SUIT_ViewWindow* aVW = GetViewWindow();
1869 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eEraseAll));
1872 void View3D_i::DisplayAll()
1874 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1875 SUIT_ViewWindow* aVW = GetViewWindow();
1877 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eDisplayAll));
1880 void View3D_i::Erase (PrsObject_ptr thePrsObj)
1882 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1883 SUIT_ViewWindow* aVW = GetViewWindow();
1884 CORBA::Object_ptr anObj = thePrsObj;
1885 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1887 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eErase));
1890 void View3D_i::Display (PrsObject_ptr thePrsObj)
1892 if(MYDEBUG) MESSAGE("View3D_i::Display");
1893 SUIT_ViewWindow* aVW = GetViewWindow();
1894 CORBA::Object_ptr anObj = thePrsObj;
1895 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1897 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay));
1900 void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
1902 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1903 SUIT_ViewWindow* aVW = GetViewWindow();
1904 CORBA::Object_ptr anObj = thePrsObj;
1905 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1907 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly));
1910 void View3D_i::FitAll()
1912 SUIT_ViewWindow* aVW = GetViewWindow();
1914 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1915 (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onFitAll));
1920 void View3D_i::SetView (VISU::View3D::ViewType theType)
1922 SUIT_ViewWindow* aVW = GetViewWindow();
1927 case VISU::View3D::FRONT :
1928 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1929 (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onFrontView));
1931 case VISU::View3D::BACK :
1932 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1933 (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onBackView));
1935 case VISU::View3D::LEFT :
1936 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1937 (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onLeftView));
1939 case VISU::View3D::RIGHT :
1940 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1941 (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onRightView));
1943 case VISU::View3D::TOP :
1944 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1945 (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onTopView));
1947 case VISU::View3D::BOTTOM :
1948 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1949 (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onBottomView));
1955 class TSet3DViewParamEvent: public SALOME_Event
1958 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]);
1959 TSet3DViewParamEvent (TFun theFun,
1960 SUIT_ViewWindow* theViewWindow,
1961 const CORBA::Double theParam[3]):
1963 myVW(theViewWindow),
1966 virtual void Execute() {
1967 myFun(myVW,myParam);
1971 SUIT_ViewWindow* myVW;
1972 const CORBA::Double* myParam;
1975 void View3D_i::SetPointOfView (SUIT_ViewWindow* theViewWindow,
1976 const CORBA::Double thePosition[3])
1978 //jfa: may be need to be enclosed in SALOME_Event?
1979 GetCamera(theViewWindow)->SetPosition(thePosition);
1982 void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
1984 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1985 SUIT_ViewWindow* aVW = GetViewWindow();
1987 ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,aVW,thePosition));
1990 void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow,
1991 CORBA::Double thePosition[3])
1993 GetCamera(theViewWindow)->GetPosition(thePosition);
1996 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
1998 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1999 CORBA::Double aPosition[3];
2000 SUIT_ViewWindow* aVW = GetViewWindow();
2002 GetPointOfView(aVW,aPosition);
2003 return VISU::View3D::XYZ_dup(aPosition);
2006 void View3D_i::SetViewUp (SUIT_ViewWindow* theViewWindow,
2007 const CORBA::Double theViewUp[3])
2009 GetCamera(theViewWindow)->SetViewUp(theViewUp);
2012 void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
2014 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
2015 SUIT_ViewWindow* aVW = GetViewWindow();
2017 ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,aVW,theViewUp));
2020 void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow,
2021 CORBA::Double theViewUp[3])
2023 GetCamera(theViewWindow)->GetViewUp(theViewUp);
2026 VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
2028 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
2029 CORBA::Double aViewUp[3];
2030 SUIT_ViewWindow* aVW = GetViewWindow();
2032 GetCamera(aVW)->GetViewUp(aViewUp);
2033 return VISU::View3D::XYZ_dup(aViewUp);
2036 void View3D_i::SetFocalPoint (SUIT_ViewWindow* theViewWindow,
2037 const CORBA::Double theFocalPnt[3])
2039 GetCamera(theViewWindow)->SetFocalPoint(theFocalPnt);
2042 void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
2044 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
2045 SUIT_ViewWindow* aVW = GetViewWindow();
2047 ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,aVW,theCoord));
2051 void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow,
2052 CORBA::Double theFocalPnt[3])
2054 GetCamera(theViewWindow)->GetFocalPoint(theFocalPnt);
2057 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
2059 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
2060 CORBA::Double aFocalPnt[3];
2061 SUIT_ViewWindow* aVW = GetViewWindow();
2063 GetFocalPoint(aVW,aFocalPnt);
2064 return VISU::View3D::XYZ_dup(aFocalPnt);
2067 class TSetViewParamEvent: public SALOME_Event
2070 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, CORBA::Double theParam);
2071 TSetViewParamEvent (TFun theFun,
2072 SUIT_ViewWindow* theViewWindow,
2073 CORBA::Double theParam):
2075 myVW(theViewWindow),
2078 virtual void Execute()
2080 myFun(myVW,myParam);
2084 SUIT_ViewWindow* myVW;
2085 CORBA::Double myParam;
2088 void View3D_i::SetParallelScale (SUIT_ViewWindow* theViewWindow,
2089 CORBA::Double theScale)
2091 GetCamera(theViewWindow)->SetParallelScale(theScale);
2094 void View3D_i::SetParallelScale (CORBA::Double theScale)
2096 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
2097 SUIT_ViewWindow* aVW = GetViewWindow();
2099 ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,aVW,theScale));
2102 CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow)
2104 return GetCamera(theViewWindow)->GetParallelScale();
2107 CORBA::Double View3D_i::GetParallelScale()
2109 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
2110 SUIT_ViewWindow* aVW = GetViewWindow();
2112 return GetParallelScale(aVW);
2116 void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow,
2117 VISU::View3D::Axis theAxis, CORBA::Double theParam)
2119 SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theViewWindow);
2120 double aScaleFactor[3];
2121 aViewWindow->GetScale(aScaleFactor);
2122 aScaleFactor[theAxis] = theParam;
2123 aViewWindow->SetScale(aScaleFactor);
2126 void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3])
2128 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
2129 VISU::GetViewWindow(theViewWindow)->SetScale(aScale);
2132 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
2134 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
2135 SUIT_ViewWindow* aVW = GetViewWindow();
2138 VISU::GetViewWindow(aVW)->GetScale(aScale);
2139 aScale[theAxis] = theParam;
2140 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2144 void View3D_i::RemoveScale()
2146 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
2147 SUIT_ViewWindow* aVW = GetViewWindow();
2149 double aScale[3] = {1.0, 1.0, 1.0};
2150 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));