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_ViewManager_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_ViewManager_i.hh"
29 #include "VISU_PrsObject_i.hh"
30 #include "VISU_Result_i.hh"
32 #include "VISU_Prs3d_i.hh"
33 #include "VISU_Mesh_i.hh"
34 #include "VISU_ScalarMap_i.hh"
35 #include "VISU_IsoSurfaces_i.hh"
36 #include "VISU_DeformedShape_i.hh"
37 #include "VISU_CutPlanes_i.hh"
38 #include "VISU_CutLines_i.hh"
39 #include "VISU_Vectors_i.hh"
40 #include "VISU_StreamLines_i.hh"
42 #include "VISU_Table_i.hh"
43 #include "VISU_ScalarBarActor.hxx"
44 #include "VISU_Actor.h"
46 #include "SALOME_Event.hxx"
48 #include "QAD_Application.h"
49 #include "QAD_Desktop.h"
50 #include "QAD_Tools.h"
51 #include "QAD_Study.h"
52 #include "QAD_RightFrame.h"
53 #include "QAD_StudyFrame.h"
55 #include "VTKViewer_ViewFrame.h"
56 #include "SALOMEGUI_TableDlg.h"
57 #include "Plot2d_CurveContainer.h"
58 #include "Plot2d_ViewFrame.h"
63 #include <qfileinfo.h>
65 #include <vtkTransformPolyDataFilter.h>
66 #include <vtkDataSetMapper.h>
67 #include <vtkRenderer.h>
68 #include <vtkCamera.h>
73 static int MYDEBUG = 0;
75 static int MYDEBUG = 0;
78 static QFileInfo aFileInfo;
79 static int MYDELAY = 1;
82 //===========================================================================
83 typedef TVoidMemFunEvent<QAD_StudyFrame> TFrameActionEvent;
85 template<class TObject>
86 class TSetBackgroundEvent: public SALOME_Event{
88 const SALOMEDS::Color& myColor;
90 TSetBackgroundEvent(TObject* theView, const SALOMEDS::Color& theColor):
91 myView(theView), myColor(theColor)
93 virtual void Execute(){
95 aColor[0] = int(255.0*myColor.R);
96 aColor[1] = int(255.0*myColor.G);
97 aColor[2] = int(255.0*myColor.B);
98 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
99 myView->setBackgroundColor(aNewColor);
104 class TSavePictureEvent: public SALOME_Event{
106 const char* myFileName;
108 typedef CORBA::Boolean TResult;
110 TSavePictureEvent(QWidget* theWidget, const char* theFileName):
112 myFileName(theFileName),
115 virtual void Execute(){
117 QPixmap px = QPixmap::grabWindow(myWidget->winId());
118 if (!QString(myFileName).isNull()) {
119 QString fmt = QAD_Tools::getFileExtensionFromPath(myFileName).upper();
121 fmt = QString("BMP"); // default format
124 myResult = px.save(myFileName, fmt.latin1());
131 void RepaintView(QAD_StudyFrame* theStudyFrame);
132 class TRepaintViewEvent: public SALOME_Event{
133 QAD_StudyFrame* myStudyFrame;
135 TRepaintViewEvent(QAD_StudyFrame* theStudyFrame):
136 myStudyFrame(theStudyFrame)
138 virtual void Execute(){
139 RepaintView(myStudyFrame);
144 VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
145 return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
147 vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame){
148 return GetViewFrame(theStudyFrame)->getRenderer();
150 vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
151 return GetRenderer(theStudyFrame)->GetActiveCamera();
155 void RepaintView(QAD_StudyFrame* theStudyFrame){
156 GetRenderer(theStudyFrame)->ResetCameraClippingRange();
157 GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render();
158 //GetViewFrame(theStudyFrame)->Repaint();
162 VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
163 VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
164 if (!vf) return NULL;
165 if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
166 vtkRenderer *aRen = vf->getRenderer();
167 vtkActorCollection *anActColl = aRen->GetActors();
169 VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
170 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
171 if(anActor->IsA("VISU_Actor")){
172 anVISUActor = VISU_Actor::SafeDownCast(anActor);
173 if (thePrs == anVISUActor->GetPrs3d()) {
174 aResActor = anVISUActor->GetParent();
175 if(theDisplaing < eErase)
176 aResActor->VisibilityOn();
178 aResActor->VisibilityOff();
180 if(theDisplaing > eDisplay)
181 anVISUActor->VisibilityOff();
183 anVISUActor->VisibilityOn();
188 RepaintView(theStudyFrame);
191 if(thePrs != NULL && theDisplaing < eErase){
193 anVISUActor = thePrs->CreateActor();
194 vf->AddActor(anVISUActor);
195 }catch(std::runtime_error& exc){
200 RepaintView(theStudyFrame);
203 void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
204 if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
207 QList<Plot2d_Curve> clist;
208 theView->getCurves( clist );
209 if ( theDisplaying == eEraseAll ) {
210 for ( int i = 0; i < clist.count(); i++ ) {
211 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
212 theView->eraseCurve( clist.at( i ) );
215 else if ( theDisplaying == eErase ) {
216 for ( int i = 0; i < clist.count(); i++ ) {
217 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
218 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
219 theView->eraseCurve( clist.at( i ) );
223 else if ( theDisplaying == eDisplay ) {
225 for ( int i = 0; i < clist.count(); i++ ) {
226 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
227 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
228 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
229 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
230 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
231 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
232 /* - DATA NOT UPDATED */
233 if ( !clist.at( i )->isAutoAssign() ) {
234 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
235 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
236 SALOMEDS::Color color = theCurve->GetColor();
237 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
238 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
240 theView->displayCurve( clist.at( i ) );
245 Plot2d_Curve* crv = theCurve->CreatePresentation();
246 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
248 theView->displayCurve( crv );
251 else if ( theDisplaying == eDisplayOnly ) {
253 for ( int i = 0; i < clist.count(); i++ ) {
254 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
255 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
256 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
257 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
258 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
259 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
260 /* - DATA NOT UPDATED */
261 if ( !clist.at( i )->isAutoAssign() ) {
262 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
263 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
264 SALOMEDS::Color color = theCurve->GetColor();
265 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
266 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
268 theView->displayCurve( clist.at( i ) );
272 theView->eraseCurve( clist.at( i ) );
276 Plot2d_Curve* crv = theCurve->CreatePresentation();
277 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
279 theView->displayCurve( crv );
284 QAD_Study* CheckStudy( SALOMEDS::Study_ptr theStudy ) {
285 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
286 QAD_Study* aStudy = aDesktop->findStudy(theStudy);
288 CORBA::String_var aName = theStudy->Name();
289 aFileInfo.setFile(aName.in());
290 if (aFileInfo.exists())
291 aStudy = aDesktop->loadStudy(aFileInfo.baseName());
293 aStudy = aDesktop->loadStudy(aName.in());
295 MESSAGE("CheckStudy()::ERROR: Can't load study");
300 //===========================================================================
301 ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
302 if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
303 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
307 VISU::View_ptr ViewManager_i::GetCurrentView(){
308 class TEvent: public SALOME_Event{
309 SALOMEDS::Study_ptr myStudyDocument;
311 TEvent( SALOMEDS::Study_ptr theStudy):
312 myStudyDocument(theStudy)
314 virtual void Execute(){
315 if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){
316 if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) {
318 MESSAGE("GetCurrentView::Execute - TypeView = "<<aStudyFrame->getTypeView());
319 if ( aStudyFrame->getTypeView() == VIEW_VTK ) {
320 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
322 myResult = pView->_this();
323 } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) {
324 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
326 myResult = pView->_this();
331 typedef VISU::View_var TResult;
334 TEvent* ve = new TEvent( myStudyDocument );
336 TEvent::TResult aResult = ve->myResult;
338 return aResult._retn();
342 class TCreateViewEvent: public SALOME_Event{
344 TCreateViewEvent( SALOMEDS::Study_ptr theStudy):
345 myStudyDocument(theStudy)
348 SALOMEDS::Study_ptr myStudyDocument;
352 template<class TViewFrame>
353 class TCreateViewFrameEvent: public TCreateViewEvent{
355 typedef typename TViewFrame::TInterface TInterface;
356 typedef typename TInterface::_ptr_type TResult;
358 TCreateViewFrameEvent(SALOMEDS::Study_ptr theStudy):
359 TCreateViewEvent(theStudy),
360 myResult(TInterface::_nil())
362 virtual void Execute(){
363 if(CheckStudy(myStudyDocument)){
364 TViewFrame* pView = new TViewFrame(myStudyDocument);
366 myResult = pView->_this();
372 VISU::View3D_ptr ViewManager_i::Create3DView(){
373 if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
374 return ProcessEvent(new TCreateViewFrameEvent<VISU::View3D_i>(myStudyDocument));
378 VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
379 if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
380 return ProcessEvent(new TCreateViewFrameEvent<VISU::XYPlot_i>(myStudyDocument));
384 VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
385 class TEvent: public TCreateViewEvent{
388 TEvent(SALOMEDS::Study_ptr theStudy,
390 TCreateViewEvent(theStudy),
393 virtual void Execute(){
394 if ( CheckStudy( myStudyDocument ) ) {
395 VISU::TableView_i* pView = new TableView_i(myStudyDocument);
396 if(pView->Create(myTable) != NULL)
397 myResult = pView->_this();
400 typedef VISU::TableView_var TResult;
403 if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
404 TEvent* ve = new TEvent(myStudyDocument,theTable);
406 TEvent::TResult aResult = ve->myResult;
408 return aResult._retn();
412 void ViewManager_i::Destroy(View_ptr theView){
413 class TEvent: public SALOME_Event{
416 TEvent(View_ptr theView):
419 virtual void Execute(){
420 if(!CORBA::is_nil(myView)){
421 if(VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
423 pView->_remove_ref();
428 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
429 ProcessVoidEvent(new TEvent(theView));
433 //===========================================================================
434 View_i::View_i(SALOMEDS::Study_ptr theStudy) {
435 if(MYDEBUG) MESSAGE("View_i::View_i");
436 CORBA::String_var aName = theStudy->Name();
437 myStudy = CheckStudy(theStudy);
438 if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
442 if(MYDEBUG) MESSAGE("View_i::~View_i");
445 void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
446 SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
447 void View_i::Minimize() {}
448 void View_i::Restore() {}
449 void View_i::Maximize() {}
450 void View_i::EraseAll() {}
451 void View_i::DisplayAll() {}
452 void View_i::Erase(PrsObject_ptr thePrsObj) {}
453 void View_i::Display(PrsObject_ptr thePrsObj) {}
454 void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
455 void View_i::Update() {}
457 CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
459 const char* View_i::GetComment() const { return "";}
460 void View_i::ToStream(std::ostringstream& theStr) {}
462 string View_i::GetEntry(){
463 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
464 CORBA::String_var anEntry = aSObject->GetID();
465 return string(anEntry.in());
469 //===========================================================================
470 XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
471 if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
474 Storable* XYPlot_i::Create(int theNew){
476 myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
478 myStudyFrame = myStudy->getActiveStudyFrame();
479 myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
485 void XYPlot_i::Update() {
486 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
490 void XYPlot_i::Close(){
491 myStudyFrame->close();
494 XYPlot_i::~XYPlot_i() {
495 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
499 void XYPlot_i::SetTitle(const char* theTitle){
500 ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
501 (myStudyFrame,&QAD_StudyFrame::setCaption,QString(theTitle)));
503 char* XYPlot_i::GetTitle() {
504 return CORBA::string_dup(myStudyFrame->title().latin1());
508 void XYPlot_i::SetSubTitle(const char* theTitle){
509 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
510 (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle)));
512 char* XYPlot_i::GetSubTitle() {
513 return CORBA::string_dup(myView->getTitle());
517 void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
518 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
519 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
521 VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
522 return (VISU::XYPlot::CurveType)myView->getCurveType();
526 void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
527 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
528 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
530 CORBA::Long XYPlot_i::GetMarkerSize(){
531 return myView->getMarkerSize();
535 class TEnbleGridEvent: public SALOME_Event{
537 typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool = true);
538 TEnbleGridEvent(Plot2d_ViewFrame* theView, TFun theFun,
539 CORBA::Boolean theMajor, CORBA::Long theNumMajor,
540 CORBA::Boolean theMinor, CORBA::Long theNumMinor):
541 myView(theView), myFun(theFun),
542 myMajor(theMajor), myNumMajor(theNumMajor),
543 myMinor(theMinor), myNumMinor(theNumMinor)
545 virtual void Execute(){
546 (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor);
549 Plot2d_ViewFrame* myView;
551 CORBA::Boolean myMajor, myNumMajor;
552 CORBA::Boolean myMinor, myNumMinor;
556 void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
557 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
559 ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
560 theMajor,theNumMajor,theMinor,theNumMinor));
562 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
563 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
565 ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
566 theMajor,theNumMajor,theMinor,theNumMinor));
570 class TSetScaleModeEvent: public SALOME_Event{
572 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool = true);
573 TSetScaleModeEvent(Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
574 myView(theView), myFun(theFun), myScaling(theScaling)
576 virtual void Execute(){
577 (myView->*myFun)(myScaling);
580 Plot2d_ViewFrame* myView;
586 void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
587 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
588 theScaling == VISU::LOGARITHMIC));
590 VISU::Scaling XYPlot_i::GetHorScaling(){
591 return (VISU::Scaling)myView->getHorScaleMode();
595 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
596 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
597 theScaling == VISU::LOGARITHMIC));
599 VISU::Scaling XYPlot_i::GetVerScaling(){
600 return (VISU::Scaling)myView->getVerScaleMode();
604 class TSetTitleEvent: public SALOME_Event{
606 typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
607 TSetTitleEvent(Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
608 myView(theView), myFun(theFun), myTitle(theTitle)
610 virtual void Execute(){
611 (myView->*myFun)(true,myTitle);
614 Plot2d_ViewFrame* myView;
620 void XYPlot_i::SetXTitle(const char* theTitle){
621 ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setXTitle,theTitle));
623 char* XYPlot_i::GetXTitle() {
624 return CORBA::string_dup(myView->getXTitle());
628 void XYPlot_i::SetYTitle(const char* theTitle){
629 ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle));
631 char* XYPlot_i::GetYTitle() {
632 return CORBA::string_dup(myView->getYTitle());
636 void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
637 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
638 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
642 void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
643 ProcessVoidEvent(new TSetBackgroundEvent<Plot2d_ViewFrame>(myView,theColor));
645 SALOMEDS::Color XYPlot_i::GetBackground() {
646 SALOMEDS::Color aColor;
647 aColor.R = myView->backgroundColor().red()/255.0;
648 aColor.G = myView->backgroundColor().green()/255.0;
649 aColor.B = myView->backgroundColor().blue()/255.0;
653 void XYPlot_i::Minimize() {
654 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
657 void XYPlot_i::Restore() {
658 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
661 void XYPlot_i::Maximize() {
662 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
666 class TXYPlotViewEvent: public SALOME_Event{
668 Plot2d_ViewFrame* myView;
669 PrsObject_ptr myPrsObj;
672 TXYPlotViewEvent(QAD_Study* theStudy,
673 Plot2d_ViewFrame* theView,
674 PrsObject_ptr thePrsObj,
679 myDisplaing(theDisplaing)
681 virtual void Execute(){
683 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
684 UpdatePlot2d(myView,myDisplaing,aCurve);
687 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
688 int nbCurves = aContainer->GetNbCurves();
689 for ( int i = 1; i <= nbCurves; i++ ) {
690 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
691 if ( aCurve && aCurve->IsValid() ) {
692 UpdatePlot2d(myView,myDisplaing,aCurve);
698 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
699 SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
700 SALOMEDS::SObject_var TableSO = aStudy->FindObjectID( aTable->GetEntry() );
701 if ( !TableSO->_is_nil() ) {
702 SALOMEDS::ChildIterator_var Iter = aStudy->NewChildIterator( TableSO );
703 for ( ; Iter->More(); Iter->Next() ) {
704 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
705 if( !CORBA::is_nil( childObject ) ) {
706 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
707 if( !CORBA::is_nil( aCurve ) )
708 UpdatePlot2d(myView,myDisplaing,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
718 void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
719 ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplay));
723 void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
724 ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eErase));
728 void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
729 ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplayOnly));
733 void XYPlot_i::EraseAll() {
734 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::EraseAll));
738 void XYPlot_i::FitAll() {
739 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::fitAll));
743 CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
744 TSavePictureEvent* ve = new TSavePictureEvent(myView->getViewWidget(),theFileName);
746 TSavePictureEvent::TResult aResult = ve->myResult;
752 //===========================================================================
753 TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
754 Storable* TableView_i::Create(VISU::Table_ptr theTable){
755 if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
756 if(!theTable->_is_nil()){
757 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
758 if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
760 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
761 if(!aSObject->_is_nil()) {
762 myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),
765 SALOMEGUI_TableDlg::ttAuto,
776 TableView_i::~TableView_i() {
777 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
782 void TableView_i::SetTitle(const char* theTitle){
783 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SALOMEGUI_TableDlg,const QString&,QString>
784 (myView,&SALOMEGUI_TableDlg::setCaption,QString(theTitle)));
788 char* TableView_i::GetTitle() {
789 return CORBA::string_dup(myView->caption().latin1());
793 void TableView_i::Close(){
798 //===========================================================================
799 int View3D_i::myNbViewParams = 0;
800 const string View3D_i::myComment = "VIEW3D";
801 const char* View3D_i::GetComment() const { return myComment.c_str();}
802 QString View3D_i::GenerateViewParamsName() {
803 return VISU::GenerateName( "ViewParams", ++myNbViewParams );
806 View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
807 if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
810 Storable* View3D_i::Create(int theNew){
811 if(MYDEBUG) MESSAGE("View3D_i::Create");
813 myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
815 myStudyFrame = myStudy->getActiveStudyFrame();
820 void View3D_i::Update(){
821 class TEvent: public SALOME_Event{
822 QAD_StudyFrame* myStudyFrame;
824 TEvent(QAD_StudyFrame* theStudyFrame):
825 myStudyFrame(theStudyFrame)
827 virtual void Execute(){
828 VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
829 vtkRenderer* Renderer = vf->getRenderer();
830 vtkActorCollection* theActors = Renderer->GetActors();
831 theActors->InitTraversal();
833 while(actor = theActors->GetNextActor()){
834 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(actor)){
835 VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
836 if(anActor->GetVisibility() && aPrs3d){
838 aPrs3d->UpdateActor(anActor);
842 RepaintView(myStudyFrame);
845 ProcessVoidEvent(new TEvent(myStudyFrame));
849 CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
850 TSavePictureEvent* ve = new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName);
852 TSavePictureEvent::TResult aResult = ve->myResult;
858 bool View3D_i::SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
859 QAD_Study* aStudy = theStudyFrame->getStudy();
860 SALOMEDS::Study_var aStudyDoc = aStudy->getStudyDocument();
862 SALOMEDS::Study::ListOfSObject_var aList =
863 aStudyDoc->FindObjectByName(theName,"VISU");
864 SALOMEDS::GenericAttribute_var anAttr;
865 int iEnd = aList->length();
866 for(int i = 0; i < iEnd; i++){
867 SALOMEDS::SObject_var anObj = aList[i];
868 CORBA::String_var aString = anObj->GetID();
869 string anEntry(aString);
870 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = "<<anEntry);
871 if(anObj->FindAttribute(anAttr, "AttributeComment")){
872 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
873 aString = aCmnt->Value();
874 string aComm(aString);
875 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
876 if(aComm.compare(View3D_i::myComment) >= 0){
877 aCmnt->SetValue(ToString(theStudyFrame).c_str());
883 SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(aStudyDoc);
884 CORBA::String_var aSComponentEntry = aSComponent->GetID();
885 string anEntry = CreateAttributes(aStudyDoc,aSComponentEntry.in(),"","",theName,"",ToString(theStudyFrame).c_str());
888 CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
889 return SaveViewParams(myStudyFrame,theName);
893 bool View3D_i::RestoreViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
894 SALOMEDS::Study::ListOfSObject_var aList =
895 theStudyFrame->getStudy()->getStudyDocument()->FindObjectByName(theName,"VISU");
896 SALOMEDS::GenericAttribute_var anAttr;
897 int iEnd = aList->length();
898 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
899 for(int i = 0; i < iEnd; i++){
900 SALOMEDS::SObject_var anObj = aList[i];
901 CORBA::String_var aString = anObj->GetID();
902 string anEntry(aString);
903 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
904 if(anObj->FindAttribute(anAttr, "AttributeComment")){
905 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
906 aString = aCmnt->Value();
907 QString strIn(aString);
908 Storable::TRestoringMap aMap;
909 Storable::StrToMap(strIn,aMap);
910 if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
911 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
912 Restore(theStudyFrame,aMap);
921 CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
922 class TEvent: public SALOME_Event{
923 QAD_StudyFrame* myStudyFrame;
926 TEvent(QAD_StudyFrame* theStudyFrame,
927 const char* theName):
928 myStudyFrame(theStudyFrame),
931 virtual void Execute(){
932 myResult = RestoreViewParams(myStudyFrame,myName);
934 typedef CORBA::Boolean TResult;
937 TEvent* ve = new TEvent(myStudyFrame,theName);
939 TEvent::TResult aResult = ve->myResult;
945 void View3D_i::Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap){
946 SALOMEDS::Color aColor;
947 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
948 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
949 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
952 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
953 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
954 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
957 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
958 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
959 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
962 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
963 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
964 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
966 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
968 double aScaleFactor[3];
969 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
970 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
971 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
973 SetBackground(theStudyFrame,aColor);
974 SetPointOfView(theStudyFrame,aPosition);
975 SetViewUp(theStudyFrame,aViewUp);
976 SetFocalPoint(theStudyFrame,aFocalPnt);
977 SetParallelScale(theStudyFrame,aParallelScale);
978 ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
979 ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
980 ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
984 string View3D_i::ToString(QAD_StudyFrame* theStudyFrame){
985 ostringstream strOut;
986 Storable::DataToStream( strOut, "myComment", myComment.c_str() );
987 ToStream(theStudyFrame,strOut);
989 if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
992 void View3D_i::ToStream(QAD_StudyFrame* theStudyFrame, std::ostringstream& theStr) {
993 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
996 GetRenderer(theStudyFrame)->GetBackground(backint);
997 Storable::DataToStream(theStr,"myColor.R",backint[0]);
998 Storable::DataToStream(theStr,"myColor.G",backint[1]);
999 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1001 double aPosition[3];
1002 GetPointOfView(theStudyFrame,aPosition);
1003 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1004 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1005 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1007 double aFocalPnt[3];
1008 GetFocalPoint(theStudyFrame,aFocalPnt);
1009 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1010 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1011 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1014 GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1015 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1016 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1017 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1019 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1021 double aScaleFactor[3];
1022 GetViewFrame(theStudyFrame)->GetScale(aScaleFactor);
1023 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1024 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1025 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1027 void View3D_i::ToStream(std::ostringstream& theStr) {
1028 ToStream(myStudyFrame,theStr);
1032 void View3D_i::Close(){
1033 myStudyFrame->close();
1036 View3D_i::~View3D_i() {
1037 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1040 //-------------------- View interface --------------------
1041 void View3D_i::SetTitle(const char* theTitle){
1042 ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
1043 (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle)));
1045 char* View3D_i::GetTitle() {
1046 return CORBA::string_dup(myStudyFrame->title().latin1());
1050 void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
1052 aColor[0] = int(255.0*theColor.R);
1053 aColor[1] = int(255.0*theColor.G);
1054 aColor[2] = int(255.0*theColor.B);
1055 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1056 GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
1058 void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
1059 ProcessVoidEvent(new TSetBackgroundEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),theColor));
1063 SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) {
1064 SALOMEDS::Color aColor;
1066 GetRenderer(theStudyFrame)->GetBackground(backint);
1067 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1070 SALOMEDS::Color View3D_i::GetBackground() {
1071 return GetBackground(myStudyFrame);
1075 void View3D_i::Minimize() {
1076 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
1078 void View3D_i::Restore() {
1079 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
1081 void View3D_i::Maximize() {
1082 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
1086 //===========================================================================
1087 class TUpdateViewerEvent: public SALOME_Event{
1088 QAD_StudyFrame* myStudyFrame;
1092 TUpdateViewerEvent(QAD_StudyFrame* theStudyFrame,
1095 myStudyFrame(theStudyFrame),
1097 myDisplaing(theDisplaing)
1099 virtual void Execute(){
1100 UpdateViewer(myStudyFrame,myDisplaing,myPrs3d);
1104 void View3D_i::EraseAll() {
1105 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1106 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eEraseAll));
1109 void View3D_i::DisplayAll() {
1110 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1111 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eDisplayAll));
1114 void View3D_i::Erase(PrsObject_ptr thePrsObj) {
1115 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1116 CORBA::Object_ptr anObj = thePrsObj;
1117 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1118 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eErase));
1122 void View3D_i::Display(PrsObject_ptr thePrsObj) {
1123 if(MYDEBUG) MESSAGE("View3D_i::Display");
1124 CORBA::Object_ptr anObj = thePrsObj;
1125 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1126 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplay));
1130 void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
1131 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1132 CORBA::Object_ptr anObj = thePrsObj;
1133 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1134 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplayOnly));
1138 //-------------------- View3D interface --------------------
1139 void View3D_i::FitAll() {
1140 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll));
1145 void View3D_i::SetView(VISU::View3D::ViewType theType) {
1147 case VISU::View3D::FRONT :
1148 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront));
1150 case VISU::View3D::BACK :
1151 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack));
1153 case VISU::View3D::LEFT :
1154 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft));
1156 case VISU::View3D::RIGHT :
1157 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight));
1159 case VISU::View3D::TOP :
1160 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop));
1162 case VISU::View3D::BOTTOM :
1163 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom));
1170 class TSet3DViewParamEvent: public SALOME_Event{
1172 typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, const CORBA::Double theParam[3]);
1173 TSet3DViewParamEvent(TFun theFun,
1174 QAD_StudyFrame* theStudyFrame,
1175 const CORBA::Double theParam[3]):
1177 myStudyFrame(theStudyFrame),
1180 virtual void Execute(){
1181 myFun(myStudyFrame,myParam);
1185 QAD_StudyFrame* myStudyFrame;
1186 const CORBA::Double* myParam;
1190 void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
1191 GetCamera(theStudyFrame)->SetPosition(thePosition);
1193 void View3D_i::SetPointOfView(const VISU::View3D::XYZ thePosition) {
1194 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1195 ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myStudyFrame,thePosition));
1199 void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) {
1200 GetCamera(theStudyFrame)->GetPosition(thePosition);
1202 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() {
1203 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1204 CORBA::Double aPosition[3];
1205 GetPointOfView(myStudyFrame,aPosition);
1206 return VISU::View3D::XYZ_dup(aPosition);
1210 void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
1211 GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1213 void View3D_i::SetViewUp(const VISU::View3D::XYZ theViewUp) {
1214 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1215 ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myStudyFrame,theViewUp));
1219 void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) {
1220 GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1222 VISU::View3D::XYZ_slice* View3D_i::GetViewUp() {
1223 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1224 CORBA::Double aViewUp[3];
1225 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
1226 return VISU::View3D::XYZ_dup(aViewUp);
1230 void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
1231 GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1233 void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1234 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1235 ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myStudyFrame,theCoord));
1239 void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) {
1240 GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1242 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() {
1243 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1244 CORBA::Double aFocalPnt[3];
1245 GetFocalPoint(myStudyFrame,aFocalPnt);
1246 return VISU::View3D::XYZ_dup(aFocalPnt);
1250 class TSetViewParamEvent: public SALOME_Event{
1252 typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, CORBA::Double theParam);
1253 TSetViewParamEvent(TFun theFun,
1254 QAD_StudyFrame* theStudyFrame,
1255 CORBA::Double theParam):
1257 myStudyFrame(theStudyFrame),
1260 virtual void Execute(){
1261 myFun(myStudyFrame,myParam);
1265 QAD_StudyFrame* myStudyFrame;
1266 CORBA::Double myParam;
1270 void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
1271 GetCamera(theStudyFrame)->SetParallelScale(theScale);
1273 void View3D_i::SetParallelScale(CORBA::Double theScale) {
1274 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1275 ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myStudyFrame,theScale));
1279 CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) {
1280 return GetCamera(theStudyFrame)->GetParallelScale();
1282 CORBA::Double View3D_i::GetParallelScale() {
1283 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1284 return GetParallelScale(myStudyFrame);
1287 void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1288 VTKViewer_ViewFrame* aViewFrame = GetViewFrame(theStudyFrame);
1289 double aScaleFactor[3];
1290 aViewFrame->GetScale(aScaleFactor);
1291 aScaleFactor[theAxis] = theParam;
1292 aViewFrame->SetScale(aScaleFactor);
1295 void SetScaleView(QAD_StudyFrame* theStudyFrame, const CORBA::Double theScale[3]){
1296 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1297 GetViewFrame(theStudyFrame)->SetScale(aScale);
1299 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1300 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1302 GetViewFrame(myStudyFrame)->GetScale(aScale);
1303 aScale[theAxis] = theParam;
1304 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1306 void View3D_i::RemoveScale() {
1307 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1308 double aScale[3] = {1.0, 1.0, 1.0};
1309 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1311 //===========================================================================
1315 /*! SAN & VSR : Test QT_EVENT
1316 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1318 #include "VISU_Gen_i.hh"
1319 #include "QAD_Config.h"
1320 #include <vtkPolyDataMapper.h>
1321 #include <vtkSphereSource.h>
1322 #include <vtkProperty.h>
1325 class TestViewEvent : public SALOME_Event {
1327 virtual void Execute(){
1328 QAD_Desktop* desktop = QAD_Application::getDesktop();
1329 QAD_Study* aStudy = desktop->getActiveStudy();
1331 QString defViewer = QAD_CONFIG->getSetting( "Viewer::DefaultViewer" );
1332 int dv = defViewer.toInt();
1333 QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( VIEW_VTK ) );
1334 desktop->createStudy();
1335 if ( !defViewer.isEmpty() ) {
1336 QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( dv ) );
1340 aStudy->newWindow3d( "", VIEW_VTK );
1345 void VISU_Gen_i::CreateTestView() {
1346 TestViewEvent* ve = new TestViewEvent();
1352 class TestObjectEvent : public SALOME_Event {
1354 virtual void Execute(){
1355 float aRadius = 150.0 * random() / RAND_MAX + 10.;
1356 float aX = 1000.0 * random() / RAND_MAX - 500.;
1357 float aY = 1000.0 * random() / RAND_MAX - 500.;
1358 float aZ = 1000.0 * random() / RAND_MAX - 500.;
1359 float aR = (float)random() / RAND_MAX;
1360 float aG = (float)random() / RAND_MAX;
1361 float aB = (float)random() / RAND_MAX;
1363 vtkSphereSource* aSource = vtkSphereSource::New();
1364 aSource->SetRadius( aRadius );
1365 aSource->SetCenter( aX, aY, aZ );
1367 vtkProperty* prop = vtkProperty::New();
1368 prop->SetColor( aR, aG, aB );
1370 vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
1371 aMapper->SetInput( aSource->GetOutput() );
1373 vtkActor* sphere = vtkActor::New();
1374 sphere->SetMapper( aMapper );
1375 sphere->SetProperty( prop );
1377 QAD_Desktop* desktop = QAD_Application::getDesktop();
1378 QAD_Study* aStudy = desktop->getActiveStudy();
1381 QAD_StudyFrame* sf = desktop->getActiveStudy()->getActiveStudyFrame();
1382 VTKViewer_ViewFrame* vf = GetViewFrame( sf );
1385 sphere->SetVisibility( true );
1386 vf->getRenderer()->AddActor(sphere);
1391 void VISU_Gen_i::ShowTestObject() {
1392 TestObjectEvent* ve = new TestObjectEvent();
1397 /*! SAN & VSR : Test QT_EVENT
1398 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<