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"
53 #include "Plot2d_ViewModel.h"
55 #include "SalomeApp_Application.h"
56 #include "SalomeApp_Study.h"
58 #include <QtxWorkstack.h>
60 #include <qworkspace.h>
62 #include <vtkCamera.h>
63 #include <vtkRenderer.h>
68 static int MYDEBUG = 0;
70 static int MYDEBUG = 0;
75 typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
77 struct TNewViewEvent: public SALOME_Event
79 SalomeApp_Application* myApplication;
80 typedef QWidget* TResult;
83 TNewViewEvent (SalomeApp_Application* theApplication):
84 myApplication(theApplication),
92 if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
93 myResult = aDesktop->workspace();
99 View_i (SalomeApp_Application *theApplication,
100 SUIT_ViewManager* theViewManager):
101 myApplication(theApplication),
103 myViewManager(theViewManager)
105 if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
106 myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
112 if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
116 struct TApplicationEvent: public SALOME_Event
118 SalomeApp_Application* myApplication;
120 TApplicationEvent(SalomeApp_Application* theApplication):
121 myApplication(theApplication)
127 ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
128 CORBA::Boolean theState)
130 struct TEvent: public TApplicationEvent
132 VISU::View::ViewRepresentation myViewRepresentation;
133 CORBA::Boolean myState;
135 TEvent(SalomeApp_Application* theApplication,
136 VISU::View::ViewRepresentation theViewRepresentation,
137 CORBA::Boolean theState):
138 TApplicationEvent(theApplication),
139 myViewRepresentation(theViewRepresentation),
147 switch(myViewRepresentation){
148 case VISU::View::OBJECTBROWSER:
149 myApplication->setWindowShown(SalomeApp_Application::WT_ObjectBrowser,myState);
151 case VISU::View::PYTHON:
152 myApplication->setWindowShown(SalomeApp_Application::WT_PyConsole,myState);
154 case VISU::View::MESSAGES:
155 myApplication->setWindowShown(SalomeApp_Application::WT_LogWindow,myState);
157 case VISU::View::VIEWER:{
158 ViewManagerList aViewManagerList = myApplication->viewManagers();
166 ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
169 struct TPartShownEvent: public TApplicationEvent
171 VISU::View::ViewRepresentation myViewRepresentation;
172 typedef bool TResult;
175 TPartShownEvent(SalomeApp_Application* theApplication,
176 VISU::View::ViewRepresentation theViewRepresentation):
177 TApplicationEvent(theApplication),
178 myViewRepresentation(theViewRepresentation),
186 switch(myViewRepresentation){
187 case VISU::View::OBJECTBROWSER:
188 myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_ObjectBrowser);
190 case VISU::View::PYTHON:
191 myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_PyConsole);
193 case VISU::View::MESSAGES:
194 myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_LogWindow);
196 case VISU::View::VIEWER:{
197 ViewManagerList aViewManagerList = myApplication->viewManagers();
207 IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
209 return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
212 // Begin: New methods for view parameters management
213 struct TSplitEvent: public SALOME_Event
215 SalomeApp_Application * myApplication;
216 SUIT_ViewWindow * myViewWindow;
217 Qt::Orientation myOrientation;
218 QtxWorkstack::SplitType mySplitType;
221 TSplitEvent (SalomeApp_Application * theApplication,
222 SUIT_ViewWindow * theViewWindow,
223 Qt::Orientation theOrientation,
224 QtxWorkstack::SplitType theSplitType):
225 myApplication(theApplication),
226 myViewWindow(theViewWindow),
227 myOrientation(theOrientation),
228 mySplitType(theSplitType)
231 virtual void Execute()
233 SUIT_Desktop* desk = myApplication->desktop();
234 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
236 QtxWorkstack* workstack = tabDesk->workstack();
238 workstack->Split(myViewWindow, myOrientation, mySplitType);
248 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
249 Qt::Horizontal,QtxWorkstack::SPLIT_MOVE));
256 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
257 Qt::Horizontal,QtxWorkstack::SPLIT_STAY));
264 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
265 Qt::Vertical,QtxWorkstack::SPLIT_MOVE));
272 ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
273 Qt::Vertical,QtxWorkstack::SPLIT_STAY));
280 struct TOnTopEvent: public SALOME_Event
282 SalomeApp_Application * myApplication;
283 SUIT_ViewWindow * myViewWindow;
286 TOnTopEvent (SalomeApp_Application * theApplication,
287 SUIT_ViewWindow * theViewWindow):
288 myApplication(theApplication),
289 myViewWindow(theViewWindow)
292 virtual void Execute()
294 SUIT_Desktop* desk = myApplication->desktop();
295 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
297 QtxWorkstack* workstack = tabDesk->workstack();
299 workstack->OnTop(myViewWindow);
305 ProcessVoidEvent(new TOnTopEvent(myApplication,myViewWindow));
308 struct TAttractEvent: public SALOME_Event
310 SalomeApp_Application * myApplication;
311 SUIT_ViewWindow * myViewWindow1;
312 SUIT_ViewWindow * myViewWindow2;
316 TAttractEvent (SalomeApp_Application * theApplication,
317 SUIT_ViewWindow * theViewWindow1,
318 SUIT_ViewWindow * theViewWindow2,
320 myApplication(theApplication),
321 myViewWindow1(theViewWindow1),
322 myViewWindow2(theViewWindow2),
323 myAttractAll(theAttractAll)
326 virtual void Execute()
328 SUIT_Desktop* desk = myApplication->desktop();
329 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
331 QtxWorkstack* workstack = tabDesk->workstack();
333 workstack->Attract(myViewWindow1, myViewWindow2, myAttractAll);
341 Attract (VISU::View_ptr theView)
343 if (!CORBA::is_nil(theView)) {
344 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
345 ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,false));
352 AttractAll (VISU::View_ptr theView)
354 if (!CORBA::is_nil(theView)) {
355 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
356 ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,true));
361 struct TSizePositionEvent: public SALOME_Event
363 SalomeApp_Application * myApplication;
364 SUIT_ViewWindow * myViewWindow;
369 TSizePositionEvent (SalomeApp_Application * theApplication,
370 SUIT_ViewWindow * theViewWindow,
373 myApplication(theApplication),
374 myViewWindow(theViewWindow),
379 virtual void Execute()
381 MESSAGE("TSizePositionEvent::Execute()");
382 SUIT_Desktop* desk = myApplication->desktop();
383 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
385 QtxWorkstack* workstack = tabDesk->workstack();
388 //jfa to do:workstack->SetRelativeSizeInSplitter(myViewWindow, myValue);
390 workstack->SetRelativePositionInSplitter(myViewWindow, myValue);
399 SetRelativePositionInSplitter (CORBA::Double thePosition)
401 if (thePosition < 0.0 || 1.0 < thePosition) {
404 ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,thePosition,false));
409 SetRelativeSizeInSplitter (CORBA::Double theSize)
411 if (theSize < 0.0 || 1.0 < theSize) {
414 ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,theSize,true));
417 struct TWSSizePositionEvent: public SALOME_Event
419 SalomeApp_Application * myApplication;
420 SUIT_ViewWindow * myViewWindow;
421 Qt::Orientation myOrientation;
426 TWSSizePositionEvent (SalomeApp_Application * theApplication,
427 SUIT_ViewWindow * theViewWindow,
428 Qt::Orientation theOrientation,
431 myApplication(theApplication),
432 myViewWindow(theViewWindow),
433 myOrientation(theOrientation),
438 virtual void Execute()
440 MESSAGE("TWSSizePositionEvent::Execute()");
441 SUIT_Desktop* desk = myApplication->desktop();
442 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
444 QtxWorkstack* workstack = tabDesk->workstack();
447 //jfa to do:workstack->SetRelativeSize(myViewWindow, myOrientation, myValue);
449 workstack->SetRelativePosition(myViewWindow, myOrientation, myValue);
458 SetRelativePositionX (CORBA::Double thePosition)
460 if (thePosition < 0.0 || 1.0 < thePosition) {
463 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
464 Qt::Horizontal,thePosition,false));
469 SetRelativePositionY (CORBA::Double thePosition)
471 if (thePosition < 0.0 || 1.0 < thePosition) {
474 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
475 Qt::Vertical,thePosition,false));
480 SetRelativeSizeX (CORBA::Double theSize)
482 if (theSize < 0.0 || 1.0 < theSize) {
485 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
486 Qt::Horizontal,theSize,true));
491 SetRelativeSizeY (CORBA::Double theSize)
493 if (theSize < 0.0 || 1.0 < theSize) {
496 ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
497 Qt::Vertical,theSize,true));
499 // End: New methods for view parameters management
501 // Begin: Old methods for view parameters management, they don't work now
502 struct TSetViewSize: public SALOME_Event
504 SUIT_ViewWindow* myViewWindow;
505 typedef void (QRect::* TAction)(int);
510 TSetViewSize(SUIT_ViewWindow* theViewWindow,
512 CORBA::Long theSize):
513 myViewWindow(theViewWindow),
522 if (QWidget* aParent = myViewWindow->parentWidget(true)) {
523 QRect aQRect = aParent->frameGeometry();
524 (aQRect.*myAction)(mySize);
525 aParent->setGeometry(aQRect);
532 SetViewWidth(CORBA::Long theWidth)
534 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
539 SetViewHeight(CORBA::Long theHeight)
541 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
545 struct TGetViewSize: public SALOME_Event
547 SUIT_ViewWindow* myViewWindow;
549 typedef int (QRect::* TAction)() const;
552 typedef CORBA::Long TResult;
556 TGetViewSize(SUIT_ViewWindow* theViewWindow,
558 myViewWindow(theViewWindow),
566 if(QWidget* aParent = myViewWindow->parentWidget(true)){
567 QRect aQRect = aParent->frameGeometry();
568 myResult = (aQRect.*myAction)();
578 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
585 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
589 class TWorkspaceEvent: public SALOME_Event
592 QWidget* myViewWindow;
593 QWidget* myWorkspace;
596 TWorkspaceEvent(QWidget* theViewWindow,
597 QWidget* theWorkspace):
598 myViewWindow(theViewWindow),
599 myWorkspace(theWorkspace)
604 class TAlignEvent: public TWorkspaceEvent
607 Qt::AlignmentFlags myAligment;
610 TAlignEvent(QWidget* theViewWindow,
611 QWidget* theWorkspace,
612 Qt::AlignmentFlags theAligment):
613 TWorkspaceEvent(theViewWindow,theWorkspace),
614 myAligment(theAligment)
621 if(QWidget* aParent = myViewWindow->parentWidget(true))
622 SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
629 SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
632 switch (theViewPosition) {
633 case VISU::View::LEFT:
634 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
636 case VISU::View::CENTER:
637 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
639 case VISU::View::RIGHT:
640 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
649 SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
652 switch (theViewPosition) {
653 case VISU::View::TOP:
654 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
656 case VISU::View::CENTER:
657 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
659 case VISU::View::BOTTOM:
660 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
667 class TXYEvent: public TWorkspaceEvent
670 CORBA::Double myX, myY;
673 TXYEvent(QWidget* theViewWindow,
674 QWidget* theWorkspace,
677 TWorkspaceEvent(theViewWindow,theWorkspace),
686 SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
688 struct TEvent: public TXYEvent
691 TEvent(QWidget* theViewWindow,
692 QWidget* theWorkspace,
695 TXYEvent(theViewWindow,theWorkspace,theX,theY)
702 if(QWidget* aParent = myViewWindow->parentWidget(true))
703 aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
708 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
713 SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
715 struct TEvent: public TXYEvent
718 TEvent(QWidget* theViewWindow,
719 QWidget* theWorkspace,
722 TXYEvent(theViewWindow,theWorkspace,theX,theY)
729 if(QWidget* aParent = myViewWindow->parentWidget(true))
730 aParent->setGeometry(aParent->x(),
732 int(myX*myWorkspace->width()),
733 int(myY*myWorkspace->height()));
738 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
740 // End: Old methods for view parameters management, they don't work now
744 SetBackground (const SALOMEDS::Color& theColor)
746 struct TEvent: public SALOME_Event
749 SALOMEDS::Color myColor;
751 TEvent(QWidget* theWidget,
752 const SALOMEDS::Color& theColor):
756 virtual void Execute(){
758 aColor[0] = int(255.0*myColor.R);
759 aColor[1] = int(255.0*myColor.G);
760 aColor[2] = int(255.0*myColor.B);
761 myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2]));
765 ProcessVoidEvent(new TEvent(myViewWindow,theColor));
769 struct TBackgroundEvent: public SALOME_Event
772 typedef SALOMEDS::Color TResult;
775 TBackgroundEvent(QWidget* theWidget):
783 const QColor& aColor = myWidget->backgroundColor();
784 myResult.R = aColor.red()/255.0;
785 myResult.G = aColor.green()/255.0;
786 myResult.B = aColor.blue()/255.0;
794 return ProcessEvent(new TBackgroundEvent(myViewWindow));
801 ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMinimized));
808 ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showNormal));
815 ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMaximized));
830 Erase (PrsObject_ptr thePrsObj)
835 Display (PrsObject_ptr thePrsObj)
840 DisplayOnly (PrsObject_ptr thePrsObj)
848 class TSavePictureEvent: public SALOME_Event
850 SUIT_ViewWindow * myViewWindow;
851 const char * myFileName;
853 typedef CORBA::Boolean TResult;
855 TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
856 : myViewWindow(theViewWindow),
857 myFileName(theFileName),
862 virtual void Execute()
865 QImage img = myViewWindow->dumpView();
867 QString fileName (myFileName);
868 if (!fileName.isEmpty()) {
869 QString fmt = SUIT_Tools::extension(fileName).upper();
870 if (fmt.isEmpty()) fmt = QString("BMP"); // default format
871 if (fmt == "JPG" ) fmt = "JPEG";
872 //QApplication::setOverrideCursor(Qt::waitCursor);
873 img.save(fileName, fmt.latin1());
874 //QApplication::restoreOverrideCursor();
882 View_i::SavePicture(const char* theFileName)
884 return ProcessEvent(new TSavePictureEvent (myViewWindow,theFileName));
896 ToStream (std::ostringstream& theStr)
901 //================= OLD CODE ===================
903 //QAD_Study* CheckStudy (SALOMEDS::Study_ptr theStudy)
905 // //QAD_Desktop* aDesktop = QAD_Application::getDesktop();
906 // //QAD_Study* aStudy = aDesktop->findStudy(theStudy);
908 // CORBA::String_var aName = theStudy->Name();
909 // aFileInfo.setFile(aName.in());
910 // if (aFileInfo.exists())
911 // aStudy = aDesktop->loadStudy(aFileInfo.baseName());
913 // aStudy = aDesktop->loadStudy(aName.in());
915 // MESSAGE("CheckStudy()::ERROR: Can't load study");
921 template<class TViewer>
922 struct TNewSpecViewEvent: public SALOME_Event
924 SalomeApp_Application* myApplication;
926 typedef SUIT_ViewManager* TResult;
929 TNewSpecViewEvent (SalomeApp_Application* theApplication):
930 myApplication(theApplication),
938 myResult = myApplication->getViewManager(TViewer::Type(), true);
942 //===========================================================================
943 XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
944 : View_i(theApplication, NULL)
946 if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
947 if (theApplication) {
948 myViewManager = ProcessEvent(new TNewSpecViewEvent<Plot2d_Viewer>(theApplication));
953 struct TCreatePlot2dViewEvent: public SALOME_Event
955 SUIT_ViewManager* myViewManager;
956 XYPlot_i * myPlot2dView;
959 typedef Plot2d_ViewFrame* TResult;
962 TCreatePlot2dViewEvent (SUIT_ViewManager* theViewManager,
963 XYPlot_i * thePlot2dView,
965 myViewManager(theViewManager),
966 myPlot2dView(thePlot2dView),
976 myPlot2dView->myViewWindow = myViewManager->createViewWindow();
978 myPlot2dView->myViewWindow = myViewManager->getActiveView();
980 if (myPlot2dView->myViewWindow) {
981 Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myPlot2dView->myViewWindow);
983 myResult = aPlot2dVW->getViewFrame();
992 Storable* XYPlot_i::Create (int theNew)
994 myView = ProcessEvent(new TCreatePlot2dViewEvent(myViewManager, this, theNew));
998 void XYPlot_i::Update()
1000 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
1003 void XYPlot_i::Close()
1005 //jfa: may be need to be enclosed in SALOME_Event?
1006 myViewWindow->close();
1009 XYPlot_i::~XYPlot_i() {
1010 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1013 void XYPlot_i::SetTitle (const char* theTitle)
1015 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1016 (myViewWindow, &SUIT_ViewWindow::setCaption, QString(theTitle)));
1018 char* XYPlot_i::GetTitle()
1020 //jfa: may be need to be enclosed in SALOME_Event?
1021 return CORBA::string_dup(myViewWindow->caption().latin1());
1024 void XYPlot_i::SetSubTitle (const char* theTitle)
1026 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1027 (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1030 char* XYPlot_i::GetSubTitle()
1032 //jfa: may be need to be enclosed in SALOME_Event?
1033 return CORBA::string_dup(myView->getTitle());
1036 void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1038 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1039 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1042 VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1044 //jfa: may be need to be enclosed in SALOME_Event?
1045 return (VISU::XYPlot::CurveType)myView->getCurveType();
1048 void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1050 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1051 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1054 CORBA::Long XYPlot_i::GetMarkerSize()
1056 //jfa: may be need to be enclosed in SALOME_Event?
1057 return myView->getMarkerSize();
1060 class TEnableGridEvent: public SALOME_Event
1063 typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool);
1064 TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun,
1065 CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1066 CORBA::Boolean theMinor, CORBA::Long theNumMinor):
1067 myView(theView), myFun(theFun),
1068 myMajor(theMajor), myNumMajor(theNumMajor),
1069 myMinor(theMinor), myNumMinor(theNumMinor)
1072 virtual void Execute()
1074 (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true);
1077 Plot2d_ViewFrame* myView;
1079 CORBA::Boolean myMajor, myNumMajor;
1080 CORBA::Boolean myMinor, myNumMinor;
1083 void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1084 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1086 ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
1087 theMajor,theNumMajor,theMinor,theNumMinor));
1089 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1090 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1092 //jfa tmp:ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
1093 //jfa tmp: theMajor,theNumMajor,theMinor,theNumMinor));
1096 class TSetScaleModeEvent: public SALOME_Event
1099 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1100 TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1101 myView(theView), myFun(theFun), myScaling(theScaling)
1104 virtual void Execute()
1106 (myView->*myFun)(myScaling,true);
1109 Plot2d_ViewFrame* myView;
1114 void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1116 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1117 theScaling == VISU::LOGARITHMIC));
1120 VISU::Scaling XYPlot_i::GetHorScaling()
1122 //jfa: may be need to be enclosed in SALOME_Event?
1123 return (VISU::Scaling)myView->getHorScaleMode();
1126 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1128 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1129 theScaling == VISU::LOGARITHMIC));
1132 VISU::Scaling XYPlot_i::GetVerScaling()
1134 //jfa: may be need to be enclosed in SALOME_Event?
1135 return (VISU::Scaling)myView->getVerScaleMode();
1138 class TSetTitleEvent: public SALOME_Event
1141 TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1142 myView(theView), myType(theType), myTitle(theTitle)
1144 virtual void Execute()
1146 myView->setTitle(true,myTitle,myType);
1149 Plot2d_ViewFrame* myView;
1150 Plot2d_ViewFrame::ObjectType myType;
1151 const char* myTitle;
1154 void XYPlot_i::SetXTitle (const char* theTitle)
1156 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1158 char* XYPlot_i::GetXTitle()
1160 //jfa: may be need to be enclosed in SALOME_Event?
1161 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
1164 void XYPlot_i::SetYTitle (const char* theTitle)
1166 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1168 char* XYPlot_i::GetYTitle()
1170 //jfa: may be need to be enclosed in SALOME_Event?
1171 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
1174 void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1176 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1177 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1180 class TXYPlotViewEvent: public SALOME_Event
1182 SalomeApp_Application* myApplication;
1183 Plot2d_ViewFrame* myView;
1184 PrsObject_ptr myPrsObj;
1188 TXYPlotViewEvent(SalomeApp_Application* theApplication,
1189 Plot2d_ViewFrame* theView,
1190 PrsObject_ptr thePrsObj,
1192 : myApplication(theApplication),
1194 myPrsObj(thePrsObj),
1195 myDisplaing(theDisplaing)
1199 virtual void Execute()
1202 if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1203 UpdatePlot2d(myView,myDisplaing,aCurve);
1205 // is it Container ?
1206 if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1207 int nbCurves = aContainer->GetNbCurves();
1208 for ( int i = 1; i <= nbCurves; i++ ) {
1209 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1210 if ( aCurve && aCurve->IsValid() ) {
1211 UpdatePlot2d(myView,myDisplaing,aCurve);
1217 if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1218 _PTR(Study) aCStudy;
1219 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1220 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1221 aCStudy = aStudy->studyDS();
1224 if (!aCStudy) return;
1225 _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
1227 _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1228 for (; Iter->More(); Iter->Next()) {
1229 CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1230 if (!CORBA::is_nil(childObject)) {
1231 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1232 if (!CORBA::is_nil(aCurve))
1233 UpdatePlot2d(myView, myDisplaing,
1234 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
1243 void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1245 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1248 void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1250 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1253 void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1255 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1258 void XYPlot_i::EraseAll()
1260 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1263 void XYPlot_i::FitAll()
1265 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1269 //===========================================================================
1270 TableView_i::TableView_i (SalomeApp_Application* theApplication)
1271 : View_i(theApplication, NULL)
1275 struct TCreateTableViewEvent: public SALOME_Event
1277 SalomeApp_Application* myApplication;
1278 VISU::Table_i* myTable;
1280 typedef VisuGUI_TableDlg* TResult;
1283 TCreateTableViewEvent (SalomeApp_Application* theApplication,
1284 VISU::Table_i* theTable):
1285 myApplication(theApplication),
1294 if (myTable != NULL) {
1295 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1296 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1297 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1298 _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
1300 myResult = new VisuGUI_TableDlg (myApplication->desktop(),
1303 VisuGUI_TableDlg::ttAuto,
1314 Storable* TableView_i::Create (VISU::Table_ptr theTable)
1316 if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1317 if (!theTable->_is_nil()) {
1318 VISU::Table_i* table =
1319 dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1320 if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1322 myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1329 TableView_i::~TableView_i()
1331 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1335 void TableView_i::SetTitle (const char* theTitle)
1337 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
1338 (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
1341 char* TableView_i::GetTitle()
1343 //jfa: may be need to be enclosed in SALOME_Event?
1344 return CORBA::string_dup(myView->caption().latin1());
1347 void TableView_i::Close()
1349 //jfa: may be need to be enclosed in SALOME_Event?
1354 //===========================================================================
1355 int View3D_i::myNbViewParams = 0;
1356 const string View3D_i::myComment = "VIEW3D";
1357 const char* View3D_i::GetComment() const { return myComment.c_str();}
1359 QString View3D_i::GenerateViewParamsName()
1361 return VISU::GenerateName("ViewParams", ++myNbViewParams);
1364 View3D_i::View3D_i (SalomeApp_Application* theApplication)
1365 : View_i(theApplication, NULL)
1367 if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1368 if (theApplication) {
1369 myViewManager = ProcessEvent(new TNewSpecViewEvent<SVTK_Viewer>(theApplication));
1373 struct TCreateView3dEvent: public SALOME_Event
1375 SUIT_ViewManager* myViewManager;
1378 typedef SUIT_ViewWindow* TResult;
1381 TCreateView3dEvent (SUIT_ViewManager* theViewManager,
1383 myViewManager(theViewManager),
1393 myResult = myViewManager->createViewWindow();
1395 myResult = myViewManager->getActiveView();
1400 Storable* View3D_i::Create (int theNew)
1402 if (MYDEBUG) MESSAGE("View3D_i::Create");
1403 myViewWindow = ProcessEvent(new TCreateView3dEvent(myViewManager, theNew));
1407 void View3D_i::Update()
1409 class TEvent: public SALOME_Event
1411 SUIT_ViewWindow* myViewWindow;
1413 TEvent(SUIT_ViewWindow* theStudyFrame):
1414 myViewWindow(theStudyFrame)
1416 virtual void Execute()
1418 SVTK_ViewWindow* vf = GetViewWindow(myViewWindow);
1419 vtkRenderer* Renderer = vf->getRenderer();
1420 vtkActorCollection* theActors = Renderer->GetActors();
1421 theActors->InitTraversal();
1422 while (vtkActor *anAct = theActors->GetNextActor()) {
1423 if (VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)) {
1424 VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
1425 if (anActor->GetVisibility() && aPrs3d) {
1427 aPrs3d->UpdateActor(anActor);
1431 RepaintView(myViewWindow);
1434 ProcessVoidEvent(new TEvent(myViewWindow));
1437 bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1439 MESSAGE("View3D_i::SaveViewParams()");
1440 _PTR(Study) aCStudy;
1441 if (SUIT_Study* aSStudy = theViewManager->study()) {
1442 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1443 aCStudy = aStudy->studyDS();
1450 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1451 _PTR(GenericAttribute) anAttr;
1452 int iEnd = aList.size();
1453 for (int i = 0; i < iEnd; i++) {
1454 _PTR(SObject) anObj = aList[i];
1455 string anEntry = anObj->GetID();
1456 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1457 if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1458 _PTR(AttributeComment) aCmnt (anAttr);
1459 string aComm (aCmnt->Value());
1460 if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1461 if (aComm.compare(View3D_i::myComment) >= 0) {
1462 aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1468 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1469 string aSComponentEntry = aSComponent->GetID();
1470 string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
1471 ToString(theViewManager->getActiveView()).c_str());
1475 class TSaveViewParamsEvent: public SALOME_Event
1477 SUIT_ViewManager* myViewManager;
1480 TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1481 const char* theName):
1482 myViewManager(theViewManager),
1486 virtual void Execute()
1488 myResult = View3D_i::SaveViewParams(myViewManager, myName);
1490 typedef CORBA::Boolean TResult;
1494 CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
1496 return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName));
1499 bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1501 _PTR(Study) aCStudy;
1502 if (SUIT_Study* aSStudy = theViewManager->study()) {
1503 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1504 aCStudy = aStudy->studyDS();
1510 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1511 _PTR(GenericAttribute) anAttr;
1512 int iEnd = aList.size();
1513 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1514 for (int i = 0; i < iEnd; i++) {
1515 _PTR(SObject) anObj = aList[i];
1516 string anEntry = anObj->GetID();
1517 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1518 if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1519 _PTR(AttributeComment) aCmnt (anAttr);
1520 QString strIn(aCmnt->Value().c_str());
1521 Storable::TRestoringMap aMap;
1522 Storable::StrToMap(strIn, aMap);
1523 if (Storable::FindValue(aMap, "myComment").compare
1524 (View3D_i::myComment.c_str()) >= 0) {
1525 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn);
1526 Restore(theViewManager->getActiveView(), aMap);
1534 class TRestoreViewParamsEvent: public SALOME_Event
1536 SUIT_ViewManager* myViewManager;
1539 TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1540 const char* theName):
1541 myViewManager(theViewManager),
1545 virtual void Execute()
1547 myResult = View3D_i::RestoreViewParams(myViewManager, myName);
1549 typedef CORBA::Boolean TResult;
1553 CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
1555 return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
1558 void View3D_i::Restore (SUIT_ViewWindow* theStudyFrame,
1559 const Storable::TRestoringMap& theMap)
1561 SALOMEDS::Color aColor;
1562 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1563 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1564 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1566 double aPosition[3];
1567 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1568 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1569 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1571 double aFocalPnt[3];
1572 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1573 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1574 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1577 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1578 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1579 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1581 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1583 double aScaleFactor[3];
1584 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1585 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1586 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1588 SetBackground(theStudyFrame,aColor);
1589 SetPointOfView(theStudyFrame,aPosition);
1590 SetViewUp(theStudyFrame,aViewUp);
1591 SetFocalPoint(theStudyFrame,aFocalPnt);
1592 SetParallelScale(theStudyFrame,aParallelScale);
1593 ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1594 ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1595 ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1599 string View3D_i::ToString (SUIT_ViewWindow* theStudyFrame)
1601 ostringstream strOut;
1602 Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1603 ToStream(theStudyFrame,strOut);
1605 if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1606 return strOut.str();
1609 void View3D_i::ToStream (SUIT_ViewWindow* theStudyFrame, std::ostringstream& theStr)
1611 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1614 GetRenderer(theStudyFrame)->GetBackground(backint);
1615 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1616 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1617 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1619 double aPosition[3];
1620 GetPointOfView(theStudyFrame,aPosition);
1621 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1622 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1623 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1625 double aFocalPnt[3];
1626 GetFocalPoint(theStudyFrame,aFocalPnt);
1627 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1628 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1629 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1632 GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1633 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1634 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1635 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1637 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1639 double aScaleFactor[3];
1640 GetViewWindow(theStudyFrame)->GetScale(aScaleFactor);
1641 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1642 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1643 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1646 void View3D_i::ToStream(std::ostringstream& theStr)
1648 ToStream(myViewWindow,theStr);
1651 void View3D_i::Close()
1653 //jfa: may be need to be enclosed in SALOME_Event?
1654 myViewWindow->close();
1657 View3D_i::~View3D_i()
1659 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1662 void View3D_i::SetTitle (const char* theTitle)
1664 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1665 (myViewWindow,&SUIT_ViewWindow::setCaption,QString(theTitle)));
1668 char* View3D_i::GetTitle()
1670 //jfa: may be need to be enclosed in SALOME_Event?
1671 return CORBA::string_dup(myViewWindow->caption().latin1());
1674 void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame,
1675 const SALOMEDS::Color& theColor)
1677 //jfa: may be need to be enclosed in SALOME_Event?
1679 aColor[0] = int(255.0*theColor.R);
1680 aColor[1] = int(255.0*theColor.G);
1681 aColor[2] = int(255.0*theColor.B);
1682 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1683 GetViewWindow(theStudyFrame)->setBackgroundColor(aNewColor);
1686 SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame)
1688 //jfa: may be need to be enclosed in SALOME_Event?
1689 SALOMEDS::Color aColor;
1691 GetRenderer(theStudyFrame)->GetBackground(backint);
1692 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1696 class TUpdateViewerEvent: public SALOME_Event
1698 SUIT_ViewWindow* myViewWindow;
1702 TUpdateViewerEvent(SUIT_ViewWindow* theStudyFrame,
1705 myViewWindow(theStudyFrame),
1707 myDisplaing(theDisplaing)
1709 virtual void Execute(){
1710 UpdateViewer(myViewWindow,myDisplaing,myPrs3d);
1714 void View3D_i::EraseAll()
1716 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1717 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eEraseAll));
1720 void View3D_i::DisplayAll()
1722 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1723 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eDisplayAll));
1726 void View3D_i::Erase (PrsObject_ptr thePrsObj)
1728 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1729 CORBA::Object_ptr anObj = thePrsObj;
1730 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1731 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eErase));
1735 void View3D_i::Display (PrsObject_ptr thePrsObj)
1737 if(MYDEBUG) MESSAGE("View3D_i::Display");
1738 CORBA::Object_ptr anObj = thePrsObj;
1739 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1740 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplay));
1744 void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
1746 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1747 CORBA::Object_ptr anObj = thePrsObj;
1748 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1749 ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplayOnly));
1753 void View3D_i::FitAll()
1755 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1756 (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFitAll));
1760 void View3D_i::SetView (VISU::View3D::ViewType theType)
1763 case VISU::View3D::FRONT :
1764 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1765 (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFrontView));
1767 case VISU::View3D::BACK :
1768 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1769 (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onBackView));
1771 case VISU::View3D::LEFT :
1772 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1773 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onLeftView));
1775 case VISU::View3D::RIGHT :
1776 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1777 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onRightView));
1779 case VISU::View3D::TOP :
1780 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1781 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onTopView));
1783 case VISU::View3D::BOTTOM :
1784 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1785 (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onBottomView));
1791 class TSet3DViewParamEvent: public SALOME_Event
1794 typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, const CORBA::Double theParam[3]);
1795 TSet3DViewParamEvent (TFun theFun,
1796 SUIT_ViewWindow* theStudyFrame,
1797 const CORBA::Double theParam[3]):
1799 myViewWindow(theStudyFrame),
1802 virtual void Execute(){
1803 myFun(myViewWindow,myParam);
1807 SUIT_ViewWindow* myViewWindow;
1808 const CORBA::Double* myParam;
1811 void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame,
1812 const CORBA::Double thePosition[3])
1814 //jfa: may be need to be enclosed in SALOME_Event?
1815 GetCamera(theStudyFrame)->SetPosition(thePosition);
1818 void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
1820 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1821 ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myViewWindow,thePosition));
1824 void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame,
1825 CORBA::Double thePosition[3])
1827 //jfa: may be need to be enclosed in SALOME_Event?
1828 GetCamera(theStudyFrame)->GetPosition(thePosition);
1831 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
1833 //jfa: may be need to be enclosed in SALOME_Event?
1834 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1835 CORBA::Double aPosition[3];
1836 GetPointOfView(myViewWindow,aPosition);
1837 return VISU::View3D::XYZ_dup(aPosition);
1840 void View3D_i::SetViewUp (SUIT_ViewWindow* theStudyFrame,
1841 const CORBA::Double theViewUp[3])
1843 GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1846 void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
1848 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1849 ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myViewWindow,theViewUp));
1852 void View3D_i::GetViewUp (SUIT_ViewWindow* theStudyFrame,
1853 CORBA::Double theViewUp[3])
1855 GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1858 VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
1860 //jfa: may be need to be enclosed in SALOME_Event?
1861 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1862 CORBA::Double aViewUp[3];
1863 GetCamera(myViewWindow)->GetViewUp(aViewUp);
1864 return VISU::View3D::XYZ_dup(aViewUp);
1867 void View3D_i::SetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1868 const CORBA::Double theFocalPnt[3])
1870 GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1873 void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
1875 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1876 ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myViewWindow,theCoord));
1880 void View3D_i::GetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1881 CORBA::Double theFocalPnt[3])
1883 GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1886 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
1888 //jfa: may be need to be enclosed in SALOME_Event?
1889 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1890 CORBA::Double aFocalPnt[3];
1891 GetFocalPoint(myViewWindow,aFocalPnt);
1892 return VISU::View3D::XYZ_dup(aFocalPnt);
1895 class TSetViewParamEvent: public SALOME_Event
1898 typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, CORBA::Double theParam);
1899 TSetViewParamEvent (TFun theFun,
1900 SUIT_ViewWindow* theStudyFrame,
1901 CORBA::Double theParam):
1903 myViewWindow(theStudyFrame),
1906 virtual void Execute()
1908 myFun(myViewWindow,myParam);
1912 SUIT_ViewWindow* myViewWindow;
1913 CORBA::Double myParam;
1916 void View3D_i::SetParallelScale (SUIT_ViewWindow* theStudyFrame,
1917 CORBA::Double theScale)
1919 GetCamera(theStudyFrame)->SetParallelScale(theScale);
1922 void View3D_i::SetParallelScale (CORBA::Double theScale)
1924 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1925 ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myViewWindow,theScale));
1928 CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theStudyFrame)
1930 return GetCamera(theStudyFrame)->GetParallelScale();
1933 CORBA::Double View3D_i::GetParallelScale()
1935 //jfa: may be need to be enclosed in SALOME_Event?
1936 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1937 return GetParallelScale(myViewWindow);
1940 void View3D_i::ScaleView (SUIT_ViewWindow* theStudyFrame,
1941 VISU::View3D::Axis theAxis, CORBA::Double theParam)
1943 SVTK_ViewWindow* aViewFrame = GetViewWindow(theStudyFrame);
1944 double aScaleFactor[3];
1945 aViewFrame->GetScale(aScaleFactor);
1946 aScaleFactor[theAxis] = theParam;
1947 aViewFrame->SetScale(aScaleFactor);
1950 void SetScaleView (SUIT_ViewWindow* theStudyFrame, const CORBA::Double theScale[3])
1952 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1953 GetViewWindow(theStudyFrame)->SetScale(aScale);
1956 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
1958 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1960 GetViewWindow(myViewWindow)->GetScale(aScale);
1961 aScale[theAxis] = theParam;
1962 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
1965 void View3D_i::RemoveScale()
1967 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1968 double aScale[3] = {1.0, 1.0, 1.0};
1969 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));