]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI.cxx
Salome HOME
SMH: 3.0.0 preparation - merged and adopted version (POLYWORK+HEAD)
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : VisuGUI.cxx
25 //  Author : Laurent CORNABE
26 //  Module : VISU
27 //  $Header$
28
29 #include <exception>
30 #include <typeinfo>
31 #include <vector>
32
33 #include <qptrlist.h>
34 #include <qptrvector.h>
35
36 #include <vtkRenderer.h>
37 #include <vtkRenderWindow.h>
38 #include <vtkActorCollection.h>
39
40 #include "SALOME_LifeCycleCORBA.hxx"
41
42 #include "SUIT_ResourceMgr.h"
43 #include "SUIT_MessageBox.h"
44
45 #include "SUIT_ViewWindow.h"
46 #include "SUIT_ViewManager.h"
47
48 #include "CAM_Module.h"
49
50 #include "SVTK_RenderWindow.h"
51 #include "SVTK_ViewWindow.h"
52
53 #include "SVTK_ViewModel.h"
54 #include "SVTK_Functor.h"
55
56 #include "OB_Browser.h"
57
58 #include "SALOME_ListIO.hxx"
59 #include "SALOME_ListIteratorOfListIO.hxx"
60
61 #include "SalomeApp_Application.h"
62 #include "SalomeApp_DataModel.h"
63 #include "SalomeApp_Study.h"
64 #include "SalomeApp_SelectionMgr.h"
65 #include "SalomeApp_Selection.h"
66
67 #include "VISUConfig.hh"
68 #include "VISU_Gen_i.hh"
69 #include "VISU_Mesh_i.hh"
70 #include "VISU_Table_i.hh"
71 #include "VISU_Result_i.hh"
72 #include "VISU_View_i.hh"
73 #include "VISU_ViewManager_i.hh"
74
75 #include "VISU_Actor.h"
76
77 #include "VisuGUI.h"
78 #include "VisuGUI_Tools.h"
79 #include "VisuGUI_PopupTools.h"
80 #include "VisuGUI_FileDlg.h"
81 #include "VisuGUI_Selection.h"
82 #include "VisuGUI_TimeAnimation.h"
83 #include "VisuGUI_EditContainerDlg.h"
84
85 #include "VISU_ScalarMap_i.hh"
86 #include "VisuGUI_ScalarBarDlg.h"
87
88 #include "VISU_DeformedShape_i.hh"
89 #include "VisuGUI_DeformedShapeDlg.h"
90
91 #include "VISU_IsoSurfaces_i.hh"
92 #include "VisuGUI_IsoSurfacesDlg.h"
93
94 #include "VISU_CutPlanes_i.hh"
95 #include "VisuGUI_CutPlanesDlg.h"
96
97 #include "VISU_CutLines_i.hh"
98 #include "VisuGUI_CutLinesDlg.h"
99
100 #include "VISU_StreamLines_i.hh"
101 #include "VisuGUI_StreamLinesDlg.h"
102
103 #include "VISU_Vectors_i.hh"
104 #include "VisuGUI_VectorsDlg.h"
105
106 #include "SALOMEconfig.h"
107 #include CORBA_SERVER_HEADER(MED_Gen)
108
109 #include "utilities.h"
110
111 using namespace VISU;
112
113 #ifdef _DEBUG_
114 static int MYDEBUG = 1;
115 #else
116 static int MYDEBUG = 0;
117 #endif
118
119 //////////////////////////////////////////////////
120 // Class: VisuGUI
121 //////////////////////////////////////////////////
122
123 VisuGUI::VisuGUI():
124   SalomeApp_Module( "VISU" )
125 {
126 }
127
128
129 VisuGUI::~VisuGUI()
130 {
131 }
132
133
134 void
135 VisuGUI::
136 OnImportFromFile()
137 {
138   if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
139   CheckLock(GetDSStudy(GetCStudy(GetAppStudy(this))),this);
140   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
141
142   QStringList aFilter;
143   aFilter.append( tr("FLT_MED_FILES") );
144   aFilter.append( tr("FLT_ALL_FILES") );
145
146   QFileInfo aFileInfo =
147     SUIT_FileDlg::getFileName(GetDesktop(this),
148                               "",
149                               aFilter,
150                               tr("MEN_IMPORT_FROM_FILE"),
151                               true);
152   if(aFileInfo.exists()){
153     application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
154
155     VISU::Result_var aResult;
156     bool anIsBuild = aResourceMgr->booleanValue("Visu:BuildResult",false);
157     if(VisuGUI_FileDlg::IsBuild){
158       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
159       if(!CORBA::is_nil(aResult.in()))
160         if(Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())){
161           if(!aRes->IsPossible())
162             SUIT_MessageBox::warn1(GetDesktop(this),
163                                    tr("WRN_VISU"),
164                                    tr("ERR_CANT_BUILD_PRESENTATION"),
165                                    tr("BUT_OK") );
166           else
167             aRes->BuildAll();
168         }
169     }else{
170       aResourceMgr->setValue("Visu:BuildResult",false);
171       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
172       aResourceMgr->setValue("Visu:BuildResult",anIsBuild);
173     }
174
175     if(CORBA::is_nil(aResult.in())) {
176       SUIT_MessageBox::warn1(GetDesktop(this),
177                              tr("WRN_VISU"),
178                              tr("ERR_ERROR_IN_THE_FILE"),
179                              tr("BUT_OK") );
180     }else{
181       application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
182       updateObjBrowser();
183     }
184   }
185 }
186
187
188 void
189 VisuGUI::
190 OnExploreMEDFile()
191 {
192   if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
193   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
194   CheckLock(GetDSStudy(aStudy),this);
195
196   SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
197
198   QStringList aFilter;
199   aFilter.append( tr("FLT_MED_FILES") );
200   aFilter.append( tr("FLT_ALL_FILES") );
201
202   QFileInfo aFileInfo =
203     SUIT_FileDlg::getFileName(GetDesktop(this),
204                               "",
205                               aFilter,
206                               tr("MEN_EXPLORE_MED_FILE"),
207                               true);
208   if(aFileInfo.exists()){
209     application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
210     std::string aStudyName = aStudy->Name();
211     aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
212     application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
213     updateObjBrowser();
214   }
215 }
216
217
218 void
219 VisuGUI::
220 OnImportTableFromFile()
221 {
222   if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
223   CheckLock(GetDSStudy(GetCStudy(GetAppStudy(this))),this);
224
225   QStringList aFilter;
226   aFilter.append( tr("FLT_TABLE_FILES") );
227   aFilter.append( tr("FLT_ALL_FILES") );
228
229   QFileInfo aFileInfo =
230     SUIT_FileDlg::getFileName(GetDesktop(this),
231                               "",
232                               aFilter,
233                               tr("MEN_IMPORT_TABLE"),
234                               true);
235   if(aFileInfo.exists()){
236     application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
237
238     CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
239
240     if(CORBA::is_nil(anObject.in())) {
241       SUIT_MessageBox::warn1(GetDesktop(this),
242                              tr("WRN_VISU"),
243                              tr("ERR_ERROR_IN_THE_FILE"),
244                              tr("BUT_OK") );
245     }else{
246       application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
247       updateObjBrowser();
248     }
249   }
250 }
251
252
253 template<class TPrs3d_i>
254 TPrs3d_i*
255 CreatePrs3d(SalomeApp_Module* theModule,
256             SALOMEDS::SObject_var theTimeStamp,
257             const char* theMeshName,
258             VISU::Entity theEntity,
259             const char* theFieldName,
260             int theTimeId)
261 {
262   VISU::Result_var aResult;
263   if(CheckResult(theModule,theTimeStamp,aResult)){
264     QApplication::setOverrideCursor(Qt::waitCursor);
265     typedef typename TPrs3d_i::TInterface TPrs3d;
266     typename TPrs3d::_var_type aPrs3d =
267       GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
268       (aResult,theMeshName,theEntity,theFieldName,theTimeId);
269     QApplication::restoreOverrideCursor();
270     if(!CORBA::is_nil(aPrs3d.in()))
271       return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
272   }
273   SUIT_MessageBox::warn1(GetDesktop(theModule),
274                          QObject::tr("WRN_VISU"),
275                          QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
276                          QObject::tr("BUT_OK") );
277   return NULL;
278 }
279
280
281 template<class TPrs3d_i, class TDlg, int IsDlgModal>
282 bool
283 CreatePrs3d(SalomeApp_Module* theModule,
284             SALOMEDS::SObject_var theTimeStamp,
285             const Handle(SALOME_InteractiveObject)& theIO)
286 {
287   using namespace VISU;
288   Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
289   bool isExist;
290   QString aType = Storable::FindValue(aMap,"myType",&isExist);
291   if(!isExist || aType.toInt() != TTIMESTAMP )
292     return false;
293   QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
294   QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
295   QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
296   QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
297   TPrs3d_i* aPrs3d =
298     CreatePrs3d<TPrs3d_i>(theModule,
299                           theTimeStamp,
300                           aMeshName.latin1(),
301                           (Entity)anEntity.toInt(),
302                           aFieldName.latin1(),
303                           aTimeStampId.toInt());
304   if(aPrs3d){
305     SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
306     int aValue = aResourceMgr->integerValue("Visu:BuildDefaultPrs3d",0);
307     if(!aValue){
308       if(TDlg* aDlg = new TDlg(GetDesktop(theModule))){
309         aDlg->initFromPrsObject(aPrs3d);
310         if(IsDlgModal)
311           if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
312             delete aDlg;
313           } else {
314             DeletePrs3d(theModule,aPrs3d,theIO);
315             delete aDlg;
316             return false;
317           }
318         else{
319           aDlg->show();
320           return true;
321         }
322       }
323     }
324     PublishInView(theModule,aPrs3d);
325     return true;
326   }
327   return false;
328 }
329
330
331 template<class TPrs3d_i, class TDlg, int IsDlgModal>
332 void
333 CreatePrs3d(SalomeApp_Module* theModule)
334 {
335   if(CheckLock(GetDSStudy(GetCStudy(GetAppStudy(theModule))),theModule))
336     return;
337
338   SALOMEDS::SObject_var aTimeStampSObj;
339   Handle(SALOME_InteractiveObject) anIO;
340   if(!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
341     return;
342
343   if(!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
344     return;
345
346   theModule->application()->putInfo(QObject::tr("INF_DONE"));
347   theModule->updateObjBrowser();
348
349   if(SVTK_ViewWindow* aView = GetViewWindow(theModule))
350     aView->onFitAll();
351 }
352
353 void
354 VisuGUI::
355 OnCreateMesh()
356 {
357   SALOMEDS::Study_var aStudy = GetDSStudy(GetCStudy(GetAppStudy(this)));
358   if (CheckLock(aStudy, this))
359     return;
360
361   // Get selected SObject
362   SALOMEDS::SObject_var aResultSObj;
363   Handle(SALOME_InteractiveObject) anIO;
364   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
365   if (anIO.IsNull() || !anIO->hasEntry())
366     return;
367
368   aResultSObj = aStudy->FindObjectID(anIO->getEntry());
369
370   // Get VISU::Result
371   VISU::Result_var aResult;
372   VISU::Result_i* pResult = CheckResult(this, aResultSObj, aResult);
373   if (pResult == NULL)
374     return;
375
376   Storable::TRestoringMap aMap = getMapOfValue(aResultSObj);
377   bool isExist;
378   string aComment = Storable::FindValue(aMap,"myComment",&isExist).latin1();
379   if (!isExist)
380     return;
381
382   CORBA::Object_var aMesh;
383   string aMeshName = Storable::FindValue(aMap,"myMeshName").latin1();
384 #ifdef CHECKTIME
385   Utils_Timer timer;
386   timer.Start();
387 #endif
388   if (aComment == "ENTITY") {
389     VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
390     if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
391       aMesh = GetVisuGen(this)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
392   } else if (aComment == "FAMILY") {
393     VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
394     string aFamilyName = Storable::FindValue(aMap,"myName").latin1();
395     if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
396       aMesh = GetVisuGen(this)->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
397   } else if (aComment == "GROUP") {
398     string aGroupName = Storable::FindValue(aMap,"myName").latin1();
399     if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
400       aMesh = GetVisuGen(this)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
401   }
402 #ifdef CHECKTIME
403   timer.Stop();
404   MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
405   timer.Show();
406 #endif
407
408   QApplication::restoreOverrideCursor();
409   VISU::Mesh_i* pPresent = NULL;
410   if (!CORBA::is_nil(aMesh))
411     pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
412   if (pPresent == NULL) {
413     SUIT_MessageBox::warn1 (GetDesktop(this),
414                             tr("VISU_WARNING"),
415                             tr("ERR_CANT_BUILD_PRESENTATION"),
416                             tr("VISU_BUT_OK"));
417     return;
418   }
419
420   if (SVTK_ViewWindow* aView = GetViewWindow(this)){
421     try {
422 #ifdef CHECKTIME
423       Utils_Timer timer;
424       timer.Start();
425 #endif
426       PublishInView(this, pPresent);
427       aView->onFitAll();
428 #ifdef CHECKTIME
429       timer.Stop();
430       MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
431       timer.Show();
432 #endif
433       application()->putInfo(QObject::tr("INF_DONE"));
434     } catch (std::runtime_error& exc) {
435       INFOS(exc.what());
436       SUIT_MessageBox::warn1 (GetDesktop(this),
437                               tr("VISU_WARNING"),
438                               tr("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
439                               tr("VISU_BUT_OK"));
440     }
441   }
442 }
443
444 void
445 VisuGUI::
446 OnCreateScalarMap()
447 {
448   CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
449 }
450
451
452 void
453 VisuGUI::
454 OnCreateDeformedShape()
455 {
456   CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
457 }
458
459 void
460 VisuGUI::
461 OnCreateVectors()
462 {
463   CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
464 }
465
466 void
467 VisuGUI::
468 OnCreateIsoSurfaces()
469 {
470   CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
471 }
472
473 void
474 VisuGUI::
475 OnCreateCutPlanes()
476 {
477   CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
478 }
479
480 void
481 VisuGUI::
482 OnCreateCutLines()
483 {
484   CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
485 }
486
487 void
488 VisuGUI::
489 OnCreateStreamLines()
490 {
491   CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
492 }
493
494 void
495 VisuGUI::
496 OnCreateManyMesh()
497 {
498 }
499
500 void
501 VisuGUI::
502 OnCreatePlot2dView()
503 {
504   CheckLock(GetDSStudy(GetCStudy(GetAppStudy(this))),this);
505   GetVisuGen( this )->CreateContainer();
506   updateObjBrowser();
507 }
508
509 void
510 VisuGUI::
511 OnDisplayPrs()
512 {
513   if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
514   Handle(SALOME_InteractiveObject) anIO;
515   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
516   if ( !CORBA::is_nil( anObject ) ) {
517     // is it Prs3d object ?
518     VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
519     if(aPrsObject){
520       if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
521       UpdateViewer( this, aPrsObject );
522       if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
523         vw->getRenderer()->ResetCameraClippingRange();
524         vw->Repaint();
525         vw->highlight(anIO, 1);
526       }
527       return;
528     }
529     // is it Curve ?
530     VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
531     if(aCurve){
532       if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
533       PlotCurve( this, aCurve, VISU::eDisplay );
534       return;
535     }/*
536     // is it Container ?
537     VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
538     if(aContainer){
539       if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
540       PlotContainer(aContainer, VISU::eDisplay );
541       return;
542     }
543     // is it Table ?
544     VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
545     if(aTable){
546       if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
547       PlotTable(aTable, VISU::eDisplay );
548       return;
549       }*/
550   }
551 }
552
553 void
554 VisuGUI::
555 OnDisplayOnlyPrs()
556 {
557 }
558
559 void VisuGUI::ErasePrs (CORBA::Object_ptr theObject)
560 {
561   if (MYDEBUG) MESSAGE("ErasePrs");
562
563   if ( !CORBA::is_nil( theObject ) ) {
564     VISU::Base_var aBase = VISU::Base::_narrow(theObject);
565     if ( CORBA::is_nil( aBase ) ) return;
566     VISU::VISUType aType = aBase->GetType();
567     switch (aType){
568     case VISU::TCURVE:{
569       if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
570         PlotCurve(this, aCurve, VISU::eErase );
571       break;
572     }
573     case VISU::TCONTAINER:{
574       if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
575         PlotContainer(this, aContainer, VISU::eErase );
576       break;
577     }
578     case VISU::TTABLE:{
579       if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
580         PlotTable(this, aTable, VISU::eErase );
581       break;
582     }
583     default:{
584       if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
585         ErasePrs3d( this, aPrsObject );
586         if (SVTK_ViewWindow* vw = GetViewWindow( this ))
587           vw->Repaint();
588       }
589     }
590     } // switch (aType)
591   }
592 }
593
594 void
595 VisuGUI::
596 OnErasePrs()
597 {
598   if(MYDEBUG) MESSAGE("OnErasePrs");
599   Handle(SALOME_InteractiveObject) anIO;
600   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
601   ErasePrs(anObject);
602 }
603
604 void
605 VisuGUI::
606 OnEditPrs()
607 {
608 }
609
610 void
611 VisuGUI::
612 OnDeletePrs()
613 {
614 }
615
616 void
617 VisuGUI::
618 OnDisplayManyPrs()
619 {
620 }
621
622 void
623 VisuGUI::
624 OnEraseManyPrs()
625 {
626 }
627
628 void
629 VisuGUI::
630 OnDisplayOnlyManyPrs()
631 {
632 }
633
634 void
635 VisuGUI::
636 OnMakeSurfaceframe()
637 {
638 }
639
640 void
641 VisuGUI::
642 OnMakeInsideframe()
643 {
644 }
645
646 void
647 VisuGUI::
648 OnMakeWireframe()
649 {
650 }
651
652 void
653 VisuGUI::
654 OnMakeSurface()
655 {
656 }
657
658 void
659 VisuGUI::
660 OnMakePoints()
661 {
662 }
663
664 void
665 VisuGUI::
666 OnMakeShrink()
667 {
668 }
669
670 void
671 VisuGUI::
672 OnChangeColor()
673 {
674 }
675
676 void
677 VisuGUI::
678 OnChangeWireframeColor()
679 {
680 }
681
682 void
683 VisuGUI::
684 OnChangeOpacity()
685 {
686 }
687
688 void
689 VisuGUI::
690 OnChangeLines()
691 {
692 }
693
694 void
695 VisuGUI::
696 OnShowTable()
697 {
698 }
699
700 void
701 VisuGUI::
702 OnCreateTable()
703 {
704   Handle(SALOME_InteractiveObject) anIO;
705   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );  
706   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
707   _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
708   VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
709   if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
710     GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
711     updateObjBrowser();
712   }
713 }
714
715 void
716 VisuGUI::
717 OnDeleteObject()
718 {
719   SALOMEDS::Study_var aStudy = GetDSStudy(GetCStudy(GetAppStudy(this)));
720   if (CheckLock(aStudy, this))
721     return;
722
723   Handle(SALOME_InteractiveObject) anIO;
724   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
725   if (anIO.IsNull() || !anIO->hasEntry())
726     return;
727
728   SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
729   if (!aSObject->_is_nil()) {
730     SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
731     for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
732       SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
733       CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
734       ErasePrs(aChildObj);
735     }
736     SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
737     // There is a transaction
738     aStudyBuilder->NewCommand();
739     CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
740     if (!CORBA::is_nil(anObj)) {
741       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
742       if (!CORBA::is_nil(aBase)) {
743         VISU::VISUType aType = aBase->GetType();
744         switch (aType) {
745         case VISU::TRESULT:
746           {
747             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
748             for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
749               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
750               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
751               if (CORBA::is_nil(aChildObj)) continue;
752               VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
753               if (CORBA::is_nil(aPrs3d)) continue;
754               VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
755               //jfa tmp:DeletePresentation(pPrs3d);
756             }
757             break;
758           }
759         case VISU::TTABLE:
760           {
761             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
762             for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
763               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
764               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
765               if (CORBA::is_nil(aChildObj)) continue;
766               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(aChildObj);
767               if (CORBA::is_nil(aCurve)) continue;
768               VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
769               //jfa tmp:DeletePresentation(pCurve);
770             }
771             break;
772           }
773         }
774       }
775     }
776     aStudyBuilder->RemoveObjectWithChildren(aSObject);
777     aStudyBuilder->CommitCommand();
778     //jfa tmp:GetActiveStudy()->unHighlightAll();
779     updateObjBrowser(true);
780   }
781 }
782
783 void
784 VisuGUI::
785 OnPlotData()
786 {
787 }
788
789 void
790 VisuGUI::
791 OnCurveProperties()
792 {
793 }
794
795 void
796 VisuGUI::
797 OnClearContainer()
798 {
799   SALOMEDS::Study_var aStudy = GetDSStudy(GetCStudy(GetAppStudy(this)));
800   if (CheckLock(aStudy, this))
801     return;
802
803   Handle(SALOME_InteractiveObject) anIO;
804   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
805   if (anIO.IsNull() || CORBA::is_nil(anObject))
806     return;
807
808   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
809   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
810     // Container object
811     CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
812     if (!CORBA::is_nil(aCnt)) {
813       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
814       if (container && container->GetNbCurves() > 0) {
815         container->Clear();
816         updateObjBrowser();
817       }
818     }
819   }
820 }
821
822 void
823 VisuGUI::
824 OnEditContainer()
825 {
826   Handle(SALOME_InteractiveObject) anIO;
827   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
828   if (CORBA::is_nil(anObject)) return;
829
830   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
831   if (!aServant.in()) return;
832   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
833   if (!aContainer) return;
834
835   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (GetDesktop(this));
836   aDlg->initFromPrsObject(aContainer);
837   if (aDlg->exec()) {
838     aDlg->storeToPrsObject(aContainer);
839     updateObjBrowser(true);
840   }
841   delete aDlg;
842 }
843
844 void
845 VisuGUI::
846 OnSaveViewParams()
847 {
848   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
849   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
850   if (CheckLock(aStudy, this))
851     return;
852
853   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
854   if (aViewMgr->getType() != SVTK_Viewer::Type())
855     return;
856
857   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
858   SALOME_ListIO aListIO;
859   aSelectionMgr->selectedObjects(aListIO);
860   if (aListIO.Extent() > 1)
861     return;
862
863   if (aListIO.Extent() == 0) {
864     VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
865   } else {
866     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
867     VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
868   }
869   updateObjBrowser();
870 }
871
872 void
873 VisuGUI::
874 OnRestoreViewParams()
875 {
876   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
877   if (aViewMgr->getType() != SVTK_Viewer::Type())
878     return;
879
880   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
881   SALOME_ListIO aListIO;
882   aSelectionMgr->selectedObjects(aListIO);
883   if (aListIO.Extent() != 1)
884     return;
885
886   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
887   //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
888   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
889   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
890   VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
891 }
892
893 void
894 VisuGUI::
895 OnDeleteViewParams()
896 {
897   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
898   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
899   if (CheckLock(aStudy, this))
900     return;
901
902   Handle(SALOME_InteractiveObject) anIO;
903   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
904   _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
905   if (!aSObject) return;
906
907   VISU::VISUType aType = (VISU::VISUType)getValue(aSObject, "myType").toInt();
908   if (aType == VISU::TVIEW3D) {
909     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
910     SALOME_ListIO aListIO, aNewListIO;
911     aSelectionMgr->selectedObjects(aListIO);
912     for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
913       if (it.Value()->getEntry() != anIO->getEntry()) {
914         aNewListIO.Append(it.Value());
915       }
916     }
917     aSelectionMgr->setSelectedObjects(aNewListIO);
918
919     aCStudy->NewBuilder()->RemoveObject(aSObject);
920
921     updateObjBrowser();
922   }
923 }
924
925 void
926 VisuGUI::
927 OnRename()
928 {
929 }
930
931 void
932 VisuGUI::
933 OnRenameTable()
934 {
935 }
936
937 void
938 VisuGUI::
939 OnRenameContainer()
940 {
941 }
942
943 void
944 VisuGUI::
945 OnSweep()
946 {
947   // GetSelectedPrs3d
948   Handle(SALOME_InteractiveObject) anIO;
949   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
950   if (CORBA::is_nil(anObject)) return;
951   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
952   if (!aServant.in()) return;
953
954   VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
955   if (!aPrsObject) return;
956
957   SVTK_ViewWindow* vw = GetViewWindow();
958   if (!vw) return;
959
960   VISU_Actor* aActor = GetActor(aPrsObject, vw);
961   if (!aActor) return;
962
963   if (!aActor->GetVisibility()) {
964     aActor->VisibilityOn();
965   }
966
967   // Get sweep parameters
968   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
969
970   double aTempoDbl = aResourceMgr->doubleValue("Visu:SweepTempo", 0.1);
971   int aTemp = int(1.E6 * aTempoDbl);
972
973   int aCycles = aResourceMgr->integerValue("Visu:SweepCycles", 1);
974   int aSteps  = aResourceMgr->integerValue("Visu:SweepSteps", 40);
975
976   // Sweep
977   QApplication::setOverrideCursor(Qt::waitCursor);
978   try {
979     for (int j = 0; j < aCycles; j++) {
980       for (int i = 0; i <= aSteps; i++) {
981         float aPercents = float(i)/aSteps;
982         aPrsObject->SetMapScale(aPercents);
983         aPrsObject->UpdateActor(aActor);
984         vw->getRenderWindow()->getRenderWindow()->Render();
985         usleep(aTemp);
986       }
987     }
988   } catch (std::exception& exc) {
989     INFOS("Follow exception was occured :\n" << exc.what());
990   } catch (...) {
991     INFOS("Unknown exception was occured!");
992   }
993   QApplication::restoreOverrideCursor();
994 }
995
996 void
997 VisuGUI::
998 OnTimeAnimation()
999 {
1000   _PTR(Study) aStudyDS = GetCStudy(GetAppStudy(this));
1001   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1002     new VisuGUI_TimeAnimationDlg(GetDesktop(this), aStudyDS);
1003
1004   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1005   SALOME_ListIO aListIO;
1006   aSelectionMgr->selectedObjects(aListIO);
1007
1008   bool isDefined = false;
1009   long aNbTimes = 0;
1010   SALOME_ListIteratorOfListIO It (aListIO);
1011   for (; It.More(); It.Next()) {
1012     _PTR(SObject) aSObject = aStudyDS->FindObjectID(It.Value()->getEntry());
1013     if (!aSObject) continue;
1014     if (getValue(aSObject, "myComment") == QString("FIELD")) {
1015       long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1016       if (aNumber > 1) {
1017         if (!isDefined) {
1018           aNbTimes = aNumber;
1019           aAnimationDlg->addField(aSObject);
1020           isDefined = true;
1021         } else if (aNbTimes == aNumber) {
1022           aAnimationDlg->addField(aSObject);
1023         }
1024       }
1025     }
1026   }
1027   if (isDefined) aAnimationDlg->show();
1028   else delete aAnimationDlg;
1029 }
1030
1031 void
1032 VisuGUI::
1033 OnCopyPresentation()
1034 {
1035 }
1036
1037 void
1038 VisuGUI::
1039 OnSelectionInfo()
1040 {
1041   //mySelectionDlg = new VisuGUI_SelectionDlg();
1042   //mySelectionDlg->show();
1043   (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1044 }
1045
1046 void
1047 VisuGUI::
1048 initialize( CAM_Application* theApp )
1049 {
1050   SalomeApp_Module::initialize( theApp );
1051
1052   createActions();
1053   createMenus();
1054   createToolBars();
1055   createPopupMenus();
1056 }
1057
1058 void
1059 VisuGUI::
1060 createActions()
1061 {
1062   QPixmap aPixmap;
1063   QWidget* aParent = application()->desktop();
1064   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1065
1066   // Create actions
1067   createAction( 112, "", QIconSet(), tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1068                 this, SLOT(OnImportFromFile()));
1069   createAction( 113, "", QIconSet(), tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1070                 this, SLOT(OnExploreMEDFile()));
1071   createAction( 199, "", QIconSet(), tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1072                 this, SLOT(OnImportTableFromFile()));
1073
1074   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1075   createAction( 4011, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap), tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1076                 this, SLOT(OnCreateScalarMap()));
1077
1078   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1079   createAction( 4012, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap), tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1080                 this, SLOT(OnCreateDeformedShape()));
1081
1082   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1083   createAction( 4013, tr("MEN_VECTORS"), QIconSet(aPixmap), tr("MEN_VECTORS"), "", 0, aParent, false,
1084                 this, SLOT(OnCreateVectors()));
1085
1086   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
1087   createAction( 4014, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap), tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
1088                 this, SLOT(OnCreateIsoSurfaces()));
1089
1090   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
1091   createAction( 4015, tr("MEN_CUT_PLANES"), QIconSet(aPixmap), tr("MEN_CUT_PLANES"), "", 0, aParent, false,
1092                 this, SLOT(OnCreateCutPlanes()));
1093
1094   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
1095   createAction( 4016, tr("MEN_STREAM_LINES"), QIconSet(aPixmap), tr("MEN_STREAM_LINES"), "", 0, aParent, false,
1096                 this, SLOT(OnCreateStreamLines()));
1097
1098   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
1099   createAction( 4018, tr("MEN_CUT_LINES"), QIconSet(aPixmap), tr("MEN_CUT_LINES"), "", 0, aParent, false,
1100                 this, SLOT(OnCreateCutLines()));
1101
1102   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1103   createAction( 4020, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap), tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
1104                 this, SLOT(OnCreatePlot2dView()));
1105
1106   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1107   createAction( 4021, tr("MEN_DELETE_OBJ"), QIconSet(aPixmap), tr("MEN_DELETE_OBJ"), "", 0, aParent, false,
1108                 this, SLOT(OnDeleteObject()));
1109
1110   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1111   createAction( 4022, tr("MEN_RENAME_TABLE"), QIconSet(aPixmap), tr("MEN_RENAME_TABLE"), "", 0, aParent, false,
1112                 this, SLOT(OnRenameTable()));
1113
1114   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1115   createAction( 4023, tr("MEN_SHOW_TABLE"), QIconSet(aPixmap), tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
1116                 this, SLOT(OnShowTable()));
1117
1118   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1119   createAction( 4024, tr("MEN_CREATE_CURVES"), QIconSet(aPixmap), tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
1120                 this, SLOT(OnPlotData()));
1121
1122   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1123   createAction( 4025, tr("MEN_EXPORT_TABLE"), QIconSet(aPixmap), tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
1124                 this, SLOT(OnExportTableToFile()));
1125
1126   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1127   createAction( 4026, tr("MEN_CREATE_PRS"), QIconSet(aPixmap), tr("MEN_CREATE_PRS"), "", 0, aParent, false,
1128                 this, SLOT(OnCreateMesh()));
1129
1130   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1131   createAction( 4027, tr("MEN_CREATE_MANY_PRS"), QIconSet(aPixmap), tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
1132                 this, SLOT(OnCreateManyMesh()));
1133
1134   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1135   createAction( 4030, tr("MEN_ERASE"), QIconSet(aPixmap), tr("MEN_ERASE"), "", 0, aParent, false,
1136                 this, SLOT(OnErasePrs()));
1137
1138   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1139   createAction( 4031, tr("MEN_DISPLAY"), QIconSet(aPixmap), tr("MEN_DISPLAY"), "", 0, aParent, false,
1140                 this, SLOT(OnDisplayPrs()));
1141
1142   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1143   createAction( 4032, tr("MEN_DISPLAY_ONLY"), QIconSet(aPixmap), tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
1144                 this, SLOT(OnDisplayOnlyPrs()));
1145
1146   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1147   createAction( 4033, tr("MEN_DELETE_PRS"), QIconSet(aPixmap), tr("MEN_DELETE_PRS"), "", 0, aParent, false,
1148                 this, SLOT(OnDeletePrs()));
1149
1150   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1151   createAction( 4034, tr("MEN_DISPLAY"), QIconSet(aPixmap), tr("MEN_DISPLAY"), "", 0, aParent, false,
1152                 this, SLOT(OnDisplayManyPrs()));
1153
1154   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1155   createAction( 4035, tr("MEN_ERASE"), QIconSet(aPixmap), tr("MEN_ERASE"), "", 0, aParent, false,
1156                 this, SLOT(OnEraseManyPrs()));
1157
1158   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1159   createAction( 4036, tr("MEN_DISPLAY_ONLY"), QIconSet(aPixmap), tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
1160                 this, SLOT(OnDisplayOnlyManyPrs()));
1161
1162   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1163   createAction( 4037, tr("MEN_DELETE_PRS"), QIconSet(aPixmap), tr("MEN_DELETE_PRS"), "", 0, aParent, false,
1164                 this, SLOT(OnCopyPresentation()));
1165
1166   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1167   createAction( 4040, tr("MEN_CURVE_PROPS"), QIconSet(aPixmap), tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
1168                 this, SLOT(OnCurveProperties()));
1169
1170   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1171   createAction( 4041, tr("MEN_RENAME"), QIconSet(aPixmap), tr("MEN_RENAME"), "", 0, aParent, false,
1172                 this, SLOT(OnRename()));
1173
1174   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1175   createAction( 4042, tr("MEN_EDIT_CONTAINER"), QIconSet(aPixmap), tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
1176                 this, SLOT(OnEditContainer()));
1177
1178   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1179   createAction( 4043, tr("MEN_RENAME_CONTAINER"), QIconSet(aPixmap), tr("MEN_RENAME_CONTAINER"), "", 0, aParent, false,
1180                 this, SLOT(OnRenameContainer()));
1181
1182   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1183   createAction( 4044, tr("MEN_CLEAR_CONTAINER"), QIconSet(aPixmap), tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
1184                 this, SLOT(OnClearContainer()));
1185
1186   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1187   createAction( 4046, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(aPixmap),
1188                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
1189                 this, SLOT(OnSaveViewParams()));
1190
1191   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1192   createAction( 4047, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(aPixmap),
1193                 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
1194                 this, SLOT(OnRestoreViewParams()));
1195
1196   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1197   createAction( 4048, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(aPixmap),
1198                 tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
1199                 this, SLOT(OnDeleteViewParams()));
1200
1201   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1202   createAction( 4050, tr("MEN_POINTS"), QIconSet(aPixmap), tr("MEN_POINTS"), "", 0, aParent, false,
1203                 this, SLOT(OnMakePoints()));
1204
1205   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1206   createAction( 4051, tr("MEN_WIREFRAME"), QIconSet(aPixmap), tr("MEN_WIREFRAME"), "", 0, aParent, false,
1207                 this, SLOT(OnMakeWireframe()));
1208
1209   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1210   createAction( 4052, tr("MEN_SURFACE"), QIconSet(aPixmap), tr("MEN_SURFACE"), "", 0, aParent, false,
1211                 this, SLOT(OnMakeSurface()));
1212
1213   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1214   createAction( 4053, tr("MEN_INSIDEFRAME"), QIconSet(aPixmap), tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
1215                 this, SLOT(OnMakeInsideframe()));
1216
1217   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1218   createAction( 4054, tr("MEN_SURFACEFRAME"), QIconSet(aPixmap), tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
1219                 this, SLOT(OnMakeSurfaceframe()));
1220
1221   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1222   createAction( 4055, tr("MEN_SHRINK"), QIconSet(aPixmap), tr("MEN_SHRINK"), "", 0, aParent, false,
1223                 this, SLOT(OnMakeShrink()));
1224
1225   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1226   createAction( 4056, tr("MEN_UNSHRINK"), QIconSet(aPixmap), tr("MEN_UNSHRINK"), "", 0, aParent, false,
1227                 this, SLOT(OnMakeShrink()));
1228
1229   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1230   createAction( 4057, tr("MEN_CELL_COLOR"), QIconSet(aPixmap), tr("MEN_CELL_COLOR"), "", 0, aParent, false,
1231                 this, SLOT(OnChangeColor()));
1232
1233   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1234   createAction( 4058, tr("MEN_COLOR"), QIconSet(aPixmap), tr("MEN_COLOR"), "", 0, aParent, false,
1235                 this, SLOT(OnChangeColor()));
1236
1237   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1238   createAction( 4059, tr("MEN_EDGE_COLOR"), QIconSet(aPixmap), tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
1239                 this, SLOT(OnChangeWireframeColor()));
1240
1241   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1242   createAction( 4060, tr("MEN_OPACITY"), QIconSet(aPixmap), tr("MEN_OPACITY"), "", 0, aParent, false,
1243                 this, SLOT(OnChangeOpacity()));
1244
1245   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1246   createAction( 4061, tr("MEN_LINE_WIDTH"), QIconSet(aPixmap), tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
1247                 this, SLOT(OnChangeLines()));
1248
1249   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1250   createAction( 4062, tr("MEN_EDIT_PRS"), QIconSet(aPixmap), tr("MEN_EDIT_PRS"), "", 0, aParent, false,
1251                 this, SLOT(OnEditPrs()));
1252
1253   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1254   createAction( 4063, tr("MEN_CREATE_TABLE"), QIconSet(aPixmap), tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
1255                 this, SLOT(OnCreateTable()));
1256
1257   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1258   createAction( 4064, tr("MEN_SWEEP"), QIconSet(aPixmap), tr("MEN_SWEEP"), "", 0, aParent, false,
1259                 this, SLOT(OnSweep()));
1260
1261   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1262   createAction( 4065, tr("MEN_SELECTION_INFO"), QIconSet(aPixmap),
1263                 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
1264                 this, SLOT(OnSelectionInfo()));
1265
1266   aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1267   createAction( 4066, tr("MEN_ANIMATION"), QIconSet(aPixmap), tr("MEN_ANIMATION"), "", 0, aParent, false,
1268                 this, SLOT(OnTimeAnimation()));
1269 }
1270
1271 void
1272 VisuGUI::
1273 createMenus()
1274 {
1275   // Add actions to menus
1276   int aMenuId;
1277   aMenuId = createMenu( tr( "MEN_FILE" ), -1 );
1278   createMenu( separator(), aMenuId, 10 );
1279   createMenu( 112, aMenuId, 10 );
1280   createMenu( 113, aMenuId, 10 );
1281   createMenu( 199, aMenuId, 10 );
1282
1283   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
1284   //aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, 90 );
1285   createMenu( 4011, aMenuId, 10 );
1286   createMenu( 4012, aMenuId, 10 );
1287   createMenu( 4013, aMenuId, 10 );
1288   createMenu( 4014, aMenuId, 10 );
1289   createMenu( 4015, aMenuId, 10 );
1290   createMenu( 4016, aMenuId, 10 );
1291   createMenu( 4018, aMenuId, 10 );
1292   createMenu( 4065, aMenuId, 10 );
1293 }
1294
1295 void
1296 VisuGUI::
1297 createToolBars()
1298 {
1299   int aToolId = createTool(tr("TOOL_VISUALISATION"));
1300   createTool( 4011, aToolId );
1301   createTool( 4012, aToolId );
1302   createTool( 4013, aToolId );
1303   createTool( 4014, aToolId );
1304   createTool( 4015, aToolId );
1305   createTool( 4016, aToolId );
1306   createTool( 4018, aToolId );
1307 }
1308
1309 void
1310 VisuGUI::
1311 createPopupMenus()
1312 {
1313   // Prepare popup menus
1314   QtxPopupMgr* mgr = popupMgr();
1315
1316   // VISU root commands
1317   QString aRule( "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'" );
1318   mgr->insert( action(  112 ), -1, -1, -1 ); // import MED
1319   mgr->setRule( action( 112 ), aRule, true );
1320   mgr->insert( action(  199 ), -1, -1, -1 ); // import tables
1321   mgr->setRule( action( 199 ), aRule, true );
1322   mgr->insert( action(  4020 ), -1, -1, -1 ); // create Plot2d
1323   mgr->setRule( action( 4020 ), aRule, true );
1324   aRule = "client='ObjectBrowser' and selcount=1 and $type in {'VISU::TRESULT' 'VISU::TTABLE' 'VISU::TCONTAINER'}";
1325   mgr->insert( action(  4021 ), -1, -1, -1 ); // delete object
1326   mgr->setRule( action( 4021 ), aRule, true );
1327
1328   // timestamp commands
1329   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
1330   mgr->insert( action(  4011 ), -1, -1, -1 ); // scalar bar
1331   mgr->setRule( action( 4011 ), aRule, true );
1332   mgr->insert( action(  4014 ), -1, -1, -1 ); // iso surface
1333   mgr->setRule( action( 4014 ), aRule, true );
1334   mgr->insert( action(  4015 ), -1, -1, -1 ); // cut planes
1335   mgr->setRule( action( 4015 ), aRule, true );
1336   mgr->insert( action(  4018 ), -1, -1, -1 ); // cut lines
1337   mgr->setRule( action( 4018 ), aRule, true );
1338   aRule += " and nbComponents>1";
1339   mgr->insert( action(  4012 ), -1, -1, -1 ); // deformed shape
1340   mgr->setRule( action( 4012 ), aRule, true );
1341   mgr->insert( action(  4013 ), -1, -1, -1 ); // vectors
1342   mgr->setRule( action( 4013 ), aRule, true );
1343   mgr->insert( action(  4016 ), -1, -1, -1 ); // stream lines
1344   mgr->setRule( action( 4016 ), aRule, true );
1345
1346   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTABLE'";
1347   mgr->insert( action(  4022 ), -1, -1, -1 ); // rename table
1348   mgr->setRule( action( 4022 ), aRule, true );
1349   mgr->insert( action(  4023 ), -1, -1, -1 ); // show table
1350   mgr->setRule( action( 4023 ), aRule, true );
1351   mgr->insert( action(  4024 ), -1, -1, -1 ); // create curves
1352   mgr->setRule( action( 4024 ), aRule, true );
1353   mgr->insert( action(  4025 ), -1, -1, -1 ); // export table
1354   mgr->setRule( action( 4025 ), aRule, true );
1355   mgr->insert( separator(), -1, -1, -1 );
1356   aRule = "(client='ObjectBrowser' and selcount=1 and ((type='VISU::TTABLE' and nbChildren>0) "
1357           "or (type='VISU::TCURVE'%1) or (type='VISU::TCONTAINER'))) "
1358           " or (selcount>0 and $type in {"
1359           "'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
1360           "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'})";
1361   mgr->insert( action(  4030 ), -1, -1, -1 ); // erase
1362   mgr->setRule( action( 4030 ), aRule.arg(" and isVisible=1"), true );
1363   mgr->insert( action(  4031 ), -1, -1, -1 ); // display
1364   mgr->setRule( action( 4031 ), aRule.arg(" and isVisible=0"), true );
1365   mgr->insert( action(  4032 ), -1, -1, -1 ); // display only
1366   mgr->setRule( action( 4032 ), aRule.arg(""), true );
1367
1368   // View parameters
1369   mgr->insert ( action( 4046 ), -1, -1, -1 ); // save view params
1370   //jfa tmp:mgr->setRule( action( 4046 ), "(client='VTKViewer' and selcount=0) or (selcount=1 and type='VISU::TVIEW3D')", true );
1371   mgr->setRule( action( 4046 ), "selcount=0", true ); //jfa tmp
1372   mgr->insert ( action( 4047 ), -1, -1, -1 ); // restore view params
1373   mgr->setRule( action( 4047 ), "selcount=1 and type='VISU::TVIEW3D'", true );
1374   mgr->insert ( action( 4048 ), -1, -1, -1 ); // delete view params
1375   mgr->setRule( action( 4048 ), "selcount=1 and type='VISU::TVIEW3D'", true );
1376
1377   // 3D presentations commands
1378   QString aPrsType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
1379                      "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
1380   QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
1381   QString aSurfType   = " and $type in {'VISU::TMESH'}";
1382   QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
1383                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES'}";
1384   QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
1385                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES'}";
1386   aRule = "selcount=1";
1387
1388   int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 ); // "Representation" submenu
1389   mgr->insert( action(  4050 ), parentId, -1, -1 ); // points
1390   mgr->setRule( action( 4050 ), aRule + aPrsType +
1391                " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
1392   mgr->insert( action(  4051 ), parentId, -1, -1 ); // wireframe
1393   mgr->setRule( action( 4051 ), aRule + aPrsType +
1394                " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
1395   mgr->insert( action(  4052 ), parentId, -1, -1 ); // surface
1396   mgr->setRule( action( 4052 ), aRule + aPrsType +
1397                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
1398   mgr->insert( action(  4053 ), parentId, -1, -1 ); // insideframe
1399   mgr->setRule( action( 4053 ), aRule + aInsideType +
1400                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}", true );
1401   mgr->insert( action(  4054 ), parentId, -1, -1 ); // surfaceframe
1402   mgr->setRule( action( 4054 ), aRule + aSurfType +
1403                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}", true );
1404   mgr->insert( action(  4055 ), parentId, -1, -1 ); // shrink
1405   mgr->setRule( action( 4055 ), aRule + aShrinkType + " and isShrunk=0", true );
1406   mgr->insert( action(  4056 ), parentId, -1, -1 ); // unshrink
1407   mgr->setRule( action( 4056 ), aRule + aShrinkType + " and isShrunk=1", true );
1408
1409   parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 ); // "Properties" submenu
1410   mgr->insert( action(  4057 ), parentId, -1, -1 ); // cell color
1411   mgr->setRule( action( 4057 ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
1412   mgr->insert( action(  4059 ), parentId, -1, -1 ); // edge color
1413   mgr->setRule( action( 4059 ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
1414   mgr->insert( action(  4058 ), parentId, -1, -1 ); // color
1415   mgr->setRule( action( 4058 ), aRule + " and ((type='VISU::TMESH'"
1416                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
1417                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
1418   mgr->insert( action(  4060 ), parentId, -1, -1 ); // opacity
1419   mgr->setRule( action( 4060 ), aRule + aShrinkType + " and hasActor=1", true );
1420   mgr->insert( action(  4061 ), parentId, -1, -1 ); // line width
1421   mgr->setRule( action( 4061 ), aRule + aLineType + " and hasActor=1", true );
1422
1423   // curve commands
1424   aRule = "selcount=1 and type='VISU::TCURVE'";
1425   mgr->insert( action(  4040 ), -1, -1, -1 ); // curve properties
1426   mgr->setRule( action( 4040 ), aRule, true );
1427   mgr->insert( action(  4041 ), -1, -1, -1 ); // rename curve
1428   mgr->setRule( action( 4041 ), aRule, true );
1429   QString aCurveType = "$type in {'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'}";
1430   aPrsType = "$type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
1431              "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
1432   aRule = "client='ObjectBrowser' and selcount>1";
1433   mgr->insert( action(  4034 ), -1, -1, -1 ); // display many
1434   mgr->setRule( action( 4034 ), aRule + " and (" + aCurveType + " or " + aPrsType + ")", true );
1435   mgr->insert( action(  4035 ), -1, -1, -1 ); // erase many
1436   mgr->setRule( action( 4035 ), aRule + " and (" + aCurveType + " or " + aPrsType + ")", true );
1437   mgr->insert( action(  4036 ), -1, -1, -1 ); // display only many
1438   mgr->setRule( action( 4036 ),  aRule + " and " + aCurveType, true );
1439
1440   // curve container commands
1441   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
1442   mgr->insert( action(  4042 ), -1, -1, -1 ); // edit container
1443   mgr->setRule( action( 4042 ), aRule, true );
1444   mgr->insert( action(  4043 ), -1, -1, -1 ); // rename container
1445   mgr->setRule( action( 4043 ), aRule, true );
1446   mgr->insert( action(  4044 ), -1, -1, -1 ); // clear container
1447   mgr->setRule( action( 4044 ), aRule, true );
1448
1449   aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
1450   mgr->insert( action(  4063 ), -1, -1, -1 ); // create table
1451   mgr->setRule( action( 4063 ), aRule, true );
1452
1453   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TSCALARMAP'";
1454   mgr->insert ( action( 4064 ), -1, -1, -1 ); // sweep
1455   mgr->setRule( action( 4064 ), aRule, true );
1456
1457   // Selection info popup item
1458   aRule = "client='ObjectBrowser' and selcount=1" + aInsideType;
1459   mgr->insert( action(  4065 ), -1, -1, -1 ); // Selection info
1460   mgr->setRule( action( 4065 ), aRule, true );
1461
1462   aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
1463   mgr->insert( action(  4066 ), -1, -1, -1 ); // animation
1464   mgr->setRule( action( 4066 ), aRule, true );
1465
1466   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
1467   mgr->insert( action(  4026 ), -1, -1, -1 ); // create presentation
1468   mgr->setRule( action( 4026 ), aRule + " and selcount=1", true );
1469   mgr->insert( action(  4027 ), -1, -1, -1 ); // create presentations
1470   mgr->setRule( action( 4027 ), aRule + " and selcount>1", true );
1471 }
1472
1473 void
1474 VisuGUI::
1475 windows( QMap<int, int>& theMap ) const
1476 {
1477   theMap.clear();
1478   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
1479 }
1480
1481
1482 void
1483 VisuGUI::
1484 viewManagers( QStringList& theList ) const
1485 {
1486   theList.clear();
1487   theList.append( SVTK_Viewer::Type() );
1488 }
1489
1490
1491 QString
1492 VisuGUI::
1493 engineIOR() const
1494 {
1495   CORBA::String_var anIOR = GetVisuGen(this)->GetID();
1496   return QString(anIOR.in());
1497 }
1498
1499
1500 bool
1501 VisuGUI::
1502 activateModule( SUIT_Study* theStudy )
1503 {
1504   SalomeApp_Module::activateModule( theStudy );
1505
1506   setMenuShown( true );
1507   setToolShown( true );
1508   return true;
1509 }
1510
1511
1512 bool
1513 VisuGUI::
1514 deactivateModule( SUIT_Study* theStudy )
1515 {
1516   setMenuShown( false );
1517   setToolShown( false );
1518
1519   SalomeApp_Module::deactivateModule( theStudy );
1520   return true;
1521 }
1522
1523 SalomeApp_Selection*
1524 VisuGUI::
1525 createSelection() const
1526 {
1527   return new VisuGUI_Selection( (SalomeApp_Module*)this );
1528 }
1529
1530 extern "C" {
1531   CAM_Module*
1532   createModule()
1533   {
1534     return new VisuGUI();
1535   }
1536 }