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 * myViewWindow;
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),
225 myViewWindow(theViewWindow),
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(myViewWindow, myOrientation, mySplitType);
247 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
248 Qt::Horizontal,QtxWorkstack::SPLIT_MOVE));
255 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
256 Qt::Horizontal,QtxWorkstack::SPLIT_STAY));
263 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
264 Qt::Vertical,QtxWorkstack::SPLIT_MOVE));
271 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
272 Qt::Vertical,QtxWorkstack::SPLIT_STAY));
279 struct TOnTopEvent: public SALOME_Event
281 SUIT_ViewWindow * myViewWindow;
284 TOnTopEvent (SUIT_ViewWindow * theViewWindow):
285 myViewWindow(theViewWindow)
288 virtual void Execute()
291 myViewWindow->setFocus();
296 ProcessVoidEvent(new TOnTopEvent(myViewWindow));
299 struct TAttractEvent: public SALOME_Event
301 SalomeApp_Application * myApplication;
302 SUIT_ViewWindow * myViewWindow1;
303 SUIT_ViewWindow * myViewWindow2;
307 TAttractEvent (SalomeApp_Application * theApplication,
308 SUIT_ViewWindow * theViewWindow1,
309 SUIT_ViewWindow * theViewWindow2,
311 myApplication(theApplication),
312 myViewWindow1(theViewWindow1),
313 myViewWindow2(theViewWindow2),
314 myAttractAll(theAttractAll)
317 virtual void Execute()
319 SUIT_Desktop* desk = myApplication->desktop();
320 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
322 QtxWorkstack* workstack = tabDesk->workstack();
324 workstack->Attract(myViewWindow1, myViewWindow2, myAttractAll);
332 Attract (VISU::View_ptr theView)
334 if (!CORBA::is_nil(theView)) {
335 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
336 ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,false));
343 AttractAll (VISU::View_ptr theView)
345 if (!CORBA::is_nil(theView)) {
346 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
347 ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,true));
352 struct TSizePositionEvent: public SALOME_Event
354 SalomeApp_Application * myApplication;
355 SUIT_ViewWindow * myViewWindow;
360 TSizePositionEvent (SalomeApp_Application * theApplication,
361 SUIT_ViewWindow * theViewWindow,
364 myApplication(theApplication),
365 myViewWindow(theViewWindow),
370 virtual void Execute()
372 MESSAGE("TSizePositionEvent::Execute()");
373 SUIT_Desktop* desk = myApplication->desktop();
374 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
376 QtxWorkstack* workstack = tabDesk->workstack();
379 //jfa to do:workstack->SetRelativeSizeInSplitter(myViewWindow, myValue);
381 workstack->SetRelativePositionInSplitter(myViewWindow, myValue);
390 SetRelativePositionInSplitter (CORBA::Double thePosition)
392 if (thePosition < 0.0 || 1.0 < thePosition) {
395 ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,thePosition,false));
400 SetRelativeSizeInSplitter (CORBA::Double theSize)
402 if (theSize < 0.0 || 1.0 < theSize) {
405 ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,theSize,true));
408 struct TWSSizePositionEvent: public SALOME_Event
410 SalomeApp_Application * myApplication;
411 SUIT_ViewWindow * myViewWindow;
412 Qt::Orientation myOrientation;
417 TWSSizePositionEvent (SalomeApp_Application * theApplication,
418 SUIT_ViewWindow * theViewWindow,
419 Qt::Orientation theOrientation,
422 myApplication(theApplication),
423 myViewWindow(theViewWindow),
424 myOrientation(theOrientation),
429 virtual void Execute()
431 MESSAGE("TWSSizePositionEvent::Execute()");
432 SUIT_Desktop* desk = myApplication->desktop();
433 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
435 QtxWorkstack* workstack = tabDesk->workstack();
438 //jfa to do:workstack->SetRelativeSize(myViewWindow, myOrientation, myValue);
440 workstack->SetRelativePosition(myViewWindow, myOrientation, myValue);
449 SetRelativePositionX (CORBA::Double thePosition)
451 if (thePosition < 0.0 || 1.0 < thePosition) {
454 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
455 Qt::Horizontal,thePosition,false));
460 SetRelativePositionY (CORBA::Double thePosition)
462 if (thePosition < 0.0 || 1.0 < thePosition) {
465 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
466 Qt::Vertical,thePosition,false));
471 SetRelativeSizeX (CORBA::Double theSize)
473 if (theSize < 0.0 || 1.0 < theSize) {
476 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
477 Qt::Horizontal,theSize,true));
482 SetRelativeSizeY (CORBA::Double theSize)
484 if (theSize < 0.0 || 1.0 < theSize) {
487 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
488 Qt::Vertical,theSize,true));
490 // End: New methods for view parameters management
492 // Begin: Old methods for view parameters management, they don't work now
493 struct TSetViewSize: public SALOME_Event
495 SUIT_ViewWindow* myViewWindow;
496 typedef void (QRect::* TAction)(int);
501 TSetViewSize(SUIT_ViewWindow* theViewWindow,
503 CORBA::Long theSize):
504 myViewWindow(theViewWindow),
513 if (QWidget* aParent = myViewWindow->parentWidget(true)) {
514 QRect aQRect = aParent->frameGeometry();
515 (aQRect.*myAction)(mySize);
516 aParent->setGeometry(aQRect);
523 SetViewWidth(CORBA::Long theWidth)
525 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
530 SetViewHeight(CORBA::Long theHeight)
532 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
536 struct TGetViewSize: public SALOME_Event
538 SUIT_ViewWindow* myViewWindow;
540 typedef int (QRect::* TAction)() const;
543 typedef CORBA::Long TResult;
547 TGetViewSize(SUIT_ViewWindow* theViewWindow,
549 myViewWindow(theViewWindow),
557 if(QWidget* aParent = myViewWindow->parentWidget(true)){
558 QRect aQRect = aParent->frameGeometry();
559 myResult = (aQRect.*myAction)();
569 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
576 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
580 class TWorkspaceEvent: public SALOME_Event
583 QWidget* myViewWindow;
584 QWidget* myWorkspace;
587 TWorkspaceEvent(QWidget* theViewWindow,
588 QWidget* theWorkspace):
589 myViewWindow(theViewWindow),
590 myWorkspace(theWorkspace)
595 class TAlignEvent: public TWorkspaceEvent
598 Qt::AlignmentFlags myAligment;
601 TAlignEvent(QWidget* theViewWindow,
602 QWidget* theWorkspace,
603 Qt::AlignmentFlags theAligment):
604 TWorkspaceEvent(theViewWindow,theWorkspace),
605 myAligment(theAligment)
612 if(QWidget* aParent = myViewWindow->parentWidget(true))
613 SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
620 SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
623 switch (theViewPosition) {
624 case VISU::View::LEFT:
625 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
627 case VISU::View::CENTER:
628 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
630 case VISU::View::RIGHT:
631 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
640 SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
643 switch (theViewPosition) {
644 case VISU::View::TOP:
645 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
647 case VISU::View::CENTER:
648 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
650 case VISU::View::BOTTOM:
651 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
658 class TXYEvent: public TWorkspaceEvent
661 CORBA::Double myX, myY;
664 TXYEvent(QWidget* theViewWindow,
665 QWidget* theWorkspace,
668 TWorkspaceEvent(theViewWindow,theWorkspace),
677 SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
679 struct TEvent: public TXYEvent
682 TEvent(QWidget* theViewWindow,
683 QWidget* theWorkspace,
686 TXYEvent(theViewWindow,theWorkspace,theX,theY)
693 if(QWidget* aParent = myViewWindow->parentWidget(true))
694 aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
699 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
704 SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
706 struct TEvent: public TXYEvent
709 TEvent(QWidget* theViewWindow,
710 QWidget* theWorkspace,
713 TXYEvent(theViewWindow,theWorkspace,theX,theY)
720 if(QWidget* aParent = myViewWindow->parentWidget(true))
721 aParent->setGeometry(aParent->x(),
723 int(myX*myWorkspace->width()),
724 int(myY*myWorkspace->height()));
729 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
731 // End: Old methods for view parameters management, they don't work now
735 SetBackground (const SALOMEDS::Color& theColor)
737 struct TEvent: public SALOME_Event
740 SALOMEDS::Color myColor;
742 TEvent(QWidget* theWidget,
743 const SALOMEDS::Color& theColor):
747 virtual void Execute(){
749 aColor[0] = int(255.0*myColor.R);
750 aColor[1] = int(255.0*myColor.G);
751 aColor[2] = int(255.0*myColor.B);
752 myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2]));
756 ProcessVoidEvent(new TEvent(myViewWindow,theColor));
760 struct TBackgroundEvent: public SALOME_Event
763 typedef SALOMEDS::Color TResult;
766 TBackgroundEvent(QWidget* theWidget):
774 const QColor& aColor = myWidget->backgroundColor();
775 myResult.R = aColor.red()/255.0;
776 myResult.G = aColor.green()/255.0;
777 myResult.B = aColor.blue()/255.0;
785 return ProcessEvent(new TBackgroundEvent(myViewWindow));
792 ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMinimized));
799 ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showNormal));
806 ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMaximized));
821 Erase (PrsObject_ptr thePrsObj)
826 Display (PrsObject_ptr thePrsObj)
831 DisplayOnly (PrsObject_ptr thePrsObj)
839 class TSavePictureEvent: public SALOME_Event
841 SUIT_ViewWindow * myViewWindow;
842 const char * myFileName;
844 typedef CORBA::Boolean TResult;
846 TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
847 : myViewWindow(theViewWindow),
848 myFileName(theFileName),
853 virtual void Execute()
856 QImage img = myViewWindow->dumpView();
858 QString fileName (myFileName);
859 if (!fileName.isEmpty()) {
860 QString fmt = SUIT_Tools::extension(fileName).upper();
861 if (fmt.isEmpty()) fmt = QString("BMP"); // default format
862 if (fmt == "JPG" ) fmt = "JPEG";
863 //QApplication::setOverrideCursor(Qt::waitCursor);
864 img.save(fileName, fmt.latin1());
865 //QApplication::restoreOverrideCursor();
873 View_i::SavePicture(const char* theFileName)
875 return ProcessEvent(new TSavePictureEvent (myViewWindow,theFileName));
887 ToStream (std::ostringstream& theStr)
892 //================= OLD CODE ===================
894 //QAD_Study* CheckStudy (SALOMEDS::Study_ptr theStudy)
896 // //QAD_Desktop* aDesktop = QAD_Application::getDesktop();
897 // //QAD_Study* aStudy = aDesktop->findStudy(theStudy);
899 // CORBA::String_var aName = theStudy->Name();
900 // aFileInfo.setFile(aName.in());
901 // if (aFileInfo.exists())
902 // aStudy = aDesktop->loadStudy(aFileInfo.baseName());
904 // aStudy = aDesktop->loadStudy(aName.in());
906 // MESSAGE("CheckStudy()::ERROR: Can't load study");
912 template<class TViewer>
913 struct TNewSpecViewEvent: public SALOME_Event
915 SalomeApp_Application* myApplication;
917 typedef SUIT_ViewManager* TResult;
920 TNewSpecViewEvent (SalomeApp_Application* theApplication):
921 myApplication(theApplication),
929 myResult = myApplication->getViewManager(TViewer::Type(), false);
931 myResult = myApplication->getViewManager(TViewer::Type(), true);
932 myResult->closeAllViews();
937 //===========================================================================
938 XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
939 : View_i(theApplication, NULL)
941 if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
942 if (theApplication) {
943 myViewManager = ProcessEvent(new TNewSpecViewEvent<SPlot2d_Viewer>(theApplication));
948 struct TCreatePlot2dViewEvent: public SALOME_Event
950 SUIT_ViewManager* myViewManager;
951 XYPlot_i * myPlot2dView;
954 typedef Plot2d_ViewFrame* TResult;
957 TCreatePlot2dViewEvent (SUIT_ViewManager* theViewManager,
958 XYPlot_i * thePlot2dView,
960 myViewManager(theViewManager),
961 myPlot2dView(thePlot2dView),
971 myPlot2dView->myViewWindow = myViewManager->createViewWindow();
973 myPlot2dView->myViewWindow = myViewManager->getActiveView();
975 if (myPlot2dView->myViewWindow) {
976 Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myPlot2dView->myViewWindow);
978 myResult = aPlot2dVW->getViewFrame();
987 Storable* XYPlot_i::Create (int theNew)
989 myView = ProcessEvent(new TCreatePlot2dViewEvent(myViewManager, this, theNew));
993 void XYPlot_i::Update()
995 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
998 void XYPlot_i::Close()
1000 //jfa: may be need to be enclosed in SALOME_Event?
1001 myViewWindow->close();
1004 XYPlot_i::~XYPlot_i() {
1005 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1008 void XYPlot_i::SetTitle (const char* theTitle)
1010 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1011 (myViewWindow, &SUIT_ViewWindow::setCaption, QString(theTitle)));
1013 char* XYPlot_i::GetTitle()
1015 //jfa: may be need to be enclosed in SALOME_Event?
1016 return CORBA::string_dup(myViewWindow->caption().latin1());
1019 void XYPlot_i::SetSubTitle (const char* theTitle)
1021 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1022 (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1025 char* XYPlot_i::GetSubTitle()
1027 //jfa: may be need to be enclosed in SALOME_Event?
1028 return CORBA::string_dup(myView->getTitle());
1031 void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1033 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1034 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1037 VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1039 //jfa: may be need to be enclosed in SALOME_Event?
1040 return (VISU::XYPlot::CurveType)myView->getCurveType();
1043 void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1045 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1046 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1049 CORBA::Long XYPlot_i::GetMarkerSize()
1051 //jfa: may be need to be enclosed in SALOME_Event?
1052 return myView->getMarkerSize();
1055 class TEnableGridEvent: public SALOME_Event
1058 typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool);
1059 TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun,
1060 CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1061 CORBA::Boolean theMinor, CORBA::Long theNumMinor):
1062 myView(theView), myFun(theFun),
1063 myMajor(theMajor), myNumMajor(theNumMajor),
1064 myMinor(theMinor), myNumMinor(theNumMinor)
1067 virtual void Execute()
1069 (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true);
1072 Plot2d_ViewFrame* myView;
1074 CORBA::Boolean myMajor, myMinor;
1075 CORBA::Long myNumMajor, myNumMinor;
1078 void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1079 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1081 ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
1082 theMajor,theNumMajor,theMinor,theNumMinor));
1084 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1085 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1087 //asl: Plot2d_ViewFrame::setYGrid has more parameters
1088 //ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
1089 // theMajor,theNumMajor,theMinor,theNumMinor));
1092 class TSetScaleModeEvent: public SALOME_Event
1095 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1096 TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1097 myView(theView), myFun(theFun), myScaling(theScaling)
1100 virtual void Execute()
1102 (myView->*myFun)(myScaling,true);
1105 Plot2d_ViewFrame* myView;
1110 void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1112 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1113 theScaling == VISU::LOGARITHMIC));
1116 VISU::Scaling XYPlot_i::GetHorScaling()
1118 //jfa: may be need to be enclosed in SALOME_Event?
1119 return (VISU::Scaling)myView->getHorScaleMode();
1122 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1124 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1125 theScaling == VISU::LOGARITHMIC));
1128 VISU::Scaling XYPlot_i::GetVerScaling()
1130 //jfa: may be need to be enclosed in SALOME_Event?
1131 return (VISU::Scaling)myView->getVerScaleMode();
1134 class TSetTitleEvent: public SALOME_Event
1137 TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1138 myView(theView), myType(theType), myTitle(theTitle)
1140 virtual void Execute()
1142 myView->setTitle(true,myTitle,myType);
1145 Plot2d_ViewFrame* myView;
1146 Plot2d_ViewFrame::ObjectType myType;
1147 const char* myTitle;
1150 void XYPlot_i::SetXTitle (const char* theTitle)
1152 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1154 char* XYPlot_i::GetXTitle()
1156 //jfa: may be need to be enclosed in SALOME_Event?
1157 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
1160 void XYPlot_i::SetYTitle (const char* theTitle)
1162 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1164 char* XYPlot_i::GetYTitle()
1166 //jfa: may be need to be enclosed in SALOME_Event?
1167 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
1170 void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1172 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1173 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1176 class TXYPlotViewEvent: public SALOME_Event
1178 SalomeApp_Application* myApplication;
1179 Plot2d_ViewFrame* myView;
1180 PrsObject_ptr myPrsObj;
1184 TXYPlotViewEvent(SalomeApp_Application* theApplication,
1185 Plot2d_ViewFrame* theView,
1186 PrsObject_ptr thePrsObj,
1188 : myApplication(theApplication),
1190 myPrsObj(thePrsObj),
1191 myDisplaing(theDisplaing)
1195 virtual void Execute()
1198 if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1199 UpdatePlot2d(myView,myDisplaing,aCurve);
1201 // is it Container ?
1202 if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1203 int nbCurves = aContainer->GetNbCurves();
1204 for ( int i = 1; i <= nbCurves; i++ ) {
1205 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1206 if ( aCurve && aCurve->IsValid() ) {
1207 UpdatePlot2d(myView,myDisplaing,aCurve);
1213 if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1214 _PTR(Study) aCStudy;
1215 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1216 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1217 aCStudy = aStudy->studyDS();
1220 if (!aCStudy) return;
1221 _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
1223 _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1224 for (; Iter->More(); Iter->Next()) {
1225 CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1226 if (!CORBA::is_nil(childObject)) {
1227 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1228 if (!CORBA::is_nil(aCurve))
1229 UpdatePlot2d(myView, myDisplaing,
1230 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
1239 void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1241 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1244 void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1246 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1249 void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1251 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1254 void XYPlot_i::EraseAll()
1256 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1259 void XYPlot_i::FitAll()
1261 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1265 //===========================================================================
1266 TableView_i::TableView_i (SalomeApp_Application* theApplication)
1267 : View_i(theApplication, NULL)
1271 struct TCreateTableViewEvent: public SALOME_Event
1273 SalomeApp_Application* myApplication;
1274 VISU::Table_i* myTable;
1276 typedef VisuGUI_TableDlg* TResult;
1279 TCreateTableViewEvent (SalomeApp_Application* theApplication,
1280 VISU::Table_i* theTable):
1281 myApplication(theApplication),
1290 if (myTable != NULL) {
1291 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1292 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1293 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1294 _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
1296 myResult = new VisuGUI_TableDlg (myApplication->desktop(),
1299 VisuGUI_TableDlg::ttAuto,
1310 Storable* TableView_i::Create (VISU::Table_ptr theTable)
1312 if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1313 if (!theTable->_is_nil()) {
1314 VISU::Table_i* table =
1315 dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1316 if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1318 myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1325 TableView_i::~TableView_i()
1327 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1331 void TableView_i::SetTitle (const char* theTitle)
1333 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
1334 (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
1337 char* TableView_i::GetTitle()
1339 //jfa: may be need to be enclosed in SALOME_Event?
1340 return CORBA::string_dup(myView->caption().latin1());
1343 void TableView_i::Close()
1345 //jfa: may be need to be enclosed in SALOME_Event?
1350 //===========================================================================
1351 int View3D_i::myNbViewParams = 0;
1352 const string View3D_i::myComment = "VIEW3D";
1353 const char* View3D_i::GetComment() const { return myComment.c_str();}
1355 QString View3D_i::GenerateViewParamsName()
1357 return VISU::GenerateName("ViewParams", ++myNbViewParams);
1360 View3D_i::View3D_i (SalomeApp_Application* theApplication)
1361 : View_i(theApplication, NULL)
1363 if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1364 if (theApplication) {
1365 myViewManager = ProcessEvent(new TNewSpecViewEvent<SVTK_Viewer>(theApplication));
1369 struct TCreateView3dEvent: public SALOME_Event
1371 SUIT_ViewManager* myViewManager;
1374 typedef SUIT_ViewWindow* TResult;
1377 TCreateView3dEvent (SUIT_ViewManager* theViewManager,
1379 myViewManager(theViewManager),
1389 myResult = myViewManager->createViewWindow();
1391 myResult = myViewManager->getActiveView();
1396 Storable* View3D_i::Create (int theNew)
1398 if (MYDEBUG) MESSAGE("View3D_i::Create");
1399 myViewWindow = ProcessEvent(new TCreateView3dEvent(myViewManager, theNew));
1403 void View3D_i::Update()
1405 class TEvent: public SALOME_Event
1407 SUIT_ViewWindow* myViewWindow;
1409 TEvent(SUIT_ViewWindow* theStudyFrame):
1410 myViewWindow(theStudyFrame)
1412 virtual void Execute()
1414 SVTK_ViewWindow* vf = GetViewWindow(myViewWindow);
1415 vtkRenderer* Renderer = vf->getRenderer();
1416 vtkActorCollection* theActors = Renderer->GetActors();
1417 theActors->InitTraversal();
1418 while (vtkActor *anAct = theActors->GetNextActor()) {
1419 if (VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)) {
1420 VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
1421 if (anActor->GetVisibility() && aPrs3d) {
1423 aPrs3d->UpdateActor(anActor);
1427 RepaintView(myViewWindow);
1430 ProcessVoidEvent(new TEvent(myViewWindow));
1433 bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1435 MESSAGE("View3D_i::SaveViewParams()");
1436 _PTR(Study) aCStudy;
1437 if (SUIT_Study* aSStudy = theViewManager->study()) {
1438 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1439 aCStudy = aStudy->studyDS();
1446 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1447 _PTR(GenericAttribute) anAttr;
1448 int iEnd = aList.size();
1449 for (int i = 0; i < iEnd; i++) {
1450 _PTR(SObject) anObj = aList[i];
1451 string anEntry = anObj->GetID();
1452 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1453 if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1454 _PTR(AttributeComment) aCmnt (anAttr);
1455 string aComm (aCmnt->Value());
1456 if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1457 if (aComm.compare(View3D_i::myComment) >= 0) {
1458 aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1464 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1465 string aSComponentEntry = aSComponent->GetID();
1466 string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
1467 ToString(theViewManager->getActiveView()).c_str());
1471 class TSaveViewParamsEvent: public SALOME_Event
1473 SUIT_ViewManager* myViewManager;
1476 TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1477 const char* theName):
1478 myViewManager(theViewManager),
1482 virtual void Execute()
1484 myResult = View3D_i::SaveViewParams(myViewManager, myName);
1486 typedef CORBA::Boolean TResult;
1490 CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
1492 return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName));
1495 bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1497 _PTR(Study) aCStudy;
1498 if (SUIT_Study* aSStudy = theViewManager->study()) {
1499 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1500 aCStudy = aStudy->studyDS();
1506 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1507 _PTR(GenericAttribute) anAttr;
1508 int iEnd = aList.size();
1509 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1510 for (int i = 0; i < iEnd; i++) {
1511 _PTR(SObject) anObj = aList[i];
1512 string anEntry = anObj->GetID();
1513 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1514 if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1515 _PTR(AttributeComment) aCmnt (anAttr);
1516 QString strIn(aCmnt->Value().c_str());
1517 Storable::TRestoringMap aMap;
1518 Storable::StrToMap(strIn, aMap);
1519 if (Storable::FindValue(aMap, "myComment").compare
1520 (View3D_i::myComment.c_str()) >= 0) {
1521 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn);
1522 Restore(theViewManager->getActiveView(), aMap);
1530 class TRestoreViewParamsEvent: public SALOME_Event
1532 SUIT_ViewManager* myViewManager;
1535 TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1536 const char* theName):
1537 myViewManager(theViewManager),
1541 virtual void Execute()
1543 myResult = View3D_i::RestoreViewParams(myViewManager, myName);
1545 typedef CORBA::Boolean TResult;
1549 CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
1551 return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
1554 void View3D_i::Restore (SUIT_ViewWindow* theStudyFrame,
1555 const Storable::TRestoringMap& theMap)
1557 SALOMEDS::Color aColor;
1558 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1559 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1560 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1562 double aPosition[3];
1563 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1564 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1565 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1567 double aFocalPnt[3];
1568 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1569 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1570 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1573 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1574 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1575 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1577 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1579 double aScaleFactor[3];
1580 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1581 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1582 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1584 SetBackground(theStudyFrame,aColor);
1585 SetPointOfView(theStudyFrame,aPosition);
1586 SetViewUp(theStudyFrame,aViewUp);
1587 SetFocalPoint(theStudyFrame,aFocalPnt);
1588 SetParallelScale(theStudyFrame,aParallelScale);
1589 ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1590 ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1591 ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1595 string View3D_i::ToString (SUIT_ViewWindow* theStudyFrame)
1597 ostringstream strOut;
1598 Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1599 ToStream(theStudyFrame,strOut);
1601 if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1602 return strOut.str();
1605 void View3D_i::ToStream (SUIT_ViewWindow* theStudyFrame, std::ostringstream& theStr)
1607 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1610 GetRenderer(theStudyFrame)->GetBackground(backint);
1611 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1612 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1613 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1615 double aPosition[3];
1616 GetPointOfView(theStudyFrame,aPosition);
1617 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1618 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1619 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1621 double aFocalPnt[3];
1622 GetFocalPoint(theStudyFrame,aFocalPnt);
1623 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1624 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1625 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1628 GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1629 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1630 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1631 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1633 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1635 double aScaleFactor[3];
1636 GetViewWindow(theStudyFrame)->GetScale(aScaleFactor);
1637 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1638 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1639 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1642 void View3D_i::ToStream(std::ostringstream& theStr)
1644 ToStream(myViewWindow,theStr);
1647 void View3D_i::Close()
1649 //jfa: may be need to be enclosed in SALOME_Event?
1650 myViewWindow->close();
1653 View3D_i::~View3D_i()
1655 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1658 void View3D_i::SetTitle (const char* theTitle)
1660 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1661 (myViewWindow,&SUIT_ViewWindow::setCaption,QString(theTitle)));
1664 char* View3D_i::GetTitle()
1666 //jfa: may be need to be enclosed in SALOME_Event?
1667 return CORBA::string_dup(myViewWindow->caption().latin1());
1670 void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame,
1671 const SALOMEDS::Color& theColor)
1673 //jfa: may be need to be enclosed in SALOME_Event?
1675 aColor[0] = int(255.0*theColor.R);
1676 aColor[1] = int(255.0*theColor.G);
1677 aColor[2] = int(255.0*theColor.B);
1678 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1679 GetViewWindow(theStudyFrame)->setBackgroundColor(aNewColor);
1682 SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame)
1684 //jfa: may be need to be enclosed in SALOME_Event?
1685 SALOMEDS::Color aColor;
1687 GetRenderer(theStudyFrame)->GetBackground(backint);
1688 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1692 class TUpdateViewerEvent: public SALOME_Event
1694 SUIT_ViewWindow* myViewWindow;
1698 TUpdateViewerEvent(SUIT_ViewWindow* theStudyFrame,
1701 myViewWindow(theStudyFrame),
1703 myDisplaing(theDisplaing)
1705 virtual void Execute(){
1706 UpdateViewer(myViewWindow,myDisplaing,myPrs3d);
1710 void View3D_i::EraseAll()
1712 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1713 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eEraseAll));
1716 void View3D_i::DisplayAll()
1718 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1719 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eDisplayAll));
1722 void View3D_i::Erase (PrsObject_ptr thePrsObj)
1724 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1725 CORBA::Object_ptr anObj = thePrsObj;
1726 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1727 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eErase));
1731 void View3D_i::Display (PrsObject_ptr thePrsObj)
1733 if(MYDEBUG) MESSAGE("View3D_i::Display");
1734 CORBA::Object_ptr anObj = thePrsObj;
1735 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1736 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplay));
1740 void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
1742 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1743 CORBA::Object_ptr anObj = thePrsObj;
1744 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1745 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplayOnly));
1749 void View3D_i::FitAll()
1751 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1752 (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFitAll));
1756 void View3D_i::SetView (VISU::View3D::ViewType theType)
1759 case VISU::View3D::FRONT :
1760 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1761 (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFrontView));
1763 case VISU::View3D::BACK :
1764 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1765 (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onBackView));
1767 case VISU::View3D::LEFT :
1768 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1769 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onLeftView));
1771 case VISU::View3D::RIGHT :
1772 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1773 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onRightView));
1775 case VISU::View3D::TOP :
1776 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1777 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onTopView));
1779 case VISU::View3D::BOTTOM :
1780 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1781 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onBottomView));
1787 class TSet3DViewParamEvent: public SALOME_Event
1790 typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, const CORBA::Double theParam[3]);
1791 TSet3DViewParamEvent (TFun theFun,
1792 SUIT_ViewWindow* theStudyFrame,
1793 const CORBA::Double theParam[3]):
1795 myViewWindow(theStudyFrame),
1798 virtual void Execute(){
1799 myFun(myViewWindow,myParam);
1803 SUIT_ViewWindow* myViewWindow;
1804 const CORBA::Double* myParam;
1807 void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame,
1808 const CORBA::Double thePosition[3])
1810 //jfa: may be need to be enclosed in SALOME_Event?
1811 GetCamera(theStudyFrame)->SetPosition(thePosition);
1814 void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
1816 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1817 ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myViewWindow,thePosition));
1820 void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame,
1821 CORBA::Double thePosition[3])
1823 //jfa: may be need to be enclosed in SALOME_Event?
1824 GetCamera(theStudyFrame)->GetPosition(thePosition);
1827 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
1829 //jfa: may be need to be enclosed in SALOME_Event?
1830 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1831 CORBA::Double aPosition[3];
1832 GetPointOfView(myViewWindow,aPosition);
1833 return VISU::View3D::XYZ_dup(aPosition);
1836 void View3D_i::SetViewUp (SUIT_ViewWindow* theStudyFrame,
1837 const CORBA::Double theViewUp[3])
1839 GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1842 void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
1844 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1845 ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myViewWindow,theViewUp));
1848 void View3D_i::GetViewUp (SUIT_ViewWindow* theStudyFrame,
1849 CORBA::Double theViewUp[3])
1851 GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1854 VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
1856 //jfa: may be need to be enclosed in SALOME_Event?
1857 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1858 CORBA::Double aViewUp[3];
1859 GetCamera(myViewWindow)->GetViewUp(aViewUp);
1860 return VISU::View3D::XYZ_dup(aViewUp);
1863 void View3D_i::SetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1864 const CORBA::Double theFocalPnt[3])
1866 GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1869 void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
1871 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1872 ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myViewWindow,theCoord));
1876 void View3D_i::GetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1877 CORBA::Double theFocalPnt[3])
1879 GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1882 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
1884 //jfa: may be need to be enclosed in SALOME_Event?
1885 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1886 CORBA::Double aFocalPnt[3];
1887 GetFocalPoint(myViewWindow,aFocalPnt);
1888 return VISU::View3D::XYZ_dup(aFocalPnt);
1891 class TSetViewParamEvent: public SALOME_Event
1894 typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, CORBA::Double theParam);
1895 TSetViewParamEvent (TFun theFun,
1896 SUIT_ViewWindow* theStudyFrame,
1897 CORBA::Double theParam):
1899 myViewWindow(theStudyFrame),
1902 virtual void Execute()
1904 myFun(myViewWindow,myParam);
1908 SUIT_ViewWindow* myViewWindow;
1909 CORBA::Double myParam;
1912 void View3D_i::SetParallelScale (SUIT_ViewWindow* theStudyFrame,
1913 CORBA::Double theScale)
1915 GetCamera(theStudyFrame)->SetParallelScale(theScale);
1918 void View3D_i::SetParallelScale (CORBA::Double theScale)
1920 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1921 ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myViewWindow,theScale));
1924 CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theStudyFrame)
1926 return GetCamera(theStudyFrame)->GetParallelScale();
1929 CORBA::Double View3D_i::GetParallelScale()
1931 //jfa: may be need to be enclosed in SALOME_Event?
1932 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1933 return GetParallelScale(myViewWindow);
1936 void View3D_i::ScaleView (SUIT_ViewWindow* theStudyFrame,
1937 VISU::View3D::Axis theAxis, CORBA::Double theParam)
1939 SVTK_ViewWindow* aViewFrame = GetViewWindow(theStudyFrame);
1940 double aScaleFactor[3];
1941 aViewFrame->GetScale(aScaleFactor);
1942 aScaleFactor[theAxis] = theParam;
1943 aViewFrame->SetScale(aScaleFactor);
1946 void SetScaleView (SUIT_ViewWindow* theStudyFrame, const CORBA::Double theScale[3])
1948 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1949 GetViewWindow(theStudyFrame)->SetScale(aScale);
1952 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
1954 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1956 GetViewWindow(myViewWindow)->GetScale(aScale);
1957 aScale[theAxis] = theParam;
1958 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
1961 void View3D_i::RemoveScale()
1963 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1964 double aScale[3] = {1.0, 1.0, 1.0};
1965 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));