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 "LightApp_SelectionMgr.h"
75 #include "LightApp_Selection.h"
76 #include "LightApp_Preferences.h"
78 #include "QtxAction.h"
80 #include "VISUConfig.hh"
81 #include "VISU_Gen_i.hh"
82 #include "VISU_Mesh_i.hh"
83 #include "VISU_Table_i.hh"
84 #include "VISU_Result_i.hh"
85 #include "VISU_View_i.hh"
86 #include "VISU_ViewManager_i.hh"
87 #include "VISU_Plot3D_i.hh"
89 #include "VISU_Actor.h"
91 #include "VisuGUI_Prs3dTools.h"
92 #include "VisuGUI_Tools.h"
94 #include "VisuGUI_PopupTools.h"
95 #include "VisuGUI_NameDlg.h"
96 #include "VisuGUI_FileDlg.h"
97 #include "VisuGUI_CursorDlg.h"
98 #include "VisuGUI_Selection.h"
99 #include "VisuGUI_TimeAnimation.h"
100 #include "VisuGUI_EditContainerDlg.h"
101 #include "VisuGUI_NonIsometricDlg.h"
102 #include "VisuGUI_ClippingDlg.h"
103 #include "VisuGUI_Plot3DDlg.h"
104 #include "VisuGUI_CubeAxesDlg.h"
105 #include "VisuGUI_OffsetDlg.h"
106 #include "VisuGUI_Displayer.h"
108 #include "VISU_ScalarMap_i.hh"
109 #include "VisuGUI_ScalarBarDlg.h"
111 #include "VISU_DeformedShape_i.hh"
112 #include "VisuGUI_DeformedShapeDlg.h"
114 #include "VISU_IsoSurfaces_i.hh"
115 #include "VisuGUI_IsoSurfacesDlg.h"
117 #include "VISU_CutPlanes_i.hh"
118 #include "VisuGUI_CutPlanesDlg.h"
120 #include "VISU_CutLines_i.hh"
121 #include "VisuGUI_CutLinesDlg.h"
123 #include "VISU_StreamLines_i.hh"
124 #include "VisuGUI_StreamLinesDlg.h"
126 #include "VISU_Vectors_i.hh"
127 #include "VisuGUI_VectorsDlg.h"
129 #include "VisuGUI_TableDlg.h"
131 #include "SALOMEconfig.h"
132 #include CORBA_SERVER_HEADER(MED_Gen)
134 #include "utilities.h"
136 #include "VisuGUI_ActionsDef.h"
138 using namespace VISU;
141 static int MYDEBUG = 1;
143 static int MYDEBUG = 0;
146 //////////////////////////////////////////////////
148 //////////////////////////////////////////////////
151 SalomeApp_Module( "VISU" ),
166 if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
167 CheckLock(GetCStudy(GetAppStudy(this)));
168 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
171 aFilter.append( tr("FLT_MED_FILES") );
172 aFilter.append( tr("FLT_ALL_FILES") );
174 QFileInfo aFileInfo =
175 SUIT_FileDlg::getFileName(GetDesktop(this),
178 tr("MEN_IMPORT_FROM_FILE"),
180 if(aFileInfo.exists()) {
181 application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
183 VISU::Result_var aResult;
184 bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
185 if (VisuGUI_FileDlg::IsBuild) {
186 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
187 if (!CORBA::is_nil(aResult.in()))
188 if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
189 if (!aRes->IsPossible())
190 SUIT_MessageBox::warn1(GetDesktop(this),
192 tr("ERR_CANT_BUILD_PRESENTATION"),
198 aResourceMgr->setValue("VISU", "full_med_loading", false);
199 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
200 aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
203 if (CORBA::is_nil(aResult.in())) {
204 SUIT_MessageBox::warn1(GetDesktop(this),
206 tr("ERR_ERROR_IN_THE_FILE"),
209 application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
210 UpdateObjBrowser(this);
220 if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
221 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
224 SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
227 aFilter.append( tr("FLT_MED_FILES") );
228 aFilter.append( tr("FLT_ALL_FILES") );
230 QFileInfo aFileInfo =
231 SUIT_FileDlg::getFileName(GetDesktop(this),
234 tr("MEN_EXPLORE_MED_FILE"),
236 if(aFileInfo.exists()){
237 application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
238 std::string aStudyName = aStudy->Name();
241 aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
245 SUIT_MessageBox::warn1(GetDesktop(this),
247 tr("ERR_ERROR_IN_THE_FILE"),
250 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
251 getApp()->updateObjectBrowser(true); // as need to update MED tree
252 getApp()->updateActions();
259 OnImportTableFromFile()
261 if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
262 CheckLock(GetCStudy(GetAppStudy(this)));
265 aFilter.append( tr("FLT_TABLE_FILES") );
266 aFilter.append( tr("FLT_ALL_FILES") );
268 QFileInfo aFileInfo =
269 SUIT_FileDlg::getFileName(GetDesktop(this),
272 tr("MEN_IMPORT_TABLE"),
274 if (aFileInfo.exists()) {
275 application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
277 CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
279 if (CORBA::is_nil(anObject.in())) {
280 SUIT_MessageBox::warn1(GetDesktop(this),
282 tr("ERR_ERROR_IN_THE_FILE"),
285 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
286 UpdateObjBrowser(this);
293 OnExportTableToFile()
295 if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
297 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
299 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
300 SALOME_ListIO aListIO;
301 aSelectionMgr->selectedObjects(aListIO);
303 if (aListIO.Extent() > 0) {
304 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
305 if (anIO->hasEntry()) {
306 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
309 // find table attribute
311 _PTR(GenericAttribute) anAttr;
313 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
315 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
316 // if the current SObject is a table title
317 // we take a father contaning the table
318 aSObj = aSObj->GetFather();
320 if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
323 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
330 // get table title in order to have default name of the file
333 _PTR(AttributeTableOfReal) aTabAttr (anAttr);
334 if (!aTabAttr) return;
335 aTitle = aTabAttr->GetTitle().c_str();
337 _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
338 if (!aTabAttr) return;
339 aTitle = aTabAttr->GetTitle().c_str();
341 aTitle.simplifyWhiteSpace();
342 aTitle = aTitle.replace(QRegExp(" "), "_");
344 // get default path for the file
345 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
346 QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
347 if (aDir.isEmpty()) {
348 aDir = aResourceMgr->stringValue("VISU","InputDir","");
349 if (aDir.isEmpty()) {
350 aDir = getenv("CSF_PATHData");
353 QString aPath = Qtx::addSlash(aDir) + aTitle;
355 // get name for the file
357 aFilter.append("Table Files (*.xls)");
359 QFileInfo aFileInfo =
360 SUIT_FileDlg::getFileName(GetDesktop(this),
363 tr("MEN_EXPORT_TABLE"), // "Export Table To File"
367 QString aFile = aFileInfo.filePath();
368 if (!aFile.isEmpty()) {
369 application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
370 aDir = Qtx::dir(aFile, true);
371 aResourceMgr->setValue("VISU", "OutputDir", aDir);
374 GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
375 application()->putInfo(aFile + " " + tr("INF_DONE"));
376 } catch(std::exception& ex) {
378 SUIT_MessageBox::warn1(GetDesktop(this),
380 tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
383 INFOS(tr("ERR_ERROR_DURING_EXPORT"));
384 SUIT_MessageBox::warn1(GetDesktop(this),
386 tr("ERR_ERROR_DURING_EXPORT"),
398 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
399 if (CheckLock(aCStudy))
401 SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
403 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
404 SALOME_ListIO aListIO;
405 aSelectionMgr->selectedObjects(aListIO);
407 SALOME_ListIteratorOfListIO It (aListIO);
408 QApplication::setOverrideCursor(Qt::waitCursor);
409 for (; It.More(); It.Next()) {
410 Handle(SALOME_InteractiveObject) anIO = It.Value();
411 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
412 if (!aSObject->_is_nil()) {
413 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
414 if (!CORBA::is_nil(anObject)) {
415 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
416 if (!CORBA::is_nil(aMED.in()))
417 GetVisuGen(this)->ImportMed(aSObject);
418 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
419 if (!CORBA::is_nil(aField.in()))
420 GetVisuGen(this)->ImportMedField(aField);
422 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
423 SALOMEDS::GenericAttribute_var anAttr;
424 aSFather->FindAttribute(anAttr, "AttributeName");
425 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
426 CORBA::String_var aValue = aName->Value();
427 if (strcmp(aValue.in(), "MEDFIELD") == 0)
428 GetVisuGen(this)->ImportMed(aSObject);
432 UpdateObjBrowser(this, true);
433 QApplication::restoreOverrideCursor();
437 CreateCurves( SalomeApp_Module* theModule,
438 VISU::CutLines_i* thePrs,
440 const bool theCreate = true )
444 VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
448 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
449 _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
451 if ( !theCreate && aSObject ) {
453 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
454 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
455 for (; aIter->More(); aIter->Next()) {
456 _PTR(SObject) aTblObj = aIter->Value();
458 _PTR(GenericAttribute) anAttr;
459 if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
460 aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
467 if ( aCutDlg->isGenerateTable() ) {
468 GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
469 if ( aCutDlg->isGenerateCurves() ) {
471 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
472 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
473 for (; aIter->More(); aIter->Next()) {
474 _PTR(SObject) aTblObj = aIter->Value();
476 _PTR(GenericAttribute) anAttr;
477 if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
478 CreatePlot( theModule, aTblObj );
486 if (!theCreate && aSObject) {
487 UpdateObjBrowser(theModule);
495 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
496 if (CheckLock(aStudy))
499 // Get selected SObject
500 Handle(SALOME_InteractiveObject) anIO;
501 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
502 if (anIO.IsNull() || !anIO->hasEntry())
505 // create a VTK view window if it does not exist
506 GetViewWindow( this, /*create=*/true );
508 CreateMesh(this, anIO);
515 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
516 if (CheckLock(aStudy))
519 // create a VTK view window if it does not exist
520 GetViewWindow( this, /*create=*/true );
522 // Get selected SObject
523 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
524 SALOME_ListIO aListIO;
525 aSelectionMgr->selectedObjects(aListIO);
526 SALOME_ListIteratorOfListIO anIter (aListIO);
527 for (; anIter.More(); anIter.Next()) {
528 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
529 if (anIO.IsNull() || !anIO->hasEntry())
532 CreateMesh(this, anIO);
540 CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
546 OnCreateDeformedShape()
548 CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
555 CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
560 OnCreateIsoSurfaces()
562 CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
569 CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
576 CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
581 OnCreateStreamLines()
583 CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
590 CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
597 CheckLock(GetCStudy(GetAppStudy(this)));
598 GetVisuGen( this )->CreateContainer();
599 UpdateObjBrowser(this);
606 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
608 QApplication::setOverrideCursor(Qt::waitCursor);
610 LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
611 mgr->selectedObjects(aList);
613 Handle(SALOME_InteractiveObject) anIO;
614 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
616 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
617 if ( !CORBA::is_nil( anObject ) ) {
618 // is it Prs3d object ?
619 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
621 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
622 UpdateViewer( this, aPrsObject );
623 SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true );
625 vw->highlight(anIO, 1);
630 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
632 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
633 PlotCurve( this, aCurve, VISU::eDisplay );
637 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
639 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
640 PlotContainer( this, aContainer, VISU::eDisplay );
644 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
646 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
647 PlotTable( this, aTable, VISU::eDisplay );
652 SVTK_ViewWindow* vw = GetViewWindow( this );
654 vw->getRenderer()->ResetCameraClippingRange();
657 QApplication::restoreOverrideCursor();
672 if(MYDEBUG) MESSAGE("OnErasePrs");
674 QApplication::setOverrideCursor(Qt::waitCursor);
676 SVTK_ViewWindow* vw = GetViewWindow( this );
678 vw->unHighlightAll();
681 LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
682 mgr->selectedObjects(aList);
684 Handle(SALOME_InteractiveObject) anIO;
685 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
687 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
688 ErasePrs( this, anObject, false );
694 QApplication::restoreOverrideCursor();
702 Handle(SALOME_InteractiveObject) anIO;
703 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
704 EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg,1>(this, aPrs3d);
705 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
706 aViewWindow->highlight(anIO, 1);
714 OnEditDeformedShape()
716 Handle(SALOME_InteractiveObject) anIO;
717 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
718 EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg,1>(this, aPrs3d);
719 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
720 aViewWindow->highlight(anIO, 1);
730 Handle(SALOME_InteractiveObject) anIO;
731 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
732 EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg,0>(this, aPrs3d);
733 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
734 aViewWindow->highlight(anIO, 1);
744 Handle(SALOME_InteractiveObject) anIO;
745 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
746 EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg,0>(this, aPrs3d);
747 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
748 aViewWindow->highlight(anIO, 1);
758 Handle(SALOME_InteractiveObject) anIO;
759 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
760 EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg,1>(this, aPrs3d);
761 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
762 aViewWindow->highlight(anIO, 1);
772 Handle(SALOME_InteractiveObject) anIO;
773 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
774 EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg,1>(this, aPrs3d);
775 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
776 aViewWindow->highlight(anIO, 1);
786 Handle(SALOME_InteractiveObject) anIO;
787 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
788 EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg,1>(this, aPrs3d);
789 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
790 aViewWindow->highlight(anIO, 1);
800 Handle(SALOME_InteractiveObject) anIO;
801 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
802 EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg,0>(this, aPrs3d);
803 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
804 aViewWindow->highlight(anIO, 1);
814 if (SVTK_ViewWindow* vw = GetViewWindow()) {
815 vw->unHighlightAll();
816 if (vtkRenderer *aRen = vw->getRenderer()) {
818 vtkActorCollection *anActColl = aRen->GetActors();
819 for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
820 if (anActor->GetVisibility() > 0)
821 if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
822 anVISUActor = anVISUActor->GetParent();
823 anVISUActor->VisibilityOff();
828 } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
837 ChangeRepresentation(this, VISU::SURFACEFRAME);
844 ChangeRepresentation(this, VISU::INSIDEFRAME);
851 ChangeRepresentation(this, VISU::WIREFRAME);
858 ChangeRepresentation(this, VISU::SHADED);
865 ChangeRepresentation(this, VISU::POINT);
872 ChangeRepresentation(this, VISU::SHRINK);
879 SetShading(this, true);
886 SetShading(this, false);
893 Handle(SALOME_InteractiveObject) anIO;
894 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
895 if (CORBA::is_nil(anObject)) return;
896 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
897 if (!aServant.in()) return;
899 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
902 SVTK_ViewWindow* vw = GetViewWindow();
905 VISU_Actor* anActor = GetActor(aPrs3d, vw);
906 if (!anActor) return;
908 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
909 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
910 SALOMEDS::Color anOldColor, aNewColor;
911 int aRepresent = anActor->GetRepresentation();
913 switch (aRepresent) {
915 anOldColor = aMesh->GetNodeColor();
917 case VISU::WIREFRAME :
918 case VISU::INSIDEFRAME :
919 anOldColor = aMesh->GetLinkColor();
922 case VISU::SURFACEFRAME :
923 anOldColor = aMesh->GetCellColor();
926 } else if (aDeformedShape) {
927 anOldColor = aDeformedShape->GetColor();
932 QColor aColor (int(255*anOldColor.R),
933 int(255*anOldColor.G),
934 int(255*anOldColor.B));
935 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
936 if (aColorNew.isValid()) {
937 aNewColor.R = aColorNew.red()/255.;
938 aNewColor.G = aColorNew.green()/255.;
939 aNewColor.B = aColorNew.blue()/255.;
941 switch (aRepresent) {
943 aMesh->SetNodeColor(aNewColor);
945 case VISU::WIREFRAME :
946 case VISU::INSIDEFRAME :
947 aMesh->SetLinkColor(aNewColor);
950 case VISU::SURFACEFRAME :
951 aMesh->SetCellColor(aNewColor);
955 aDeformedShape->SetColor(aNewColor);
957 RecreateActor(this, aPrs3d);
963 OnChangeWireframeColor()
965 Handle(SALOME_InteractiveObject) anIO;
966 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
967 if (CORBA::is_nil(anObject)) return;
968 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
969 if (!aServant.in()) return;
971 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
974 SVTK_ViewWindow* vw = GetViewWindow();
977 VISU_Actor* anActor = GetActor(aPrs3d, vw);
978 if (!anActor) return;
980 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
981 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
982 QColor aColor (int(255*anOldColor.R),
983 int(255*anOldColor.G),
984 int(255*anOldColor.B));
985 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
986 if (aColorNew.isValid()) {
987 aNewColor.R = aColorNew.red()/255.;
988 aNewColor.G = aColorNew.green()/255.;
989 aNewColor.B = aColorNew.blue()/255.;
990 aMesh->SetLinkColor(aNewColor);
991 RecreateActor(this, aMesh);
1000 Handle(SALOME_InteractiveObject) anIO;
1001 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1002 if (CORBA::is_nil(anObject)) return;
1003 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1004 if (!aServant.in()) return;
1006 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1007 if (!aPrsObject) return;
1009 SVTK_ViewWindow* vw = GetViewWindow();
1012 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1013 if (!anActor) return;
1015 VisuGUI_CursorDlg* CursorDlg =
1016 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
1018 CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1019 CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1020 CursorDlg->SpinBox1->setMinValue(0);
1021 CursorDlg->SpinBox1->setMaxValue(100);
1023 float oldopac = anActor->GetOpacity();
1024 int intopac = int(oldopac*100. + 0.5);
1025 CursorDlg->SpinBox1->setValue(intopac);
1027 int ret = CursorDlg->exec();
1029 intopac = CursorDlg->SpinBox1->value();
1030 float newopac = intopac/100.;
1031 anActor->SetOpacity(newopac);
1040 Handle(SALOME_InteractiveObject) anIO;
1041 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1042 if (CORBA::is_nil(anObject)) return;
1043 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1044 if (!aServant.in()) return;
1046 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1047 if (!aPrsObject) return;
1049 SVTK_ViewWindow* vw = GetViewWindow();
1052 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1053 if (!anActor) return;
1055 VisuGUI_CursorDlg* CursorDlg =
1056 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1058 CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1059 CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1060 CursorDlg->SpinBox1->setMinValue(1);
1061 CursorDlg->SpinBox1->setMaxValue(10);
1063 float oldlwid = anActor->GetLineWidth();
1064 int intlwid = int(oldlwid);
1065 CursorDlg->SpinBox1->setValue(intlwid);
1067 int ret = CursorDlg->exec();
1069 intlwid = CursorDlg->SpinBox1->value();
1070 float newlwid = intlwid;
1071 anActor->SetLineWidth(newlwid);
1080 Handle(SALOME_InteractiveObject) anIO;
1081 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1083 if ( !CORBA::is_nil( anObject ) ) {
1084 VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1085 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1086 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1087 if( !CORBA::is_nil( aTable ) ) {
1088 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1090 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1095 // possibly this is Table SObject
1096 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1099 if( !IsSObjectTable( SO ) )
1102 VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1105 //SAL2670 Orientation of show tables
1106 VisuGUI_TableDlg::ttAuto,
1115 Handle(SALOME_InteractiveObject) anIO;
1116 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1117 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1118 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1119 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1120 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1121 GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1122 UpdateObjBrowser(this);
1130 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1131 if (CheckLock(aCStudy))
1134 SALOME_ListIO aList;
1135 LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
1136 mgr->selectedObjects(aList,QString::null,false);
1137 int i = 0, nbSelected = aList.Extent();
1138 if (nbSelected < 1) return;
1140 const char* entries [nbSelected];
1141 Handle(SALOME_InteractiveObject) anIO;
1142 for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1144 if (anIO->hasEntry())
1145 entries[i++] = anIO->getEntry();
1148 if (nbSelected < 1) return;
1150 // There is a transaction
1151 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1152 aStudyBuilder->NewCommand();
1154 for (i = 0; i < nbSelected; i++) {
1155 _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1157 DeleteSObject(this, aCStudy, aSObject);
1161 // Finish transaction
1162 aStudyBuilder->CommitCommand();
1164 //GetActiveStudy()->unHighlightAll();
1165 UpdateObjBrowser(this, true);
1172 Handle(SALOME_InteractiveObject) anIO;
1173 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1175 _PTR(GenericAttribute) anAttr;
1176 _PTR(AttributeName) aName;
1178 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1180 if ( !CORBA::is_nil( anObject ) ) {
1181 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1182 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1183 // Table (VISU object) is selected
1184 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1185 if( !CORBA::is_nil( aTbl ) ) {
1186 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1188 _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1189 if ( IsSObjectTable(SO) ) {
1190 // get name of SObject
1191 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1193 SOName = QString( aName->Value().c_str() );
1195 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1196 if ( dlg->exec() == QDialog::Accepted ) {
1197 if ( !IsStudyLocked( aStudy ) ) {
1198 // if study is not locked - create new container, create curves and insert them
1199 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1201 QValueList<int> verIndices;
1202 dlg->getCurvesSource( horIndex, verIndices );
1203 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1204 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1205 if( !CORBA::is_nil( aContainer ) ) {
1206 VISU::Container_i* pContainer =
1207 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1209 for ( int i = 0; i < verIndices.count(); i++ ) {
1210 CORBA::Object_var aNewCurve =
1211 GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1212 if( !CORBA::is_nil( aNewCurve ) ) {
1213 VISU::Curve_i* pCrv =
1214 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1217 int marker, line, lineWidth;
1219 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1220 line, lineWidth, color) && !isAuto ) {
1222 c.R = color.red() /255.;
1223 c.G = color.green()/255.;
1224 c.B = color.blue() /255.;
1225 pCrv->SetColor( c );
1226 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1227 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1229 pContainer->AddCurve( pCrv->_this() );
1233 UpdateObjBrowser(this);
1234 PlotContainer( this, pContainer, VISU::eDisplay );
1240 // if study is locked just get curves info and plot them
1241 // if current viewer is of VIEW_PLOT2D type
1242 QPtrList<Plot2d_Curve> container;
1243 dlg->getCurves( container );
1244 if ( !container.isEmpty() ) {
1245 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1246 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1256 else if ( !anIO.IsNull() ) {
1257 // check if Table SObject is selected
1258 SO = aStudy->FindObjectID( anIO->getEntry() );
1259 if ( IsSObjectTable(SO) ) {
1260 // get name of SObject
1261 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1263 SOName = QString( aName->Value().c_str() );
1265 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1266 if ( dlg->exec() == QDialog::Accepted ) {
1267 if ( !IsStudyLocked( aStudy ) ) {
1268 // if study is not locked - create new table and container objects, create curves
1269 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1271 QValueList<int> verIndices;
1272 dlg->getCurvesSource( horIndex, verIndices );
1273 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1274 CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1275 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1276 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1277 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1278 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1280 if ( pContainer && pTable ) {
1281 for ( int i = 0; i < verIndices.count(); i++ ) {
1282 CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1283 ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1284 if( !CORBA::is_nil( aNewCurve ) ) {
1285 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1288 int marker, line, lineWidth;
1290 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1291 line, lineWidth, color) && !isAuto ) {
1293 c.R = color.red()/255.;
1294 c.G = color.green()/255.;
1295 c.B = color.blue()/255.;
1296 pCrv->SetColor( c );
1297 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1298 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1300 pContainer->AddCurve( pCrv->_this() );
1304 UpdateObjBrowser(this);
1305 PlotContainer( this, pContainer, VISU::eDisplay );
1310 // if study is locked just get curves info and plot them
1311 QPtrList<Plot2d_Curve> container;
1312 dlg->getCurves( container );
1313 if ( !container.isEmpty() ) {
1314 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1315 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1328 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1329 SALOME_ListIO aListIO;
1330 aSelectionMgr->selectedObjects(aListIO);
1331 if (aListIO.Extent() != 1) return;
1333 SalomeApp_Study* aAppStudy = GetAppStudy(this);
1334 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1335 CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1336 if (CORBA::is_nil( anObject )) return;
1338 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1339 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1341 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1342 if( !CORBA::is_nil( aCurve ) ) {
1343 VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1344 if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1345 Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1347 aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1348 aDlg.setMarker( (int)aDSCurve->GetMarker() );
1349 SALOMEDS::Color aColor = aDSCurve->GetColor();
1350 aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1351 if( aDlg.exec() == QDialog::Accepted ) {
1352 aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1353 aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1354 SALOMEDS::Color newColor;
1355 newColor.R = aDlg.getColor().red()/255.;
1356 newColor.G = aDlg.getColor().green()/255.;
1357 newColor.B = aDlg.getColor().blue()/255.;
1358 aDSCurve->SetColor( newColor );
1359 PlotCurve(this, aDSCurve, VISU::eDisplay);
1370 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1371 if (CheckLock(aCStudy))
1373 Handle(SALOME_InteractiveObject) anIO;
1374 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1375 if (anIO.IsNull() || CORBA::is_nil(anObject))
1378 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1379 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1381 CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1382 if (!CORBA::is_nil(aCnt)) {
1383 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1384 if (container && container->GetNbCurves() > 0) {
1386 UpdateObjBrowser(this);
1396 Handle(SALOME_InteractiveObject) anIO;
1397 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1398 if (CORBA::is_nil(anObject)) return;
1400 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1401 if (!aServant.in()) return;
1402 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1403 if (!aContainer) return;
1405 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1406 aDlg->initFromPrsObject(aContainer);
1408 aDlg->storeToPrsObject(aContainer);
1409 UpdateObjBrowser(this, true);
1418 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1419 if (CheckLock(aCStudy))
1422 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1423 if (aViewMgr->getType() != SVTK_Viewer::Type())
1426 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1427 SALOME_ListIO aListIO;
1428 aSelectionMgr->selectedObjects(aListIO);
1429 if (aListIO.Extent() > 1)
1432 if (aListIO.Extent() == 0) {
1433 VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1435 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1436 VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1438 UpdateObjBrowser(this);
1443 OnRestoreViewParams()
1445 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1446 if (aViewMgr->getType() != SVTK_Viewer::Type())
1449 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1450 SALOME_ListIO aListIO;
1451 aSelectionMgr->selectedObjects(aListIO);
1452 if (aListIO.Extent() != 1)
1455 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1456 //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1457 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1458 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1459 VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1466 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1467 if (CheckLock(aCStudy))
1470 Handle(SALOME_InteractiveObject) anIO;
1471 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1473 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1476 //TEST DU PARENT == VISU
1477 _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
1478 _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
1480 _PTR(AttributeName) aName (anAttr);
1481 QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1482 if (!Name.isEmpty()) {
1483 QApplication::setOverrideCursor(Qt::waitCursor);
1485 // rename specific objects
1486 if (!CORBA::is_nil(anObject)) {
1487 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1488 if (!CORBA::is_nil(aVisuObj)) {
1489 switch (aVisuObj->GetType()) {
1490 case VISU::TCURVE: // Curve object
1492 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1493 if (!CORBA::is_nil(aCurve)) {
1494 VISU::Curve_i* curve =
1495 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1497 curve->SetName(Name.latin1());
1501 case VISU::TTABLE: // Table object
1503 CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1504 if (!CORBA::is_nil(aTable)) {
1505 VISU::Table_i* table =
1506 dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1508 table->SetName(Name.latin1());
1512 case VISU::TCONTAINER: // Container object
1514 CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1515 if (!CORBA::is_nil(aContainer)) {
1516 VISU::Container_i* container =
1517 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1519 container->SetName(Name.latin1());
1530 // rename the study object
1531 aName->SetValue(Name.latin1()); // rename the SObject
1532 anIO->setName(Name.latin1()); // rename the InteractiveObject
1533 UpdateObjBrowser(this, false);
1535 QApplication::restoreOverrideCursor();
1544 new VisuGUI_ClippingDlg (this, "", false);
1552 Handle(SALOME_InteractiveObject) anIO;
1553 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1554 if (CORBA::is_nil(anObject)) return;
1555 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1556 if (!aServant.in()) return;
1558 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1559 if (!aPrsObject) return;
1561 SVTK_ViewWindow* vw = GetViewWindow();
1564 VISU_Actor* aActor = GetActor(aPrsObject, vw);
1565 if (!aActor) return;
1567 if (!aActor->GetVisibility()) {
1568 aActor->VisibilityOn();
1571 // Get sweep parameters
1572 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1574 double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1575 int aTemp = int(1.E6 * aTempoDbl);
1577 int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1578 int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1581 QApplication::setOverrideCursor(Qt::waitCursor);
1582 for (int j = 0; j < aCycles; j++) {
1583 for (int i = 0; i <= aSteps; i++) {
1585 float aPercents = float(i)/aSteps;
1586 aPrsObject->SetMapScale(aPercents);
1587 aPrsObject->UpdateActor(aActor);
1588 vw->getRenderWindow()->getRenderWindow()->Render();
1590 } catch (std::exception& exc) {
1591 INFOS("Follow exception was occured :\n" << exc.what());
1593 INFOS("Unknown exception was occured!");
1597 QApplication::restoreOverrideCursor();
1604 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1605 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1606 // new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1607 new VisuGUI_TimeAnimationDlg (this, aCStudy);
1609 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1610 SALOME_ListIO aListIO;
1611 aSelectionMgr->selectedObjects(aListIO);
1613 bool isDefined = false;
1615 SALOME_ListIteratorOfListIO It (aListIO);
1616 for (; It.More(); It.Next()) {
1617 _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1618 if (!aSObject) continue;
1619 if (getValue(aSObject, "myComment") == QString("FIELD")) {
1620 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1624 aAnimationDlg->addField(aSObject);
1626 } else if (aNbTimes == aNumber) {
1627 aAnimationDlg->addField(aSObject);
1632 if (isDefined) aAnimationDlg->show();
1633 else delete aAnimationDlg;
1636 //************************************************************************
1641 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1642 SALOME_ListIO aListIO;
1643 aSelectionMgr->selectedObjects(aListIO);
1645 if (aListIO.Extent() != 1)
1648 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1650 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1652 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1655 VISU::Storable::TRestoringMap aMap;
1656 _PTR(GenericAttribute) anAttr;
1657 if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1659 _PTR(AttributeComment) aComment (anAttr);
1660 string aComm = aComment->Value();
1661 QString strIn (aComm.c_str());
1662 VISU::Storable::StrToMap(strIn, aMap);
1664 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1665 if (aType != VISU::TANIMATION) return;
1667 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1668 new VisuGUI_TimeAnimationDlg(this, aCStudy);
1669 aAnimationDlg->restoreFromStudy(aSObj);
1670 aAnimationDlg->show();
1675 OnCopyPresentation()
1677 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1678 if (CheckLock(aCStudy))
1681 Handle(SALOME_InteractiveObject) anIO;
1682 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1683 if (CORBA::is_nil(anObject)) return;
1684 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1685 if (!aServant.in()) return;
1687 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1688 if (!aPrsObject) return;
1690 switch (aPrsObject->GetType()) {
1693 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1694 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1695 aSameMesh->SameAs(aMeshPrs);
1696 UpdateViewer(this, aSameMesh);
1699 case VISU::TSCALARMAP:
1701 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1702 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1703 aSameScalar->SameAs(aScalarPrs);
1704 UpdateViewer(this, aSameScalar);
1707 case VISU::TDEFORMEDSHAPE:
1709 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1710 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1711 aSameDeformed->SameAs(aDefPrs);
1712 UpdateViewer(this, aSameDeformed);
1715 case VISU::TCUTPLANES:
1717 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1718 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1719 aSameCut->SameAs(aCutPrs);
1720 UpdateViewer(this, aSameCut);
1723 case VISU::TCUTLINES:
1725 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1726 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1727 aSameCut->SameAs(aCutPrs);
1728 UpdateViewer(this, aSameCut);
1731 case VISU::TISOSURFACE:
1733 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1734 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1735 aSameIso->SameAs(aIsoPrs);
1736 UpdateViewer(this, aSameIso);
1739 case VISU::TSTREAMLINES:
1741 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1742 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1743 aSameLines->SameAs(aLinesPrs);
1744 UpdateViewer(this, aSameLines);
1747 case VISU::TVECTORS:
1749 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1750 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1751 aSameVectors->SameAs(aVectorsPrs);
1752 UpdateViewer(this, aSameVectors);
1757 VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1758 VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1759 aSamePlot3D->SameAs(aPlot3DPrs);
1760 UpdateViewer(this, aSamePlot3D);
1764 UpdateObjBrowser(this);
1771 if (GetViewWindow())
1772 (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1774 SUIT_MessageBox::warn1(GetDesktop(this),
1776 tr("ERR_ACTIVATE_VIEW3D"),
1784 VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1785 new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1786 false, Qt::WDestructiveClose);
1787 m_NonIsoDlg->show();
1794 //Show dialog that allows to select scale function and corresponding scale factor
1795 VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1803 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1804 SALOME_ListIO aListIO;
1805 aSelectionMgr->selectedObjects(aListIO);
1807 SALOME_ListIteratorOfListIO It (aListIO);
1809 // first find the bounds
1810 double aMin, aMax; bool first = true;
1811 for (; It.More(); It.Next()) {
1812 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1813 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1814 if (!aPrsList.empty()) {
1815 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1816 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1818 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1822 aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1824 if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1825 if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1833 // set the computed range to every selected ScalarMap
1834 bool update = false;
1835 for (It.Initialize(aListIO); It.More(); It.Next() ) {
1836 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1837 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1838 if (!aPrsList.empty()) {
1839 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1840 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1842 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1844 aScalar->SetRange(aMin, aMax);
1845 RecreateActor(this, aScalar);
1853 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1854 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1855 vw->getRenderer()->ResetCameraClippingRange();
1866 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1867 SALOME_ListIO aListIO;
1868 aSelectionMgr->selectedObjects(aListIO);
1870 SALOME_ListIteratorOfListIO It (aListIO);
1872 // restore the source range for every ScalarMap
1873 bool update = false;
1874 for (; It.More(); It.Next()) {
1875 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1876 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1877 if (!aPrsList.empty()) {
1878 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1879 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1881 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1883 aScalar->SetSourceRange();
1884 RecreateActor(this, aScalar);
1892 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1893 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1894 vw->getRenderer()->ResetCameraClippingRange();
1905 if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1906 VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1908 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1910 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1911 SALOME_ListIO aListIO;
1912 aSelectionMgr->selectedObjects(aListIO);
1914 SALOME_ListIteratorOfListIO It (aListIO);
1915 for (; It.More(); It.Next()) {
1916 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1917 if (anIO->hasEntry()) {
1918 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1920 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1921 if (!CORBA::is_nil(aCORBAObject)) {
1922 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1923 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1924 aDlg->addPresentation(aPrsObject);
1930 if (aDlg->getPrsCount() > 0)
1940 SVTK_ViewWindow* vw = GetViewWindow();
1942 ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1951 initialize( CAM_Application* theApp )
1953 SalomeApp_Module::initialize( theApp );
1966 QWidget* aParent = application()->desktop();
1967 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1970 createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
1971 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1972 this, SLOT(OnImportFromFile()));
1974 createAction( VISU_EXPLORE_MED, "", QIconSet(),
1975 tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1976 this, SLOT(OnExploreMEDFile()));
1978 createAction( VISU_IMPORT_TABLE, "", QIconSet(),
1979 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1980 this, SLOT(OnImportTableFromFile()));
1982 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1983 createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
1984 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1985 this, SLOT(OnCreateScalarMap()));
1987 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1988 createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
1989 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1990 this, SLOT(OnCreateDeformedShape()));
1992 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1993 createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
1994 tr("MEN_VECTORS"), "", 0, aParent, false,
1995 this, SLOT(OnCreateVectors()));
1997 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
1998 createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
1999 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
2000 this, SLOT(OnCreateIsoSurfaces()));
2002 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
2003 createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
2004 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
2005 this, SLOT(OnCreateCutPlanes()));
2007 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
2008 createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
2009 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
2010 this, SLOT(OnCreateStreamLines()));
2012 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
2013 createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
2014 tr("MEN_CUT_LINES"), "", 0, aParent, false,
2015 this, SLOT(OnCreateCutLines()));
2017 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2018 createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
2019 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2020 this, SLOT(OnCreatePlot3D()));
2022 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2023 createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
2024 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2025 this, SLOT(OnCreatePlot2dView()));
2027 createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
2028 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
2029 this, SLOT(OnDeleteObjects()));
2031 createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
2032 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2033 this, SLOT(OnShowTable()));
2035 createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
2036 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2037 this, SLOT(OnPlotData()));
2039 createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
2040 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2041 this, SLOT(OnExportTableToFile()));
2043 createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
2044 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2045 this, SLOT(OnImportMedField()));
2047 createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
2048 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2049 this, SLOT(OnImportMedField()));
2051 createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2052 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2053 this, SLOT(OnImportMedField()));
2055 createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
2056 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2057 this, SLOT(OnCreateMesh()));
2059 createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2060 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2061 this, SLOT(OnCreateManyMesh()));
2063 createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2064 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2065 this, SLOT(OnTranslatePrs()));
2067 createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2068 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2069 this, SLOT(OnMergeScalarBars()));
2071 createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2072 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2073 this, SLOT(OnFreeScalarBars()));
2075 createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
2076 tr("MEN_ERASE"), "", 0, aParent, false,
2077 this, SLOT(OnErasePrs()));
2079 createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
2080 tr("MEN_DISPLAY"), "", 0, aParent, false,
2081 this, SLOT(OnDisplayPrs()));
2083 createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
2084 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2085 this, SLOT(OnDisplayOnlyPrs()));
2087 createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
2088 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2089 this, SLOT(OnCopyPresentation()));
2091 createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
2092 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2093 this, SLOT(OnCurveProperties()));
2095 createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2096 this, SLOT(OnRename()));
2098 createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
2099 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2100 this, SLOT(OnEditContainer()));
2102 createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
2103 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2104 this, SLOT(OnClearContainer()));
2106 createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2107 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2108 this, SLOT(OnSaveViewParams()));
2109 createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2110 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2111 this, SLOT(OnSaveViewParams()));
2113 createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2114 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2115 this, SLOT(OnRestoreViewParams()));
2117 //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2118 // tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2119 // this, SLOT(OnDeleteObjects()));
2121 createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2122 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2123 this, SLOT(OnArrangeActors()));
2125 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2126 createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
2127 tr("MEN_POINTS"), "", 0, aParent, false,
2128 this, SLOT(OnMakePoints()));
2130 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2131 createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
2132 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2133 this, SLOT(OnMakeWireframe()));
2135 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2136 createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
2137 tr("MEN_SURFACE"), "", 0, aParent, false,
2138 this, SLOT(OnMakeSurface()));
2140 createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
2141 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2142 this, SLOT(OnMakeInsideframe()));
2144 createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
2145 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2146 this, SLOT(OnMakeSurfaceframe()));
2148 createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
2149 tr("MEN_SHRINK"), "", 0, aParent, false,
2150 this, SLOT(OnMakeShrink()));
2152 createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
2153 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2154 this, SLOT(OnMakeShrink()));
2156 createAction( VISU_SHADING, tr("MEN_SHADING"), QIconSet(),
2157 tr("MEN_SHADING"), "", 0, aParent, false,
2158 this, SLOT(OnSetShadingOn()));
2160 createAction( VISU_NOSHADING, tr("MEN_NOSHADING"), QIconSet(),
2161 tr("MEN_NOSHADING"), "", 0, aParent, false,
2162 this, SLOT(OnSetShadingOff()));
2164 createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
2165 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2166 this, SLOT(OnChangeColor()));
2168 createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
2169 tr("MEN_COLOR"), "", 0, aParent, false,
2170 this, SLOT(OnChangeColor()));
2172 createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
2173 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2174 this, SLOT(OnChangeWireframeColor()));
2176 createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
2177 tr("MEN_OPACITY"), "", 0, aParent, false,
2178 this, SLOT(OnChangeOpacity()));
2180 createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
2181 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2182 this, SLOT(OnChangeLines()));
2185 createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIconSet(),
2186 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2187 this, SLOT(OnEditScalarMap()));
2189 createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(),
2190 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2191 this, SLOT(OnEditDeformedShape()));
2193 createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIconSet(),
2194 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2195 this, SLOT(OnEditCutPlanes()));
2197 createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2198 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2199 this, SLOT(OnEditCutLines()));
2201 createAction( VISU_EDIT_ISOSURFACE, tr("MEN_EDIT_PRS"), QIconSet(),
2202 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2203 this, SLOT(OnEditIsoSurfaces()));
2205 createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIconSet(),
2206 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2207 this, SLOT(OnEditVectors()));
2209 createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2210 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2211 this, SLOT(OnEditStreamLines()));
2213 createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIconSet(),
2214 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2215 this, SLOT(OnEditPlot3D()));
2218 createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
2219 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2220 this, SLOT(OnCreateTable()));
2222 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2223 createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
2224 tr("MEN_SWEEP"), "", 0, aParent, false,
2225 this, SLOT(OnSweep()));
2227 createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2228 tr("MEN_CLIPPING"), "", 0, aParent, false,
2229 this, SLOT(OnClippingPlanes()));
2231 createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2232 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2233 this, SLOT(OnSelectionInfo()));
2235 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2236 createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
2237 tr("MEN_ANIMATION"), "", 0, aParent, false,
2238 this, SLOT(OnTimeAnimation()));
2240 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2241 createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2242 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2243 this, SLOT(OnEraseAll()));
2245 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2246 createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2247 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2248 //this, SLOT(OnEraseAll()));
2251 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2252 createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2253 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2254 //this, SLOT(OnEraseAll()));
2257 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2258 createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2259 tr("MEN_SCALING"), "", 0, aParent, false,
2260 this, SLOT(OnScaling()));
2262 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2263 createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2264 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2265 this, SLOT(OnCubeAxes()));
2267 createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2268 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2269 this, SLOT(OnShowAnimation()));
2276 // Add actions to menus
2278 aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2279 createMenu( separator(), aMenuId, -1, 10 );
2280 createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2281 createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2282 createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2284 aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2285 createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2286 createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2287 createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2288 createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2289 createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2290 createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2291 createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2292 createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2294 aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2295 createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2297 aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2299 createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2300 createMenu( VISU_POINTS, parentId, 10 ); // points
2301 createMenu( VISU_WIREFRAME, parentId, 10 ); // wireframe
2302 createMenu( VISU_SURFACE, parentId, 10 ); // surface
2303 createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2304 createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2305 createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2306 createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2307 createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2314 int aToolId = createTool(tr("TOOL_VISUALISATION"));
2315 createTool( VISU_SCALAR_MAP, aToolId );
2316 createTool( VISU_DEFORMED_SHAPE, aToolId );
2317 createTool( VISU_VECTORS, aToolId );
2318 createTool( VISU_ISO_SURFACES, aToolId );
2319 createTool( VISU_CUT_PLANES, aToolId );
2320 createTool( VISU_CUT_LINES, aToolId );
2321 createTool( VISU_STREAM_LINES, aToolId );
2322 createTool( VISU_PLOT_3D, aToolId );
2324 aToolId = createTool(tr("TOOL_REPRESENTATION"));
2325 createTool( VISU_POINTS, aToolId );
2326 createTool( VISU_WIREFRAME, aToolId );
2327 createTool( VISU_SURFACE, aToolId );
2328 createTool( VISU_ERASE_ALL, aToolId );
2329 createTool( VISU_GLOBAL_SELECTION, aToolId );
2330 createTool( VISU_PARTIAL_SELECTION, aToolId );
2331 createTool( VISU_SCALING, aToolId );
2332 createTool( VISU_CUBE_AXES, aToolId );
2339 // Prepare popup menus
2340 QtxPopupMgr* mgr = popupMgr();
2342 // VISU root commands
2343 mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2344 mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2345 mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2347 //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2350 mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2351 mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2352 mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2353 mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2354 mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2355 mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2356 mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2357 mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2359 mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2360 mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2362 mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2365 mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 );
2366 mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 );
2367 mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 );
2368 mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 );
2369 mgr->insert( action( VISU_EDIT_ISOSURFACE ), -1, -1, -1 );
2370 mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 );
2371 mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 );
2372 mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 );
2373 mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2376 mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2379 mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2382 mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2385 //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2386 //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2387 //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2389 mgr->insert( separator(), -1, -1, -1 );
2391 mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2392 mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2393 mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2395 // "Representation" submenu
2396 int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2397 mgr->insert( action( VISU_POINTS ) , parentId, -1, -1 ); // points
2398 mgr->insert( action( VISU_WIREFRAME ) , parentId, -1, -1 ); // wireframe
2399 mgr->insert( action( VISU_SURFACE ) , parentId, -1, -1 ); // surface
2400 mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2401 mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2402 mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink
2403 mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink
2404 mgr->insert( separator(), parentId, -1, -1 );
2405 mgr->insert( action( VISU_SHADING ) , parentId, -1, -1 ); // shading
2406 mgr->insert( action( VISU_NOSHADING ) , parentId, -1, -1 ); // noshading
2408 // "Properties" submenu
2409 parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2410 mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2411 mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2412 mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color
2413 mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity
2414 mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2416 mgr->insert( separator(), -1, -1, -1 );
2418 // Other presentations management
2419 mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2420 mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2422 mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2423 mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2425 mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2426 mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2428 mgr->insert( separator(), -1, -1, -1 );
2430 // view parameters commands
2431 mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2432 mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
2433 mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2434 //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2436 mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2438 mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2440 mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2444 QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2445 "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2447 // VISU root commands
2448 QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
2449 mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2450 mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2451 mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2453 // timestamp commands
2454 aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
2455 mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2456 mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2457 mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2458 mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2459 mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2460 aRule += " and nbComponents>1";
2461 mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2462 mgr->setRule( action( VISU_VECTORS ), aRule, true );
2463 mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2465 // display/erase commands
2466 QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))";
2467 QString aTableOrCont = "(type='VISU::TTABLE' and nbChildren>0) or type='VISU::TCONTAINER'";
2468 QString orCurveVisible = "or (type='VISU::TCURVE' and isVisible)";
2469 QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")";
2470 QString aPrsVisible = "(($type in {'VISU::TMESH' " + aPrsAll + "}) and isVisible)";
2471 QString aPrsInvisible = "(($type in {'VISU::TMESH' " + aPrsAll + "})" + andInvisible + ")";
2473 QString anEraseRule = "selcount>0 and (" + aPrsVisible +
2474 " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + ")))";
2476 QString aDisplayRule = "selcount>0 and (" + aPrsInvisible +
2477 " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + ")))";
2479 QString aDOnlyRule = "selcount>0 and (($type in {'VISU::TMESH' " + aPrsAll + "})"
2480 " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or"
2481 " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))))";
2483 mgr->setRule( action( VISU_ERASE ), anEraseRule, true );
2484 mgr->setRule( action( VISU_DISPLAY ), aDisplayRule, true );
2485 mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule, true );
2487 aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2488 mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2490 aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2491 mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2492 mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2495 aRule = "selcount=1 and type='VISU::TVIEW3D'";
2496 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2497 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2498 mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2499 //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2501 mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2503 // 3D presentations commands
2504 QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2505 QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2506 QString aSurfType = " and $type in {'VISU::TMESH'}";
2507 QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2508 "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2509 QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2510 "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2512 aRule = "selcount=1";
2513 mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2515 // "Representation" submenu
2516 QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2517 QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2518 QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2519 QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2520 QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2522 mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints, true );
2523 mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr, true );
2524 mgr->setRule( action( VISU_SURFACE ) , aRule + aPrsType + aNotSurfac, true );
2525 mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2526 mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2528 mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true );
2529 mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2531 mgr->setRule( action( VISU_SHADING ) , aRule + " and isScalarMapAct=1 and isShading=0", true );
2532 mgr->setRule( action( VISU_NOSHADING ), aRule + " and isScalarMapAct=1 and isShading=1", true );
2534 // "Properties" submenu
2535 mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2536 mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2537 mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2538 " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2539 "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2540 mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2541 mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2544 QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2546 aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
2547 mgr->setRule( action( VISU_RENAME ), aRule, true );
2549 // copy presentation command
2550 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2551 mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2554 aRule = "selcount=1 and type='VISU::TCURVE'";
2555 mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2557 // curve container commands
2558 aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
2559 mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2560 mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2562 mgr->setRule( action( VISU_EDIT_SCALARMAP ),
2563 "selcount=1 and type='VISU::TSCALARMAP'", true );
2564 mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
2565 "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
2566 mgr->setRule( action( VISU_EDIT_CUTPLANES ),
2567 "selcount=1 and type='VISU::TCUTPLANES'", true );
2568 mgr->setRule( action( VISU_EDIT_CUTLINES ),
2569 "selcount=1 and type='VISU::TCUTLINES'", true );
2570 mgr->setRule( action( VISU_EDIT_ISOSURFACE ),
2571 "selcount=1 and type='VISU::TISOSURFACE'", true );
2572 mgr->setRule( action( VISU_EDIT_VECTORS ),
2573 "selcount=1 and type='VISU::TVECTORS'", true );
2574 mgr->setRule( action( VISU_EDIT_STREAMLINES ),
2575 "selcount=1 and type='VISU::TSTREAMLINES'", true );
2576 mgr->setRule( action( VISU_EDIT_PLOT3D ),
2577 "selcount=1 and type='VISU::TPLOT3D'", true );
2579 aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2580 mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2582 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2583 mgr->setRule( action( VISU_SWEEP ), aRule, true );
2585 // "Selection info" popup item
2586 aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2587 mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2589 aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2590 mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2592 aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2593 mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2594 mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2596 //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2597 //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2600 //***************************************************************************
2601 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2603 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2605 OB_Browser* ob = getApp()->objectBrowser();
2606 bool isOBClient = (ob && theClient == ob->popupClientType());
2608 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2609 SALOME_ListIO aListIO;
2610 aSelectionMgr->selectedObjects(aListIO);
2612 if (aListIO.Extent() < 1) return;
2614 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2616 // Check if "Merge Scalar Range" can be applied
2618 SALOME_ListIteratorOfListIO It (aListIO);
2619 for (; It.More(); It.Next()) {
2620 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2622 if (!anIO.IsNull() && anIO->hasEntry()) {
2623 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2624 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2625 if (CORBA::is_nil(aCORBAObject)) {
2626 _PTR(GenericAttribute) anAttr;
2627 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2628 _PTR(AttributeComment) aComment (anAttr);
2629 string aComm = aComment->Value();
2630 QString strIn (aComm.c_str());
2631 VISU::Storable::TRestoringMap pMap;
2632 VISU::Storable::StrToMap(strIn, pMap);
2634 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2635 if (isExist && aType == VISU::TTIMESTAMP) {
2636 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2638 for (; anIter->More(); anIter->Next()) {
2639 aPrs = anIter->Value();
2640 if (!aPrs) continue;
2641 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2642 nbPrs += aSubList.size();
2651 theMenu->insertSeparator();
2652 action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2653 action( VISU_FREE_SCALAR_BARS )->addTo(theMenu);
2656 theMenu->insertSeparator();
2658 // Check if some (nb > 0) removable objects selected
2659 if (isOBClient && IsRemovableSelected(this)) {
2660 action( VISU_DELETE_OBJS )->addTo(theMenu);
2663 // Check single selection
2664 if (aListIO.Extent() != 1) return;
2666 Handle(SALOME_InteractiveObject) anIO;
2667 VISU::Storable::TRestoringMap aMap;
2668 CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2670 _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2672 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2674 if (aType == VISU::TANIMATION) {
2675 action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2677 } else if (isOBClient) {
2678 if (IsSObjectTable(SO)) {
2679 action( VISU_SHOW_TABLE )->addTo(theMenu);
2680 action( VISU_CREATE_CURVES )->addTo(theMenu);
2681 action( VISU_EXPORT_TABLE )->addTo(theMenu);
2682 theMenu->insertSeparator();
2684 if (!CORBA::is_nil(anObject)) {
2685 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2686 if (!CORBA::is_nil(aMED.in())) {
2687 action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2690 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2691 if (!CORBA::is_nil(aField)) {
2692 action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2695 _PTR(SObject) aSFather = SO->GetFather();
2697 _PTR(GenericAttribute) anAttr;
2698 aSFather->FindAttribute(anAttr, "AttributeName");
2700 _PTR(AttributeName) aName (anAttr);
2701 std::string aValue = aName->Value();
2702 if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2703 action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2713 //***************************************************************************
2716 windows( QMap<int, int>& theMap ) const
2719 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2720 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2726 viewManagers( QStringList& theList ) const
2729 theList.append( SVTK_Viewer::Type() );
2737 CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2738 return QString(anIOR.in());
2744 activateModule( SUIT_Study* theStudy )
2746 SalomeApp_Module::activateModule( theStudy );
2748 setMenuShown( true );
2749 setToolShown( true );
2756 deactivateModule( SUIT_Study* theStudy )
2758 setMenuShown( false );
2759 setToolShown( false );
2761 SalomeApp_Module::deactivateModule( theStudy );
2767 createSelection() const
2769 return new VisuGUI_Selection( (SalomeApp_Module*)this );
2772 //******************************************************************
2773 void VisuGUI::studyActivated()
2775 GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2783 return new VisuGUI();
2787 void VisuGUI::createPreferences()
2789 int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2791 int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2792 int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2793 addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2794 int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2795 addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2798 fam.append( tr( "VISU_FONT_ARIAL" ) );
2799 fam.append( tr( "VISU_FONT_COURIER" ) );
2800 fam.append( tr( "VISU_FONT_TIMES" ) );
2801 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2803 setPreferenceProperty( tfont, "families", fam );
2804 setPreferenceProperty( tfont, "system", false );
2805 setPreferenceProperty( tfont, "widget_flags", wflag );
2806 setPreferenceProperty( lfont, "families", fam );
2807 setPreferenceProperty( lfont, "system", false );
2808 setPreferenceProperty( lfont, "widget_flags", wflag );
2810 int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2812 int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2813 setPreferenceProperty( numcol, "min", 2 );
2814 setPreferenceProperty( numcol, "max", 64 );
2816 int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2817 setPreferenceProperty( numlab, "min", 2 );
2818 setPreferenceProperty( numlab, "max", 65 );
2820 int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2821 int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2822 QStringList orients;
2823 orients.append( tr( "VISU_VERTICAL" ) );
2824 orients.append( tr( "VISU_HORIZONTAL" ) );
2825 QValueList<QVariant> indices;
2826 indices.append( 0 );
2827 indices.append( 1 );
2828 setPreferenceProperty( orient, "strings", orients );
2829 setPreferenceProperty( orient, "indexes", indices );
2831 int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2832 int xv = addPreference( tr( "VISU_X" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2833 int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
2834 int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2835 int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2836 setPreferenceProperty( xv, "step", 0.1 );
2837 setPreferenceProperty( yv, "step", 0.1 );
2838 setPreferenceProperty( wv, "step", 0.1 );
2839 setPreferenceProperty( hv, "step", 0.1 );
2840 setPreferenceProperty( xv, "min", 0.0 );
2841 setPreferenceProperty( yv, "min", 0.0 );
2842 setPreferenceProperty( wv, "min", 0.0 );
2843 setPreferenceProperty( hv, "min", 0.0 );
2844 setPreferenceProperty( xv, "max", 1.0 );
2845 setPreferenceProperty( yv, "max", 1.0 );
2846 setPreferenceProperty( wv, "max", 1.0 );
2847 setPreferenceProperty( hv, "max", 1.0 );
2849 int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2850 int xh = addPreference( tr( "VISU_X" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2851 int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2852 int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2853 int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2854 setPreferenceProperty( xh, "step", 0.1 );
2855 setPreferenceProperty( yh, "step", 0.1 );
2856 setPreferenceProperty( wh, "step", 0.1 );
2857 setPreferenceProperty( hh, "step", 0.1 );
2858 setPreferenceProperty( xh, "min", 0.0 );
2859 setPreferenceProperty( yh, "min", 0.0 );
2860 setPreferenceProperty( wh, "min", 0.0 );
2861 setPreferenceProperty( hh, "min", 0.0 );
2862 setPreferenceProperty( xh, "max", 1.0 );
2863 setPreferenceProperty( yh, "max", 1.0 );
2864 setPreferenceProperty( wh, "max", 1.0 );
2865 setPreferenceProperty( hh, "max", 1.0 );
2867 int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2869 int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2870 setPreferenceProperty( rangeGr, "columns", 1 );
2872 int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2874 modes.append( tr( "VISU_MODULUS" ) );
2875 modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2876 modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2877 modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2879 indices.append( 0 );
2880 indices.append( 1 );
2881 indices.append( 2 );
2882 indices.append( 3 );
2883 setPreferenceProperty( mode, "strings", modes );
2884 setPreferenceProperty( mode, "indexes", indices );
2886 addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, LightApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2888 int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_range_type" );
2890 types.append( tr( "VISU_FIELD_RANGE" ) );
2891 types.append( tr( "VISU_IMPOSED_RANGE" ) );
2893 indices.append( 0 );
2894 indices.append( 1 );
2895 setPreferenceProperty( rangetype, "strings", types );
2896 setPreferenceProperty( rangetype, "indexes", indices );
2898 int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2900 int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2901 int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2902 setPreferenceProperty( min, "step", 0.1 );
2903 setPreferenceProperty( max, "step", 0.1 );
2905 int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2906 setPreferenceProperty( sweepGr, "columns", 1 );
2908 int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2909 int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2910 int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2911 setPreferenceProperty( timestep, "min", 0.1 );
2912 setPreferenceProperty( timestep, "step", 0.1 );
2913 setPreferenceProperty( timestep, "max", 1000 );
2914 setPreferenceProperty( nbcycles, "max", 100 );
2915 setPreferenceProperty( nbsteps, "max", 200 );
2917 int importGr = addPreference( tr( "MED files import" ), srangeTab );
2918 addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
2921 void VisuGUI::preferencesChanged( const QString&, const QString& )
2927 ::getViewManager(const QString& theType,
2928 const bool theIsCreate)
2930 return getApp()->getViewManager(theType,theIsCreate);
2933 LightApp_Displayer* VisuGUI::displayer()
2936 myDisplayer = new VisuGUI_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );