1 // VISU VISUGUI : GUI of VISU component
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
25 // Author : Laurent CORNABE
38 #include <qptrvector.h>
39 #include <qcolordialog.h>
42 #include <vtkRenderer.h>
43 #include <vtkRenderWindow.h>
44 #include <vtkActorCollection.h>
47 #include "SALOME_LifeCycleCORBA.hxx"
49 #include "SUIT_ResourceMgr.h"
50 #include "SUIT_MessageBox.h"
52 #include "SUIT_ViewWindow.h"
53 #include "SUIT_ViewManager.h"
55 #include "CAM_Module.h"
57 #include "SVTK_RenderWindow.h"
58 #include "SVTK_ViewWindow.h"
59 #include "SVTK_ViewModel.h"
60 #include "SVTK_Functor.h"
62 #include "SPlot2d_ViewModel.h"
63 #include "SPlot2d_SetupPlot2dDlg.h"
64 #include "Plot2d_SetupCurveDlg.h"
66 #include "OB_Browser.h"
68 #include "SALOME_ListIO.hxx"
69 #include "SALOME_ListIteratorOfListIO.hxx"
71 #include "SalomeApp_Application.h"
72 #include "SalomeApp_DataModel.h"
73 #include "SalomeApp_Study.h"
74 #include "SalomeApp_SelectionMgr.h"
75 #include "SalomeApp_Selection.h"
76 #include "SalomeApp_Preferences.h"
78 #include "VISUConfig.hh"
79 #include "VISU_Gen_i.hh"
80 #include "VISU_Mesh_i.hh"
81 #include "VISU_Table_i.hh"
82 #include "VISU_Result_i.hh"
83 #include "VISU_View_i.hh"
84 #include "VISU_ViewManager_i.hh"
85 #include "VISU_Plot3D_i.hh"
87 #include "VISU_Actor.h"
89 #include "VisuGUI_Tools.h"
90 #include "VisuGUI_PopupTools.h"
91 #include "VisuGUI_NameDlg.h"
92 #include "VisuGUI_FileDlg.h"
93 #include "VisuGUI_CursorDlg.h"
94 #include "VisuGUI_Selection.h"
95 #include "VisuGUI_TimeAnimation.h"
96 #include "VisuGUI_EditContainerDlg.h"
97 #include "VisuGUI_NonIsometricDlg.h"
98 #include "VisuGUI_ClippingDlg.h"
99 #include "VisuGUI_Plot3DDlg.h"
100 #include "VisuGUI_CubeAxesDlg.h"
101 #include "VisuGUI_OffsetDlg.h"
103 #include "VISU_ScalarMap_i.hh"
104 #include "VisuGUI_ScalarBarDlg.h"
106 #include "VISU_DeformedShape_i.hh"
107 #include "VisuGUI_DeformedShapeDlg.h"
109 #include "VISU_IsoSurfaces_i.hh"
110 #include "VisuGUI_IsoSurfacesDlg.h"
112 #include "VISU_CutPlanes_i.hh"
113 #include "VisuGUI_CutPlanesDlg.h"
115 #include "VISU_CutLines_i.hh"
116 #include "VisuGUI_CutLinesDlg.h"
118 #include "VISU_StreamLines_i.hh"
119 #include "VisuGUI_StreamLinesDlg.h"
121 #include "VISU_Vectors_i.hh"
122 #include "VisuGUI_VectorsDlg.h"
124 #include "VisuGUI_TableDlg.h"
126 #include "SALOMEconfig.h"
127 #include CORBA_SERVER_HEADER(MED_Gen)
129 #include "utilities.h"
131 #include "VisuGUI_ActionsDef.h"
133 using namespace VISU;
136 static int MYDEBUG = 1;
138 static int MYDEBUG = 0;
141 //////////////////////////////////////////////////
143 //////////////////////////////////////////////////
146 SalomeApp_Module( "VISU" )
160 if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
161 CheckLock(GetCStudy(GetAppStudy(this)));
162 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
165 aFilter.append( tr("FLT_MED_FILES") );
166 aFilter.append( tr("FLT_ALL_FILES") );
168 QFileInfo aFileInfo =
169 SUIT_FileDlg::getFileName(GetDesktop(this),
172 tr("MEN_IMPORT_FROM_FILE"),
174 if(aFileInfo.exists()) {
175 application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
177 VISU::Result_var aResult;
178 bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
179 if (VisuGUI_FileDlg::IsBuild) {
180 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
181 if (!CORBA::is_nil(aResult.in()))
182 if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
183 if (!aRes->IsPossible())
184 SUIT_MessageBox::warn1(GetDesktop(this),
186 tr("ERR_CANT_BUILD_PRESENTATION"),
192 aResourceMgr->setValue("VISU", "full_med_loading", false);
193 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
194 aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
197 if (CORBA::is_nil(aResult.in())) {
198 SUIT_MessageBox::warn1(GetDesktop(this),
200 tr("ERR_ERROR_IN_THE_FILE"),
203 application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
204 UpdateObjBrowser(this);
214 if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
215 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
218 SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
221 aFilter.append( tr("FLT_MED_FILES") );
222 aFilter.append( tr("FLT_ALL_FILES") );
224 QFileInfo aFileInfo =
225 SUIT_FileDlg::getFileName(GetDesktop(this),
228 tr("MEN_EXPLORE_MED_FILE"),
230 if(aFileInfo.exists()){
231 application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
232 std::string aStudyName = aStudy->Name();
233 aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
234 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
235 getApp()->updateObjectBrowser(true); // as need to update MED tree
236 getApp()->updateActions();
243 OnImportTableFromFile()
245 if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
246 CheckLock(GetCStudy(GetAppStudy(this)));
249 aFilter.append( tr("FLT_TABLE_FILES") );
250 aFilter.append( tr("FLT_ALL_FILES") );
252 QFileInfo aFileInfo =
253 SUIT_FileDlg::getFileName(GetDesktop(this),
256 tr("MEN_IMPORT_TABLE"),
258 if (aFileInfo.exists()) {
259 application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
261 CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
263 if (CORBA::is_nil(anObject.in())) {
264 SUIT_MessageBox::warn1(GetDesktop(this),
266 tr("ERR_ERROR_IN_THE_FILE"),
269 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
270 UpdateObjBrowser(this);
277 OnExportTableToFile()
279 if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
286 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
287 if (CheckLock(aCStudy))
289 SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
291 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
292 SALOME_ListIO aListIO;
293 aSelectionMgr->selectedObjects(aListIO);
295 SALOME_ListIteratorOfListIO It (aListIO);
296 QApplication::setOverrideCursor(Qt::waitCursor);
297 for (; It.More(); It.Next()) {
298 Handle(SALOME_InteractiveObject) anIO = It.Value();
299 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
300 if (!aSObject->_is_nil()) {
301 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
302 if (!CORBA::is_nil(anObject)) {
303 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
304 if (!CORBA::is_nil(aMED.in()))
305 GetVisuGen(this)->ImportMed(aSObject);
306 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
307 if (!CORBA::is_nil(aField.in()))
308 GetVisuGen(this)->ImportMedField(aField);
310 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
311 SALOMEDS::GenericAttribute_var anAttr;
312 aSFather->FindAttribute(anAttr, "AttributeName");
313 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
314 CORBA::String_var aValue = aName->Value();
315 if (strcmp(aValue.in(), "MEDFIELD") == 0)
316 GetVisuGen(this)->ImportMed(aSObject);
320 UpdateObjBrowser(this, true);
321 QApplication::restoreOverrideCursor();
325 CreateCurves( SalomeApp_Module* theModule,
326 VISU::CutLines_i* thePrs,
328 const bool theCreate = true )
332 VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
336 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
337 _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
339 if ( !theCreate && aSObject ) {
341 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
342 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
343 for (; aIter->More(); aIter->Next()) {
344 _PTR(SObject) aTblObj = aIter->Value();
346 _PTR(GenericAttribute) anAttr;
347 if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
348 aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
355 if ( aCutDlg->isGenerateTable() ) {
356 GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
357 if ( aCutDlg->isGenerateCurves() ) {
359 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
360 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
361 for (; aIter->More(); aIter->Next()) {
362 _PTR(SObject) aTblObj = aIter->Value();
364 _PTR(GenericAttribute) anAttr;
365 if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
366 CreatePlot( theModule, aTblObj );
374 if (!theCreate && aSObject) {
375 UpdateObjBrowser(theModule);
379 template<class TPrs3d_i>
381 CreatePrs3d(SalomeApp_Module* theModule,
382 _PTR(SObject) theTimeStamp,
383 const char* theMeshName,
384 VISU::Entity theEntity,
385 const char* theFieldName,
388 VISU::Result_var aResult;
389 if (CheckResult(theModule,theTimeStamp,aResult)){
390 QApplication::setOverrideCursor(Qt::waitCursor);
391 typedef typename TPrs3d_i::TInterface TPrs3d;
392 typename TPrs3d::_var_type aPrs3d =
393 GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
394 (aResult,theMeshName,theEntity,theFieldName,theTimeId);
395 QApplication::restoreOverrideCursor();
396 if (!CORBA::is_nil(aPrs3d.in()))
397 return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
399 SUIT_MessageBox::warn1(GetDesktop(theModule),
400 QObject::tr("WRN_VISU"),
401 QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
402 QObject::tr("BUT_OK") );
407 template<class TPrs3d_i, class TDlg, int IsDlgModal>
409 CreatePrs3d(SalomeApp_Module* theModule,
410 _PTR(SObject) theTimeStamp,
411 const Handle(SALOME_InteractiveObject)& theIO)
413 using namespace VISU;
414 Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
416 QString aType = Storable::FindValue(aMap,"myType",&isExist);
417 if(!isExist || aType.toInt() != TTIMESTAMP )
419 QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
420 QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
421 QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
422 QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
423 QApplication::setOverrideCursor(Qt::waitCursor);
425 CreatePrs3d<TPrs3d_i>(theModule,
428 (Entity)anEntity.toInt(),
430 aTimeStampId.toInt());
431 QApplication::restoreOverrideCursor();
433 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
434 int aValue = aResourceMgr->integerValue("Visu:BuildDefaultPrs3d",0);
436 if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
437 aDlg->initFromPrsObject(aPrs3d);
439 if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
440 // Optionally, create table and curves for cut lines
441 QApplication::setOverrideCursor(Qt::waitCursor);
442 CreateCurves( theModule,
443 dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
445 true ); // in creation mode
446 QApplication::restoreOverrideCursor();
449 DeletePrs3d(theModule,aPrs3d,theIO);
459 PublishInView(theModule,aPrs3d);
466 template<class TPrs3d_i, class TDlg, int IsDlgModal>
468 CreatePrs3d(SalomeApp_Module* theModule)
470 if (CheckLock(GetCStudy(GetAppStudy(theModule))))
473 _PTR(SObject) aTimeStampSObj;
474 Handle(SALOME_InteractiveObject) anIO;
475 if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
478 if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
481 theModule->application()->putInfo(QObject::tr("INF_DONE"));
482 theModule->updateObjBrowser();
483 UpdateObjBrowser(theModule);
485 if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
493 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
494 if (CheckLock(aStudy))
497 // Get selected SObject
498 Handle(SALOME_InteractiveObject) anIO;
499 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
500 if (anIO.IsNull() || !anIO->hasEntry())
503 CreateMesh(this, anIO);
510 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
511 if (CheckLock(aStudy))
514 // Get selected SObject
515 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
516 SALOME_ListIO aListIO;
517 aSelectionMgr->selectedObjects(aListIO);
518 SALOME_ListIteratorOfListIO anIter (aListIO);
519 for (; anIter.More(); anIter.Next()) {
520 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
521 if (anIO.IsNull() || !anIO->hasEntry())
524 CreateMesh(this, anIO);
532 CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
538 OnCreateDeformedShape()
540 CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
547 CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
552 OnCreateIsoSurfaces()
554 CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
561 CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
568 CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
573 OnCreateStreamLines()
575 CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
582 CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,1>(this);
589 CheckLock(GetCStudy(GetAppStudy(this)));
590 GetVisuGen( this )->CreateContainer();
591 UpdateObjBrowser(this);
598 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
600 QApplication::setOverrideCursor(Qt::waitCursor);
602 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
603 mgr->selectedObjects(aList);
605 Handle(SALOME_InteractiveObject) anIO;
606 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
608 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
609 if ( !CORBA::is_nil( anObject ) ) {
610 // is it Prs3d object ?
611 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
613 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
614 UpdateViewer( this, aPrsObject );
615 if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
616 vw->highlight(anIO, 1);
621 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
623 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
624 PlotCurve( this, aCurve, VISU::eDisplay );
628 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
630 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
631 PlotContainer( this, aContainer, VISU::eDisplay );
635 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
637 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
638 PlotTable( this, aTable, VISU::eDisplay );
643 if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
644 vw->getRenderer()->ResetCameraClippingRange();
647 QApplication::restoreOverrideCursor();
662 if(MYDEBUG) MESSAGE("OnErasePrs");
664 QApplication::setOverrideCursor(Qt::waitCursor);
666 SVTK_ViewWindow* vw = GetViewWindow(this);
667 if (vw) vw->unHighlightAll();
670 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
671 mgr->selectedObjects(aList);
673 Handle(SALOME_InteractiveObject) anIO;
674 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
676 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
677 ErasePrs(this, anObject, false);
680 if (vw) vw->Repaint();
682 QApplication::restoreOverrideCursor();
685 template<class TPrs3d_i, class TDlg>
687 EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
689 TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
691 TDlg* aDlg = new TDlg (theModule);
692 aDlg->initFromPrsObject(aPrsObject);
694 if (!(aDlg->storeToPrsObject(aPrsObject))) {
698 RecreateActor(theModule, aPrsObject);
699 if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
700 vw->getRenderer()->ResetCameraClippingRange();
703 // Optionally, create table and curves for cut lines
704 QApplication::setOverrideCursor(Qt::waitCursor);
705 CreateCurves( theModule,
706 dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
708 false ); // in edition mode
709 QApplication::restoreOverrideCursor();
719 if (CheckLock(GetCStudy(GetAppStudy(this))))
722 Handle(SALOME_InteractiveObject) anIO;
723 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
724 if (CORBA::is_nil(anObject)) return;
725 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
726 if (!aServant.in()) return;
728 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
731 switch (aPrs3d->GetType()) {
734 case VISU::TSCALARMAP:
735 EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg>(this, aPrs3d);
737 case VISU::TDEFORMEDSHAPE:
738 EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg>(this, aPrs3d);
740 case VISU::TCUTPLANES:
741 EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
743 case VISU::TCUTLINES:
744 EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
746 case VISU::TISOSURFACE:
747 EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
750 EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg>(this, aPrs3d);
752 case VISU::TSTREAMLINES:
753 EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg>(this, aPrs3d);
756 EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg>(this, aPrs3d);
762 if (SVTK_ViewWindow* vw = GetViewWindow())
763 vw->highlight(anIO, 1);
770 if (SVTK_ViewWindow* vw = GetViewWindow()) {
771 vw->unHighlightAll();
772 if (vtkRenderer *aRen = vw->getRenderer()) {
774 vtkActorCollection *anActColl = aRen->GetActors();
775 for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
776 if (anActor->GetVisibility() > 0)
777 if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
778 anVISUActor = anVISUActor->GetParent();
779 anVISUActor->VisibilityOff();
784 } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
793 ChangeRepresentation(this, VISU::SURFACEFRAME);
800 ChangeRepresentation(this, VISU::INSIDEFRAME);
807 ChangeRepresentation(this, VISU::WIREFRAME);
814 ChangeRepresentation(this, VISU::SHADED);
821 ChangeRepresentation(this, VISU::POINT);
828 ChangeRepresentation(this, VISU::SHRINK);
835 Handle(SALOME_InteractiveObject) anIO;
836 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
837 if (CORBA::is_nil(anObject)) return;
838 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
839 if (!aServant.in()) return;
841 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
844 SVTK_ViewWindow* vw = GetViewWindow();
847 VISU_Actor* anActor = GetActor(aPrs3d, vw);
848 if (!anActor) return;
850 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
851 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
852 SALOMEDS::Color anOldColor, aNewColor;
853 int aRepresent = anActor->GetRepresentation();
855 switch (aRepresent) {
857 anOldColor = aMesh->GetNodeColor();
859 case VISU::WIREFRAME :
860 case VISU::INSIDEFRAME :
861 anOldColor = aMesh->GetLinkColor();
864 case VISU::SURFACEFRAME :
865 anOldColor = aMesh->GetCellColor();
868 } else if (aDeformedShape) {
869 anOldColor = aDeformedShape->GetColor();
874 QColor aColor (int(255*anOldColor.R),
875 int(255*anOldColor.G),
876 int(255*anOldColor.B));
877 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
878 if (aColorNew.isValid()) {
879 aNewColor.R = aColorNew.red()/255.;
880 aNewColor.G = aColorNew.green()/255.;
881 aNewColor.B = aColorNew.blue()/255.;
883 switch (aRepresent) {
885 aMesh->SetNodeColor(aNewColor);
887 case VISU::WIREFRAME :
888 case VISU::INSIDEFRAME :
889 aMesh->SetLinkColor(aNewColor);
892 case VISU::SURFACEFRAME :
893 aMesh->SetCellColor(aNewColor);
897 aDeformedShape->SetColor(aNewColor);
899 RecreateActor(this, aPrs3d);
905 OnChangeWireframeColor()
907 Handle(SALOME_InteractiveObject) anIO;
908 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
909 if (CORBA::is_nil(anObject)) return;
910 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
911 if (!aServant.in()) return;
913 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
916 SVTK_ViewWindow* vw = GetViewWindow();
919 VISU_Actor* anActor = GetActor(aPrs3d, vw);
920 if (!anActor) return;
922 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
923 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
924 QColor aColor (int(255*anOldColor.R),
925 int(255*anOldColor.G),
926 int(255*anOldColor.B));
927 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
928 if (aColorNew.isValid()) {
929 aNewColor.R = aColorNew.red()/255.;
930 aNewColor.G = aColorNew.green()/255.;
931 aNewColor.B = aColorNew.blue()/255.;
932 aMesh->SetLinkColor(aNewColor);
933 RecreateActor(this, aMesh);
942 Handle(SALOME_InteractiveObject) anIO;
943 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
944 if (CORBA::is_nil(anObject)) return;
945 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
946 if (!aServant.in()) return;
948 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
949 if (!aPrsObject) return;
951 SVTK_ViewWindow* vw = GetViewWindow();
954 VISU_Actor* anActor = GetActor(aPrsObject, vw);
955 if (!anActor) return;
957 VisuGUI_CursorDlg* CursorDlg =
958 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
960 CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
961 CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
962 CursorDlg->SpinBox1->setMinValue(0);
963 CursorDlg->SpinBox1->setMaxValue(100);
965 float oldopac = anActor->GetOpacity();
966 int intopac = int(oldopac*100. + 0.5);
967 CursorDlg->SpinBox1->setValue(intopac);
969 int ret = CursorDlg->exec();
971 intopac = CursorDlg->SpinBox1->value();
972 float newopac = intopac/100.;
973 anActor->SetOpacity(newopac);
982 Handle(SALOME_InteractiveObject) anIO;
983 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
984 if (CORBA::is_nil(anObject)) return;
985 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
986 if (!aServant.in()) return;
988 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
989 if (!aPrsObject) return;
991 SVTK_ViewWindow* vw = GetViewWindow();
994 VISU_Actor* anActor = GetActor(aPrsObject, vw);
995 if (!anActor) return;
997 VisuGUI_CursorDlg* CursorDlg =
998 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1000 CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1001 CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1002 CursorDlg->SpinBox1->setMinValue(1);
1003 CursorDlg->SpinBox1->setMaxValue(10);
1005 float oldlwid = anActor->GetLineWidth();
1006 int intlwid = int(oldlwid);
1007 CursorDlg->SpinBox1->setValue(intlwid);
1009 int ret = CursorDlg->exec();
1011 intlwid = CursorDlg->SpinBox1->value();
1012 float newlwid = intlwid;
1013 anActor->SetLineWidth(newlwid);
1022 Handle(SALOME_InteractiveObject) anIO;
1023 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1025 if ( !CORBA::is_nil( anObject ) ) {
1026 VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1027 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1028 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1029 if( !CORBA::is_nil( aTable ) ) {
1030 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1032 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1037 // possibly this is Table SObject
1038 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1041 if( !IsSObjectTable( SO ) )
1044 VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1047 //SAL2670 Orientation of show tables
1048 VisuGUI_TableDlg::ttAuto,
1057 Handle(SALOME_InteractiveObject) anIO;
1058 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1059 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1060 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1061 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1062 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1063 GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1064 UpdateObjBrowser(this);
1072 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1073 if (CheckLock(aCStudy))
1076 SALOME_ListIO aList;
1077 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
1078 mgr->selectedObjects(aList);
1079 int i = 0, nbSelected = aList.Extent();
1080 if (nbSelected < 1) return;
1082 const char* entries [nbSelected];
1083 Handle(SALOME_InteractiveObject) anIO;
1084 for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1086 if (anIO->hasEntry())
1087 entries[i++] = anIO->getEntry();
1090 if (nbSelected < 1) return;
1092 // There is a transaction
1093 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1094 aStudyBuilder->NewCommand();
1096 for (i = 0; i < nbSelected; i++) {
1097 _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1099 DeleteSObject(this, aCStudy, aSObject);
1103 // Finish transaction
1104 aStudyBuilder->CommitCommand();
1106 //GetActiveStudy()->unHighlightAll();
1107 UpdateObjBrowser(this, true);
1114 Handle(SALOME_InteractiveObject) anIO;
1115 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1117 _PTR(GenericAttribute) anAttr;
1118 _PTR(AttributeName) aName;
1120 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1122 if ( !CORBA::is_nil( anObject ) ) {
1123 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1124 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1125 // Table (VISU object) is selected
1126 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1127 if( !CORBA::is_nil( aTbl ) ) {
1128 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1130 _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1131 if ( IsSObjectTable(SO) ) {
1132 // get name of SObject
1133 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1135 SOName = QString( aName->Value().c_str() );
1137 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1138 if ( dlg->exec() == QDialog::Accepted ) {
1139 if ( !IsStudyLocked( aStudy ) ) {
1140 // if study is not locked - create new container, create curves and insert them
1141 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1143 QValueList<int> verIndices;
1144 dlg->getCurvesSource( horIndex, verIndices );
1145 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1146 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1147 if( !CORBA::is_nil( aContainer ) ) {
1148 VISU::Container_i* pContainer =
1149 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1151 for ( int i = 0; i < verIndices.count(); i++ ) {
1152 CORBA::Object_var aNewCurve =
1153 GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1154 if( !CORBA::is_nil( aNewCurve ) ) {
1155 VISU::Curve_i* pCrv =
1156 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1159 int marker, line, lineWidth;
1161 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1162 line, lineWidth, color) && !isAuto ) {
1164 c.R = color.red() /255.;
1165 c.G = color.green()/255.;
1166 c.B = color.blue() /255.;
1167 pCrv->SetColor( c );
1168 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1169 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1171 pContainer->AddCurve( pCrv->_this() );
1175 UpdateObjBrowser(this);
1176 PlotContainer( this, pContainer, VISU::eDisplay );
1182 // if study is locked just get curves info and plot them
1183 // if current viewer is of VIEW_PLOT2D type
1184 QPtrList<Plot2d_Curve> container;
1185 dlg->getCurves( container );
1186 if ( !container.isEmpty() ) {
1187 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1188 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1198 else if ( !anIO.IsNull() ) {
1199 // check if Table SObject is selected
1200 SO = aStudy->FindObjectID( anIO->getEntry() );
1201 if ( IsSObjectTable(SO) ) {
1202 // get name of SObject
1203 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1205 SOName = QString( aName->Value().c_str() );
1207 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1208 if ( dlg->exec() == QDialog::Accepted ) {
1209 if ( !IsStudyLocked( aStudy ) ) {
1210 // if study is not locked - create new table and container objects, create curves
1211 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1213 QValueList<int> verIndices;
1214 dlg->getCurvesSource( horIndex, verIndices );
1215 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1216 CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1217 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1218 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1219 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1220 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1222 if ( pContainer && pTable ) {
1223 for ( int i = 0; i < verIndices.count(); i++ ) {
1224 CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1225 ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1226 if( !CORBA::is_nil( aNewCurve ) ) {
1227 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1230 int marker, line, lineWidth;
1232 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1233 line, lineWidth, color) && !isAuto ) {
1235 c.R = color.red()/255.;
1236 c.G = color.green()/255.;
1237 c.B = color.blue()/255.;
1238 pCrv->SetColor( c );
1239 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1240 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1242 pContainer->AddCurve( pCrv->_this() );
1246 UpdateObjBrowser(this);
1247 PlotContainer( this, pContainer, VISU::eDisplay );
1252 // if study is locked just get curves info and plot them
1253 QPtrList<Plot2d_Curve> container;
1254 dlg->getCurves( container );
1255 if ( !container.isEmpty() ) {
1256 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1257 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1270 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1271 SALOME_ListIO aListIO;
1272 aSelectionMgr->selectedObjects(aListIO);
1273 if (aListIO.Extent() != 1) return;
1275 SalomeApp_Study* aAppStudy = GetAppStudy(this);
1276 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1277 CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1278 if (CORBA::is_nil( anObject )) return;
1280 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1281 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1283 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1284 if( !CORBA::is_nil( aCurve ) ) {
1285 VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1286 if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1287 Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1289 aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1290 aDlg.setMarker( (int)aDSCurve->GetMarker() );
1291 SALOMEDS::Color aColor = aDSCurve->GetColor();
1292 aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1293 if( aDlg.exec() == QDialog::Accepted ) {
1294 aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1295 aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1296 SALOMEDS::Color newColor;
1297 newColor.R = aDlg.getColor().red()/255.;
1298 newColor.G = aDlg.getColor().green()/255.;
1299 newColor.B = aDlg.getColor().blue()/255.;
1300 aDSCurve->SetColor( newColor );
1301 PlotCurve(this, aDSCurve, VISU::eDisplay);
1312 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1313 if (CheckLock(aCStudy))
1315 Handle(SALOME_InteractiveObject) anIO;
1316 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1317 if (anIO.IsNull() || CORBA::is_nil(anObject))
1320 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1321 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1323 CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1324 if (!CORBA::is_nil(aCnt)) {
1325 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1326 if (container && container->GetNbCurves() > 0) {
1328 UpdateObjBrowser(this);
1338 Handle(SALOME_InteractiveObject) anIO;
1339 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1340 if (CORBA::is_nil(anObject)) return;
1342 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1343 if (!aServant.in()) return;
1344 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1345 if (!aContainer) return;
1347 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1348 aDlg->initFromPrsObject(aContainer);
1350 aDlg->storeToPrsObject(aContainer);
1351 UpdateObjBrowser(this, true);
1360 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1361 if (CheckLock(aCStudy))
1364 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1365 if (aViewMgr->getType() != SVTK_Viewer::Type())
1368 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1369 SALOME_ListIO aListIO;
1370 aSelectionMgr->selectedObjects(aListIO);
1371 if (aListIO.Extent() > 1)
1374 if (aListIO.Extent() == 0) {
1375 VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1377 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1378 VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1380 UpdateObjBrowser(this);
1385 OnRestoreViewParams()
1387 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1388 if (aViewMgr->getType() != SVTK_Viewer::Type())
1391 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1392 SALOME_ListIO aListIO;
1393 aSelectionMgr->selectedObjects(aListIO);
1394 if (aListIO.Extent() != 1)
1397 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1398 //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1399 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1400 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1401 VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1408 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1409 if (CheckLock(aCStudy))
1412 Handle(SALOME_InteractiveObject) anIO;
1413 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1415 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1418 //TEST DU PARENT == VISU
1419 _PTR(GenericAttribute) anAttr;
1420 if (aSObj->FindAttribute(anAttr, "AttributeName")) {
1421 _PTR(AttributeName) aName (anAttr);
1422 QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1423 if (!Name.isEmpty()) {
1424 QApplication::setOverrideCursor(Qt::waitCursor);
1426 // rename specific objects
1427 if (!CORBA::is_nil(anObject)) {
1428 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1429 if (!CORBA::is_nil(aVisuObj)) {
1430 switch (aVisuObj->GetType()) {
1431 case VISU::TCURVE: // Curve object
1433 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1434 if (!CORBA::is_nil(aCurve)) {
1435 VISU::Curve_i* curve =
1436 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1438 curve->SetName(Name.latin1());
1442 case VISU::TTABLE: // Table object
1444 CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1445 if (!CORBA::is_nil(aTable)) {
1446 VISU::Table_i* table =
1447 dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1449 table->SetName(Name.latin1());
1453 case VISU::TCONTAINER: // Container object
1455 CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1456 if (!CORBA::is_nil(aContainer)) {
1457 VISU::Container_i* container =
1458 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1460 container->SetName(Name.latin1());
1471 // rename the study object
1472 aName->SetValue(Name.latin1()); // rename the SObject
1473 anIO->setName(Name.latin1()); // rename the InteractiveObject
1474 UpdateObjBrowser(this, false);
1476 QApplication::restoreOverrideCursor();
1485 new VisuGUI_ClippingDlg (this, "", false);
1493 Handle(SALOME_InteractiveObject) anIO;
1494 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1495 if (CORBA::is_nil(anObject)) return;
1496 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1497 if (!aServant.in()) return;
1499 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1500 if (!aPrsObject) return;
1502 SVTK_ViewWindow* vw = GetViewWindow();
1505 VISU_Actor* aActor = GetActor(aPrsObject, vw);
1506 if (!aActor) return;
1508 if (!aActor->GetVisibility()) {
1509 aActor->VisibilityOn();
1512 // Get sweep parameters
1513 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1515 double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1516 int aTemp = int(1.E6 * aTempoDbl);
1518 int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1519 int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1522 QApplication::setOverrideCursor(Qt::waitCursor);
1524 for (int j = 0; j < aCycles; j++) {
1525 for (int i = 0; i <= aSteps; i++) {
1526 float aPercents = float(i)/aSteps;
1527 aPrsObject->SetMapScale(aPercents);
1528 aPrsObject->UpdateActor(aActor);
1529 vw->getRenderWindow()->getRenderWindow()->Render();
1533 } catch (std::exception& exc) {
1534 INFOS("Follow exception was occured :\n" << exc.what());
1536 INFOS("Unknown exception was occured!");
1538 QApplication::restoreOverrideCursor();
1545 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1546 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1547 // new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1548 new VisuGUI_TimeAnimationDlg (this, aCStudy);
1550 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1551 SALOME_ListIO aListIO;
1552 aSelectionMgr->selectedObjects(aListIO);
1554 bool isDefined = false;
1556 SALOME_ListIteratorOfListIO It (aListIO);
1557 for (; It.More(); It.Next()) {
1558 _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1559 if (!aSObject) continue;
1560 if (getValue(aSObject, "myComment") == QString("FIELD")) {
1561 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1565 aAnimationDlg->addField(aSObject);
1567 } else if (aNbTimes == aNumber) {
1568 aAnimationDlg->addField(aSObject);
1573 if (isDefined) aAnimationDlg->show();
1574 else delete aAnimationDlg;
1577 //************************************************************************
1582 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1583 SALOME_ListIO aListIO;
1584 aSelectionMgr->selectedObjects(aListIO);
1586 if (aListIO.Extent() != 1)
1589 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1591 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1593 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1596 VISU::Storable::TRestoringMap aMap;
1597 _PTR(GenericAttribute) anAttr;
1598 if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1600 _PTR(AttributeComment) aComment (anAttr);
1601 string aComm = aComment->Value();
1602 QString strIn (aComm.c_str());
1603 VISU::Storable::StrToMap(strIn, aMap);
1605 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1606 if (aType != VISU::TANIMATION) return;
1608 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1609 new VisuGUI_TimeAnimationDlg(this, aCStudy);
1610 aAnimationDlg->restoreFromStudy(aSObj);
1611 aAnimationDlg->show();
1616 OnCopyPresentation()
1618 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1619 if (CheckLock(aCStudy))
1622 Handle(SALOME_InteractiveObject) anIO;
1623 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1624 if (CORBA::is_nil(anObject)) return;
1625 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1626 if (!aServant.in()) return;
1628 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1629 if (!aPrsObject) return;
1631 switch (aPrsObject->GetType()) {
1634 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1635 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1636 aSameMesh->SameAs(aMeshPrs);
1637 UpdateViewer(this, aSameMesh);
1640 case VISU::TSCALARMAP:
1642 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1643 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1644 aSameScalar->SameAs(aScalarPrs);
1645 UpdateViewer(this, aSameScalar);
1648 case VISU::TDEFORMEDSHAPE:
1650 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1651 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1652 aSameDeformed->SameAs(aDefPrs);
1653 UpdateViewer(this, aSameDeformed);
1656 case VISU::TCUTPLANES:
1658 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1659 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1660 aSameCut->SameAs(aCutPrs);
1661 UpdateViewer(this, aSameCut);
1664 case VISU::TCUTLINES:
1666 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1667 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1668 aSameCut->SameAs(aCutPrs);
1669 UpdateViewer(this, aSameCut);
1672 case VISU::TISOSURFACE:
1674 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1675 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1676 aSameIso->SameAs(aIsoPrs);
1677 UpdateViewer(this, aSameIso);
1680 case VISU::TSTREAMLINES:
1682 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1683 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1684 aSameLines->SameAs(aLinesPrs);
1685 UpdateViewer(this, aSameLines);
1688 case VISU::TVECTORS:
1690 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1691 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1692 aSameVectors->SameAs(aVectorsPrs);
1693 UpdateViewer(this, aSameVectors);
1698 VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1699 VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1700 aSamePlot3D->SameAs(aPlot3DPrs);
1701 UpdateViewer(this, aSamePlot3D);
1705 UpdateObjBrowser(this);
1712 if (GetViewWindow())
1713 (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1715 SUIT_MessageBox::warn1(GetDesktop(this),
1717 tr("ERR_ACTIVATE_VIEW3D"),
1725 VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1726 new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1727 false, Qt::WDestructiveClose);
1728 m_NonIsoDlg->show();
1735 //Show dialog that allows to select scale function and corresponding scale factor
1736 VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1744 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1745 SALOME_ListIO aListIO;
1746 aSelectionMgr->selectedObjects(aListIO);
1748 SALOME_ListIteratorOfListIO It (aListIO);
1750 // first find the bounds
1751 double aMin, aMax; bool first = true;
1752 for (; It.More(); It.Next()) {
1753 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1754 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1755 if (!aPrsList.empty()) {
1756 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1757 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1759 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1763 aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1765 if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1766 if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1774 // set the computed range to every selected ScalarMap
1775 bool update = false;
1776 for (It.Initialize(aListIO); It.More(); It.Next() ) {
1777 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1778 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1779 if (!aPrsList.empty()) {
1780 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1781 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1783 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1785 aScalar->SetRange(aMin, aMax);
1786 RecreateActor(this, aScalar);
1794 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1795 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1796 vw->getRenderer()->ResetCameraClippingRange();
1807 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1808 SALOME_ListIO aListIO;
1809 aSelectionMgr->selectedObjects(aListIO);
1811 SALOME_ListIteratorOfListIO It (aListIO);
1813 // restore the source range for every ScalarMap
1814 bool update = false;
1815 for (; It.More(); It.Next()) {
1816 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1817 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1818 if (!aPrsList.empty()) {
1819 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1820 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1822 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1824 aScalar->SetSourceRange();
1825 RecreateActor(this, aScalar);
1833 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1834 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1835 vw->getRenderer()->ResetCameraClippingRange();
1846 if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1847 VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1849 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1851 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1852 SALOME_ListIO aListIO;
1853 aSelectionMgr->selectedObjects(aListIO);
1855 SALOME_ListIteratorOfListIO It (aListIO);
1856 for (; It.More(); It.Next()) {
1857 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1858 if (anIO->hasEntry()) {
1859 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1861 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1862 if (!CORBA::is_nil(aCORBAObject)) {
1863 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1864 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1865 aDlg->addPresentation(aPrsObject);
1871 if (aDlg->getPrsCount() > 0)
1881 SVTK_ViewWindow* vw = GetViewWindow();
1883 ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1892 initialize( CAM_Application* theApp )
1894 SalomeApp_Module::initialize( theApp );
1907 QWidget* aParent = application()->desktop();
1908 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1911 createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
1912 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1913 this, SLOT(OnImportFromFile()));
1915 createAction( VISU_EXPLORE_MED, "", QIconSet(),
1916 tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1917 this, SLOT(OnExploreMEDFile()));
1919 createAction( VISU_IMPORT_TABLE, "", QIconSet(),
1920 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1921 this, SLOT(OnImportTableFromFile()));
1923 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1924 createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
1925 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1926 this, SLOT(OnCreateScalarMap()));
1928 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1929 createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
1930 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1931 this, SLOT(OnCreateDeformedShape()));
1933 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1934 createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
1935 tr("MEN_VECTORS"), "", 0, aParent, false,
1936 this, SLOT(OnCreateVectors()));
1938 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
1939 createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
1940 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
1941 this, SLOT(OnCreateIsoSurfaces()));
1943 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
1944 createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
1945 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
1946 this, SLOT(OnCreateCutPlanes()));
1948 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
1949 createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
1950 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
1951 this, SLOT(OnCreateStreamLines()));
1953 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
1954 createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
1955 tr("MEN_CUT_LINES"), "", 0, aParent, false,
1956 this, SLOT(OnCreateCutLines()));
1958 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
1959 createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
1960 tr("MEN_PLOT_3D"), "", 0, aParent, false,
1961 this, SLOT(OnCreatePlot3D()));
1963 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
1964 createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
1965 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
1966 this, SLOT(OnCreatePlot2dView()));
1968 createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
1969 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
1970 this, SLOT(OnDeleteObjects()));
1972 createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
1973 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
1974 this, SLOT(OnShowTable()));
1976 createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
1977 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
1978 this, SLOT(OnPlotData()));
1980 createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
1981 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
1982 this, SLOT(OnExportTableToFile()));
1984 createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
1985 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
1986 this, SLOT(OnImportMedField()));
1988 createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
1989 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
1990 this, SLOT(OnImportMedField()));
1992 createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
1993 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
1994 this, SLOT(OnImportMedField()));
1996 createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
1997 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
1998 this, SLOT(OnCreateMesh()));
2000 createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2001 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2002 this, SLOT(OnCreateManyMesh()));
2004 createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2005 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2006 this, SLOT(OnTranslatePrs()));
2008 createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2009 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2010 this, SLOT(OnMergeScalarBars()));
2012 createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2013 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2014 this, SLOT(OnFreeScalarBars()));
2016 createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
2017 tr("MEN_ERASE"), "", 0, aParent, false,
2018 this, SLOT(OnErasePrs()));
2020 createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
2021 tr("MEN_DISPLAY"), "", 0, aParent, false,
2022 this, SLOT(OnDisplayPrs()));
2024 createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
2025 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2026 this, SLOT(OnDisplayOnlyPrs()));
2028 createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
2029 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2030 this, SLOT(OnCopyPresentation()));
2032 createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
2033 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2034 this, SLOT(OnCurveProperties()));
2036 createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2037 this, SLOT(OnRename()));
2039 createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
2040 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2041 this, SLOT(OnEditContainer()));
2043 createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
2044 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2045 this, SLOT(OnClearContainer()));
2047 createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2048 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2049 this, SLOT(OnSaveViewParams()));
2050 createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2051 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2052 this, SLOT(OnSaveViewParams()));
2054 createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2055 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2056 this, SLOT(OnRestoreViewParams()));
2058 //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2059 // tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2060 // this, SLOT(OnDeleteObjects()));
2062 createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2063 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2064 this, SLOT(OnArrangeActors()));
2066 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2067 createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
2068 tr("MEN_POINTS"), "", 0, aParent, false,
2069 this, SLOT(OnMakePoints()));
2071 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2072 createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
2073 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2074 this, SLOT(OnMakeWireframe()));
2076 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2077 createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
2078 tr("MEN_SURFACE"), "", 0, aParent, false,
2079 this, SLOT(OnMakeSurface()));
2081 createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
2082 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2083 this, SLOT(OnMakeInsideframe()));
2085 createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
2086 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2087 this, SLOT(OnMakeSurfaceframe()));
2089 createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
2090 tr("MEN_SHRINK"), "", 0, aParent, false,
2091 this, SLOT(OnMakeShrink()));
2093 createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
2094 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2095 this, SLOT(OnMakeShrink()));
2097 createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
2098 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2099 this, SLOT(OnChangeColor()));
2101 createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
2102 tr("MEN_COLOR"), "", 0, aParent, false,
2103 this, SLOT(OnChangeColor()));
2105 createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
2106 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2107 this, SLOT(OnChangeWireframeColor()));
2109 createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
2110 tr("MEN_OPACITY"), "", 0, aParent, false,
2111 this, SLOT(OnChangeOpacity()));
2113 createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
2114 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2115 this, SLOT(OnChangeLines()));
2117 createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(),
2118 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2119 this, SLOT(OnEditPrs()));
2121 createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
2122 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2123 this, SLOT(OnCreateTable()));
2125 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2126 createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
2127 tr("MEN_SWEEP"), "", 0, aParent, false,
2128 this, SLOT(OnSweep()));
2130 createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2131 tr("MEN_CLIPPING"), "", 0, aParent, false,
2132 this, SLOT(OnClippingPlanes()));
2134 createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2135 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2136 this, SLOT(OnSelectionInfo()));
2138 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2139 createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
2140 tr("MEN_ANIMATION"), "", 0, aParent, false,
2141 this, SLOT(OnTimeAnimation()));
2143 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2144 createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2145 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2146 this, SLOT(OnEraseAll()));
2148 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2149 createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2150 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2151 //this, SLOT(OnEraseAll()));
2154 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2155 createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2156 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2157 //this, SLOT(OnEraseAll()));
2160 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2161 createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2162 tr("MEN_SCALING"), "", 0, aParent, false,
2163 this, SLOT(OnScaling()));
2165 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2166 createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2167 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2168 this, SLOT(OnCubeAxes()));
2170 createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2171 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2172 this, SLOT(OnShowAnimation()));
2179 // Add actions to menus
2181 aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2182 createMenu( separator(), aMenuId, -1, 10 );
2183 createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2184 createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2185 createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2187 aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2188 createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2189 createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2190 createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2191 createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2192 createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2193 createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2194 createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2195 createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2197 aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2198 createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2200 aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2202 createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2203 createMenu( VISU_POINTS, parentId, 10 ); // points
2204 createMenu( VISU_WIREFRAME, parentId, 10 ); // wireframe
2205 createMenu( VISU_SURFACE, parentId, 10 ); // surface
2206 createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2207 createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2208 createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2209 createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2210 createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2217 int aToolId = createTool(tr("TOOL_VISUALISATION"));
2218 createTool( VISU_SCALAR_MAP, aToolId );
2219 createTool( VISU_DEFORMED_SHAPE, aToolId );
2220 createTool( VISU_VECTORS, aToolId );
2221 createTool( VISU_ISO_SURFACES, aToolId );
2222 createTool( VISU_CUT_PLANES, aToolId );
2223 createTool( VISU_CUT_LINES, aToolId );
2224 createTool( VISU_STREAM_LINES, aToolId );
2225 createTool( VISU_PLOT_3D, aToolId );
2227 aToolId = createTool(tr("TOOL_REPRESENTATION"));
2228 createTool( VISU_POINTS, aToolId );
2229 createTool( VISU_WIREFRAME, aToolId );
2230 createTool( VISU_SURFACE, aToolId );
2231 createTool( VISU_ERASE_ALL, aToolId );
2232 createTool( VISU_GLOBAL_SELECTION, aToolId );
2233 createTool( VISU_PARTIAL_SELECTION, aToolId );
2234 createTool( VISU_SCALING, aToolId );
2235 createTool( VISU_CUBE_AXES, aToolId );
2242 // Prepare popup menus
2243 QtxPopupMgr* mgr = popupMgr();
2245 // VISU root commands
2246 mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2247 mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2248 mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2250 //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2253 mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2254 mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2255 mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2256 mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2257 mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2258 mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2259 mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2260 mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2262 mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2263 mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2265 mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2268 mgr->insert( action( VISU_EDIT_PRS ), -1, -1, -1 );
2269 mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2272 mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2275 mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2278 mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2281 //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2282 //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2283 //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2285 mgr->insert( separator(), -1, -1, -1 );
2287 mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2288 mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2289 mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2291 // "Representation" submenu
2292 int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2293 mgr->insert( action( VISU_POINTS ) , parentId, -1, -1 ); // points
2294 mgr->insert( action( VISU_WIREFRAME ) , parentId, -1, -1 ); // wireframe
2295 mgr->insert( action( VISU_SURFACE ) , parentId, -1, -1 ); // surface
2296 mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2297 mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2298 mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink
2299 mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink
2301 // "Properties" submenu
2302 parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2303 mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2304 mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2305 mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color
2306 mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity
2307 mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2309 mgr->insert( separator(), -1, -1, -1 );
2311 // Other presentations management
2312 mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2313 mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2315 mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2316 mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2318 mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2319 mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2321 mgr->insert( separator(), -1, -1, -1 );
2323 // view parameters commands
2324 mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2325 mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
2326 mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2327 //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2329 mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2331 mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2333 mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2337 QString aSel_One_ObjBr ("client='ObjectBrowser' and selcount=1");
2338 QString aSel_Some_ObjBr ("client='ObjectBrowser' and selcount>0");
2339 QString aSel_Many_ObjBr ("client='ObjectBrowser' and selcount>1");
2341 QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2342 "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2344 QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2346 // VISU root commands
2347 QString aRule = aSel_One_ObjBr + " and type='VISU::TVISUGEN'";
2348 mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2349 mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2350 mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2352 // timestamp commands
2353 aRule = aSel_One_ObjBr + " and type='VISU::TTIMESTAMP'";
2354 mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2355 mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2356 mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2357 mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2358 mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2359 aRule += " and nbComponents>1";
2360 mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2361 mgr->setRule( action( VISU_VECTORS ), aRule, true );
2362 mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2365 //aRule = aSel_One_ObjBr + " and type='VISU::TTABLE'";
2366 //mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
2367 //mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
2368 //mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
2370 aRule = "(" + aSel_Some_ObjBr + " and ((type='VISU::TTABLE' and nbChildren>0) or"
2371 " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))"
2372 ") or (selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "})";
2374 mgr->setRule( action( VISU_ERASE ), aRule + "and (isVisible=true)", true );// TODO: aRule.arg(" and isVisible=1"), true );
2375 mgr->setRule( action( VISU_DISPLAY ), aRule + "and (isVisible=false)", true );// TODO: aRule.arg(" and isVisible=0"), true );
2376 mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule, true );
2378 aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2379 mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2381 aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2382 mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2383 mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2386 aRule = "selcount=1 and type='VISU::TVIEW3D'";
2387 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2388 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2389 mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2390 //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2392 mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2394 // 3D presentations commands
2395 QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2396 QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2397 QString aSurfType = " and $type in {'VISU::TMESH'}";
2398 QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2399 "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2400 QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2401 "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2403 aRule = "selcount=1";
2404 mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2406 // "Representation" submenu
2407 QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2408 QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2409 QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2410 QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2411 QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2413 mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints, true );
2414 mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr, true );
2415 mgr->setRule( action( VISU_SURFACE ) , aRule + aPrsType + aNotSurfac, true );
2416 mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2417 mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2419 mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true );
2420 mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2422 // "Properties" submenu
2423 mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2424 mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2425 mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2426 " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2427 "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2428 mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2429 mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2432 aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
2433 mgr->setRule( action( VISU_RENAME ), aRule, true );
2435 // copy presentation command
2436 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2437 mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2440 aRule = "selcount=1 and type='VISU::TCURVE'";
2441 mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2443 // curve container commands
2444 aRule = aSel_One_ObjBr + " and type='VISU::TCONTAINER'";
2445 mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2446 mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2448 aRule = "selcount=1 and $type in {" + aPrsAll + "}";
2449 mgr->setRule( action( VISU_EDIT_PRS ), aRule, true );
2451 aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2452 mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2454 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2455 mgr->setRule( action( VISU_SWEEP ), aRule, true );
2457 // Selection info popup item
2458 aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2459 mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2461 aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2462 mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2464 aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2465 mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2466 mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2468 //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2469 //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2472 //***************************************************************************
2473 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2475 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2477 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2478 SALOME_ListIO aListIO;
2479 aSelectionMgr->selectedObjects(aListIO);
2481 if (aListIO.Extent() < 1) return;
2483 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2485 // Check if "Merge Scalar Range" can be applied
2487 SALOME_ListIteratorOfListIO It (aListIO);
2488 for (; It.More(); It.Next()) {
2489 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2490 /*std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
2491 nbPrs += aPrsList.size();*/
2493 if (!anIO.IsNull() && anIO->hasEntry()) {
2494 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2495 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2496 if (CORBA::is_nil(aCORBAObject)) {
2497 _PTR(GenericAttribute) anAttr;
2498 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2499 _PTR(AttributeComment) aComment (anAttr);
2500 string aComm = aComment->Value();
2501 QString strIn (aComm.c_str());
2502 VISU::Storable::TRestoringMap pMap;
2503 VISU::Storable::StrToMap(strIn, pMap);
2505 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2506 if (isExist && aType == VISU::TTIMESTAMP) {
2507 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2509 for (; anIter->More(); anIter->Next()) {
2510 aPrs = anIter->Value();
2511 if (!aPrs) continue;
2512 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2513 nbPrs += aSubList.size();
2522 theMenu->insertSeparator();
2523 action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2524 action( VISU_FREE_SCALAR_BARS )->addTo(theMenu);
2527 theMenu->insertSeparator();
2529 // Check if some (nb > 0) removable objects selected
2530 if (IsRemovableSelected(this)) {
2531 action( VISU_DELETE_OBJS )->addTo(theMenu);
2534 // Check single selection
2535 if (aListIO.Extent() != 1) return;
2537 Handle(SALOME_InteractiveObject) anIO;
2538 VISU::Storable::TRestoringMap aMap;
2539 CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2541 _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2543 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2545 if (aType == VISU::TANIMATION) {
2546 action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2548 } else if (IsSObjectTable(SO)) {
2549 action( VISU_SHOW_TABLE )->addTo(theMenu);
2550 action( VISU_CREATE_CURVES )->addTo(theMenu);
2551 action( VISU_EXPORT_TABLE )->addTo(theMenu);
2552 theMenu->insertSeparator();
2555 if (!CORBA::is_nil(anObject)) {
2556 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2557 if (!CORBA::is_nil(aMED.in())) {
2558 action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2561 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2562 if (!CORBA::is_nil(aField)) {
2563 action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2566 _PTR(SObject) aSFather = SO->GetFather();
2568 _PTR(GenericAttribute) anAttr;
2569 aSFather->FindAttribute(anAttr, "AttributeName");
2571 _PTR(AttributeName) aName (anAttr);
2572 std::string aValue = aName->Value();
2573 if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2574 action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2583 //***************************************************************************
2586 windows( QMap<int, int>& theMap ) const
2589 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2590 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2596 viewManagers( QStringList& theList ) const
2599 theList.append( SVTK_Viewer::Type() );
2607 CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2608 return QString(anIOR.in());
2614 activateModule( SUIT_Study* theStudy )
2616 SalomeApp_Module::activateModule( theStudy );
2618 setMenuShown( true );
2619 setToolShown( true );
2626 deactivateModule( SUIT_Study* theStudy )
2628 setMenuShown( false );
2629 setToolShown( false );
2631 SalomeApp_Module::deactivateModule( theStudy );
2635 SalomeApp_Selection*
2637 createSelection() const
2639 return new VisuGUI_Selection( (SalomeApp_Module*)this );
2642 //******************************************************************
2643 void VisuGUI::studyActivated()
2645 GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2653 return new VisuGUI();
2657 void VisuGUI::createPreferences()
2659 int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2661 int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2662 int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2663 addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2664 int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2665 addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2668 fam.append( tr( "VISU_FONT_ARIAL" ) );
2669 fam.append( tr( "VISU_FONT_COURIER" ) );
2670 fam.append( tr( "VISU_FONT_TIMES" ) );
2671 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2673 setPreferenceProperty( tfont, "families", fam );
2674 setPreferenceProperty( tfont, "system", false );
2675 setPreferenceProperty( tfont, "widget_flags", wflag );
2676 setPreferenceProperty( lfont, "families", fam );
2677 setPreferenceProperty( lfont, "system", false );
2678 setPreferenceProperty( lfont, "widget_flags", wflag );
2680 int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2682 int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2683 setPreferenceProperty( numcol, "min", 2 );
2684 setPreferenceProperty( numcol, "max", 64 );
2686 int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2687 setPreferenceProperty( numlab, "min", 2 );
2688 setPreferenceProperty( numlab, "max", 65 );
2690 int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2691 int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2692 QStringList orients;
2693 orients.append( tr( "VISU_VERTICAL" ) );
2694 orients.append( tr( "VISU_HORIZONTAL" ) );
2695 QValueList<QVariant> indices;
2696 indices.append( 0 );
2697 indices.append( 1 );
2698 setPreferenceProperty( orient, "strings", orients );
2699 setPreferenceProperty( orient, "indexes", indices );
2701 int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2702 int xv = addPreference( tr( "VISU_X" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2703 int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
2704 int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2705 int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2706 setPreferenceProperty( xv, "step", 0.1 );
2707 setPreferenceProperty( yv, "step", 0.1 );
2708 setPreferenceProperty( wv, "step", 0.1 );
2709 setPreferenceProperty( hv, "step", 0.1 );
2710 setPreferenceProperty( xv, "min", 0.0 );
2711 setPreferenceProperty( yv, "min", 0.0 );
2712 setPreferenceProperty( wv, "min", 0.0 );
2713 setPreferenceProperty( hv, "min", 0.0 );
2714 setPreferenceProperty( xv, "max", 1.0 );
2715 setPreferenceProperty( yv, "max", 1.0 );
2716 setPreferenceProperty( wv, "max", 1.0 );
2717 setPreferenceProperty( hv, "max", 1.0 );
2719 int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2720 int xh = addPreference( tr( "VISU_X" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2721 int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2722 int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2723 int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2724 setPreferenceProperty( xh, "step", 0.1 );
2725 setPreferenceProperty( yh, "step", 0.1 );
2726 setPreferenceProperty( wh, "step", 0.1 );
2727 setPreferenceProperty( hh, "step", 0.1 );
2728 setPreferenceProperty( xh, "min", 0.0 );
2729 setPreferenceProperty( yh, "min", 0.0 );
2730 setPreferenceProperty( wh, "min", 0.0 );
2731 setPreferenceProperty( hh, "min", 0.0 );
2732 setPreferenceProperty( xh, "max", 1.0 );
2733 setPreferenceProperty( yh, "max", 1.0 );
2734 setPreferenceProperty( wh, "max", 1.0 );
2735 setPreferenceProperty( hh, "max", 1.0 );
2737 int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2739 int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2740 setPreferenceProperty( rangeGr, "columns", 1 );
2742 int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2744 modes.append( tr( "VISU_MODULUS" ) );
2745 modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2746 modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2747 modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2749 indices.append( 0 );
2750 indices.append( 1 );
2751 indices.append( 2 );
2752 indices.append( 3 );
2753 setPreferenceProperty( mode, "strings", modes );
2754 setPreferenceProperty( mode, "indexes", indices );
2756 addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2758 int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" );
2760 types.append( tr( "VISU_FIELD_RANGE" ) );
2761 types.append( tr( "VISU_IMPOSED_RANGE" ) );
2763 indices.append( 0 );
2764 indices.append( 1 );
2765 setPreferenceProperty( rangetype, "strings", types );
2766 setPreferenceProperty( rangetype, "indexes", indices );
2768 int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2770 int min = addPreference( tr( "VISU_MIN" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2771 int max = addPreference( tr( "VISU_MAX" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2772 setPreferenceProperty( min, "step", 0.1 );
2773 setPreferenceProperty( max, "step", 0.1 );
2775 int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2776 setPreferenceProperty( sweepGr, "columns", 1 );
2778 int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, SalomeApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2779 int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2780 int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2781 setPreferenceProperty( timestep, "min", 0.1 );
2782 setPreferenceProperty( timestep, "step", 0.1 );
2783 setPreferenceProperty( timestep, "max", 1000 );
2784 setPreferenceProperty( nbcycles, "max", 100 );
2785 setPreferenceProperty( nbsteps, "max", 200 );
2787 int importGr = addPreference( tr( "MED files import" ), srangeTab );
2788 addPreference( tr( "Full MED loading" ), importGr, SalomeApp_Preferences::Bool, "VISU", "full_med_loading" );
2791 void VisuGUI::preferencesChanged( const QString&, const QString& )