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_Prs3dTools.h"
90 #include "VisuGUI_Tools.h"
92 #include "VisuGUI_PopupTools.h"
93 #include "VisuGUI_NameDlg.h"
94 #include "VisuGUI_FileDlg.h"
95 #include "VisuGUI_CursorDlg.h"
96 #include "VisuGUI_Selection.h"
97 #include "VisuGUI_TimeAnimation.h"
98 #include "VisuGUI_EditContainerDlg.h"
99 #include "VisuGUI_NonIsometricDlg.h"
100 #include "VisuGUI_ClippingDlg.h"
101 #include "VisuGUI_Plot3DDlg.h"
102 #include "VisuGUI_CubeAxesDlg.h"
103 #include "VisuGUI_OffsetDlg.h"
105 #include "VISU_ScalarMap_i.hh"
106 #include "VisuGUI_ScalarBarDlg.h"
108 #include "VISU_DeformedShape_i.hh"
109 #include "VisuGUI_DeformedShapeDlg.h"
111 #include "VISU_IsoSurfaces_i.hh"
112 #include "VisuGUI_IsoSurfacesDlg.h"
114 #include "VISU_CutPlanes_i.hh"
115 #include "VisuGUI_CutPlanesDlg.h"
117 #include "VISU_CutLines_i.hh"
118 #include "VisuGUI_CutLinesDlg.h"
120 #include "VISU_StreamLines_i.hh"
121 #include "VisuGUI_StreamLinesDlg.h"
123 #include "VISU_Vectors_i.hh"
124 #include "VisuGUI_VectorsDlg.h"
126 #include "VisuGUI_TableDlg.h"
128 #include "SALOMEconfig.h"
129 #include CORBA_SERVER_HEADER(MED_Gen)
131 #include "utilities.h"
133 #include "VisuGUI_ActionsDef.h"
135 using namespace VISU;
138 static int MYDEBUG = 1;
140 static int MYDEBUG = 0;
143 //////////////////////////////////////////////////
145 //////////////////////////////////////////////////
148 SalomeApp_Module( "VISU" )
162 if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
163 CheckLock(GetCStudy(GetAppStudy(this)));
164 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
167 aFilter.append( tr("FLT_MED_FILES") );
168 aFilter.append( tr("FLT_ALL_FILES") );
170 QFileInfo aFileInfo =
171 SUIT_FileDlg::getFileName(GetDesktop(this),
174 tr("MEN_IMPORT_FROM_FILE"),
176 if(aFileInfo.exists()) {
177 application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
179 VISU::Result_var aResult;
180 bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
181 if (VisuGUI_FileDlg::IsBuild) {
182 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
183 if (!CORBA::is_nil(aResult.in()))
184 if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
185 if (!aRes->IsPossible())
186 SUIT_MessageBox::warn1(GetDesktop(this),
188 tr("ERR_CANT_BUILD_PRESENTATION"),
194 aResourceMgr->setValue("VISU", "full_med_loading", false);
195 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
196 aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
199 if (CORBA::is_nil(aResult.in())) {
200 SUIT_MessageBox::warn1(GetDesktop(this),
202 tr("ERR_ERROR_IN_THE_FILE"),
205 application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
206 UpdateObjBrowser(this);
216 if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
217 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
220 SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
223 aFilter.append( tr("FLT_MED_FILES") );
224 aFilter.append( tr("FLT_ALL_FILES") );
226 QFileInfo aFileInfo =
227 SUIT_FileDlg::getFileName(GetDesktop(this),
230 tr("MEN_EXPLORE_MED_FILE"),
232 if(aFileInfo.exists()){
233 application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
234 std::string aStudyName = aStudy->Name();
237 aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
241 SUIT_MessageBox::warn1(GetDesktop(this),
243 tr("ERR_ERROR_IN_THE_FILE"),
246 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
247 getApp()->updateObjectBrowser(true); // as need to update MED tree
248 getApp()->updateActions();
255 OnImportTableFromFile()
257 if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
258 CheckLock(GetCStudy(GetAppStudy(this)));
261 aFilter.append( tr("FLT_TABLE_FILES") );
262 aFilter.append( tr("FLT_ALL_FILES") );
264 QFileInfo aFileInfo =
265 SUIT_FileDlg::getFileName(GetDesktop(this),
268 tr("MEN_IMPORT_TABLE"),
270 if (aFileInfo.exists()) {
271 application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
273 CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
275 if (CORBA::is_nil(anObject.in())) {
276 SUIT_MessageBox::warn1(GetDesktop(this),
278 tr("ERR_ERROR_IN_THE_FILE"),
281 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
282 UpdateObjBrowser(this);
289 OnExportTableToFile()
291 if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
293 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
295 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
296 SALOME_ListIO aListIO;
297 aSelectionMgr->selectedObjects(aListIO);
299 if (aListIO.Extent() > 0) {
300 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
301 if (anIO->hasEntry()) {
302 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
305 // find table attribute
307 _PTR(GenericAttribute) anAttr;
309 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
311 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
312 // if the current SObject is a table title
313 // we take a father contaning the table
314 aSObj = aSObj->GetFather();
316 if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
319 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
326 // get table title in order to have default name of the file
329 _PTR(AttributeTableOfReal) aTabAttr (anAttr);
330 if (!aTabAttr) return;
331 aTitle = aTabAttr->GetTitle().c_str();
333 _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
334 if (!aTabAttr) return;
335 aTitle = aTabAttr->GetTitle().c_str();
337 aTitle.simplifyWhiteSpace();
338 aTitle = aTitle.replace(QRegExp(" "), "_");
340 // get default path for the file
341 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
342 QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
343 if (aDir.isEmpty()) {
344 aDir = aResourceMgr->stringValue("VISU","InputDir","");
345 if (aDir.isEmpty()) {
346 aDir = getenv("CSF_PATHData");
349 QString aPath = Qtx::addSlash(aDir) + aTitle;
351 // get name for the file
353 aFilter.append("Table Files (*.xls)");
355 QFileInfo aFileInfo =
356 SUIT_FileDlg::getFileName(GetDesktop(this),
359 tr("MEN_EXPORT_TABLE"), // "Export Table To File"
363 QString aFile = aFileInfo.filePath();
364 if (!aFile.isEmpty()) {
365 application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
366 aDir = Qtx::dir(aFile, true);
367 aResourceMgr->setValue("VISU", "OutputDir", aDir);
370 GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
371 application()->putInfo(aFile + " " + tr("INF_DONE"));
372 } catch(std::exception& ex) {
374 SUIT_MessageBox::warn1(GetDesktop(this),
376 tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
379 INFOS(tr("ERR_ERROR_DURING_EXPORT"));
380 SUIT_MessageBox::warn1(GetDesktop(this),
382 tr("ERR_ERROR_DURING_EXPORT"),
394 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
395 if (CheckLock(aCStudy))
397 SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
399 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
400 SALOME_ListIO aListIO;
401 aSelectionMgr->selectedObjects(aListIO);
403 SALOME_ListIteratorOfListIO It (aListIO);
404 QApplication::setOverrideCursor(Qt::waitCursor);
405 for (; It.More(); It.Next()) {
406 Handle(SALOME_InteractiveObject) anIO = It.Value();
407 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
408 if (!aSObject->_is_nil()) {
409 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
410 if (!CORBA::is_nil(anObject)) {
411 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
412 if (!CORBA::is_nil(aMED.in()))
413 GetVisuGen(this)->ImportMed(aSObject);
414 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
415 if (!CORBA::is_nil(aField.in()))
416 GetVisuGen(this)->ImportMedField(aField);
418 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
419 SALOMEDS::GenericAttribute_var anAttr;
420 aSFather->FindAttribute(anAttr, "AttributeName");
421 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
422 CORBA::String_var aValue = aName->Value();
423 if (strcmp(aValue.in(), "MEDFIELD") == 0)
424 GetVisuGen(this)->ImportMed(aSObject);
428 UpdateObjBrowser(this, true);
429 QApplication::restoreOverrideCursor();
433 CreateCurves( SalomeApp_Module* theModule,
434 VISU::CutLines_i* thePrs,
436 const bool theCreate = true )
440 VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
444 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
445 _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
447 if ( !theCreate && aSObject ) {
449 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
450 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
451 for (; aIter->More(); aIter->Next()) {
452 _PTR(SObject) aTblObj = aIter->Value();
454 _PTR(GenericAttribute) anAttr;
455 if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
456 aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
463 if ( aCutDlg->isGenerateTable() ) {
464 GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
465 if ( aCutDlg->isGenerateCurves() ) {
467 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
468 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
469 for (; aIter->More(); aIter->Next()) {
470 _PTR(SObject) aTblObj = aIter->Value();
472 _PTR(GenericAttribute) anAttr;
473 if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
474 CreatePlot( theModule, aTblObj );
482 if (!theCreate && aSObject) {
483 UpdateObjBrowser(theModule);
491 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
492 if (CheckLock(aStudy))
495 // Get selected SObject
496 Handle(SALOME_InteractiveObject) anIO;
497 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
498 if (anIO.IsNull() || !anIO->hasEntry())
501 // create a VTK view window if it does not exist
502 GetViewWindow( this, /*create=*/true );
504 CreateMesh(this, anIO);
511 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
512 if (CheckLock(aStudy))
515 // create a VTK view window if it does not exist
516 GetViewWindow( this, /*create=*/true );
518 // Get selected SObject
519 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
520 SALOME_ListIO aListIO;
521 aSelectionMgr->selectedObjects(aListIO);
522 SALOME_ListIteratorOfListIO anIter (aListIO);
523 for (; anIter.More(); anIter.Next()) {
524 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
525 if (anIO.IsNull() || !anIO->hasEntry())
528 CreateMesh(this, anIO);
536 CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
542 OnCreateDeformedShape()
544 CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
551 CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
556 OnCreateIsoSurfaces()
558 CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
565 CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
572 CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
577 OnCreateStreamLines()
579 CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
586 CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,1>(this);
593 CheckLock(GetCStudy(GetAppStudy(this)));
594 GetVisuGen( this )->CreateContainer();
595 UpdateObjBrowser(this);
602 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
604 SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true );
606 QApplication::setOverrideCursor(Qt::waitCursor);
608 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
609 mgr->selectedObjects(aList);
611 Handle(SALOME_InteractiveObject) anIO;
612 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
614 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
615 if ( !CORBA::is_nil( anObject ) ) {
616 // is it Prs3d object ?
617 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
619 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
620 UpdateViewer( this, aPrsObject );
622 vw->highlight(anIO, 1);
627 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
629 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
630 PlotCurve( this, aCurve, VISU::eDisplay );
634 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
636 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
637 PlotContainer( this, aContainer, VISU::eDisplay );
641 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
643 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
644 PlotTable( this, aTable, VISU::eDisplay );
650 vw->getRenderer()->ResetCameraClippingRange();
653 QApplication::restoreOverrideCursor();
668 if(MYDEBUG) MESSAGE("OnErasePrs");
670 QApplication::setOverrideCursor(Qt::waitCursor);
672 SVTK_ViewWindow* vw = GetViewWindow( this );
674 vw->unHighlightAll();
677 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
678 mgr->selectedObjects(aList);
680 Handle(SALOME_InteractiveObject) anIO;
681 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
683 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
684 ErasePrs( this, anObject, false );
690 QApplication::restoreOverrideCursor();
698 Handle(SALOME_InteractiveObject) anIO;
699 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
700 EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg>(this, aPrs3d);
701 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
702 aViewWindow->highlight(anIO, 1);
710 OnEditDeformedShape()
712 Handle(SALOME_InteractiveObject) anIO;
713 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
714 EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg>(this, aPrs3d);
715 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
716 aViewWindow->highlight(anIO, 1);
726 Handle(SALOME_InteractiveObject) anIO;
727 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
728 EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
729 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
730 aViewWindow->highlight(anIO, 1);
740 Handle(SALOME_InteractiveObject) anIO;
741 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
742 EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
743 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
744 aViewWindow->highlight(anIO, 1);
754 Handle(SALOME_InteractiveObject) anIO;
755 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
756 EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
757 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
758 aViewWindow->highlight(anIO, 1);
768 Handle(SALOME_InteractiveObject) anIO;
769 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
770 EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg>(this, aPrs3d);
771 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
772 aViewWindow->highlight(anIO, 1);
782 Handle(SALOME_InteractiveObject) anIO;
783 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
784 EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg>(this, aPrs3d);
785 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
786 aViewWindow->highlight(anIO, 1);
796 Handle(SALOME_InteractiveObject) anIO;
797 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
798 EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg>(this, aPrs3d);
799 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
800 aViewWindow->highlight(anIO, 1);
810 if (SVTK_ViewWindow* vw = GetViewWindow()) {
811 vw->unHighlightAll();
812 if (vtkRenderer *aRen = vw->getRenderer()) {
814 vtkActorCollection *anActColl = aRen->GetActors();
815 for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
816 if (anActor->GetVisibility() > 0)
817 if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
818 anVISUActor = anVISUActor->GetParent();
819 anVISUActor->VisibilityOff();
824 } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
833 ChangeRepresentation(this, VISU::SURFACEFRAME);
840 ChangeRepresentation(this, VISU::INSIDEFRAME);
847 ChangeRepresentation(this, VISU::WIREFRAME);
854 ChangeRepresentation(this, VISU::SHADED);
861 ChangeRepresentation(this, VISU::POINT);
868 ChangeRepresentation(this, VISU::SHRINK);
875 Handle(SALOME_InteractiveObject) anIO;
876 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
877 if (CORBA::is_nil(anObject)) return;
878 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
879 if (!aServant.in()) return;
881 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
884 SVTK_ViewWindow* vw = GetViewWindow();
887 VISU_Actor* anActor = GetActor(aPrs3d, vw);
888 if (!anActor) return;
890 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
891 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
892 SALOMEDS::Color anOldColor, aNewColor;
893 int aRepresent = anActor->GetRepresentation();
895 switch (aRepresent) {
897 anOldColor = aMesh->GetNodeColor();
899 case VISU::WIREFRAME :
900 case VISU::INSIDEFRAME :
901 anOldColor = aMesh->GetLinkColor();
904 case VISU::SURFACEFRAME :
905 anOldColor = aMesh->GetCellColor();
908 } else if (aDeformedShape) {
909 anOldColor = aDeformedShape->GetColor();
914 QColor aColor (int(255*anOldColor.R),
915 int(255*anOldColor.G),
916 int(255*anOldColor.B));
917 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
918 if (aColorNew.isValid()) {
919 aNewColor.R = aColorNew.red()/255.;
920 aNewColor.G = aColorNew.green()/255.;
921 aNewColor.B = aColorNew.blue()/255.;
923 switch (aRepresent) {
925 aMesh->SetNodeColor(aNewColor);
927 case VISU::WIREFRAME :
928 case VISU::INSIDEFRAME :
929 aMesh->SetLinkColor(aNewColor);
932 case VISU::SURFACEFRAME :
933 aMesh->SetCellColor(aNewColor);
937 aDeformedShape->SetColor(aNewColor);
939 RecreateActor(this, aPrs3d);
945 OnChangeWireframeColor()
947 Handle(SALOME_InteractiveObject) anIO;
948 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
949 if (CORBA::is_nil(anObject)) return;
950 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
951 if (!aServant.in()) return;
953 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
956 SVTK_ViewWindow* vw = GetViewWindow();
959 VISU_Actor* anActor = GetActor(aPrs3d, vw);
960 if (!anActor) return;
962 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
963 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
964 QColor aColor (int(255*anOldColor.R),
965 int(255*anOldColor.G),
966 int(255*anOldColor.B));
967 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
968 if (aColorNew.isValid()) {
969 aNewColor.R = aColorNew.red()/255.;
970 aNewColor.G = aColorNew.green()/255.;
971 aNewColor.B = aColorNew.blue()/255.;
972 aMesh->SetLinkColor(aNewColor);
973 RecreateActor(this, aMesh);
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_OPACITY_TITLE"), TRUE);
1000 CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1001 CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1002 CursorDlg->SpinBox1->setMinValue(0);
1003 CursorDlg->SpinBox1->setMaxValue(100);
1005 float oldopac = anActor->GetOpacity();
1006 int intopac = int(oldopac*100. + 0.5);
1007 CursorDlg->SpinBox1->setValue(intopac);
1009 int ret = CursorDlg->exec();
1011 intopac = CursorDlg->SpinBox1->value();
1012 float newopac = intopac/100.;
1013 anActor->SetOpacity(newopac);
1022 Handle(SALOME_InteractiveObject) anIO;
1023 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1024 if (CORBA::is_nil(anObject)) return;
1025 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1026 if (!aServant.in()) return;
1028 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1029 if (!aPrsObject) return;
1031 SVTK_ViewWindow* vw = GetViewWindow();
1034 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1035 if (!anActor) return;
1037 VisuGUI_CursorDlg* CursorDlg =
1038 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1040 CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1041 CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1042 CursorDlg->SpinBox1->setMinValue(1);
1043 CursorDlg->SpinBox1->setMaxValue(10);
1045 float oldlwid = anActor->GetLineWidth();
1046 int intlwid = int(oldlwid);
1047 CursorDlg->SpinBox1->setValue(intlwid);
1049 int ret = CursorDlg->exec();
1051 intlwid = CursorDlg->SpinBox1->value();
1052 float newlwid = intlwid;
1053 anActor->SetLineWidth(newlwid);
1062 Handle(SALOME_InteractiveObject) anIO;
1063 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1065 if ( !CORBA::is_nil( anObject ) ) {
1066 VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1067 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1068 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1069 if( !CORBA::is_nil( aTable ) ) {
1070 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1072 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1077 // possibly this is Table SObject
1078 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1081 if( !IsSObjectTable( SO ) )
1084 VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1087 //SAL2670 Orientation of show tables
1088 VisuGUI_TableDlg::ttAuto,
1097 Handle(SALOME_InteractiveObject) anIO;
1098 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1099 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1100 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1101 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1102 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1103 GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1104 UpdateObjBrowser(this);
1112 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1113 if (CheckLock(aCStudy))
1116 SALOME_ListIO aList;
1117 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
1118 mgr->selectedObjects(aList);
1119 int i = 0, nbSelected = aList.Extent();
1120 if (nbSelected < 1) return;
1122 const char* entries [nbSelected];
1123 Handle(SALOME_InteractiveObject) anIO;
1124 for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1126 if (anIO->hasEntry())
1127 entries[i++] = anIO->getEntry();
1130 if (nbSelected < 1) return;
1132 // There is a transaction
1133 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1134 aStudyBuilder->NewCommand();
1136 for (i = 0; i < nbSelected; i++) {
1137 _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1139 DeleteSObject(this, aCStudy, aSObject);
1143 // Finish transaction
1144 aStudyBuilder->CommitCommand();
1146 //GetActiveStudy()->unHighlightAll();
1147 UpdateObjBrowser(this, true);
1154 Handle(SALOME_InteractiveObject) anIO;
1155 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1157 _PTR(GenericAttribute) anAttr;
1158 _PTR(AttributeName) aName;
1160 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1162 if ( !CORBA::is_nil( anObject ) ) {
1163 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1164 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1165 // Table (VISU object) is selected
1166 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1167 if( !CORBA::is_nil( aTbl ) ) {
1168 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1170 _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1171 if ( IsSObjectTable(SO) ) {
1172 // get name of SObject
1173 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1175 SOName = QString( aName->Value().c_str() );
1177 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1178 if ( dlg->exec() == QDialog::Accepted ) {
1179 if ( !IsStudyLocked( aStudy ) ) {
1180 // if study is not locked - create new container, create curves and insert them
1181 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1183 QValueList<int> verIndices;
1184 dlg->getCurvesSource( horIndex, verIndices );
1185 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1186 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1187 if( !CORBA::is_nil( aContainer ) ) {
1188 VISU::Container_i* pContainer =
1189 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1191 for ( int i = 0; i < verIndices.count(); i++ ) {
1192 CORBA::Object_var aNewCurve =
1193 GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1194 if( !CORBA::is_nil( aNewCurve ) ) {
1195 VISU::Curve_i* pCrv =
1196 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1199 int marker, line, lineWidth;
1201 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1202 line, lineWidth, color) && !isAuto ) {
1204 c.R = color.red() /255.;
1205 c.G = color.green()/255.;
1206 c.B = color.blue() /255.;
1207 pCrv->SetColor( c );
1208 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1209 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1211 pContainer->AddCurve( pCrv->_this() );
1215 UpdateObjBrowser(this);
1216 PlotContainer( this, pContainer, VISU::eDisplay );
1222 // if study is locked just get curves info and plot them
1223 // if current viewer is of VIEW_PLOT2D type
1224 QPtrList<Plot2d_Curve> container;
1225 dlg->getCurves( container );
1226 if ( !container.isEmpty() ) {
1227 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1228 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1238 else if ( !anIO.IsNull() ) {
1239 // check if Table SObject is selected
1240 SO = aStudy->FindObjectID( anIO->getEntry() );
1241 if ( IsSObjectTable(SO) ) {
1242 // get name of SObject
1243 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1245 SOName = QString( aName->Value().c_str() );
1247 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1248 if ( dlg->exec() == QDialog::Accepted ) {
1249 if ( !IsStudyLocked( aStudy ) ) {
1250 // if study is not locked - create new table and container objects, create curves
1251 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1253 QValueList<int> verIndices;
1254 dlg->getCurvesSource( horIndex, verIndices );
1255 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1256 CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1257 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1258 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1259 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1260 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1262 if ( pContainer && pTable ) {
1263 for ( int i = 0; i < verIndices.count(); i++ ) {
1264 CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1265 ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1266 if( !CORBA::is_nil( aNewCurve ) ) {
1267 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1270 int marker, line, lineWidth;
1272 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1273 line, lineWidth, color) && !isAuto ) {
1275 c.R = color.red()/255.;
1276 c.G = color.green()/255.;
1277 c.B = color.blue()/255.;
1278 pCrv->SetColor( c );
1279 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1280 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1282 pContainer->AddCurve( pCrv->_this() );
1286 UpdateObjBrowser(this);
1287 PlotContainer( this, pContainer, VISU::eDisplay );
1292 // if study is locked just get curves info and plot them
1293 QPtrList<Plot2d_Curve> container;
1294 dlg->getCurves( container );
1295 if ( !container.isEmpty() ) {
1296 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1297 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1310 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1311 SALOME_ListIO aListIO;
1312 aSelectionMgr->selectedObjects(aListIO);
1313 if (aListIO.Extent() != 1) return;
1315 SalomeApp_Study* aAppStudy = GetAppStudy(this);
1316 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1317 CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1318 if (CORBA::is_nil( anObject )) return;
1320 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1321 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1323 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1324 if( !CORBA::is_nil( aCurve ) ) {
1325 VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1326 if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1327 Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1329 aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1330 aDlg.setMarker( (int)aDSCurve->GetMarker() );
1331 SALOMEDS::Color aColor = aDSCurve->GetColor();
1332 aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1333 if( aDlg.exec() == QDialog::Accepted ) {
1334 aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1335 aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1336 SALOMEDS::Color newColor;
1337 newColor.R = aDlg.getColor().red()/255.;
1338 newColor.G = aDlg.getColor().green()/255.;
1339 newColor.B = aDlg.getColor().blue()/255.;
1340 aDSCurve->SetColor( newColor );
1341 PlotCurve(this, aDSCurve, VISU::eDisplay);
1352 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1353 if (CheckLock(aCStudy))
1355 Handle(SALOME_InteractiveObject) anIO;
1356 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1357 if (anIO.IsNull() || CORBA::is_nil(anObject))
1360 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1361 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1363 CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1364 if (!CORBA::is_nil(aCnt)) {
1365 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1366 if (container && container->GetNbCurves() > 0) {
1368 UpdateObjBrowser(this);
1378 Handle(SALOME_InteractiveObject) anIO;
1379 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1380 if (CORBA::is_nil(anObject)) return;
1382 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1383 if (!aServant.in()) return;
1384 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1385 if (!aContainer) return;
1387 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1388 aDlg->initFromPrsObject(aContainer);
1390 aDlg->storeToPrsObject(aContainer);
1391 UpdateObjBrowser(this, true);
1400 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1401 if (CheckLock(aCStudy))
1404 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1405 if (aViewMgr->getType() != SVTK_Viewer::Type())
1408 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1409 SALOME_ListIO aListIO;
1410 aSelectionMgr->selectedObjects(aListIO);
1411 if (aListIO.Extent() > 1)
1414 if (aListIO.Extent() == 0) {
1415 VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1417 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1418 VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1420 UpdateObjBrowser(this);
1425 OnRestoreViewParams()
1427 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1428 if (aViewMgr->getType() != SVTK_Viewer::Type())
1431 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1432 SALOME_ListIO aListIO;
1433 aSelectionMgr->selectedObjects(aListIO);
1434 if (aListIO.Extent() != 1)
1437 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1438 //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1439 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1440 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1441 VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1448 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1449 if (CheckLock(aCStudy))
1452 Handle(SALOME_InteractiveObject) anIO;
1453 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1455 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1458 //TEST DU PARENT == VISU
1459 _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
1460 _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
1462 _PTR(AttributeName) aName (anAttr);
1463 QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1464 if (!Name.isEmpty()) {
1465 QApplication::setOverrideCursor(Qt::waitCursor);
1467 // rename specific objects
1468 if (!CORBA::is_nil(anObject)) {
1469 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1470 if (!CORBA::is_nil(aVisuObj)) {
1471 switch (aVisuObj->GetType()) {
1472 case VISU::TCURVE: // Curve object
1474 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1475 if (!CORBA::is_nil(aCurve)) {
1476 VISU::Curve_i* curve =
1477 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1479 curve->SetName(Name.latin1());
1483 case VISU::TTABLE: // Table object
1485 CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1486 if (!CORBA::is_nil(aTable)) {
1487 VISU::Table_i* table =
1488 dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1490 table->SetName(Name.latin1());
1494 case VISU::TCONTAINER: // Container object
1496 CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1497 if (!CORBA::is_nil(aContainer)) {
1498 VISU::Container_i* container =
1499 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1501 container->SetName(Name.latin1());
1512 // rename the study object
1513 aName->SetValue(Name.latin1()); // rename the SObject
1514 anIO->setName(Name.latin1()); // rename the InteractiveObject
1515 UpdateObjBrowser(this, false);
1517 QApplication::restoreOverrideCursor();
1526 new VisuGUI_ClippingDlg (this, "", false);
1534 Handle(SALOME_InteractiveObject) anIO;
1535 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1536 if (CORBA::is_nil(anObject)) return;
1537 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1538 if (!aServant.in()) return;
1540 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1541 if (!aPrsObject) return;
1543 SVTK_ViewWindow* vw = GetViewWindow();
1546 VISU_Actor* aActor = GetActor(aPrsObject, vw);
1547 if (!aActor) return;
1549 if (!aActor->GetVisibility()) {
1550 aActor->VisibilityOn();
1553 // Get sweep parameters
1554 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1556 double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1557 int aTemp = int(1.E6 * aTempoDbl);
1559 int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1560 int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1563 QApplication::setOverrideCursor(Qt::waitCursor);
1565 for (int j = 0; j < aCycles; j++) {
1566 for (int i = 0; i <= aSteps; i++) {
1567 float aPercents = float(i)/aSteps;
1568 aPrsObject->SetMapScale(aPercents);
1569 aPrsObject->UpdateActor(aActor);
1570 vw->getRenderWindow()->getRenderWindow()->Render();
1574 } catch (std::exception& exc) {
1575 INFOS("Follow exception was occured :\n" << exc.what());
1577 INFOS("Unknown exception was occured!");
1579 QApplication::restoreOverrideCursor();
1586 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1587 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1588 // new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1589 new VisuGUI_TimeAnimationDlg (this, aCStudy);
1591 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1592 SALOME_ListIO aListIO;
1593 aSelectionMgr->selectedObjects(aListIO);
1595 bool isDefined = false;
1597 SALOME_ListIteratorOfListIO It (aListIO);
1598 for (; It.More(); It.Next()) {
1599 _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1600 if (!aSObject) continue;
1601 if (getValue(aSObject, "myComment") == QString("FIELD")) {
1602 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1606 aAnimationDlg->addField(aSObject);
1608 } else if (aNbTimes == aNumber) {
1609 aAnimationDlg->addField(aSObject);
1614 if (isDefined) aAnimationDlg->show();
1615 else delete aAnimationDlg;
1618 //************************************************************************
1623 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1624 SALOME_ListIO aListIO;
1625 aSelectionMgr->selectedObjects(aListIO);
1627 if (aListIO.Extent() != 1)
1630 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1632 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1634 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1637 VISU::Storable::TRestoringMap aMap;
1638 _PTR(GenericAttribute) anAttr;
1639 if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1641 _PTR(AttributeComment) aComment (anAttr);
1642 string aComm = aComment->Value();
1643 QString strIn (aComm.c_str());
1644 VISU::Storable::StrToMap(strIn, aMap);
1646 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1647 if (aType != VISU::TANIMATION) return;
1649 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1650 new VisuGUI_TimeAnimationDlg(this, aCStudy);
1651 aAnimationDlg->restoreFromStudy(aSObj);
1652 aAnimationDlg->show();
1657 OnCopyPresentation()
1659 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1660 if (CheckLock(aCStudy))
1663 Handle(SALOME_InteractiveObject) anIO;
1664 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1665 if (CORBA::is_nil(anObject)) return;
1666 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1667 if (!aServant.in()) return;
1669 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1670 if (!aPrsObject) return;
1672 switch (aPrsObject->GetType()) {
1675 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1676 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1677 aSameMesh->SameAs(aMeshPrs);
1678 UpdateViewer(this, aSameMesh);
1681 case VISU::TSCALARMAP:
1683 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1684 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1685 aSameScalar->SameAs(aScalarPrs);
1686 UpdateViewer(this, aSameScalar);
1689 case VISU::TDEFORMEDSHAPE:
1691 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1692 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1693 aSameDeformed->SameAs(aDefPrs);
1694 UpdateViewer(this, aSameDeformed);
1697 case VISU::TCUTPLANES:
1699 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1700 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1701 aSameCut->SameAs(aCutPrs);
1702 UpdateViewer(this, aSameCut);
1705 case VISU::TCUTLINES:
1707 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1708 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1709 aSameCut->SameAs(aCutPrs);
1710 UpdateViewer(this, aSameCut);
1713 case VISU::TISOSURFACE:
1715 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1716 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1717 aSameIso->SameAs(aIsoPrs);
1718 UpdateViewer(this, aSameIso);
1721 case VISU::TSTREAMLINES:
1723 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1724 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1725 aSameLines->SameAs(aLinesPrs);
1726 UpdateViewer(this, aSameLines);
1729 case VISU::TVECTORS:
1731 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1732 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1733 aSameVectors->SameAs(aVectorsPrs);
1734 UpdateViewer(this, aSameVectors);
1739 VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1740 VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1741 aSamePlot3D->SameAs(aPlot3DPrs);
1742 UpdateViewer(this, aSamePlot3D);
1746 UpdateObjBrowser(this);
1753 if (GetViewWindow())
1754 (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1756 SUIT_MessageBox::warn1(GetDesktop(this),
1758 tr("ERR_ACTIVATE_VIEW3D"),
1766 VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1767 new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1768 false, Qt::WDestructiveClose);
1769 m_NonIsoDlg->show();
1776 //Show dialog that allows to select scale function and corresponding scale factor
1777 VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1785 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1786 SALOME_ListIO aListIO;
1787 aSelectionMgr->selectedObjects(aListIO);
1789 SALOME_ListIteratorOfListIO It (aListIO);
1791 // first find the bounds
1792 double aMin, aMax; bool first = true;
1793 for (; It.More(); It.Next()) {
1794 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1795 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1796 if (!aPrsList.empty()) {
1797 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1798 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1800 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1804 aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1806 if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1807 if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1815 // set the computed range to every selected ScalarMap
1816 bool update = false;
1817 for (It.Initialize(aListIO); It.More(); It.Next() ) {
1818 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1819 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1820 if (!aPrsList.empty()) {
1821 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1822 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1824 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1826 aScalar->SetRange(aMin, aMax);
1827 RecreateActor(this, aScalar);
1835 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1836 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1837 vw->getRenderer()->ResetCameraClippingRange();
1848 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1849 SALOME_ListIO aListIO;
1850 aSelectionMgr->selectedObjects(aListIO);
1852 SALOME_ListIteratorOfListIO It (aListIO);
1854 // restore the source range for every ScalarMap
1855 bool update = false;
1856 for (; It.More(); It.Next()) {
1857 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1858 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1859 if (!aPrsList.empty()) {
1860 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1861 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1863 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1865 aScalar->SetSourceRange();
1866 RecreateActor(this, aScalar);
1874 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1875 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1876 vw->getRenderer()->ResetCameraClippingRange();
1887 if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1888 VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1890 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1892 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1893 SALOME_ListIO aListIO;
1894 aSelectionMgr->selectedObjects(aListIO);
1896 SALOME_ListIteratorOfListIO It (aListIO);
1897 for (; It.More(); It.Next()) {
1898 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1899 if (anIO->hasEntry()) {
1900 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1902 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1903 if (!CORBA::is_nil(aCORBAObject)) {
1904 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1905 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1906 aDlg->addPresentation(aPrsObject);
1912 if (aDlg->getPrsCount() > 0)
1922 SVTK_ViewWindow* vw = GetViewWindow();
1924 ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1933 initialize( CAM_Application* theApp )
1935 SalomeApp_Module::initialize( theApp );
1948 QWidget* aParent = application()->desktop();
1949 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1952 createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
1953 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1954 this, SLOT(OnImportFromFile()));
1956 createAction( VISU_EXPLORE_MED, "", QIconSet(),
1957 tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1958 this, SLOT(OnExploreMEDFile()));
1960 createAction( VISU_IMPORT_TABLE, "", QIconSet(),
1961 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1962 this, SLOT(OnImportTableFromFile()));
1964 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1965 createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
1966 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1967 this, SLOT(OnCreateScalarMap()));
1969 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1970 createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
1971 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1972 this, SLOT(OnCreateDeformedShape()));
1974 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1975 createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
1976 tr("MEN_VECTORS"), "", 0, aParent, false,
1977 this, SLOT(OnCreateVectors()));
1979 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
1980 createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
1981 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
1982 this, SLOT(OnCreateIsoSurfaces()));
1984 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
1985 createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
1986 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
1987 this, SLOT(OnCreateCutPlanes()));
1989 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
1990 createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
1991 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
1992 this, SLOT(OnCreateStreamLines()));
1994 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
1995 createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
1996 tr("MEN_CUT_LINES"), "", 0, aParent, false,
1997 this, SLOT(OnCreateCutLines()));
1999 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2000 createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
2001 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2002 this, SLOT(OnCreatePlot3D()));
2004 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2005 createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
2006 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2007 this, SLOT(OnCreatePlot2dView()));
2009 createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
2010 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
2011 this, SLOT(OnDeleteObjects()));
2013 createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
2014 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2015 this, SLOT(OnShowTable()));
2017 createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
2018 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2019 this, SLOT(OnPlotData()));
2021 createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
2022 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2023 this, SLOT(OnExportTableToFile()));
2025 createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
2026 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2027 this, SLOT(OnImportMedField()));
2029 createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
2030 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2031 this, SLOT(OnImportMedField()));
2033 createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2034 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2035 this, SLOT(OnImportMedField()));
2037 createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
2038 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2039 this, SLOT(OnCreateMesh()));
2041 createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2042 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2043 this, SLOT(OnCreateManyMesh()));
2045 createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2046 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2047 this, SLOT(OnTranslatePrs()));
2049 createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2050 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2051 this, SLOT(OnMergeScalarBars()));
2053 createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2054 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2055 this, SLOT(OnFreeScalarBars()));
2057 createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
2058 tr("MEN_ERASE"), "", 0, aParent, false,
2059 this, SLOT(OnErasePrs()));
2061 createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
2062 tr("MEN_DISPLAY"), "", 0, aParent, false,
2063 this, SLOT(OnDisplayPrs()));
2065 createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
2066 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2067 this, SLOT(OnDisplayOnlyPrs()));
2069 createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
2070 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2071 this, SLOT(OnCopyPresentation()));
2073 createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
2074 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2075 this, SLOT(OnCurveProperties()));
2077 createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2078 this, SLOT(OnRename()));
2080 createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
2081 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2082 this, SLOT(OnEditContainer()));
2084 createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
2085 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2086 this, SLOT(OnClearContainer()));
2088 createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2089 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2090 this, SLOT(OnSaveViewParams()));
2091 createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2092 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2093 this, SLOT(OnSaveViewParams()));
2095 createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2096 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2097 this, SLOT(OnRestoreViewParams()));
2099 //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2100 // tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2101 // this, SLOT(OnDeleteObjects()));
2103 createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2104 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2105 this, SLOT(OnArrangeActors()));
2107 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2108 createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
2109 tr("MEN_POINTS"), "", 0, aParent, false,
2110 this, SLOT(OnMakePoints()));
2112 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2113 createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
2114 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2115 this, SLOT(OnMakeWireframe()));
2117 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2118 createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
2119 tr("MEN_SURFACE"), "", 0, aParent, false,
2120 this, SLOT(OnMakeSurface()));
2122 createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
2123 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2124 this, SLOT(OnMakeInsideframe()));
2126 createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
2127 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2128 this, SLOT(OnMakeSurfaceframe()));
2130 createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
2131 tr("MEN_SHRINK"), "", 0, aParent, false,
2132 this, SLOT(OnMakeShrink()));
2134 createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
2135 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2136 this, SLOT(OnMakeShrink()));
2138 createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
2139 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2140 this, SLOT(OnChangeColor()));
2142 createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
2143 tr("MEN_COLOR"), "", 0, aParent, false,
2144 this, SLOT(OnChangeColor()));
2146 createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
2147 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2148 this, SLOT(OnChangeWireframeColor()));
2150 createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
2151 tr("MEN_OPACITY"), "", 0, aParent, false,
2152 this, SLOT(OnChangeOpacity()));
2154 createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
2155 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2156 this, SLOT(OnChangeLines()));
2159 createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIconSet(),
2160 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2161 this, SLOT(OnEditScalarMap()));
2163 createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(),
2164 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2165 this, SLOT(OnEditDeformedShape()));
2167 createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIconSet(),
2168 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2169 this, SLOT(OnEditCutPlanes()));
2171 createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2172 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2173 this, SLOT(OnEditCutLines()));
2175 createAction( VISU_EDIT_ISOSURFACE, tr("MEN_EDIT_PRS"), QIconSet(),
2176 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2177 this, SLOT(OnEditIsoSurfaces()));
2179 createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIconSet(),
2180 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2181 this, SLOT(OnEditVectors()));
2183 createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2184 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2185 this, SLOT(OnEditStreamLines()));
2187 createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIconSet(),
2188 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2189 this, SLOT(OnEditPlot3D()));
2192 createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
2193 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2194 this, SLOT(OnCreateTable()));
2196 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2197 createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
2198 tr("MEN_SWEEP"), "", 0, aParent, false,
2199 this, SLOT(OnSweep()));
2201 createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2202 tr("MEN_CLIPPING"), "", 0, aParent, false,
2203 this, SLOT(OnClippingPlanes()));
2205 createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2206 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2207 this, SLOT(OnSelectionInfo()));
2209 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2210 createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
2211 tr("MEN_ANIMATION"), "", 0, aParent, false,
2212 this, SLOT(OnTimeAnimation()));
2214 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2215 createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2216 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2217 this, SLOT(OnEraseAll()));
2219 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2220 createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2221 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2222 //this, SLOT(OnEraseAll()));
2225 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2226 createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2227 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2228 //this, SLOT(OnEraseAll()));
2231 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2232 createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2233 tr("MEN_SCALING"), "", 0, aParent, false,
2234 this, SLOT(OnScaling()));
2236 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2237 createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2238 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2239 this, SLOT(OnCubeAxes()));
2241 createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2242 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2243 this, SLOT(OnShowAnimation()));
2250 // Add actions to menus
2252 aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2253 createMenu( separator(), aMenuId, -1, 10 );
2254 createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2255 createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2256 createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2258 aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2259 createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2260 createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2261 createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2262 createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2263 createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2264 createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2265 createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2266 createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2268 aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2269 createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2271 aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2273 createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2274 createMenu( VISU_POINTS, parentId, 10 ); // points
2275 createMenu( VISU_WIREFRAME, parentId, 10 ); // wireframe
2276 createMenu( VISU_SURFACE, parentId, 10 ); // surface
2277 createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2278 createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2279 createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2280 createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2281 createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2288 int aToolId = createTool(tr("TOOL_VISUALISATION"));
2289 createTool( VISU_SCALAR_MAP, aToolId );
2290 createTool( VISU_DEFORMED_SHAPE, aToolId );
2291 createTool( VISU_VECTORS, aToolId );
2292 createTool( VISU_ISO_SURFACES, aToolId );
2293 createTool( VISU_CUT_PLANES, aToolId );
2294 createTool( VISU_CUT_LINES, aToolId );
2295 createTool( VISU_STREAM_LINES, aToolId );
2296 createTool( VISU_PLOT_3D, aToolId );
2298 aToolId = createTool(tr("TOOL_REPRESENTATION"));
2299 createTool( VISU_POINTS, aToolId );
2300 createTool( VISU_WIREFRAME, aToolId );
2301 createTool( VISU_SURFACE, aToolId );
2302 createTool( VISU_ERASE_ALL, aToolId );
2303 createTool( VISU_GLOBAL_SELECTION, aToolId );
2304 createTool( VISU_PARTIAL_SELECTION, aToolId );
2305 createTool( VISU_SCALING, aToolId );
2306 createTool( VISU_CUBE_AXES, aToolId );
2313 // Prepare popup menus
2314 QtxPopupMgr* mgr = popupMgr();
2316 // VISU root commands
2317 mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2318 mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2319 mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2321 //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2324 mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2325 mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2326 mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2327 mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2328 mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2329 mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2330 mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2331 mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2333 mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2334 mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2336 mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2339 mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 );
2340 mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 );
2341 mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 );
2342 mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 );
2343 mgr->insert( action( VISU_EDIT_ISOSURFACE ), -1, -1, -1 );
2344 mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 );
2345 mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 );
2346 mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 );
2347 mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2350 mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2353 mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2356 mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2359 //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2360 //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2361 //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2363 mgr->insert( separator(), -1, -1, -1 );
2365 mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2366 mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2367 mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2369 // "Representation" submenu
2370 int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2371 mgr->insert( action( VISU_POINTS ) , parentId, -1, -1 ); // points
2372 mgr->insert( action( VISU_WIREFRAME ) , parentId, -1, -1 ); // wireframe
2373 mgr->insert( action( VISU_SURFACE ) , parentId, -1, -1 ); // surface
2374 mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2375 mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2376 mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink
2377 mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink
2379 // "Properties" submenu
2380 parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2381 mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2382 mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2383 mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color
2384 mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity
2385 mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2387 mgr->insert( separator(), -1, -1, -1 );
2389 // Other presentations management
2390 mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2391 mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2393 mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2394 mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2396 mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2397 mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2399 mgr->insert( separator(), -1, -1, -1 );
2401 // view parameters commands
2402 mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2403 mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
2404 mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2405 //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2407 mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2409 mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2411 mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2415 QString aSel_One_ObjBr ("client='ObjectBrowser' and selcount=1");
2416 QString aSel_Some_ObjBr ("client='ObjectBrowser' and selcount>0");
2417 QString aSel_Many_ObjBr ("client='ObjectBrowser' and selcount>1");
2419 QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2420 "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2422 QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2424 // VISU root commands
2425 QString aRule = aSel_One_ObjBr + " and type='VISU::TVISUGEN'";
2426 mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2427 mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2428 mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2430 // timestamp commands
2431 aRule = aSel_One_ObjBr + " and type='VISU::TTIMESTAMP'";
2432 mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2433 mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2434 mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2435 mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2436 mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2437 aRule += " and nbComponents>1";
2438 mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2439 mgr->setRule( action( VISU_VECTORS ), aRule, true );
2440 mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2443 //aRule = aSel_One_ObjBr + " and type='VISU::TTABLE'";
2444 //mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
2445 //mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
2446 //mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
2448 aRule = "(" + aSel_Some_ObjBr + " and ((type='VISU::TTABLE' and nbChildren>0) or"
2449 " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))"
2450 ") or (selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "})";
2452 mgr->setRule( action( VISU_ERASE ), aRule + "and (isVisible=true)", true );// TODO: aRule.arg(" and isVisible=1"), true );
2453 mgr->setRule( action( VISU_DISPLAY ), aRule + "and ((isVisible=false and isActiveView=true) or (isActiveView=false))", true );// TODO: aRule.arg(" and isVisible=0"), true );
2454 mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule, true );
2456 aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2457 mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2459 aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2460 mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2461 mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2464 aRule = "selcount=1 and type='VISU::TVIEW3D'";
2465 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2466 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2467 mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2468 //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2470 mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2472 // 3D presentations commands
2473 QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2474 QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2475 QString aSurfType = " and $type in {'VISU::TMESH'}";
2476 QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2477 "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2478 QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2479 "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2481 aRule = "selcount=1";
2482 mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2484 // "Representation" submenu
2485 QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2486 QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2487 QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2488 QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2489 QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2491 mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints, true );
2492 mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr, true );
2493 mgr->setRule( action( VISU_SURFACE ) , aRule + aPrsType + aNotSurfac, true );
2494 mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2495 mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2497 mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true );
2498 mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2500 // "Properties" submenu
2501 mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2502 mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2503 mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2504 " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2505 "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2506 mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2507 mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2510 aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
2511 mgr->setRule( action( VISU_RENAME ), aRule, true );
2513 // copy presentation command
2514 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2515 mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2518 aRule = "selcount=1 and type='VISU::TCURVE'";
2519 mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2521 // curve container commands
2522 aRule = aSel_One_ObjBr + " and type='VISU::TCONTAINER'";
2523 mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2524 mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2526 mgr->setRule( action( VISU_EDIT_SCALARMAP ),
2527 "selcount=1 and type='VISU::TSCALARMAP'", true );
2528 mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
2529 "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
2530 mgr->setRule( action( VISU_EDIT_CUTPLANES ),
2531 "selcount=1 and type='VISU::TCUTPLANES'", true );
2532 mgr->setRule( action( VISU_EDIT_CUTLINES ),
2533 "selcount=1 and type='VISU::TCUTLINES'", true );
2534 mgr->setRule( action( VISU_EDIT_ISOSURFACE ),
2535 "selcount=1 and type='VISU::TISOSURFACE'", true );
2536 mgr->setRule( action( VISU_EDIT_VECTORS ),
2537 "selcount=1 and type='VISU::TVECTORS'", true );
2538 mgr->setRule( action( VISU_EDIT_STREAMLINES ),
2539 "selcount=1 and type='VISU::TSTREAMLINES'", true );
2540 mgr->setRule( action( VISU_EDIT_PLOT3D ),
2541 "selcount=1 and type='VISU::TPLOT3D'", true );
2543 aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2544 mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2546 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2547 mgr->setRule( action( VISU_SWEEP ), aRule, true );
2549 // Selection info popup item
2550 aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2551 mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2553 aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2554 mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2556 aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2557 mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2558 mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2560 //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2561 //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2564 //***************************************************************************
2565 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2567 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2569 OB_Browser* ob = getApp()->objectBrowser();
2570 bool isOBClient = (ob && theClient == ob->popupClientType());
2572 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2573 SALOME_ListIO aListIO;
2574 aSelectionMgr->selectedObjects(aListIO);
2576 if (aListIO.Extent() < 1) return;
2578 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2580 // Check if "Merge Scalar Range" can be applied
2582 SALOME_ListIteratorOfListIO It (aListIO);
2583 for (; It.More(); It.Next()) {
2584 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2586 if (!anIO.IsNull() && anIO->hasEntry()) {
2587 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2588 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2589 if (CORBA::is_nil(aCORBAObject)) {
2590 _PTR(GenericAttribute) anAttr;
2591 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2592 _PTR(AttributeComment) aComment (anAttr);
2593 string aComm = aComment->Value();
2594 QString strIn (aComm.c_str());
2595 VISU::Storable::TRestoringMap pMap;
2596 VISU::Storable::StrToMap(strIn, pMap);
2598 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2599 if (isExist && aType == VISU::TTIMESTAMP) {
2600 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2602 for (; anIter->More(); anIter->Next()) {
2603 aPrs = anIter->Value();
2604 if (!aPrs) continue;
2605 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2606 nbPrs += aSubList.size();
2615 theMenu->insertSeparator();
2616 action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2617 action( VISU_FREE_SCALAR_BARS )->addTo(theMenu);
2620 theMenu->insertSeparator();
2622 // Check if some (nb > 0) removable objects selected
2623 if (isOBClient && IsRemovableSelected(this)) {
2624 action( VISU_DELETE_OBJS )->addTo(theMenu);
2627 // Check single selection
2628 if (aListIO.Extent() != 1) return;
2630 Handle(SALOME_InteractiveObject) anIO;
2631 VISU::Storable::TRestoringMap aMap;
2632 CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2634 _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2636 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2638 if (aType == VISU::TANIMATION) {
2639 action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2641 } else if (isOBClient) {
2642 if (IsSObjectTable(SO)) {
2643 action( VISU_SHOW_TABLE )->addTo(theMenu);
2644 action( VISU_CREATE_CURVES )->addTo(theMenu);
2645 action( VISU_EXPORT_TABLE )->addTo(theMenu);
2646 theMenu->insertSeparator();
2648 if (!CORBA::is_nil(anObject)) {
2649 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2650 if (!CORBA::is_nil(aMED.in())) {
2651 action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2654 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2655 if (!CORBA::is_nil(aField)) {
2656 action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2659 _PTR(SObject) aSFather = SO->GetFather();
2661 _PTR(GenericAttribute) anAttr;
2662 aSFather->FindAttribute(anAttr, "AttributeName");
2664 _PTR(AttributeName) aName (anAttr);
2665 std::string aValue = aName->Value();
2666 if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2667 action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2677 //***************************************************************************
2680 windows( QMap<int, int>& theMap ) const
2683 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2684 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2690 viewManagers( QStringList& theList ) const
2693 theList.append( SVTK_Viewer::Type() );
2701 CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2702 return QString(anIOR.in());
2708 activateModule( SUIT_Study* theStudy )
2710 SalomeApp_Module::activateModule( theStudy );
2712 setMenuShown( true );
2713 setToolShown( true );
2720 deactivateModule( SUIT_Study* theStudy )
2722 setMenuShown( false );
2723 setToolShown( false );
2725 SalomeApp_Module::deactivateModule( theStudy );
2729 SalomeApp_Selection*
2731 createSelection() const
2733 return new VisuGUI_Selection( (SalomeApp_Module*)this );
2736 //******************************************************************
2737 void VisuGUI::studyActivated()
2739 GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2747 return new VisuGUI();
2751 void VisuGUI::createPreferences()
2753 int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2755 int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2756 int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2757 addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2758 int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2759 addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2762 fam.append( tr( "VISU_FONT_ARIAL" ) );
2763 fam.append( tr( "VISU_FONT_COURIER" ) );
2764 fam.append( tr( "VISU_FONT_TIMES" ) );
2765 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2767 setPreferenceProperty( tfont, "families", fam );
2768 setPreferenceProperty( tfont, "system", false );
2769 setPreferenceProperty( tfont, "widget_flags", wflag );
2770 setPreferenceProperty( lfont, "families", fam );
2771 setPreferenceProperty( lfont, "system", false );
2772 setPreferenceProperty( lfont, "widget_flags", wflag );
2774 int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2776 int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2777 setPreferenceProperty( numcol, "min", 2 );
2778 setPreferenceProperty( numcol, "max", 64 );
2780 int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2781 setPreferenceProperty( numlab, "min", 2 );
2782 setPreferenceProperty( numlab, "max", 65 );
2784 int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2785 int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2786 QStringList orients;
2787 orients.append( tr( "VISU_VERTICAL" ) );
2788 orients.append( tr( "VISU_HORIZONTAL" ) );
2789 QValueList<QVariant> indices;
2790 indices.append( 0 );
2791 indices.append( 1 );
2792 setPreferenceProperty( orient, "strings", orients );
2793 setPreferenceProperty( orient, "indexes", indices );
2795 int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2796 int xv = addPreference( tr( "VISU_X" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2797 int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
2798 int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2799 int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2800 setPreferenceProperty( xv, "step", 0.1 );
2801 setPreferenceProperty( yv, "step", 0.1 );
2802 setPreferenceProperty( wv, "step", 0.1 );
2803 setPreferenceProperty( hv, "step", 0.1 );
2804 setPreferenceProperty( xv, "min", 0.0 );
2805 setPreferenceProperty( yv, "min", 0.0 );
2806 setPreferenceProperty( wv, "min", 0.0 );
2807 setPreferenceProperty( hv, "min", 0.0 );
2808 setPreferenceProperty( xv, "max", 1.0 );
2809 setPreferenceProperty( yv, "max", 1.0 );
2810 setPreferenceProperty( wv, "max", 1.0 );
2811 setPreferenceProperty( hv, "max", 1.0 );
2813 int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2814 int xh = addPreference( tr( "VISU_X" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2815 int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2816 int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2817 int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2818 setPreferenceProperty( xh, "step", 0.1 );
2819 setPreferenceProperty( yh, "step", 0.1 );
2820 setPreferenceProperty( wh, "step", 0.1 );
2821 setPreferenceProperty( hh, "step", 0.1 );
2822 setPreferenceProperty( xh, "min", 0.0 );
2823 setPreferenceProperty( yh, "min", 0.0 );
2824 setPreferenceProperty( wh, "min", 0.0 );
2825 setPreferenceProperty( hh, "min", 0.0 );
2826 setPreferenceProperty( xh, "max", 1.0 );
2827 setPreferenceProperty( yh, "max", 1.0 );
2828 setPreferenceProperty( wh, "max", 1.0 );
2829 setPreferenceProperty( hh, "max", 1.0 );
2831 int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2833 int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2834 setPreferenceProperty( rangeGr, "columns", 1 );
2836 int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2838 modes.append( tr( "VISU_MODULUS" ) );
2839 modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2840 modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2841 modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2843 indices.append( 0 );
2844 indices.append( 1 );
2845 indices.append( 2 );
2846 indices.append( 3 );
2847 setPreferenceProperty( mode, "strings", modes );
2848 setPreferenceProperty( mode, "indexes", indices );
2850 addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2852 int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" );
2854 types.append( tr( "VISU_FIELD_RANGE" ) );
2855 types.append( tr( "VISU_IMPOSED_RANGE" ) );
2857 indices.append( 0 );
2858 indices.append( 1 );
2859 setPreferenceProperty( rangetype, "strings", types );
2860 setPreferenceProperty( rangetype, "indexes", indices );
2862 int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2864 int min = addPreference( tr( "VISU_MIN" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2865 int max = addPreference( tr( "VISU_MAX" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2866 setPreferenceProperty( min, "step", 0.1 );
2867 setPreferenceProperty( max, "step", 0.1 );
2869 int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2870 setPreferenceProperty( sweepGr, "columns", 1 );
2872 int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, SalomeApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2873 int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2874 int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2875 setPreferenceProperty( timestep, "min", 0.1 );
2876 setPreferenceProperty( timestep, "step", 0.1 );
2877 setPreferenceProperty( timestep, "max", 1000 );
2878 setPreferenceProperty( nbcycles, "max", 100 );
2879 setPreferenceProperty( nbsteps, "max", 200 );
2881 int importGr = addPreference( tr( "MED files import" ), srangeTab );
2882 addPreference( tr( "Full MED loading" ), importGr, SalomeApp_Preferences::Bool, "VISU", "full_med_loading" );
2885 void VisuGUI::preferencesChanged( const QString&, const QString& )