1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 // Author : Laurent CORNABE
38 #include <qptrvector.h>
39 #include <qcolordialog.h>
42 #include <vtkRenderer.h>
43 #include <vtkRenderWindow.h>
44 #include <vtkActorCollection.h>
47 #include "SALOME_LifeCycleCORBA.hxx"
49 #include "SUIT_ResourceMgr.h"
50 #include "SUIT_MessageBox.h"
52 #include "SUIT_ViewWindow.h"
53 #include "SUIT_ViewManager.h"
55 #include "CAM_Module.h"
57 #include "SVTK_RenderWindow.h"
58 #include "SVTK_ViewWindow.h"
59 #include "SVTK_ViewModel.h"
60 #include "SVTK_Functor.h"
62 #include "SPlot2d_ViewModel.h"
63 #include "SPlot2d_SetupPlot2dDlg.h"
64 #include "Plot2d_SetupCurveDlg.h"
66 #include "OB_Browser.h"
68 #include "SALOME_ListIO.hxx"
69 #include "SALOME_ListIteratorOfListIO.hxx"
71 #include "SalomeApp_Application.h"
72 #include "SalomeApp_DataModel.h"
73 #include "SalomeApp_Study.h"
74 #include "SalomeApp_SelectionMgr.h"
75 #include "SalomeApp_Selection.h"
76 #include "SalomeApp_Preferences.h"
78 #include "VISUConfig.hh"
79 #include "VISU_Gen_i.hh"
80 #include "VISU_Mesh_i.hh"
81 #include "VISU_Table_i.hh"
82 #include "VISU_Result_i.hh"
83 #include "VISU_View_i.hh"
84 #include "VISU_ViewManager_i.hh"
85 #include "VISU_Plot3D_i.hh"
87 #include "VISU_Actor.h"
89 #include "VisuGUI_Tools.h"
90 #include "VisuGUI_PopupTools.h"
91 #include "VisuGUI_NameDlg.h"
92 #include "VisuGUI_FileDlg.h"
93 #include "VisuGUI_CursorDlg.h"
94 #include "VisuGUI_Selection.h"
95 #include "VisuGUI_TimeAnimation.h"
96 #include "VisuGUI_EditContainerDlg.h"
97 #include "VisuGUI_NonIsometricDlg.h"
98 #include "VisuGUI_ClippingDlg.h"
99 #include "VisuGUI_Plot3DDlg.h"
100 #include "VisuGUI_CubeAxesDlg.h"
101 #include "VisuGUI_OffsetDlg.h"
103 #include "VISU_ScalarMap_i.hh"
104 #include "VisuGUI_ScalarBarDlg.h"
106 #include "VISU_DeformedShape_i.hh"
107 #include "VisuGUI_DeformedShapeDlg.h"
109 #include "VISU_IsoSurfaces_i.hh"
110 #include "VisuGUI_IsoSurfacesDlg.h"
112 #include "VISU_CutPlanes_i.hh"
113 #include "VisuGUI_CutPlanesDlg.h"
115 #include "VISU_CutLines_i.hh"
116 #include "VisuGUI_CutLinesDlg.h"
118 #include "VISU_StreamLines_i.hh"
119 #include "VisuGUI_StreamLinesDlg.h"
121 #include "VISU_Vectors_i.hh"
122 #include "VisuGUI_VectorsDlg.h"
124 #include "VisuGUI_TableDlg.h"
126 #include "SALOMEconfig.h"
127 #include CORBA_SERVER_HEADER(MED_Gen)
129 #include "utilities.h"
131 #include "VisuGUI_ActionsDef.h"
133 using namespace VISU;
136 static int MYDEBUG = 1;
138 static int MYDEBUG = 0;
141 //////////////////////////////////////////////////
143 //////////////////////////////////////////////////
146 SalomeApp_Module( "VISU" )
160 if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
161 CheckLock(GetCStudy(GetAppStudy(this)));
162 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
165 aFilter.append( tr("FLT_MED_FILES") );
166 aFilter.append( tr("FLT_ALL_FILES") );
168 QFileInfo aFileInfo =
169 SUIT_FileDlg::getFileName(GetDesktop(this),
172 tr("MEN_IMPORT_FROM_FILE"),
174 if(aFileInfo.exists()) {
175 application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
177 VISU::Result_var aResult;
178 bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
179 if (VisuGUI_FileDlg::IsBuild) {
180 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
181 if (!CORBA::is_nil(aResult.in()))
182 if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
183 if (!aRes->IsPossible())
184 SUIT_MessageBox::warn1(GetDesktop(this),
186 tr("ERR_CANT_BUILD_PRESENTATION"),
192 aResourceMgr->setValue("VISU", "full_med_loading", false);
193 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
194 aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
197 if (CORBA::is_nil(aResult.in())) {
198 SUIT_MessageBox::warn1(GetDesktop(this),
200 tr("ERR_ERROR_IN_THE_FILE"),
203 application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
204 UpdateObjBrowser(this);
214 if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
215 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
218 SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
221 aFilter.append( tr("FLT_MED_FILES") );
222 aFilter.append( tr("FLT_ALL_FILES") );
224 QFileInfo aFileInfo =
225 SUIT_FileDlg::getFileName(GetDesktop(this),
228 tr("MEN_EXPLORE_MED_FILE"),
230 if(aFileInfo.exists()){
231 application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
232 std::string aStudyName = aStudy->Name();
233 aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
234 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
235 getApp()->updateObjectBrowser(true); // as need to update MED tree
236 getApp()->updateActions();
243 OnImportTableFromFile()
245 if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
246 CheckLock(GetCStudy(GetAppStudy(this)));
249 aFilter.append( tr("FLT_TABLE_FILES") );
250 aFilter.append( tr("FLT_ALL_FILES") );
252 QFileInfo aFileInfo =
253 SUIT_FileDlg::getFileName(GetDesktop(this),
256 tr("MEN_IMPORT_TABLE"),
258 if (aFileInfo.exists()) {
259 application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
261 CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
263 if (CORBA::is_nil(anObject.in())) {
264 SUIT_MessageBox::warn1(GetDesktop(this),
266 tr("ERR_ERROR_IN_THE_FILE"),
269 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
270 UpdateObjBrowser(this);
277 OnExportTableToFile()
279 if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
281 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
283 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
284 SALOME_ListIO aListIO;
285 aSelectionMgr->selectedObjects(aListIO);
287 if (aListIO.Extent() > 0) {
288 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
289 if (anIO->hasEntry()) {
290 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
293 // find table attribute
295 _PTR(GenericAttribute) anAttr;
297 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
299 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
300 // if the current SObject is a table title
301 // we take a father contaning the table
302 aSObj = aSObj->GetFather();
304 if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
307 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
314 // get table title in order to have default name of the file
317 _PTR(AttributeTableOfReal) aTabAttr (anAttr);
318 if (!aTabAttr) return;
319 aTitle = aTabAttr->GetTitle().c_str();
321 _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
322 if (!aTabAttr) return;
323 aTitle = aTabAttr->GetTitle().c_str();
325 aTitle.simplifyWhiteSpace();
326 aTitle = aTitle.replace(QRegExp(" "), "_");
328 // get default path for the file
329 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
330 QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
331 if (aDir.isEmpty()) {
332 aDir = aResourceMgr->stringValue("VISU","InputDir","");
333 if (aDir.isEmpty()) {
334 aDir = getenv("CSF_PATHData");
337 QString aPath = Qtx::addSlash(aDir) + aTitle;
339 // get name for the file
341 aFilter.append("Table Files (*.xls)");
343 QFileInfo aFileInfo =
344 SUIT_FileDlg::getFileName(GetDesktop(this),
347 tr("MEN_EXPORT_TABLE"), // "Export Table To File"
351 QString aFile = aFileInfo.filePath();
352 if (!aFile.isEmpty()) {
353 application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
354 aDir = Qtx::dir(aFile, true);
355 aResourceMgr->setValue("VISU", "OutputDir", aDir);
358 GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
359 application()->putInfo(aFile + " " + tr("INF_DONE"));
360 } catch(std::exception& ex) {
362 SUIT_MessageBox::warn1(GetDesktop(this),
364 tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
367 INFOS(tr("ERR_ERROR_DURING_EXPORT"));
368 SUIT_MessageBox::warn1(GetDesktop(this),
370 tr("ERR_ERROR_DURING_EXPORT"),
382 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
383 if (CheckLock(aCStudy))
385 SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
387 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
388 SALOME_ListIO aListIO;
389 aSelectionMgr->selectedObjects(aListIO);
391 SALOME_ListIteratorOfListIO It (aListIO);
392 QApplication::setOverrideCursor(Qt::waitCursor);
393 for (; It.More(); It.Next()) {
394 Handle(SALOME_InteractiveObject) anIO = It.Value();
395 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
396 if (!aSObject->_is_nil()) {
397 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
398 if (!CORBA::is_nil(anObject)) {
399 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
400 if (!CORBA::is_nil(aMED.in()))
401 GetVisuGen(this)->ImportMed(aSObject);
402 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
403 if (!CORBA::is_nil(aField.in()))
404 GetVisuGen(this)->ImportMedField(aField);
406 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
407 SALOMEDS::GenericAttribute_var anAttr;
408 aSFather->FindAttribute(anAttr, "AttributeName");
409 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
410 CORBA::String_var aValue = aName->Value();
411 if (strcmp(aValue.in(), "MEDFIELD") == 0)
412 GetVisuGen(this)->ImportMed(aSObject);
416 UpdateObjBrowser(this, true);
417 QApplication::restoreOverrideCursor();
421 CreateCurves( SalomeApp_Module* theModule,
422 VISU::CutLines_i* thePrs,
424 const bool theCreate = true )
428 VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
432 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
433 _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
435 if ( !theCreate && aSObject ) {
437 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
438 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
439 for (; aIter->More(); aIter->Next()) {
440 _PTR(SObject) aTblObj = aIter->Value();
442 _PTR(GenericAttribute) anAttr;
443 if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
444 aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
451 if ( aCutDlg->isGenerateTable() ) {
452 GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
453 if ( aCutDlg->isGenerateCurves() ) {
455 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
456 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
457 for (; aIter->More(); aIter->Next()) {
458 _PTR(SObject) aTblObj = aIter->Value();
460 _PTR(GenericAttribute) anAttr;
461 if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
462 CreatePlot( theModule, aTblObj );
470 if (!theCreate && aSObject) {
471 UpdateObjBrowser(theModule);
475 template<class TPrs3d_i>
477 CreatePrs3d(SalomeApp_Module* theModule,
478 _PTR(SObject) theTimeStamp,
479 const char* theMeshName,
480 VISU::Entity theEntity,
481 const char* theFieldName,
484 VISU::Result_var aResult;
485 if (CheckResult(theModule,theTimeStamp,aResult)){
486 QApplication::setOverrideCursor(Qt::waitCursor);
487 typedef typename TPrs3d_i::TInterface TPrs3d;
488 typename TPrs3d::_var_type aPrs3d =
489 GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
490 (aResult,theMeshName,theEntity,theFieldName,theTimeId);
491 QApplication::restoreOverrideCursor();
492 if (!CORBA::is_nil(aPrs3d.in()))
493 return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
495 SUIT_MessageBox::warn1(GetDesktop(theModule),
496 QObject::tr("WRN_VISU"),
497 QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
498 QObject::tr("BUT_OK") );
503 template<class TPrs3d_i, class TDlg, int IsDlgModal>
505 CreatePrs3d(SalomeApp_Module* theModule,
506 _PTR(SObject) theTimeStamp,
507 const Handle(SALOME_InteractiveObject)& theIO)
509 using namespace VISU;
510 Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
512 QString aType = Storable::FindValue(aMap,"myType",&isExist);
513 if(!isExist || aType.toInt() != TTIMESTAMP )
515 QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
516 QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
517 QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
518 QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
519 QApplication::setOverrideCursor(Qt::waitCursor);
521 CreatePrs3d<TPrs3d_i>(theModule,
524 (Entity)anEntity.toInt(),
526 aTimeStampId.toInt());
527 QApplication::restoreOverrideCursor();
529 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
530 int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
532 if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
533 aDlg->initFromPrsObject(aPrs3d);
535 if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
536 // Optionally, create table and curves for cut lines
537 QApplication::setOverrideCursor(Qt::waitCursor);
538 CreateCurves( theModule,
539 dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
541 true ); // in creation mode
542 QApplication::restoreOverrideCursor();
545 DeletePrs3d(theModule,aPrs3d,theIO);
555 PublishInView(theModule,aPrs3d);
562 template<class TPrs3d_i, class TDlg, int IsDlgModal>
564 CreatePrs3d(SalomeApp_Module* theModule)
566 if (CheckLock(GetCStudy(GetAppStudy(theModule))))
569 _PTR(SObject) aTimeStampSObj;
570 Handle(SALOME_InteractiveObject) anIO;
571 if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
574 if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
577 theModule->application()->putInfo(QObject::tr("INF_DONE"));
578 theModule->updateObjBrowser();
579 UpdateObjBrowser(theModule);
581 if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
589 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
590 if (CheckLock(aStudy))
593 // Get selected SObject
594 Handle(SALOME_InteractiveObject) anIO;
595 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
596 if (anIO.IsNull() || !anIO->hasEntry())
599 // create a VTK view window if it does not exist
600 GetViewWindow( this, /*create=*/true );
602 CreateMesh(this, anIO);
609 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
610 if (CheckLock(aStudy))
613 // create a VTK view window if it does not exist
614 GetViewWindow( this, /*create=*/true );
616 // Get selected SObject
617 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
618 SALOME_ListIO aListIO;
619 aSelectionMgr->selectedObjects(aListIO);
620 SALOME_ListIteratorOfListIO anIter (aListIO);
621 for (; anIter.More(); anIter.Next()) {
622 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
623 if (anIO.IsNull() || !anIO->hasEntry())
626 CreateMesh(this, anIO);
634 CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
640 OnCreateDeformedShape()
642 CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
649 CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
654 OnCreateIsoSurfaces()
656 CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
663 CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
670 CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
675 OnCreateStreamLines()
677 CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
684 CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,1>(this);
691 CheckLock(GetCStudy(GetAppStudy(this)));
692 GetVisuGen( this )->CreateContainer();
693 UpdateObjBrowser(this);
700 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
702 SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true );
704 QApplication::setOverrideCursor(Qt::waitCursor);
706 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
707 mgr->selectedObjects(aList);
709 Handle(SALOME_InteractiveObject) anIO;
710 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
712 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
713 if ( !CORBA::is_nil( anObject ) ) {
714 // is it Prs3d object ?
715 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
717 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
718 UpdateViewer( this, aPrsObject );
720 vw->highlight(anIO, 1);
725 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
727 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
728 PlotCurve( this, aCurve, VISU::eDisplay );
732 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
734 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
735 PlotContainer( this, aContainer, VISU::eDisplay );
739 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
741 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
742 PlotTable( this, aTable, VISU::eDisplay );
748 vw->getRenderer()->ResetCameraClippingRange();
751 QApplication::restoreOverrideCursor();
766 if(MYDEBUG) MESSAGE("OnErasePrs");
768 QApplication::setOverrideCursor(Qt::waitCursor);
770 SVTK_ViewWindow* vw = GetViewWindow( this );
772 vw->unHighlightAll();
775 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
776 mgr->selectedObjects(aList);
778 Handle(SALOME_InteractiveObject) anIO;
779 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
781 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
782 ErasePrs( this, anObject, false );
788 QApplication::restoreOverrideCursor();
791 template<class TPrs3d_i, class TDlg>
793 EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
795 TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
797 TDlg* aDlg = new TDlg (theModule);
798 aDlg->initFromPrsObject(aPrsObject);
800 if (!(aDlg->storeToPrsObject(aPrsObject))) {
804 RecreateActor(theModule, aPrsObject);
805 if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
806 vw->getRenderer()->ResetCameraClippingRange();
809 // Optionally, create table and curves for cut lines
810 QApplication::setOverrideCursor(Qt::waitCursor);
811 CreateCurves( theModule,
812 dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
814 false ); // in edition mode
815 QApplication::restoreOverrideCursor();
825 if (CheckLock(GetCStudy(GetAppStudy(this))))
828 Handle(SALOME_InteractiveObject) anIO;
829 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
830 if (CORBA::is_nil(anObject)) return;
831 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
832 if (!aServant.in()) return;
834 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
837 switch (aPrs3d->GetType()) {
840 case VISU::TSCALARMAP:
841 EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg>(this, aPrs3d);
843 case VISU::TDEFORMEDSHAPE:
844 EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg>(this, aPrs3d);
846 case VISU::TCUTPLANES:
847 EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
849 case VISU::TCUTLINES:
850 EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
852 case VISU::TISOSURFACE:
853 EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
856 EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg>(this, aPrs3d);
858 case VISU::TSTREAMLINES:
859 EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg>(this, aPrs3d);
862 EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg>(this, aPrs3d);
868 if (SVTK_ViewWindow* vw = GetViewWindow())
869 vw->highlight(anIO, 1);
876 if (SVTK_ViewWindow* vw = GetViewWindow()) {
877 vw->unHighlightAll();
878 if (vtkRenderer *aRen = vw->getRenderer()) {
880 vtkActorCollection *anActColl = aRen->GetActors();
881 for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
882 if (anActor->GetVisibility() > 0)
883 if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
884 anVISUActor = anVISUActor->GetParent();
885 anVISUActor->VisibilityOff();
890 } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
899 ChangeRepresentation(this, VISU::SURFACEFRAME);
906 ChangeRepresentation(this, VISU::INSIDEFRAME);
913 ChangeRepresentation(this, VISU::WIREFRAME);
920 ChangeRepresentation(this, VISU::SHADED);
927 ChangeRepresentation(this, VISU::POINT);
934 ChangeRepresentation(this, VISU::SHRINK);
941 Handle(SALOME_InteractiveObject) anIO;
942 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
943 if (CORBA::is_nil(anObject)) return;
944 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
945 if (!aServant.in()) return;
947 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
950 SVTK_ViewWindow* vw = GetViewWindow();
953 VISU_Actor* anActor = GetActor(aPrs3d, vw);
954 if (!anActor) return;
956 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
957 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
958 SALOMEDS::Color anOldColor, aNewColor;
959 int aRepresent = anActor->GetRepresentation();
961 switch (aRepresent) {
963 anOldColor = aMesh->GetNodeColor();
965 case VISU::WIREFRAME :
966 case VISU::INSIDEFRAME :
967 anOldColor = aMesh->GetLinkColor();
970 case VISU::SURFACEFRAME :
971 anOldColor = aMesh->GetCellColor();
974 } else if (aDeformedShape) {
975 anOldColor = aDeformedShape->GetColor();
980 QColor aColor (int(255*anOldColor.R),
981 int(255*anOldColor.G),
982 int(255*anOldColor.B));
983 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
984 if (aColorNew.isValid()) {
985 aNewColor.R = aColorNew.red()/255.;
986 aNewColor.G = aColorNew.green()/255.;
987 aNewColor.B = aColorNew.blue()/255.;
989 switch (aRepresent) {
991 aMesh->SetNodeColor(aNewColor);
993 case VISU::WIREFRAME :
994 case VISU::INSIDEFRAME :
995 aMesh->SetLinkColor(aNewColor);
998 case VISU::SURFACEFRAME :
999 aMesh->SetCellColor(aNewColor);
1003 aDeformedShape->SetColor(aNewColor);
1005 RecreateActor(this, aPrs3d);
1011 OnChangeWireframeColor()
1013 Handle(SALOME_InteractiveObject) anIO;
1014 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1015 if (CORBA::is_nil(anObject)) return;
1016 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1017 if (!aServant.in()) return;
1019 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1020 if (!aPrs3d) return;
1022 SVTK_ViewWindow* vw = GetViewWindow();
1025 VISU_Actor* anActor = GetActor(aPrs3d, vw);
1026 if (!anActor) return;
1028 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
1029 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
1030 QColor aColor (int(255*anOldColor.R),
1031 int(255*anOldColor.G),
1032 int(255*anOldColor.B));
1033 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
1034 if (aColorNew.isValid()) {
1035 aNewColor.R = aColorNew.red()/255.;
1036 aNewColor.G = aColorNew.green()/255.;
1037 aNewColor.B = aColorNew.blue()/255.;
1038 aMesh->SetLinkColor(aNewColor);
1039 RecreateActor(this, aMesh);
1048 Handle(SALOME_InteractiveObject) anIO;
1049 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1050 if (CORBA::is_nil(anObject)) return;
1051 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1052 if (!aServant.in()) return;
1054 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1055 if (!aPrsObject) return;
1057 SVTK_ViewWindow* vw = GetViewWindow();
1060 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1061 if (!anActor) return;
1063 VisuGUI_CursorDlg* CursorDlg =
1064 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
1066 CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1067 CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1068 CursorDlg->SpinBox1->setMinValue(0);
1069 CursorDlg->SpinBox1->setMaxValue(100);
1071 float oldopac = anActor->GetOpacity();
1072 int intopac = int(oldopac*100. + 0.5);
1073 CursorDlg->SpinBox1->setValue(intopac);
1075 int ret = CursorDlg->exec();
1077 intopac = CursorDlg->SpinBox1->value();
1078 float newopac = intopac/100.;
1079 anActor->SetOpacity(newopac);
1088 Handle(SALOME_InteractiveObject) anIO;
1089 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1090 if (CORBA::is_nil(anObject)) return;
1091 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1092 if (!aServant.in()) return;
1094 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1095 if (!aPrsObject) return;
1097 SVTK_ViewWindow* vw = GetViewWindow();
1100 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1101 if (!anActor) return;
1103 VisuGUI_CursorDlg* CursorDlg =
1104 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1106 CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1107 CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1108 CursorDlg->SpinBox1->setMinValue(1);
1109 CursorDlg->SpinBox1->setMaxValue(10);
1111 float oldlwid = anActor->GetLineWidth();
1112 int intlwid = int(oldlwid);
1113 CursorDlg->SpinBox1->setValue(intlwid);
1115 int ret = CursorDlg->exec();
1117 intlwid = CursorDlg->SpinBox1->value();
1118 float newlwid = intlwid;
1119 anActor->SetLineWidth(newlwid);
1128 Handle(SALOME_InteractiveObject) anIO;
1129 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1131 if ( !CORBA::is_nil( anObject ) ) {
1132 VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1133 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1134 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1135 if( !CORBA::is_nil( aTable ) ) {
1136 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1138 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1143 // possibly this is Table SObject
1144 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1147 if( !IsSObjectTable( SO ) )
1150 VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1153 //SAL2670 Orientation of show tables
1154 VisuGUI_TableDlg::ttAuto,
1163 Handle(SALOME_InteractiveObject) anIO;
1164 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1165 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1166 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1167 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1168 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1169 GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1170 UpdateObjBrowser(this);
1178 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1179 if (CheckLock(aCStudy))
1182 SALOME_ListIO aList;
1183 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
1184 mgr->selectedObjects(aList);
1185 int i = 0, nbSelected = aList.Extent();
1186 if (nbSelected < 1) return;
1188 const char* entries [nbSelected];
1189 Handle(SALOME_InteractiveObject) anIO;
1190 for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1192 if (anIO->hasEntry())
1193 entries[i++] = anIO->getEntry();
1196 if (nbSelected < 1) return;
1198 // There is a transaction
1199 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1200 aStudyBuilder->NewCommand();
1202 for (i = 0; i < nbSelected; i++) {
1203 _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1205 DeleteSObject(this, aCStudy, aSObject);
1209 // Finish transaction
1210 aStudyBuilder->CommitCommand();
1212 //GetActiveStudy()->unHighlightAll();
1213 UpdateObjBrowser(this, true);
1220 Handle(SALOME_InteractiveObject) anIO;
1221 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1223 _PTR(GenericAttribute) anAttr;
1224 _PTR(AttributeName) aName;
1226 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1228 if ( !CORBA::is_nil( anObject ) ) {
1229 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1230 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1231 // Table (VISU object) is selected
1232 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1233 if( !CORBA::is_nil( aTbl ) ) {
1234 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1236 _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1237 if ( IsSObjectTable(SO) ) {
1238 // get name of SObject
1239 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1241 SOName = QString( aName->Value().c_str() );
1243 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1244 if ( dlg->exec() == QDialog::Accepted ) {
1245 if ( !IsStudyLocked( aStudy ) ) {
1246 // if study is not locked - create new container, create curves and insert them
1247 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1249 QValueList<int> verIndices;
1250 dlg->getCurvesSource( horIndex, verIndices );
1251 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1252 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1253 if( !CORBA::is_nil( aContainer ) ) {
1254 VISU::Container_i* pContainer =
1255 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1257 for ( int i = 0; i < verIndices.count(); i++ ) {
1258 CORBA::Object_var aNewCurve =
1259 GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1260 if( !CORBA::is_nil( aNewCurve ) ) {
1261 VISU::Curve_i* pCrv =
1262 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1265 int marker, line, lineWidth;
1267 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1268 line, lineWidth, color) && !isAuto ) {
1270 c.R = color.red() /255.;
1271 c.G = color.green()/255.;
1272 c.B = color.blue() /255.;
1273 pCrv->SetColor( c );
1274 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1275 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1277 pContainer->AddCurve( pCrv->_this() );
1281 UpdateObjBrowser(this);
1282 PlotContainer( this, pContainer, VISU::eDisplay );
1288 // if study is locked just get curves info and plot them
1289 // if current viewer is of VIEW_PLOT2D type
1290 QPtrList<Plot2d_Curve> container;
1291 dlg->getCurves( container );
1292 if ( !container.isEmpty() ) {
1293 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1294 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1304 else if ( !anIO.IsNull() ) {
1305 // check if Table SObject is selected
1306 SO = aStudy->FindObjectID( anIO->getEntry() );
1307 if ( IsSObjectTable(SO) ) {
1308 // get name of SObject
1309 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1311 SOName = QString( aName->Value().c_str() );
1313 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1314 if ( dlg->exec() == QDialog::Accepted ) {
1315 if ( !IsStudyLocked( aStudy ) ) {
1316 // if study is not locked - create new table and container objects, create curves
1317 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1319 QValueList<int> verIndices;
1320 dlg->getCurvesSource( horIndex, verIndices );
1321 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1322 CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1323 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1324 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1325 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1326 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1328 if ( pContainer && pTable ) {
1329 for ( int i = 0; i < verIndices.count(); i++ ) {
1330 CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1331 ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1332 if( !CORBA::is_nil( aNewCurve ) ) {
1333 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1336 int marker, line, lineWidth;
1338 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1339 line, lineWidth, color) && !isAuto ) {
1341 c.R = color.red()/255.;
1342 c.G = color.green()/255.;
1343 c.B = color.blue()/255.;
1344 pCrv->SetColor( c );
1345 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1346 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1348 pContainer->AddCurve( pCrv->_this() );
1352 UpdateObjBrowser(this);
1353 PlotContainer( this, pContainer, VISU::eDisplay );
1358 // if study is locked just get curves info and plot them
1359 QPtrList<Plot2d_Curve> container;
1360 dlg->getCurves( container );
1361 if ( !container.isEmpty() ) {
1362 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1363 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1376 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1377 SALOME_ListIO aListIO;
1378 aSelectionMgr->selectedObjects(aListIO);
1379 if (aListIO.Extent() != 1) return;
1381 SalomeApp_Study* aAppStudy = GetAppStudy(this);
1382 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1383 CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1384 if (CORBA::is_nil( anObject )) return;
1386 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1387 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1389 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1390 if( !CORBA::is_nil( aCurve ) ) {
1391 VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1392 if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1393 Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1395 aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1396 aDlg.setMarker( (int)aDSCurve->GetMarker() );
1397 SALOMEDS::Color aColor = aDSCurve->GetColor();
1398 aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1399 if( aDlg.exec() == QDialog::Accepted ) {
1400 aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1401 aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1402 SALOMEDS::Color newColor;
1403 newColor.R = aDlg.getColor().red()/255.;
1404 newColor.G = aDlg.getColor().green()/255.;
1405 newColor.B = aDlg.getColor().blue()/255.;
1406 aDSCurve->SetColor( newColor );
1407 PlotCurve(this, aDSCurve, VISU::eDisplay);
1418 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1419 if (CheckLock(aCStudy))
1421 Handle(SALOME_InteractiveObject) anIO;
1422 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1423 if (anIO.IsNull() || CORBA::is_nil(anObject))
1426 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1427 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1429 CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1430 if (!CORBA::is_nil(aCnt)) {
1431 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1432 if (container && container->GetNbCurves() > 0) {
1434 UpdateObjBrowser(this);
1444 Handle(SALOME_InteractiveObject) anIO;
1445 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1446 if (CORBA::is_nil(anObject)) return;
1448 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1449 if (!aServant.in()) return;
1450 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1451 if (!aContainer) return;
1453 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1454 aDlg->initFromPrsObject(aContainer);
1456 aDlg->storeToPrsObject(aContainer);
1457 UpdateObjBrowser(this, true);
1466 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1467 if (CheckLock(aCStudy))
1470 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1471 if (aViewMgr->getType() != SVTK_Viewer::Type())
1474 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1475 SALOME_ListIO aListIO;
1476 aSelectionMgr->selectedObjects(aListIO);
1477 if (aListIO.Extent() > 1)
1480 if (aListIO.Extent() == 0) {
1481 VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1483 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1484 VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1486 UpdateObjBrowser(this);
1491 OnRestoreViewParams()
1493 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1494 if (aViewMgr->getType() != SVTK_Viewer::Type())
1497 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1498 SALOME_ListIO aListIO;
1499 aSelectionMgr->selectedObjects(aListIO);
1500 if (aListIO.Extent() != 1)
1503 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1504 //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1505 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1506 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1507 VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1514 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1515 if (CheckLock(aCStudy))
1518 Handle(SALOME_InteractiveObject) anIO;
1519 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1521 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1524 //TEST DU PARENT == VISU
1525 _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
1526 _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
1528 _PTR(AttributeName) aName (anAttr);
1529 QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1530 if (!Name.isEmpty()) {
1531 QApplication::setOverrideCursor(Qt::waitCursor);
1533 // rename specific objects
1534 if (!CORBA::is_nil(anObject)) {
1535 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1536 if (!CORBA::is_nil(aVisuObj)) {
1537 switch (aVisuObj->GetType()) {
1538 case VISU::TCURVE: // Curve object
1540 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1541 if (!CORBA::is_nil(aCurve)) {
1542 VISU::Curve_i* curve =
1543 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1545 curve->SetName(Name.latin1());
1549 case VISU::TTABLE: // Table object
1551 CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1552 if (!CORBA::is_nil(aTable)) {
1553 VISU::Table_i* table =
1554 dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1556 table->SetName(Name.latin1());
1560 case VISU::TCONTAINER: // Container object
1562 CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1563 if (!CORBA::is_nil(aContainer)) {
1564 VISU::Container_i* container =
1565 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1567 container->SetName(Name.latin1());
1578 // rename the study object
1579 aName->SetValue(Name.latin1()); // rename the SObject
1580 anIO->setName(Name.latin1()); // rename the InteractiveObject
1581 UpdateObjBrowser(this, false);
1583 QApplication::restoreOverrideCursor();
1592 new VisuGUI_ClippingDlg (this, "", false);
1600 Handle(SALOME_InteractiveObject) anIO;
1601 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1602 if (CORBA::is_nil(anObject)) return;
1603 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1604 if (!aServant.in()) return;
1606 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1607 if (!aPrsObject) return;
1609 SVTK_ViewWindow* vw = GetViewWindow();
1612 VISU_Actor* aActor = GetActor(aPrsObject, vw);
1613 if (!aActor) return;
1615 if (!aActor->GetVisibility()) {
1616 aActor->VisibilityOn();
1619 // Get sweep parameters
1620 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1622 double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1623 int aTemp = int(1.E6 * aTempoDbl);
1625 int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1626 int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1629 QApplication::setOverrideCursor(Qt::waitCursor);
1631 for (int j = 0; j < aCycles; j++) {
1632 for (int i = 0; i <= aSteps; i++) {
1633 float aPercents = float(i)/aSteps;
1634 aPrsObject->SetMapScale(aPercents);
1635 aPrsObject->UpdateActor(aActor);
1636 vw->getRenderWindow()->getRenderWindow()->Render();
1640 } catch (std::exception& exc) {
1641 INFOS("Follow exception was occured :\n" << exc.what());
1643 INFOS("Unknown exception was occured!");
1645 QApplication::restoreOverrideCursor();
1652 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1653 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1654 // new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1655 new VisuGUI_TimeAnimationDlg (this, aCStudy);
1657 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1658 SALOME_ListIO aListIO;
1659 aSelectionMgr->selectedObjects(aListIO);
1661 bool isDefined = false;
1663 SALOME_ListIteratorOfListIO It (aListIO);
1664 for (; It.More(); It.Next()) {
1665 _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1666 if (!aSObject) continue;
1667 if (getValue(aSObject, "myComment") == QString("FIELD")) {
1668 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1672 aAnimationDlg->addField(aSObject);
1674 } else if (aNbTimes == aNumber) {
1675 aAnimationDlg->addField(aSObject);
1680 if (isDefined) aAnimationDlg->show();
1681 else delete aAnimationDlg;
1684 //************************************************************************
1689 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1690 SALOME_ListIO aListIO;
1691 aSelectionMgr->selectedObjects(aListIO);
1693 if (aListIO.Extent() != 1)
1696 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1698 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1700 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1703 VISU::Storable::TRestoringMap aMap;
1704 _PTR(GenericAttribute) anAttr;
1705 if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1707 _PTR(AttributeComment) aComment (anAttr);
1708 string aComm = aComment->Value();
1709 QString strIn (aComm.c_str());
1710 VISU::Storable::StrToMap(strIn, aMap);
1712 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1713 if (aType != VISU::TANIMATION) return;
1715 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1716 new VisuGUI_TimeAnimationDlg(this, aCStudy);
1717 aAnimationDlg->restoreFromStudy(aSObj);
1718 aAnimationDlg->show();
1723 OnCopyPresentation()
1725 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1726 if (CheckLock(aCStudy))
1729 Handle(SALOME_InteractiveObject) anIO;
1730 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1731 if (CORBA::is_nil(anObject)) return;
1732 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1733 if (!aServant.in()) return;
1735 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1736 if (!aPrsObject) return;
1738 switch (aPrsObject->GetType()) {
1741 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1742 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1743 aSameMesh->SameAs(aMeshPrs);
1744 UpdateViewer(this, aSameMesh);
1747 case VISU::TSCALARMAP:
1749 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1750 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1751 aSameScalar->SameAs(aScalarPrs);
1752 UpdateViewer(this, aSameScalar);
1755 case VISU::TDEFORMEDSHAPE:
1757 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1758 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1759 aSameDeformed->SameAs(aDefPrs);
1760 UpdateViewer(this, aSameDeformed);
1763 case VISU::TCUTPLANES:
1765 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1766 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1767 aSameCut->SameAs(aCutPrs);
1768 UpdateViewer(this, aSameCut);
1771 case VISU::TCUTLINES:
1773 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1774 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1775 aSameCut->SameAs(aCutPrs);
1776 UpdateViewer(this, aSameCut);
1779 case VISU::TISOSURFACE:
1781 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1782 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1783 aSameIso->SameAs(aIsoPrs);
1784 UpdateViewer(this, aSameIso);
1787 case VISU::TSTREAMLINES:
1789 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1790 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1791 aSameLines->SameAs(aLinesPrs);
1792 UpdateViewer(this, aSameLines);
1795 case VISU::TVECTORS:
1797 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1798 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1799 aSameVectors->SameAs(aVectorsPrs);
1800 UpdateViewer(this, aSameVectors);
1805 VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1806 VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1807 aSamePlot3D->SameAs(aPlot3DPrs);
1808 UpdateViewer(this, aSamePlot3D);
1812 UpdateObjBrowser(this);
1819 if (GetViewWindow())
1820 (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1822 SUIT_MessageBox::warn1(GetDesktop(this),
1824 tr("ERR_ACTIVATE_VIEW3D"),
1832 VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1833 new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1834 false, Qt::WDestructiveClose);
1835 m_NonIsoDlg->show();
1842 //Show dialog that allows to select scale function and corresponding scale factor
1843 VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1851 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1852 SALOME_ListIO aListIO;
1853 aSelectionMgr->selectedObjects(aListIO);
1855 SALOME_ListIteratorOfListIO It (aListIO);
1857 // first find the bounds
1858 double aMin, aMax; bool first = true;
1859 for (; It.More(); It.Next()) {
1860 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1861 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1862 if (!aPrsList.empty()) {
1863 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1864 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1866 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1870 aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1872 if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1873 if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1881 // set the computed range to every selected ScalarMap
1882 bool update = false;
1883 for (It.Initialize(aListIO); It.More(); It.Next() ) {
1884 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1885 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1886 if (!aPrsList.empty()) {
1887 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1888 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1890 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1892 aScalar->SetRange(aMin, aMax);
1893 RecreateActor(this, aScalar);
1901 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1902 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1903 vw->getRenderer()->ResetCameraClippingRange();
1914 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1915 SALOME_ListIO aListIO;
1916 aSelectionMgr->selectedObjects(aListIO);
1918 SALOME_ListIteratorOfListIO It (aListIO);
1920 // restore the source range for every ScalarMap
1921 bool update = false;
1922 for (; It.More(); It.Next()) {
1923 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1924 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1925 if (!aPrsList.empty()) {
1926 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1927 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1929 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1931 aScalar->SetSourceRange();
1932 RecreateActor(this, aScalar);
1940 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1941 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1942 vw->getRenderer()->ResetCameraClippingRange();
1953 if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1954 VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1956 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1958 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1959 SALOME_ListIO aListIO;
1960 aSelectionMgr->selectedObjects(aListIO);
1962 SALOME_ListIteratorOfListIO It (aListIO);
1963 for (; It.More(); It.Next()) {
1964 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1965 if (anIO->hasEntry()) {
1966 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1968 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1969 if (!CORBA::is_nil(aCORBAObject)) {
1970 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1971 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1972 aDlg->addPresentation(aPrsObject);
1978 if (aDlg->getPrsCount() > 0)
1988 SVTK_ViewWindow* vw = GetViewWindow();
1990 ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1999 initialize( CAM_Application* theApp )
2001 SalomeApp_Module::initialize( theApp );
2014 QWidget* aParent = application()->desktop();
2015 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
2018 createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
2019 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
2020 this, SLOT(OnImportFromFile()));
2022 createAction( VISU_EXPLORE_MED, "", QIconSet(),
2023 tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
2024 this, SLOT(OnExploreMEDFile()));
2026 createAction( VISU_IMPORT_TABLE, "", QIconSet(),
2027 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
2028 this, SLOT(OnImportTableFromFile()));
2030 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
2031 createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
2032 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
2033 this, SLOT(OnCreateScalarMap()));
2035 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
2036 createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
2037 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
2038 this, SLOT(OnCreateDeformedShape()));
2040 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
2041 createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
2042 tr("MEN_VECTORS"), "", 0, aParent, false,
2043 this, SLOT(OnCreateVectors()));
2045 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
2046 createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
2047 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
2048 this, SLOT(OnCreateIsoSurfaces()));
2050 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
2051 createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
2052 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
2053 this, SLOT(OnCreateCutPlanes()));
2055 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
2056 createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
2057 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
2058 this, SLOT(OnCreateStreamLines()));
2060 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
2061 createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
2062 tr("MEN_CUT_LINES"), "", 0, aParent, false,
2063 this, SLOT(OnCreateCutLines()));
2065 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2066 createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
2067 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2068 this, SLOT(OnCreatePlot3D()));
2070 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2071 createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
2072 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2073 this, SLOT(OnCreatePlot2dView()));
2075 createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
2076 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
2077 this, SLOT(OnDeleteObjects()));
2079 createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
2080 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2081 this, SLOT(OnShowTable()));
2083 createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
2084 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2085 this, SLOT(OnPlotData()));
2087 createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
2088 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2089 this, SLOT(OnExportTableToFile()));
2091 createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
2092 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2093 this, SLOT(OnImportMedField()));
2095 createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
2096 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2097 this, SLOT(OnImportMedField()));
2099 createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2100 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2101 this, SLOT(OnImportMedField()));
2103 createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
2104 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2105 this, SLOT(OnCreateMesh()));
2107 createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2108 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2109 this, SLOT(OnCreateManyMesh()));
2111 createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2112 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2113 this, SLOT(OnTranslatePrs()));
2115 createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2116 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2117 this, SLOT(OnMergeScalarBars()));
2119 createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2120 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2121 this, SLOT(OnFreeScalarBars()));
2123 createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
2124 tr("MEN_ERASE"), "", 0, aParent, false,
2125 this, SLOT(OnErasePrs()));
2127 createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
2128 tr("MEN_DISPLAY"), "", 0, aParent, false,
2129 this, SLOT(OnDisplayPrs()));
2131 createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
2132 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2133 this, SLOT(OnDisplayOnlyPrs()));
2135 createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
2136 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2137 this, SLOT(OnCopyPresentation()));
2139 createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
2140 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2141 this, SLOT(OnCurveProperties()));
2143 createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2144 this, SLOT(OnRename()));
2146 createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
2147 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2148 this, SLOT(OnEditContainer()));
2150 createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
2151 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2152 this, SLOT(OnClearContainer()));
2154 createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2155 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2156 this, SLOT(OnSaveViewParams()));
2157 createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2158 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2159 this, SLOT(OnSaveViewParams()));
2161 createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2162 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2163 this, SLOT(OnRestoreViewParams()));
2165 //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2166 // tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2167 // this, SLOT(OnDeleteObjects()));
2169 createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2170 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2171 this, SLOT(OnArrangeActors()));
2173 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2174 createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
2175 tr("MEN_POINTS"), "", 0, aParent, false,
2176 this, SLOT(OnMakePoints()));
2178 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2179 createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
2180 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2181 this, SLOT(OnMakeWireframe()));
2183 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2184 createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
2185 tr("MEN_SURFACE"), "", 0, aParent, false,
2186 this, SLOT(OnMakeSurface()));
2188 createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
2189 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2190 this, SLOT(OnMakeInsideframe()));
2192 createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
2193 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2194 this, SLOT(OnMakeSurfaceframe()));
2196 createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
2197 tr("MEN_SHRINK"), "", 0, aParent, false,
2198 this, SLOT(OnMakeShrink()));
2200 createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
2201 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2202 this, SLOT(OnMakeShrink()));
2204 createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
2205 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2206 this, SLOT(OnChangeColor()));
2208 createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
2209 tr("MEN_COLOR"), "", 0, aParent, false,
2210 this, SLOT(OnChangeColor()));
2212 createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
2213 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2214 this, SLOT(OnChangeWireframeColor()));
2216 createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
2217 tr("MEN_OPACITY"), "", 0, aParent, false,
2218 this, SLOT(OnChangeOpacity()));
2220 createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
2221 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2222 this, SLOT(OnChangeLines()));
2224 createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(),
2225 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2226 this, SLOT(OnEditPrs()));
2228 createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
2229 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2230 this, SLOT(OnCreateTable()));
2232 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2233 createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
2234 tr("MEN_SWEEP"), "", 0, aParent, false,
2235 this, SLOT(OnSweep()));
2237 createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2238 tr("MEN_CLIPPING"), "", 0, aParent, false,
2239 this, SLOT(OnClippingPlanes()));
2241 createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2242 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2243 this, SLOT(OnSelectionInfo()));
2245 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2246 createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
2247 tr("MEN_ANIMATION"), "", 0, aParent, false,
2248 this, SLOT(OnTimeAnimation()));
2250 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2251 createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2252 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2253 this, SLOT(OnEraseAll()));
2255 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2256 createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2257 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2258 //this, SLOT(OnEraseAll()));
2261 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2262 createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2263 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2264 //this, SLOT(OnEraseAll()));
2267 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2268 createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2269 tr("MEN_SCALING"), "", 0, aParent, false,
2270 this, SLOT(OnScaling()));
2272 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2273 createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2274 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2275 this, SLOT(OnCubeAxes()));
2277 createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2278 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2279 this, SLOT(OnShowAnimation()));
2286 // Add actions to menus
2288 aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2289 createMenu( separator(), aMenuId, -1, 10 );
2290 createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2291 createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2292 createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2294 aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2295 createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2296 createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2297 createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2298 createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2299 createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2300 createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2301 createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2302 createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2304 aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2305 createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2307 aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2309 createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2310 createMenu( VISU_POINTS, parentId, 10 ); // points
2311 createMenu( VISU_WIREFRAME, parentId, 10 ); // wireframe
2312 createMenu( VISU_SURFACE, parentId, 10 ); // surface
2313 createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2314 createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2315 createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2316 createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2317 createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2324 int aToolId = createTool(tr("TOOL_VISUALISATION"));
2325 createTool( VISU_SCALAR_MAP, aToolId );
2326 createTool( VISU_DEFORMED_SHAPE, aToolId );
2327 createTool( VISU_VECTORS, aToolId );
2328 createTool( VISU_ISO_SURFACES, aToolId );
2329 createTool( VISU_CUT_PLANES, aToolId );
2330 createTool( VISU_CUT_LINES, aToolId );
2331 createTool( VISU_STREAM_LINES, aToolId );
2332 createTool( VISU_PLOT_3D, aToolId );
2334 aToolId = createTool(tr("TOOL_REPRESENTATION"));
2335 createTool( VISU_POINTS, aToolId );
2336 createTool( VISU_WIREFRAME, aToolId );
2337 createTool( VISU_SURFACE, aToolId );
2338 createTool( VISU_ERASE_ALL, aToolId );
2339 createTool( VISU_GLOBAL_SELECTION, aToolId );
2340 createTool( VISU_PARTIAL_SELECTION, aToolId );
2341 createTool( VISU_SCALING, aToolId );
2342 createTool( VISU_CUBE_AXES, aToolId );
2349 // Prepare popup menus
2350 QtxPopupMgr* mgr = popupMgr();
2352 // VISU root commands
2353 mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2354 mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2355 mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2357 //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2360 mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2361 mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2362 mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2363 mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2364 mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2365 mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2366 mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2367 mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2369 mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2370 mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2372 mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2375 mgr->insert( action( VISU_EDIT_PRS ), -1, -1, -1 );
2376 mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2379 mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2382 mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2385 mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2388 //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2389 //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2390 //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2392 mgr->insert( separator(), -1, -1, -1 );
2394 mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2395 mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2396 mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2398 // "Representation" submenu
2399 int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2400 mgr->insert( action( VISU_POINTS ) , parentId, -1, -1 ); // points
2401 mgr->insert( action( VISU_WIREFRAME ) , parentId, -1, -1 ); // wireframe
2402 mgr->insert( action( VISU_SURFACE ) , parentId, -1, -1 ); // surface
2403 mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2404 mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2405 mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink
2406 mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink
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 aSel_One_ObjBr ("client='ObjectBrowser' and selcount=1");
2445 QString aSel_Some_ObjBr ("client='ObjectBrowser' and selcount>0");
2446 QString aSel_Many_ObjBr ("client='ObjectBrowser' and selcount>1");
2448 QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2449 "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2451 QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2453 // VISU root commands
2454 QString aRule = aSel_One_ObjBr + " and type='VISU::TVISUGEN'";
2455 mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2456 mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2457 mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2459 // timestamp commands
2460 aRule = aSel_One_ObjBr + " and type='VISU::TTIMESTAMP'";
2461 mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2462 mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2463 mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2464 mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2465 mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2466 aRule += " and nbComponents>1";
2467 mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2468 mgr->setRule( action( VISU_VECTORS ), aRule, true );
2469 mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2472 //aRule = aSel_One_ObjBr + " and type='VISU::TTABLE'";
2473 //mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
2474 //mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
2475 //mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
2477 aRule = "(" + aSel_Some_ObjBr + " and ((type='VISU::TTABLE' and nbChildren>0) or"
2478 " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))"
2479 ") or (selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "})";
2481 mgr->setRule( action( VISU_ERASE ), aRule + "and (isVisible=true)", true );// TODO: aRule.arg(" and isVisible=1"), true );
2482 mgr->setRule( action( VISU_DISPLAY ), aRule + "and ((isVisible=false and isActiveView=true) or (isActiveView=false))", true );// TODO: aRule.arg(" and isVisible=0"), true );
2483 mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule, true );
2485 aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2486 mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2488 aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2489 mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2490 mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2493 aRule = "selcount=1 and type='VISU::TVIEW3D'";
2494 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2495 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2496 mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2497 //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2499 mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2501 // 3D presentations commands
2502 QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2503 QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2504 QString aSurfType = " and $type in {'VISU::TMESH'}";
2505 QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2506 "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2507 QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2508 "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2510 aRule = "selcount=1";
2511 mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2513 // "Representation" submenu
2514 QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2515 QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2516 QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2517 QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2518 QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2520 mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints, true );
2521 mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr, true );
2522 mgr->setRule( action( VISU_SURFACE ) , aRule + aPrsType + aNotSurfac, true );
2523 mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2524 mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2526 mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true );
2527 mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2529 // "Properties" submenu
2530 mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2531 mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2532 mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2533 " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2534 "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2535 mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2536 mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2539 aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
2540 mgr->setRule( action( VISU_RENAME ), aRule, true );
2542 // copy presentation command
2543 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2544 mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2547 aRule = "selcount=1 and type='VISU::TCURVE'";
2548 mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2550 // curve container commands
2551 aRule = aSel_One_ObjBr + " and type='VISU::TCONTAINER'";
2552 mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2553 mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2555 aRule = "selcount=1 and $type in {" + aPrsAll + "}";
2556 mgr->setRule( action( VISU_EDIT_PRS ), aRule, true );
2558 aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2559 mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2561 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2562 mgr->setRule( action( VISU_SWEEP ), aRule, true );
2564 // Selection info popup item
2565 aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2566 mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2568 aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2569 mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2571 aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2572 mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2573 mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2575 //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2576 //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2579 //***************************************************************************
2580 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2582 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2584 OB_Browser* ob = getApp()->objectBrowser();
2585 bool isOBClient = (ob && theClient == ob->popupClientType());
2587 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2588 SALOME_ListIO aListIO;
2589 aSelectionMgr->selectedObjects(aListIO);
2591 if (aListIO.Extent() < 1) return;
2593 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2595 // Check if "Merge Scalar Range" can be applied
2597 SALOME_ListIteratorOfListIO It (aListIO);
2598 for (; It.More(); It.Next()) {
2599 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2601 if (!anIO.IsNull() && anIO->hasEntry()) {
2602 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2603 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2604 if (CORBA::is_nil(aCORBAObject)) {
2605 _PTR(GenericAttribute) anAttr;
2606 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2607 _PTR(AttributeComment) aComment (anAttr);
2608 string aComm = aComment->Value();
2609 QString strIn (aComm.c_str());
2610 VISU::Storable::TRestoringMap pMap;
2611 VISU::Storable::StrToMap(strIn, pMap);
2613 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2614 if (isExist && aType == VISU::TTIMESTAMP) {
2615 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2617 for (; anIter->More(); anIter->Next()) {
2618 aPrs = anIter->Value();
2619 if (!aPrs) continue;
2620 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2621 nbPrs += aSubList.size();
2630 theMenu->insertSeparator();
2631 action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2632 action( VISU_FREE_SCALAR_BARS )->addTo(theMenu);
2635 theMenu->insertSeparator();
2637 // Check if some (nb > 0) removable objects selected
2638 if (isOBClient && IsRemovableSelected(this)) {
2639 action( VISU_DELETE_OBJS )->addTo(theMenu);
2642 // Check single selection
2643 if (aListIO.Extent() != 1) return;
2645 Handle(SALOME_InteractiveObject) anIO;
2646 VISU::Storable::TRestoringMap aMap;
2647 CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2649 _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2651 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2653 if (aType == VISU::TANIMATION) {
2654 action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2656 } else if (isOBClient) {
2657 if (IsSObjectTable(SO)) {
2658 action( VISU_SHOW_TABLE )->addTo(theMenu);
2659 action( VISU_CREATE_CURVES )->addTo(theMenu);
2660 action( VISU_EXPORT_TABLE )->addTo(theMenu);
2661 theMenu->insertSeparator();
2663 if (!CORBA::is_nil(anObject)) {
2664 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2665 if (!CORBA::is_nil(aMED.in())) {
2666 action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2669 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2670 if (!CORBA::is_nil(aField)) {
2671 action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2674 _PTR(SObject) aSFather = SO->GetFather();
2676 _PTR(GenericAttribute) anAttr;
2677 aSFather->FindAttribute(anAttr, "AttributeName");
2679 _PTR(AttributeName) aName (anAttr);
2680 std::string aValue = aName->Value();
2681 if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2682 action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2692 //***************************************************************************
2695 windows( QMap<int, int>& theMap ) const
2698 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2699 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2705 viewManagers( QStringList& theList ) const
2708 theList.append( SVTK_Viewer::Type() );
2716 CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2717 return QString(anIOR.in());
2723 activateModule( SUIT_Study* theStudy )
2725 SalomeApp_Module::activateModule( theStudy );
2727 setMenuShown( true );
2728 setToolShown( true );
2735 deactivateModule( SUIT_Study* theStudy )
2737 setMenuShown( false );
2738 setToolShown( false );
2740 SalomeApp_Module::deactivateModule( theStudy );
2744 SalomeApp_Selection*
2746 createSelection() const
2748 return new VisuGUI_Selection( (SalomeApp_Module*)this );
2751 //******************************************************************
2752 void VisuGUI::studyActivated()
2754 GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2762 return new VisuGUI();
2766 void VisuGUI::createPreferences()
2768 int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2770 int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2771 int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2772 addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2773 int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2774 addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2777 fam.append( tr( "VISU_FONT_ARIAL" ) );
2778 fam.append( tr( "VISU_FONT_COURIER" ) );
2779 fam.append( tr( "VISU_FONT_TIMES" ) );
2780 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2782 setPreferenceProperty( tfont, "families", fam );
2783 setPreferenceProperty( tfont, "system", false );
2784 setPreferenceProperty( tfont, "widget_flags", wflag );
2785 setPreferenceProperty( lfont, "families", fam );
2786 setPreferenceProperty( lfont, "system", false );
2787 setPreferenceProperty( lfont, "widget_flags", wflag );
2789 int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2791 int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2792 setPreferenceProperty( numcol, "min", 2 );
2793 setPreferenceProperty( numcol, "max", 64 );
2795 int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2796 setPreferenceProperty( numlab, "min", 2 );
2797 setPreferenceProperty( numlab, "max", 65 );
2799 int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2800 int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2801 QStringList orients;
2802 orients.append( tr( "VISU_VERTICAL" ) );
2803 orients.append( tr( "VISU_HORIZONTAL" ) );
2804 QValueList<QVariant> indices;
2805 indices.append( 0 );
2806 indices.append( 1 );
2807 setPreferenceProperty( orient, "strings", orients );
2808 setPreferenceProperty( orient, "indexes", indices );
2810 int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2811 int xv = addPreference( tr( "VISU_X" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2812 int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
2813 int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2814 int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2815 setPreferenceProperty( xv, "step", 0.1 );
2816 setPreferenceProperty( yv, "step", 0.1 );
2817 setPreferenceProperty( wv, "step", 0.1 );
2818 setPreferenceProperty( hv, "step", 0.1 );
2819 setPreferenceProperty( xv, "min", 0.0 );
2820 setPreferenceProperty( yv, "min", 0.0 );
2821 setPreferenceProperty( wv, "min", 0.0 );
2822 setPreferenceProperty( hv, "min", 0.0 );
2823 setPreferenceProperty( xv, "max", 1.0 );
2824 setPreferenceProperty( yv, "max", 1.0 );
2825 setPreferenceProperty( wv, "max", 1.0 );
2826 setPreferenceProperty( hv, "max", 1.0 );
2828 int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2829 int xh = addPreference( tr( "VISU_X" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2830 int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2831 int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2832 int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2833 setPreferenceProperty( xh, "step", 0.1 );
2834 setPreferenceProperty( yh, "step", 0.1 );
2835 setPreferenceProperty( wh, "step", 0.1 );
2836 setPreferenceProperty( hh, "step", 0.1 );
2837 setPreferenceProperty( xh, "min", 0.0 );
2838 setPreferenceProperty( yh, "min", 0.0 );
2839 setPreferenceProperty( wh, "min", 0.0 );
2840 setPreferenceProperty( hh, "min", 0.0 );
2841 setPreferenceProperty( xh, "max", 1.0 );
2842 setPreferenceProperty( yh, "max", 1.0 );
2843 setPreferenceProperty( wh, "max", 1.0 );
2844 setPreferenceProperty( hh, "max", 1.0 );
2846 int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2848 int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2849 setPreferenceProperty( rangeGr, "columns", 1 );
2851 int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2853 modes.append( tr( "VISU_MODULUS" ) );
2854 modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2855 modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2856 modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2858 indices.append( 0 );
2859 indices.append( 1 );
2860 indices.append( 2 );
2861 indices.append( 3 );
2862 setPreferenceProperty( mode, "strings", modes );
2863 setPreferenceProperty( mode, "indexes", indices );
2865 addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2867 int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" );
2869 types.append( tr( "VISU_FIELD_RANGE" ) );
2870 types.append( tr( "VISU_IMPOSED_RANGE" ) );
2872 indices.append( 0 );
2873 indices.append( 1 );
2874 setPreferenceProperty( rangetype, "strings", types );
2875 setPreferenceProperty( rangetype, "indexes", indices );
2877 int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2879 int min = addPreference( tr( "VISU_MIN" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2880 int max = addPreference( tr( "VISU_MAX" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2881 setPreferenceProperty( min, "step", 0.1 );
2882 setPreferenceProperty( max, "step", 0.1 );
2884 int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2885 setPreferenceProperty( sweepGr, "columns", 1 );
2887 int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, SalomeApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2888 int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2889 int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2890 setPreferenceProperty( timestep, "min", 0.1 );
2891 setPreferenceProperty( timestep, "step", 0.1 );
2892 setPreferenceProperty( timestep, "max", 1000 );
2893 setPreferenceProperty( nbcycles, "max", 100 );
2894 setPreferenceProperty( nbsteps, "max", 200 );
2896 int importGr = addPreference( tr( "MED files import" ), srangeTab );
2897 addPreference( tr( "Full MED loading" ), importGr, SalomeApp_Preferences::Bool, "VISU", "full_med_loading" );
2900 void VisuGUI::preferencesChanged( const QString&, const QString& )