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
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_PrsObject_i.hh"
34 #include "VISU_ViewManager_i.hh"
36 #include "VISU_PipeLine.hxx"
38 #include "VISU_Prs3d_i.hh"
39 #include "VISU_Mesh_i.hh"
40 #include "VISU_ScalarMap_i.hh"
41 #include "VISU_IsoSurfaces_i.hh"
42 #include "VISU_DeformedShape_i.hh"
43 #include "VISU_CutPlanes_i.hh"
44 #include "VISU_CutLines_i.hh"
45 #include "VISU_Vectors_i.hh"
46 #include "VISU_StreamLines_i.hh"
47 #include "VISU_Table_i.hh"
49 #include "VISU_Actor.h"
50 #include "VISU_MeshAct.h"
52 #include "VisuGUI_MagnitudeDlg.h"
53 #include "VisuGUI_CursorDlg.h"
54 #include "VisuGUI_ScalarBarDlg.h"
55 #include "VisuGUI_SweepPrefDlg.h"
56 #include "VisuGUI_CutPlanesDlg.h"
57 #include "VisuGUI_CutLinesDlg.h"
58 #include "VisuGUI_VectorsDlg.h"
59 #include "VisuGUI_IsoSurfacesDlg.h"
60 #include "VisuGUI_StreamLinesDlg.h"
61 #include "VisuGUI_EditContainerDlg.h"
62 #include "VisuGUI_TimeAnimation.h"
64 #include "VisuGUI_Selection.h"
65 #include "VisuGUI_NonIsometricDlg.h"
67 #include "SALOMEGUI_ImportOperation.h"
68 #include "SALOMEGUI_QtCatchCorbaException.hxx"
69 #include "utilities.h"
71 #include "QAD_Config.h"
73 #include "QAD_Settings.h"
74 #include "QAD_Tools.h"
75 #include "QAD_LeftFrame.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_ObjectBrowser.h"
79 #include "QAD_ObjectBrowserItem.h"
80 #include "QAD_Menus.h"
81 #include "QAD_Resource.h"
82 #include "QAD_ResourceMgr.h"
83 #include "QAD_FileDlg.h"
84 #include "QAD_WaitCursor.h"
85 #include "SALOME_Selection.h"
86 #include "SALOMEGUI_NameDlg.h"
87 #include "SALOMEGUI_TableDlg.h"
88 #include "SALOMEGUI_SetupCurveDlg.h"
89 #include "SALOMEGUI_SetValueDlg.h"
90 #include "SALOMEGUI_Desktop.h"
91 #include "Plot2d_SetupPlot2dDlg.h"
92 #include "Plot2d_ViewFrame.h"
93 #include "VTKViewer_ViewFrame.h"
94 #include "VTKViewer_RenderWindow.h"
95 #include "VTKViewer_InteractorStyleSALOME.h"
96 #include "VTKViewer_RenderWindowInteractor.h"
97 #include "VisuGUI_FileDlg.h"
100 #define INCLUDE_MENUITEM_DEF
101 #include <qpopupmenu.h>
103 #include <qpainter.h>
105 #include <qapplication.h>
106 #include <qinputdialog.h>
107 #include <qcolordialog.h>
109 #include <qspinbox.h>
110 #include <qradiobutton.h>
112 #include <qlistbox.h>
113 #include <qcombobox.h>
116 //VRV: porting on Qt 3.0.5
117 #if QT_VERSION >= 0x030005
118 #include <qlistview.h>
120 //VRV: porting on Qt 3.0.5
121 #include <qmessagebox.h>
123 #include CORBA_CLIENT_HEADER(MED_Gen)
125 #include <vtkActor.h>
126 #include <vtkRenderer.h>
127 #include <vtkDataSetMapper.h>
128 #include <vtkActorCollection.h>
130 // Open CASCADE Include
131 #include <TCollection_AsciiString.hxx>
135 static int MYCHECKTIME = 1;
137 static int MYCHECKTIME = 0;
139 #include <Utils_Timer.hxx>
144 static int MYDEBUG = 0;
146 static int MYDEBUG = 0;
149 class CustomItem : public QCustomMenuItem
152 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
155 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
158 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
159 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
160 p->setFont( myFont );
161 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
167 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
170 bool fullSpan() const
180 inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
181 if(!theSObject->_is_nil()) {
182 SALOMEDS::GenericAttribute_var anAttr;
183 if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
185 if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
192 static VisuGUI MYVISUGUI;
193 VisuGUI *visuGUI = &MYVISUGUI;
195 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
196 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
197 return VISU::VISU_Gen_i::GetVisuGenImpl();
200 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
201 const char* theActorClassName = "VISU_Actor")
203 vtkRenderer *aRen = theViewFrame->getRenderer();
204 vtkActorCollection *anActColl = aRen->GetActors();
207 int nothingVisible=1;
209 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
210 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
211 // loop through all props
212 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
213 // if it's invisible, or has no geometry, we can skip the rest
214 if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
215 bounds = prop->GetBounds();
216 // make sure we haven't got bogus bounds
217 if ( bounds != NULL &&
218 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
219 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
220 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
223 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
224 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
225 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
226 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
227 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
228 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
232 return nothingVisible;
235 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
236 static float PRECISION = 0.000001;
237 static float DEVIATION = 600;
239 if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
241 float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
243 float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
245 float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
247 CameraOrient aCameraOrient = e3D;
248 if(absX <= PRECISION) aCameraOrient = eFront;
249 else {if(absY <= PRECISION) aCameraOrient = eLeft;
250 else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
252 float dev_abs_XY = absX / absY;
253 float dev_abs_YZ = absY / absZ;
254 float dev_abs_XZ = absX / absZ;
255 if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
256 else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
257 else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
259 switch(aCameraOrient){
260 case eFront: theViewFrame->onViewFront(); break;
261 case eLeft: theViewFrame->onViewLeft(); break;
262 case eTop: theViewFrame->onViewTop(); break;
263 case e3D: theViewFrame->onViewReset(); break;
265 theViewFrame->getRenderer()->ResetCameraClippingRange();
266 theViewFrame->onViewFitAll();
267 return aCameraOrient;
270 QAD_Desktop* VisuGUI::GetDesktop(){
271 return QAD_Application::getDesktop() ;
274 QAD_Study* VisuGUI::GetActiveStudy(){
275 return GetDesktop()->getActiveStudy() ;
278 vtkRenderer* VisuGUI::GetRenderer(){
279 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
280 return aViewFrame->getRenderer();
284 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
285 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
286 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
289 static void UpdateViewFrame() {
290 QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
292 for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
293 if (aStudyFrame->getTypeView() == VIEW_VTK) {
294 QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
295 VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
296 if (!aVtkViewFrame) continue;
297 VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
299 anInteractor->SetSelectionProp();
300 anInteractor->SetSelectionTolerance();
301 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
303 aStyle->setPreselectionProp();
310 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
311 return GetActiveStudy()->getStudyDocument();
314 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
315 return GetStudyDocument()->NewBuilder();
320 * Finds value by given key
323 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
324 VISU::Storable::TRestoringMap aMap;
325 if(!theSObject->_is_nil()){
326 SALOMEDS::GenericAttribute_var anAttr;
327 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
328 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
329 CORBA::String_var aString = aComment->Value();
330 QString strIn(aString.in());
331 VISU::Storable::StrToMap(strIn,aMap);
337 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
339 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
341 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
346 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
347 VISU::Storable::TRestoringMap* pMap = NULL)
349 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
350 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
351 if(aSel->IObjectCount() > 0){
352 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
353 if(pIO != NULL) *pIO = anIO;
354 if(anIO->hasEntry()){
355 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
356 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
357 if(!aSObject->_is_nil()){
358 SALOMEDS::GenericAttribute_var anAttr;
359 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
360 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
361 string aComm = aComment->Value();
362 QString strIn(aComm.c_str());
363 VISU::Storable::StrToMap(strIn,*pMap);
365 return VISU::SObjectToObject(aSObject);
369 return CORBA::Object::_nil();
373 int IsTrihedronDisplayed(){
374 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
375 return aVTKViewFrame->isTrihedronDisplayed();
380 void RepaintCurrentView(){
381 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
385 VisuGUI::VisuGUI( const QString& theName, QObject* theParent ):
386 SALOMEGUI( theName, theParent )
391 /* ==================================================================================== */
392 /* ==================================================================================== */
394 /* ==================================================================================== */
395 /* ==================================================================================== */
397 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
398 return theStudy->GetProperties()->IsLocked();
401 static int checkLock(const SALOMEDS::Study_var& theStudy) {
402 if (isStudyLocked(theStudy)) {
403 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
404 QObject::tr("WRN_WARNING"),
405 QObject::tr("WRN_STUDY_LOCKED"),
406 QObject::tr("BUT_OK") );
414 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
417 QString VisuInputDir = getVisuInputDir();
418 QString VisuOutputDir = getVisuOutputDir();
420 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
421 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
422 SALOMEDS::GenericAttribute_var anAttr;
423 SALOMEDS::AttributeName_var aName;
424 SALOMEDS::AttributeIOR_var anIOR;
426 switch (theCommandID){
427 /* ======================================================================================== */
428 /* Import Table from file */
429 /* ======================================================================================== */
432 if(checkLock(aStudy)) break;
433 visuGUI->ImportTablesFromFile();
437 /* ======================================================================================== */
438 /* Import Mesh from MED, DAT file */
439 /* ======================================================================================== */
443 visuGUI->CopyAndImportFile();
448 visuGUI->ImportFile();
452 /* ======================================================================================== */
453 /* Export results and mesh into a file format */
454 /* ======================================================================================== */
458 //visuGUI->ExportToFile();
462 /* ========================================================================== */
463 /* Visualization of Results : */
464 /* 4011 : Scalar Map */
465 /* 4012 : Deformed Shape */
467 /* 4014 : Iso-Surfaces */
468 /* 4015 : Cut Planes */
469 /* 4016 : Stream Lines */
470 /* ========================================================================== */
473 visuGUI->CreateScalarMap();
476 visuGUI->CreateDeformedShape();
479 visuGUI->CreateVectors();
482 visuGUI->CreateIsoSurfaces();
485 visuGUI->CreateCutPlanes();
488 visuGUI->CreateCutLines();
491 visuGUI->CreateStreamLines();
495 visuGUI->SelectionInfo();
498 /* ========================================================================================================================= */
499 /* Visualization - Wireframe */
500 /* ========================================================================================================================= */
506 /* ========================================================================================================================= */
507 /* Visualization - Surface */
508 /* ========================================================================================================================= */
514 /* ========================================================================================================================= */
515 /* Visualization - Points */
516 /* ========================================================================================================================= */
522 /* ========================================================================================================================= */
523 /* Visualization - Erase */
524 /* ========================================================================================================================= */
530 /* ========================================================================================================================= */
531 /* Visualization - Global */
532 /* ========================================================================================================================= */
536 /* ========================================================================================================================= */
537 /* Visualization - Partial */
538 /* ========================================================================================================================= */
544 //Show dialog that allows to select scale function and corresponding scale factor
545 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
546 FALSE, Qt::WDestructiveClose );
551 /* ============================ */
552 /* POP-UP OBJECTS BROWSER */
553 /* ============================ */
555 case 900 : // Rename object
559 // ---------------- For Popup in Viewer
565 case 803 : // Display only
566 case 903 : // Display only
567 visuGUI->DisplayOnlyPrs();
570 case 901 : // Display
571 visuGUI->DisplayPrs();
574 case 8041 : // Object representation : Wireframe
575 case 9041 : // Object representation : Wireframe
576 visuGUI->ChangeRepresentation(VISU::WIREFRAME);
579 case 8042 : // Object representation : Surface
580 case 9042 : // Object representation : Surface
581 visuGUI->ChangeRepresentation(VISU::SHADED);
584 case 8043 : // Object representation : Points
585 case 9043 : // Object representation : Points
586 visuGUI->ChangeRepresentation(VISU::POINT);
589 case 8044 : // Object representation : Shrink/Unshrink
590 case 9044 : // Object representation : Shrink/Unshrink
591 visuGUI->ChangeRepresentation(VISU::SHRINK);
594 case 8051 : // Change object color
595 case 9051 : // Change object color
596 visuGUI->ChageColor();
599 case 8052 : // Change object opacity
600 case 9052 : // Change object opacity
601 visuGUI->ChangeOpacity();
604 case 8053 : // Change object line width
605 case 9053 : // Change object line width
606 visuGUI->ChangeLines();
609 case 808 : // Sweep IsoSurfaces or Cutplanes
610 case 908 : // Sweep IsoSurfaces or Cutplanes
614 /* ======================================================================================== */
615 /* Preferences for Scalar Bar */
616 /* ======================================================================================== */
623 /* ======================================================================================== */
624 /* Preferences for Sweeping */
625 /* ======================================================================================== */
628 SetSweepingPreferences();
632 /* ======================================================================================== */
633 /* Preferences for Full loading */
634 /* ======================================================================================== */
639 QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
640 bool check = !pp->isItemChecked(theCommandID);
641 pp->setItemChecked(theCommandID,check);
642 switch(theCommandID){
644 QAD_CONFIG->addSetting( "Visu:BuildResult", check );
647 QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
653 case 113: // Load MED using MED component
655 if (checkLock(GetStudyDocument())) break;
657 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
658 if (CORBA::is_nil(aMedComp)) return false;
659 SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
660 if (CORBA::is_nil(aMedGen)) return false;
662 QStringList filtersList ;
664 filtersList.append( tr("MED_MEN_IMPORT_MED") );
665 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
666 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
669 tr("MED_MEN_IMPORT"),
671 if (!aFileName.isEmpty()) {
672 QApplication::setOverrideCursor( Qt::waitCursor );
673 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
674 GetActiveStudy()->updateObjBrowser();
675 QApplication::restoreOverrideCursor();
681 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
682 tr ("MSG_NOT_IMPLEMENTED"),
683 tr ("VISU_BUT_OK") );
686 } catch (const std::bad_alloc& e ) {
687 INFOS("bad_alloc exception is caught "<<e.what());
688 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
689 tr("ERR_NO_MEMORY") + " " + tr(e.what()),
693 catch (std::exception& e){
695 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
698 }catch (const SALOME::SALOME_Exception& S_ex) {
699 INFOS("const SALOME::SALOME_Exception& S_ex");
700 QtCatchCorbaException(S_ex);
704 INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
705 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
706 tr("ERR_UNKNOWN_EXCEPTION"),
713 void VisuGUI::SelectionInfo() {
714 mySelectionDlg = new VisuGUI_SelectionDlg();
715 mySelectionDlg->show();
721 /* ********************************************************************************** */
722 /* Function ShowTrihedron */
723 /* ********************************************************************************** */
725 void VisuGUI::ShowTrihedron(bool ShowThd){
726 bool ThdIsVisible = true;
727 if( ShowThd && !ThdIsVisible)
728 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
729 if( !ShowThd && ThdIsVisible)
730 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
733 /* ********************************************************************************** */
735 /* Clear all tmp files used in VISU */
736 /* ********************************************************************************** */
739 if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
742 /* ********************************************************************************** */
743 /* Function ChangeViewer */
744 /* Change representation of all actors */
745 /* ********************************************************************************** */
747 void VisuGUI::ChangeViewer(int theType){
749 GetActiveStudy()->unHighlightAll();
750 if(vtkRenderer *aRen = GetRenderer()){
752 vtkActorCollection *anActColl = aRen->GetActors();
753 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
754 if(anActor->GetVisibility() > 0)
755 if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){
756 anVISUActor = anVISUActor->GetParent();
758 anVISUActor->SetRepresentation(theType);
760 anVISUActor->VisibilityOff();
763 RepaintCurrentView();
767 // -----------------------------------------------------------------------------------------
769 // -----------------------------------------------------------------------------------------
771 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
776 // ====================================================================================================================
778 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
783 // ===================================================================================================================
785 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
787 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
790 if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
796 if(MYDEBUG) MESSAGE("--> Key : Escape")
808 //=====================================================================================
809 // Slot-functions for presentations creation
810 //=====================================================================================
812 #define CREATEPRESENTATION(FunctionName) \
813 void FunctionName() { \
814 if (checkLock(GetStudyDocument())) return; \
815 SALOMEDS::SObject_var objVisu; \
816 if (!TestObjectBrowser(objVisu)) return; \
817 if(!FunctionName(objVisu)) return; \
818 GetActiveStudy()->updateObjBrowser(); \
819 GetDesktop()->putInfo("Ready"); \
820 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
822 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
823 vf->onViewFitAll(); \
828 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
829 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
830 CREATEPRESENTATION(VisuGUI::CreateVectors);
831 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
832 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
833 CREATEPRESENTATION(VisuGUI::CreateCutLines);
834 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
838 //=====================================================================================
839 // function : SetSettings()
841 //=====================================================================================
842 bool VisuGUI::SetSettings(QAD_Desktop* parent)
846 QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
847 QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
849 if(aValue.isEmpty()? 0 : aValue.toInt())
850 pp->setItemChecked(anId, true);
853 item = parent->menuBar()->findItem(anId,&pp);
854 aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
856 if(aValue.isEmpty()? 0 : aValue.toInt())
857 pp->setItemChecked(anId, true);
860 parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
867 //=====================================================================================
868 // function : DisplayPrs()
870 //=====================================================================================
871 void VisuGUI::DisplayPrs() {
872 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
873 Handle(SALOME_InteractiveObject) anIO;
874 CORBA::Object_var anObject = GetSelectedObj(&anIO);
875 if ( !CORBA::is_nil( anObject ) ) {
876 // is it Prs3d object ?
877 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
879 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
880 UpdateViewer(aPrsObject);
881 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
882 vf->getRenderer()->ResetCameraClippingRange();
884 vf->highlight(anIO, 1);
889 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
891 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
892 PlotCurve(aCurve, VISU::eDisplay );
896 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
898 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
899 PlotContainer(aContainer, VISU::eDisplay );
903 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
905 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
906 PlotTable(aTable, VISU::eDisplay );
912 //=====================================================================================
913 // function : DisplayOnlyPrs()
915 //=====================================================================================
916 void VisuGUI::DisplayOnlyPrs() {
917 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
918 CORBA::Object_var anObject = GetSelectedObj();
919 if ( !CORBA::is_nil( anObject ) ) {
920 // is it Prs3d object ?
921 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
922 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
923 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
924 UpdateViewer(aPrsObject, true);
925 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
927 vf->getRenderer()->ResetCameraClippingRange();
930 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
931 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
932 PlotCurve(aCurve, VISU::eDisplayOnly );
933 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
934 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
935 PlotContainer(aContainer, VISU::eDisplayOnly );
936 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
937 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
938 PlotTable(aTable, VISU::eDisplayOnly );
943 //=====================================================================================
944 // function : ErasePrs()
946 //=====================================================================================
947 static void ErasePrs(CORBA::Object_ptr theObject) {
948 if(MYDEBUG) MESSAGE("ErasePrs");
949 if ( !CORBA::is_nil( theObject ) ) {
950 VISU::Base_var aBase = VISU::Base::_narrow(theObject);
951 if ( CORBA::is_nil( aBase ) ) return;
952 VISU::VISUType aType = aBase->GetType();
955 if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
956 VisuGUI::PlotCurve(aCurve, VISU::eErase );
959 case VISU::TCONTAINER:{
960 if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
961 VisuGUI::PlotContainer(aContainer, VISU::eErase );
965 if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
966 VisuGUI::PlotTable(aTable, VISU::eErase );
970 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
971 VisuGUI::ErasePrs(aPrsObject);
972 if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame())
979 void VisuGUI::ErasePrs() {
980 ::ErasePrs(GetSelectedObj());
984 //=====================================================================================
985 // function : DisplayManyPrs()
987 //=====================================================================================
988 void VisuGUI::DisplayManyPrs()
990 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
991 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
992 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
993 for ( ; It.More(); It.Next() ) {
994 Handle(SALOME_InteractiveObject)& anIO = It.Value();
995 if ( anIO->hasEntry() ) {
996 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
997 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
998 VISU::Storable::TRestoringMap pMap;
999 if( !aSObject->_is_nil() ) {
1000 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1001 if ( !CORBA::is_nil( aCORBAObject ) ) {
1002 // is it Prs3d object ?
1003 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1005 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
1006 UpdateViewer(aPrsObject);
1007 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1009 vf->getRenderer()->ResetCameraClippingRange();
1011 vf->highlight(anIO, 1);
1016 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1018 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
1019 PlotCurve(aCurve, VISU::eDisplay );
1022 // is it Container ?
1023 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1025 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
1026 PlotContainer(aContainer, VISU::eDisplay );
1030 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1032 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
1033 PlotTable(aTable, VISU::eDisplay );
1042 //=====================================================================================
1043 // function : DisplayOnlyManyPrs()
1045 //=====================================================================================
1046 void VisuGUI::DisplayOnlyManyPrs() {
1047 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
1048 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1049 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1050 bool aFirstElem = true;
1051 for ( ; It.More(); It.Next() ) {
1052 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1053 if ( anIO->hasEntry() ) {
1054 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1055 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1056 VISU::Storable::TRestoringMap pMap;
1057 if( !aSObject->_is_nil() ) {
1058 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1059 if ( !CORBA::is_nil( aCORBAObject ) ) {
1060 // is it Prs3d object ?
1061 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1063 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1064 UpdateViewer(aPrsObject, aFirstElem);
1065 if (aFirstElem) aFirstElem = false;
1066 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1068 vf->getRenderer()->ResetCameraClippingRange();
1070 vf->highlight(anIO, 1);
1075 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1077 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1079 PlotCurve(aCurve, VISU::eDisplayOnly );
1082 else PlotCurve(aCurve, VISU::eDisplay );
1085 // is it Container ?
1086 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1088 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1090 PlotContainer(aContainer, VISU::eDisplayOnly );
1093 else PlotContainer(aContainer, VISU::eDisplay );
1097 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1099 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1101 PlotTable(aTable, VISU::eDisplayOnly );
1104 else PlotTable(aTable, VISU::eDisplay );
1114 //=====================================================================================
1115 // function : EraseManyPrs()
1117 //=====================================================================================
1118 void VisuGUI::EraseManyPrs()
1120 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1121 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1122 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1123 SALOME_ListIteratorOfListIO It( LIO );
1124 for ( ; It.More(); It.Next() ) {
1125 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1126 if ( anIO->hasEntry() ) {
1127 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1128 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1129 VISU::Storable::TRestoringMap pMap;
1130 if( !aSObject->_is_nil() ) {
1131 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1132 if ( !CORBA::is_nil( aCORBAObject ) ) {
1133 // is it Prs3d object ?
1134 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1136 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1137 ErasePrs(aPrsObject);
1138 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1145 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1147 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1148 PlotCurve(aCurve, VISU::eErase );
1151 // is it Container ?
1152 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1154 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1155 PlotContainer(aContainer, VISU::eErase );
1159 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1161 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1162 PlotTable(aTable, VISU::eErase );
1171 //=====================================================================================
1172 // function : RecreateActor()
1174 //=====================================================================================
1175 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1176 QApplication::setOverrideCursor(Qt::waitCursor);
1179 //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
1180 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1181 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1182 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1183 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1184 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1185 thePrs->UpdateActor(anActor);
1187 }catch(std::runtime_error& ex){
1189 QApplication::restoreOverrideCursor();
1190 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1191 tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()),
1192 tr ("VISU_BUT_OK") );
1193 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1194 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1195 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1196 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
1197 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
1198 aViewFrame->RemoveActor(anActor);
1205 QApplication::restoreOverrideCursor();
1209 //=====================================================================================
1210 // function : EditPrs()
1212 //=====================================================================================
1213 #define EDITPRS(PrsName, DlgName) \
1215 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1217 DlgName* aDlg = new DlgName(); \
1218 aDlg->initFromPrsObject(aPrsObject); \
1219 if ( aDlg->exec() ) { \
1220 if(!(aDlg->storeToPrsObject(aPrsObject))){ \
1224 RecreateActor(aPrsObject); \
1225 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1226 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1227 vf->getRenderer()->ResetCameraClippingRange(); \
1236 void VisuGUI::EditPrs() {
1237 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1239 switch (aPrs3d->GetType()) {
1240 case VISU::TMESH: // Mesh 13
1243 case VISU::TSCALARMAP: // ScalarMap 18
1244 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1247 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1248 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1251 case VISU::TCUTPLANES: // Cut planes 42
1252 //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1254 VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
1256 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
1257 aDlg->initFromPrsObject(aPrsObject);
1259 myActiveDialogBox = aDlg;
1260 // if ( aDlg->exec() ) {
1261 // if(!(aDlg->storeToPrsObject(aPrsObject))){
1265 // RecreateActor(aPrsObject);
1266 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1267 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1268 // vf->getRenderer()->ResetCameraClippingRange();
1278 case VISU::TCUTLINES: // Cut planes 42
1279 //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1281 VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
1283 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false);
1284 aDlg->initFromPrsObject(aPrsObject);
1286 myActiveDialogBox = aDlg;
1287 // if ( aDlg->exec() ) {
1288 // aDlg->storeToPrsObject(aPrsObject);
1289 // RecreateActor(aPrsObject);
1290 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1291 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1292 // vf->getRenderer()->ResetCameraClippingRange();
1296 // // Remove old Table
1297 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1298 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
1299 // if(!aSObject->_is_nil()) {
1300 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1301 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1302 // for ( ;aIter->More(); aIter->Next()) {
1303 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1304 // if (!aTblObj->_is_nil()) {
1305 // SALOMEDS::GenericAttribute_var anAttr;
1306 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1307 // aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
1312 // if (aDlg->isGenerateTable()) {
1313 // GetVisuGen()->CreateTable(aSObject->GetID());
1314 // if (aDlg->isGenerateCurves()) {
1315 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1316 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1317 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1318 // for ( ;aIter->More(); aIter->Next()) {
1319 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1320 // if (!aTblObj->_is_nil()) {
1321 // SALOMEDS::GenericAttribute_var anAttr;
1322 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1323 // CreatePlot(aTblObj);
1330 // GetActiveStudy()->updateObjBrowser();
1338 case VISU::TISOSURFACE: // Iso surfaces
1339 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1341 case VISU::TVECTORS: // Vectors 64
1342 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1345 case VISU::TSTREAMLINES:
1346 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1352 Handle(SALOME_InteractiveObject) anIO;
1353 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1354 if ( !CORBA::is_nil( anObject ) )
1355 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1356 vf->highlight(anIO, 1);
1360 //=====================================================================================
1361 // function : CreateMesh()
1363 //=====================================================================================
1364 void VisuGUI::CreateMesh() {
1365 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1366 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1368 if (checkLock(GetStudyDocument())) return;
1370 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1371 aSObj = aSObj->GetFather();
1372 aSObj = aSObj->GetFather();
1373 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1374 if(CORBA::is_nil(anObject)) {
1375 aSObj = aSObj->GetFather();
1376 anObject = VISU::SObjectToObject(aSObj);
1378 VISU::Result_var aResult;
1379 if (!CORBA::is_nil(anObject)) {
1380 aResult = VISU::Result::_narrow(anObject);
1382 if(CORBA::is_nil(aResult)) {
1383 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1384 tr ("WRN_NO_AVAILABLE_DATA"),
1385 tr ("VISU_BUT_OK"));
1388 VISU::Storable::TRestoringMap aMap;
1389 SALOMEDS::GenericAttribute_var anAttr;
1390 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1391 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1392 string aComm = aComment->Value();
1393 QString strIn(aComm.c_str());
1394 VISU::Storable::StrToMap(strIn,aMap);
1397 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1398 if(!isExist) return;
1399 CORBA::Object_var aMesh;
1400 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1405 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
1406 if(aComment == "ENTITY"){
1407 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1408 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1409 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1410 }else if(aComment == "FAMILY"){
1411 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1412 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1413 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1414 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1415 }else if(aComment == "GROUP"){
1416 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1417 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1418 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1422 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1426 QApplication::restoreOverrideCursor();
1427 VISU::Mesh_i* pPresent = NULL;
1428 if(!CORBA::is_nil(aMesh))
1429 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1430 if (pPresent == NULL) {
1431 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1432 tr ("ERR_CANT_BUILD_PRESENTATION"),
1433 tr ("VISU_BUT_OK") );
1437 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1439 VISU_Actor *anActor = pPresent->CreateActor();
1444 vf->AddActor(anActor);
1448 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1451 //GetActiveStudy()->updateObjBrowser(); //not necessary
1452 GetDesktop()->putInfo("Ready");
1453 }catch(std::runtime_error& exc){
1455 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1456 tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
1457 tr ("VISU_BUT_OK") );
1462 //=====================================================================================
1463 // function : CreateManyMesh()
1465 //=====================================================================================
1466 void VisuGUI::CreateManyMesh(){
1467 if (checkLock(GetStudyDocument())) return;
1469 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1470 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1471 for ( ; It.More(); It.Next() ) {
1472 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1473 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1474 aSObj = aSObj->GetFather();
1475 aSObj = aSObj->GetFather();
1476 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1477 if(CORBA::is_nil(anObject)) {
1478 aSObj = aSObj->GetFather();
1479 anObject = VISU::SObjectToObject(aSObj);
1480 if(CORBA::is_nil(anObject)) return;
1482 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1483 if(CORBA::is_nil(aResult)) return;
1485 VISU::Storable::TRestoringMap aMap;
1486 SALOMEDS::GenericAttribute_var anAttr;
1487 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1488 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1489 string aComm = aComment->Value();
1490 QString strIn(aComm.c_str());
1491 VISU::Storable::StrToMap(strIn,aMap);
1494 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1495 if(!isExist) return;
1496 CORBA::Object_var aMesh;
1497 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1498 if(aComment == "ENTITY"){
1499 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1500 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1501 }else if(aComment == "FAMILY"){
1502 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1503 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1504 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1505 }else if(aComment == "GROUP"){
1506 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1507 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1509 QApplication::restoreOverrideCursor();
1510 if(CORBA::is_nil(aMesh)) return;
1512 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1514 VISU_Actor *anActor = pPresent->CreateActor();
1515 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1516 vf->AddActor(anActor);
1519 GetDesktop()->putInfo("Ready");
1520 }catch(std::runtime_error& exc){
1526 //=====================================================================================
1527 // function : ChangeRepresentation()
1529 //=====================================================================================
1531 static void ShrinkMesh(VISU_Actor *theActor){
1532 if(theActor->IsShrunk())
1533 theActor->UnShrink();
1535 theActor->SetShrink();
1538 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1539 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1540 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1543 ShrinkMesh(anActor);
1546 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1547 aMesh->SetPresentationType(theType);
1548 RecreateActor(aMesh);
1550 anActor->SetRepresentation(theType);
1552 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1558 void VisuGUI::MakeSurfaceframe() {
1559 ChangeRepresentation(VISU::SURFACEFRAME);
1562 void VisuGUI::MakeInsideframe() {
1563 ChangeRepresentation(VISU::INSIDEFRAME);
1566 void VisuGUI::MakeWireframe() {
1567 ChangeRepresentation(VISU::WIREFRAME);
1570 void VisuGUI::MakeSurface() {
1571 ChangeRepresentation(VISU::SHADED);
1574 void VisuGUI::MakePoints() {
1575 ChangeRepresentation(VISU::POINT);
1578 void VisuGUI::MakeShrink() {
1579 ChangeRepresentation(VISU::SHRINK);
1584 //=====================================================================================
1585 // functions : Change Propertise
1587 //=====================================================================================
1588 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1589 CORBA::Object_var anObject = GetSelectedObj(theIO);
1590 if(CORBA::is_nil(anObject)) return NULL;
1591 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1592 if(!aServant.in()) return NULL;
1593 return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1596 void VisuGUI::ChageColor() {
1597 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1598 if(!aPrsObject) return;
1600 VISU_Actor* anActor = GetActor(aPrsObject);
1601 if (!anActor) return;
1605 void VisuGUI::ChangeWireframeColor() {
1606 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1607 if(!aPrsObject) return;
1609 VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1610 if (!anActor) return;
1611 NewWireframeColor(anActor);
1615 void VisuGUI::ChangeOpacity() {
1616 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1617 if(!aPrsObject) return;
1619 VISU_Actor* anActor = GetActor(aPrsObject);
1620 if (!anActor) return;
1621 NewOpacity(anActor);
1625 void VisuGUI::ChangeLines() {
1626 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1627 if(!aPrsObject) return;
1629 VISU_Actor* anActor = GetActor(aPrsObject);
1630 if (!anActor) return;
1631 NewLinewidth(anActor);
1633 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1635 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1636 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1637 if ( theDisplaying == VISU::eDisplayOnly )
1639 QList<Plot2d_Curve> clist;
1640 aPlot->getCurves( clist );
1641 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1642 if ( !TableSO->_is_nil() ) {
1643 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1644 for ( ; Iter->More(); Iter->Next() ) {
1645 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1646 if( !CORBA::is_nil( childObject ) ) {
1647 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1648 if( !CORBA::is_nil( aCurve ) ) {
1649 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1650 Plot2d_Curve* plotCurve = 0;
1651 for ( int i = 0; i < clist.count(); i++ ) {
1652 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1653 plotCurve = clist.at( i );
1657 if ( theDisplaying == VISU::eErase ) {
1659 aPlot->eraseCurve( plotCurve, false );
1660 clist.remove( plotCurve );
1663 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1665 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1666 //plotCurve->setVerTitle( theCurve->GetVerTitle().c_str() );
1667 plotCurve->setVerTitle( theCurve->GetName() );
1668 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1669 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1670 /* - DATA NOT UPDATED */
1673 int nbPoints = theCurve->GetData( xList, yList );
1674 if ( nbPoints > 0 && xList && yList ) {
1675 plotCurve->setData( xList, yList, nbPoints );
1677 if ( !theCurve->IsAuto() ) {
1678 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1679 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1680 SALOMEDS::Color color = theCurve->GetColor();
1681 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1683 plotCurve->setAutoAssign( theCurve->IsAuto() );
1684 aPlot->displayCurve( plotCurve, false );
1687 Plot2d_Curve* crv = theCurve->CreatePresentation();
1689 aPlot->displayCurve( crv, false );
1690 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1691 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1692 SALOMEDS::Color newColor;
1693 newColor.R = crv->getColor().red()/255.;
1694 newColor.G = crv->getColor().green()/255.;
1695 newColor.B = crv->getColor().blue()/255.;
1696 theCurve->SetColor( newColor );
1697 crv->setAutoAssign( theCurve->IsAuto() );
1708 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1710 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1711 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1712 // if ( theDisplaying == VISU::eDisplayOnly )
1713 // aPlot->EraseAll();
1714 QList<Plot2d_Curve> clist;
1715 aPlot->getCurves( clist );
1716 Plot2d_Curve* plotCurve = 0;
1717 for ( int i = 0; i < clist.count(); i++ ) {
1718 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1719 plotCurve = clist.at( i );
1721 else if ( theDisplaying == VISU::eDisplayOnly ) {
1722 aPlot->eraseCurve( clist.at( i ) );
1725 if ( theDisplaying == VISU::eErase ) {
1727 aPlot->eraseCurve( plotCurve, false );
1729 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1731 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1732 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1733 plotCurve->setVerTitle( theCurve->GetName() );
1734 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1735 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1738 int nbPoints = theCurve->GetData( xList, yList );
1739 if ( nbPoints > 0 && xList && yList ) {
1740 plotCurve->setData( xList, yList, nbPoints );
1742 if ( !theCurve->IsAuto() ) {
1743 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1744 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1745 SALOMEDS::Color color = theCurve->GetColor();
1746 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1748 plotCurve->setAutoAssign( theCurve->IsAuto() );
1749 aPlot->displayCurve( plotCurve, false );
1752 Plot2d_Curve* crv = theCurve->CreatePresentation();
1754 aPlot->displayCurve( crv, false );
1755 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1756 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1757 SALOMEDS::Color newColor;
1758 newColor.R = crv->getColor().red()/255.;
1759 newColor.G = crv->getColor().green()/255.;
1760 newColor.B = crv->getColor().blue()/255.;
1761 theCurve->SetColor( newColor );
1762 crv->setAutoAssign( theCurve->IsAuto() );
1769 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1771 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1772 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1773 if ( theDisplaying == VISU::eDisplayOnly )
1775 QList<Plot2d_Curve> clist;
1776 aPlot->getCurves( clist );
1777 if ( container->GetNbCurves() > 0 ) {
1778 int nbCurves = container->GetNbCurves();
1779 for ( int k = 1; k <= nbCurves; k++ ) {
1780 VISU::Curve_i* theCurve = container->GetCurve( k );
1781 if ( theCurve && theCurve->IsValid() ) {
1782 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) );
1783 // for ( int i = 0; i < clist.count(); i++ ) {
1784 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1785 // plotCurve = clist.at( i );
1789 if ( theDisplaying == VISU::eErase ) {
1791 aPlot->eraseCurve( plotCurve, false );
1792 clist.remove( plotCurve );
1795 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1797 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1798 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1799 plotCurve->setVerTitle( theCurve->GetName() );
1800 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1801 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1804 int nbPoints = theCurve->GetData( xList, yList );
1805 if ( nbPoints > 0 && xList && yList ) {
1806 plotCurve->setData( xList, yList, nbPoints );
1808 if ( !theCurve->IsAuto() ) {
1809 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1810 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1811 SALOMEDS::Color color = theCurve->GetColor();
1812 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1814 plotCurve->setAutoAssign( theCurve->IsAuto() );
1815 aPlot->displayCurve( plotCurve, false );
1818 Plot2d_Curve* crv = theCurve->CreatePresentation();
1820 aPlot->displayCurve( crv, false );
1821 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1822 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1823 SALOMEDS::Color newColor;
1824 newColor.R = crv->getColor().red()/255.;
1825 newColor.G = crv->getColor().green()/255.;
1826 newColor.B = crv->getColor().blue()/255.;
1827 theCurve->SetColor( newColor );
1828 crv->setAutoAssign( theCurve->IsAuto() );
1840 Slot : opens Table view : for Table object or SObject with table attribute selected
1842 void VisuGUI::ShowTable() {
1843 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1844 if( Sel->IObjectCount() !=1 )
1846 Handle(SALOME_InteractiveObject) anIO;
1847 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1848 SALOMEDS::SObject_var SO;
1849 if ( !CORBA::is_nil( anObject ) ) {
1850 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1851 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1852 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1853 if( !CORBA::is_nil( aTable ) ) {
1854 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1856 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1861 // possibly this is Table SObject
1862 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1865 if(!IsSObjectTable(SO))
1868 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1871 //SAL2670 Orientation of show tables
1872 SALOMEGUI_TableDlg::ttAuto,
1879 Slot : opens Table view : for Table object or SObject with table attribute selected
1881 void VisuGUI::CreateTable() {
1882 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1883 if( aSel->IObjectCount() !=1 )
1886 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1887 if (anIO->hasEntry()){
1888 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1889 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1890 if(!aSObject->_is_nil()) {
1891 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1892 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1893 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1894 GetVisuGen()->CreateTable(aSObject->GetID());
1895 GetActiveStudy()->updateObjBrowser();
1903 Slot : deletes SObject with all subobjects
1905 void VisuGUI::DeleteObject() {
1906 SALOMEDS::Study_var aStudy = GetStudyDocument();
1907 if (checkLock(aStudy)) return;
1909 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1910 if( aSel->IObjectCount() !=1 )
1912 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1913 if (anIO->hasEntry()){
1914 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1915 if(!aSObject->_is_nil()){
1916 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1917 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1918 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1919 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1920 ::ErasePrs(aChildObj);
1922 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
1923 // There is a transaction
1924 aStudyBuilder->NewCommand();
1925 CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1926 if(!CORBA::is_nil(anObj)){
1927 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1928 if(!CORBA::is_nil(aBase)){
1929 VISU::VISUType aType = aBase->GetType();
1933 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1934 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1935 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1936 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1937 if(CORBA::is_nil(aChildObj)) continue;
1938 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1939 if(CORBA::is_nil(aPrs3d)) continue;
1940 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1941 DeletePresentation(pPrs3d);
1947 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1948 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1949 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1950 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1951 if(CORBA::is_nil(aChildObj)) continue;
1952 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( aChildObj );
1953 if(CORBA::is_nil(aCurve)) continue;
1954 VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1955 DeletePresentation(pCurve);
1962 aStudyBuilder->RemoveObjectWithChildren(aSObject);
1963 aStudyBuilder->CommitCommand();
1964 GetActiveStudy()->unHighlightAll();
1965 GetActiveStudy()->updateObjBrowser(true);
1972 Slot : deletes empty container
1974 void VisuGUI::CreatePlot2dView() {
1975 if (checkLock(GetStudyDocument())) return;
1976 GetVisuGen()->CreateContainer();
1977 GetActiveStudy()->updateObjBrowser( true );
1983 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1985 void VisuGUI::PlotData() {
1986 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1987 if( Sel->IObjectCount() !=1 )
1989 CORBA::Object_var anObject = GetSelectedObj();
1990 SALOMEDS::SObject_var SO;
1991 if ( !CORBA::is_nil( anObject ) ) {
1992 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1993 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1994 // Table (VISU object) is selected
1995 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1996 if( !CORBA::is_nil( aTbl ) ) {
1997 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1999 SALOMEDS::GenericAttribute_var anAttr;
2000 SALOMEDS::AttributeName_var aName;
2002 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
2003 if ( IsSObjectTable(SO) ) {
2004 // get name of SObject
2005 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2006 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2007 SOName = aName->Value();
2009 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2010 if ( dlg->exec() == QDialog::Accepted ) {
2011 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2012 // if study is not locked - create new container, create curves
2013 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2015 QValueList<int> verIndices;
2016 dlg->getCurvesSource( horIndex, verIndices );
2017 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2018 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2019 if( !CORBA::is_nil( aContainer ) ) {
2020 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2022 for ( int i = 0; i < verIndices.count(); i++ ) {
2023 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
2024 if( !CORBA::is_nil( aNewCurve ) ) {
2025 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2028 int marker, line, lineWidth;
2030 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2031 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2032 pCrv->SetColor( c );
2033 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2034 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2036 pContainer->AddCurve( pCrv->_this() );
2040 GetActiveStudy()->updateObjBrowser( true );
2041 PlotContainer( pContainer, VISU::eDisplay );
2047 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2048 Plot2d_CurveContainer container;
2049 dlg->getCurves( container );
2050 if ( !container.isEmpty() ) {
2051 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2052 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2053 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2054 getRightFrame()->getViewFrame()))->setTitle( SOName );
2065 // possibly this is Table SObject
2066 SALOMEDS::GenericAttribute_var anAttr;
2067 SALOMEDS::AttributeName_var aName;
2070 // check if Table SObject is selected
2071 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2072 if ( IsSObjectTable(SO) ) {
2073 // get name of SObject
2074 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2075 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2076 SOName = aName->Value();
2078 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2079 if ( dlg->exec() == QDialog::Accepted ) {
2080 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2081 // if study is not locked - create new table and container objects, create curves
2082 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2084 QValueList<int> verIndices;
2085 dlg->getCurvesSource( horIndex, verIndices );
2086 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2087 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
2088 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2089 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2090 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2091 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2093 if ( pContainer && pTable ) {
2094 for ( int i = 0; i < verIndices.count(); i++ ) {
2095 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2096 if( !CORBA::is_nil( aNewCurve ) ) {
2097 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2100 int marker, line, lineWidth;
2102 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2103 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2104 pCrv->SetColor( c );
2105 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2106 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2108 pContainer->AddCurve( pCrv->_this() );
2112 GetActiveStudy()->updateObjBrowser( true );
2113 PlotContainer( pContainer, VISU::eDisplay );
2118 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2119 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2120 Plot2d_CurveContainer container;
2121 dlg->getCurves( container );
2122 if ( !container.isEmpty() ) {
2123 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2124 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2125 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2126 getRightFrame()->getViewFrame()))->setTitle( SOName );
2137 void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
2138 SALOMEDS::GenericAttribute_var anAttr;
2139 SALOMEDS::AttributeName_var aName;
2141 if ( IsSObjectTable(theTableSO) ) {
2142 CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
2143 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2144 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2145 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
2146 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
2148 if ( pContainer && pTable ) {
2149 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
2150 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
2151 if( !CORBA::is_nil( aNewCurve ) ) {
2152 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
2154 pContainer->AddCurve( pCrv->_this() );
2158 GetActiveStudy()->updateObjBrowser( true );
2159 PlotContainer( pContainer, VISU::eDisplay );
2167 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2169 void VisuGUI::CurveProperties() {
2170 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2171 if( Sel->IObjectCount() !=1 )
2173 CORBA::Object_var anObject = GetSelectedObj();
2174 SALOMEDS::SObject_var SO;
2175 if (CORBA::is_nil( anObject )) return;
2177 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2178 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2180 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2181 if( !CORBA::is_nil( aCurve ) ) {
2182 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2183 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2184 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
2185 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2186 dlg->setMarker( (int)curve->GetMarker() );
2187 SALOMEDS::Color color = curve->GetColor();
2188 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2189 if( dlg->exec() == QDialog::Accepted ) {
2190 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2191 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2192 SALOMEDS::Color newColor;
2193 newColor.R = dlg->getColor().red()/255.;
2194 newColor.G = dlg->getColor().green()/255.;
2195 newColor.B = dlg->getColor().blue()/255.;
2196 curve->SetColor( newColor );
2197 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2198 if ( sfList.count() > 0 ) {
2199 QListIterator<QAD_StudyFrame> it( sfList );
2200 for ( ; it.current(); ++it ) {
2201 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2202 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2203 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2206 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2208 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2209 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2210 plotCurve->setColor( dlg->getColor() );
2211 aPlot->updateCurve( plotCurve, true );
2224 Slot : Clears container contents : for Container object selected
2226 void VisuGUI::ClearContainer() {
2227 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2228 if( Sel->IObjectCount() !=1 )
2231 CORBA::Object_var anObject = GetSelectedObj();
2232 SALOMEDS::SObject_var SO;
2233 if (CORBA::is_nil( anObject )) return;
2235 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2236 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2238 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2239 if( !CORBA::is_nil( aCnt ) ) {
2240 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2241 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2243 GetActiveStudy()->updateObjBrowser();
2250 Slot : Edit container contents : for Container object selected
2252 void VisuGUI::EditContainer() {
2253 CORBA::Object_var anObject = GetSelectedObj();
2254 if(CORBA::is_nil(anObject)) return;
2255 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
2256 if(!aServant.in()) return;
2257 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
2258 if(!aContainer) return;
2260 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
2261 aDlg->initFromPrsObject(aContainer);
2263 aDlg->storeToPrsObject(aContainer);
2264 GetActiveStudy()->updateObjBrowser( true );
2270 void VisuGUI::DeletePrs() {
2271 SALOMEDS::Study_var aStudy = GetStudyDocument();
2272 if (checkLock(aStudy)) return;
2274 // There is a transaction
2275 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
2276 aStudyBuilder->NewCommand();
2278 CORBA::Object_var anObject = GetSelectedObj();
2279 if ( !CORBA::is_nil( anObject ) ) {
2280 // is it Prs3d object ?
2281 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2283 DeletePresentation(aPrsObject);
2284 // is it Curve object ?
2285 VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
2287 DeletePresentation(aCurveObject);
2289 aStudyBuilder->CommitCommand();
2293 void VisuGUI::SaveViewParams()
2295 if (checkLock(GetStudyDocument())) return;
2296 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2297 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2298 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2300 if ( aSel->IObjectCount() == 0 ) {
2301 VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
2303 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2304 VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
2306 GetActiveStudy()->updateObjBrowser( true );
2310 void VisuGUI::RestoreViewParams()
2312 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2313 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2314 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2316 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2317 VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
2321 //=====================================================================================
2322 // function : DeleteViewParams()
2324 //=====================================================================================
2325 void VisuGUI::DeleteViewParams() {
2327 VISU::Storable::TRestoringMap aMap;
2328 Handle(SALOME_InteractiveObject) anIO;
2329 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2330 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2331 if(isExist && aType == VISU::TVIEW3D){
2332 SALOMEDS::Study_var aStudy = GetStudyDocument();
2333 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2334 aStudy->NewBuilder()->RemoveObject(aSObject);
2336 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2337 aSel->RemoveIObject(anIO, 0);
2339 GetActiveStudy()->updateObjBrowser( true );
2344 //=====================================================================================
2345 // function : Sweep()
2347 //=====================================================================================
2348 void VisuGUI::Sweep() {
2349 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2350 if (!aPrsObject) return;
2352 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2356 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2357 if ( !aTempoStr.isEmpty() )
2358 aTemp = int(1.E6*(aTempoStr.toFloat()));
2361 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2362 if ( !aCyclesStr.isEmpty() )
2363 aCycles = aCyclesStr.toInt();
2366 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2367 if ( !aStepsStr.isEmpty() )
2368 aSteps = aStepsStr.toInt();
2370 VISU_Actor* aActor = GetActor(aPrsObject);
2371 if (!aActor) return;
2373 if (!aActor->GetVisibility()) {
2374 aActor->VisibilityOn();
2377 QApplication::setOverrideCursor( Qt::waitCursor );
2379 for (int j=0 ; j<aCycles; j++) {
2380 for (int i=0 ; i<=aSteps; i++) {
2381 float aPercents = float(i)/aSteps;
2382 aPrsObject->SetMapScale(aPercents);
2383 aPrsObject->UpdateActor(aActor);
2384 vf->getRW()->getRenderWindow()->Render();
2388 }catch(std::exception& exc){
2389 INFOS("Follow exception was occured :\n"<<exc.what());
2391 INFOS("Unknown exception was occured!");
2393 QApplication::restoreOverrideCursor();
2398 void VisuGUI::TimeAnimation() {
2399 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2400 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2402 bool isDefined = false;
2404 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2405 for (; It.More(); It.Next()) {
2406 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2407 if (aSObject->_is_nil()) continue;
2408 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2409 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2413 aAnimationDlg->addField(aSObject);
2415 } else if (aNbTimes == aNumber) {
2416 aAnimationDlg->addField(aSObject);
2421 if (isDefined) aAnimationDlg->show();
2422 else delete aAnimationDlg;
2426 void VisuGUI::ImportMedField() {
2427 if (checkLock(GetStudyDocument())) return;
2428 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2429 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2430 QApplication::setOverrideCursor( Qt::waitCursor );
2431 for(;It.More();It.Next()) {
2432 Handle(SALOME_InteractiveObject) anIO = It.Value();
2433 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2434 if(!aSObject->_is_nil()){
2435 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2436 if(!CORBA::is_nil(anObject)){
2437 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2438 if(!CORBA::is_nil(aMED.in()))
2439 GetVisuGen()->ImportMed( aSObject );
2440 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2441 if(!CORBA::is_nil(aField.in()))
2442 GetVisuGen()->ImportMedField( aField );
2444 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2445 SALOMEDS::GenericAttribute_var anAttr;
2446 aSFather->FindAttribute(anAttr, "AttributeName");
2447 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2448 CORBA::String_var aValue = aName->Value();
2449 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2450 GetVisuGen()->ImportMed(aSObject);
2451 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2452 // VisuGUI::myComponent->ImportMed(aSObject);
2456 GetActiveStudy()->updateObjBrowser( true );
2457 QApplication::restoreOverrideCursor();
2460 //=====================================================================================
2461 // functions : Rename()
2463 //=====================================================================================
2464 void VisuGUI::Rename() {
2465 if (checkLock(GetStudyDocument())) return;
2466 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2467 if ( Sel->IObjectCount() != 1 )
2469 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2470 if( aSObj->_is_nil() ) return;
2472 VISU::Curve_i* curve = 0;
2473 CORBA::Object_var anObject = GetSelectedObj();
2474 if ( !CORBA::is_nil( anObject )) {
2475 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2476 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2478 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2479 if( !CORBA::is_nil( aCurve ) ) {
2480 curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2485 //TEST DU PARENT == VISU
2486 SALOMEDS::GenericAttribute_var anAttr;
2487 SALOMEDS::AttributeName_var aName;
2488 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2489 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2490 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2491 if ( !Name.isEmpty() ) {
2492 QApplication::setOverrideCursor( Qt::waitCursor );
2494 curve->SetName( Name.latin1() );
2495 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2496 QApplication::restoreOverrideCursor();
2498 //int TypeMode; bool InViewer;
2499 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2500 //ActorTmp->setName((Standard_CString)Name.latin1());
2505 //=====================================================================================
2506 // functions : RenameTable()
2508 //=====================================================================================
2509 void VisuGUI::RenameTable() {
2510 if (checkLock(GetStudyDocument())) return;
2511 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2512 if ( Sel->IObjectCount() != 1 )
2514 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2515 if( aSObj->_is_nil() ) return;
2517 VISU::Table_i* table = 0;
2518 CORBA::Object_var anObject = GetSelectedObj();
2519 if ( !CORBA::is_nil( anObject )) {
2520 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2521 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2523 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2524 if( !CORBA::is_nil( aTable ) ) {
2525 table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2530 //TEST DU PARENT == VISU
2531 SALOMEDS::GenericAttribute_var anAttr;
2532 SALOMEDS::AttributeName_var aName;
2533 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2534 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2535 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2536 if ( !Name.isEmpty() ) {
2537 QApplication::setOverrideCursor( Qt::waitCursor );
2539 table->SetName( Name.latin1() );
2540 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2541 QApplication::restoreOverrideCursor();
2543 //int TypeMode; bool InViewer;
2544 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2545 //ActorTmp->setName((Standard_CString)Name.latin1());
2552 //=====================================================================================
2553 // functions : RenameContainer()
2555 //=====================================================================================
2556 void VisuGUI::RenameContainer() {
2557 if (checkLock(GetStudyDocument())) return;
2558 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2559 if ( Sel->IObjectCount() != 1 )
2561 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2562 if( aSObj->_is_nil() ) return;
2564 VISU::Container_i* container = 0;
2565 CORBA::Object_var anObject = GetSelectedObj();
2566 if ( !CORBA::is_nil( anObject )) {
2567 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2568 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2570 CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2571 if( !CORBA::is_nil( aContainer ) ) {
2572 container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2577 //TEST DU PARENT == VISU
2578 SALOMEDS::GenericAttribute_var anAttr;
2579 SALOMEDS::AttributeName_var aName;
2580 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2581 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2582 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2583 if ( !Name.isEmpty() ) {
2584 QApplication::setOverrideCursor( Qt::waitCursor );
2586 container->SetName( Name.latin1() );
2587 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2588 QApplication::restoreOverrideCursor();
2590 //int TypeMode; bool InViewer;
2591 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2592 //ActorTmp->setName((Standard_CString)Name.latin1());
2599 //=====================================================================================
2600 // function : CopyPresentation()
2602 //=====================================================================================
2603 void VisuGUI::CopyPresentation(){
2604 if (checkLock(GetStudyDocument())) return;
2605 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2606 if (!aPrsObject) return;
2607 switch (aPrsObject->GetType()) {
2610 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2611 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2612 aSameMesh->SameAs(aMeshPrs);
2613 UpdateViewer(aSameMesh);
2616 case VISU::TSCALARMAP:
2618 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2619 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2620 aSameScalar->SameAs(aScalarPrs);
2621 UpdateViewer(aSameScalar);
2624 case VISU::TDEFORMEDSHAPE:
2626 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2627 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2628 aSameDeformed->SameAs(aDefPrs);
2629 UpdateViewer(aSameDeformed);
2632 case VISU::TCUTPLANES:
2634 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2635 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2636 aSameCut->SameAs(aCutPrs);
2637 UpdateViewer(aSameCut);
2640 case VISU::TCUTLINES:
2642 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2643 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2644 aSameCut->SameAs(aCutPrs);
2645 UpdateViewer(aSameCut);
2648 case VISU::TISOSURFACE:
2650 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2651 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2652 aSameIso->SameAs(aIsoPrs);
2653 UpdateViewer(aSameIso);
2656 case VISU::TSTREAMLINES:
2658 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2659 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2660 aSameLines->SameAs(aLinesPrs);
2661 UpdateViewer(aSameLines);
2664 case VISU::TVECTORS:
2666 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2667 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2668 aSameVectors->SameAs(aVectorsPrs);
2669 UpdateViewer(aSameVectors);
2673 GetActiveStudy()->updateObjBrowser();
2678 //=====================================================================================
2679 // function : DefinePopup()
2681 //=====================================================================================
2682 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2689 //=====================================================================================
2690 // function : checkHomoSelection()
2692 //=====================================================================================
2693 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2694 int VisuGUI::checkHomoSelection()
2696 int selMode = homoNone;
2697 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2698 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2699 for ( ; It.More(); It.Next() ) {
2700 int selNext = homoOther;
2701 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2702 if ( anIO->hasEntry() ) {
2703 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2704 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2705 VISU::Storable::TRestoringMap pMap;
2706 if( !aSObject->_is_nil() ) {
2707 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2708 if ( !CORBA::is_nil( aCORBAObject ) ) {
2709 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2710 if ( !CORBA::is_nil( aVisuObj ) ) {
2711 VISU::VISUType aType = aVisuObj->GetType();
2715 case VISU::TCONTAINER:
2716 selNext = homoCurves; break;
2718 case VISU::TSCALARMAP:
2719 case VISU::TISOSURFACE:
2720 case VISU::TDEFORMEDSHAPE:
2721 case VISU::TCUTPLANES:
2722 case VISU::TCUTLINES:
2723 case VISU::TVECTORS:
2724 case VISU::TSTREAMLINES:
2725 selNext = homoPresentations; break;
2727 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2728 selNext = homoAnimatable; break;
2730 selNext = homoOther; break;
2732 selNext = homoOther;
2737 SALOMEDS::GenericAttribute_var anAttr;
2738 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2739 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2740 string aComm = aComment->Value();
2741 QString strIn( aComm.c_str() );
2742 VISU::Storable::StrToMap( strIn, pMap );
2744 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2750 selNext = homoPresentable; break;
2752 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2753 selNext = homoAnimatable; break;
2755 selNext = homoOther; break;
2757 selNext = homoOther;
2764 if ( selMode == homoNone )
2767 if ( selMode != selNext )
2774 //=====================================================================================
2775 // function : GetNbChildren() [ static ]
2776 // purpose : get number of children
2777 //=====================================================================================
2778 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2780 if ( SO->_is_nil() )
2783 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2784 for ( ; Iter->More(); Iter->Next() ) {
2785 SALOMEDS::SObject_var refSO;
2786 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2792 //=====================================================================================
2793 // function : CustomPopup()
2795 //=====================================================================================
2796 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2797 const QString & theParent, const QString & theObject)
2799 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2801 bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
2803 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2804 SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2805 QString aParentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
2806 int nbSel = aSelection->IObjectCount();
2811 if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
2812 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2816 int selMode = checkHomoSelection();
2817 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2818 if ( selMode == homoCurves ) {
2819 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2820 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2821 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2822 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2825 else if ( selMode == homoPresentations ) {
2827 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2828 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2831 else if ( selMode == homoPresentable ) {
2832 if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2834 else if ( selMode == homoAnimatable ) {
2835 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2839 VISU::Storable::TRestoringMap aMap;
2840 Handle(SALOME_InteractiveObject) anIO;
2841 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2842 if (!CORBA::is_nil(anObject)) {
2843 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2844 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2845 if (!CORBA::is_nil(aVisuObj)) {
2846 VISU::VISUType aType = aVisuObj->GetType();
2847 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2849 case VISU::TVISUGEN:
2850 thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
2851 thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
2852 thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
2856 if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
2860 if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2861 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2862 if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2863 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
2864 thePopup->insertSeparator();
2865 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2866 if ( GetNbChildren( aSObject, false ) > 0 ) {
2867 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2868 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2869 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2872 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2877 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2878 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2880 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2881 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2882 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2884 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2885 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2887 if ( !aIsLocked ) thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2890 case VISU::TCONTAINER:
2891 // if( !CORBA::is_nil( anObject ) ) {
2892 // CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2893 // if( !CORBA::is_nil( aCnt ) ) {
2894 // VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2895 // if ( container ) {
2896 // if ( !aIsLocked ) {
2897 // thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2898 // thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2899 // if (container->GetNbCurves() > 0)
2900 // thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2902 // if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2903 // thePopup->insertSeparator();
2904 // thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2905 // thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2906 // thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2912 thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2913 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2914 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2916 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2917 thePopup->insertSeparator();
2918 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2919 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2920 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2922 if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2925 default: // Presentation
2927 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2930 // Add Presentation menu
2931 if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2932 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2933 int aRepresent = anVISUActor->GetRepresentation();
2936 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2937 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2938 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2939 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2940 if (aType == VISU::TMESH)
2941 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2943 case VISU::WIREFRAME :
2944 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2945 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2946 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2947 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2948 if (aType == VISU::TMESH)
2949 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2952 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2953 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2954 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2955 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2956 if (aType == VISU::TMESH)
2957 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2959 case VISU::INSIDEFRAME :
2960 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2961 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2962 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2963 if (aType == VISU::TMESH)
2964 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2966 case VISU::SURFACEFRAME :
2967 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2968 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2969 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2970 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2973 if(anVISUActor->IsShrunkable())
2974 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2975 if (anVISUActor->IsShrunk())
2976 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2978 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2980 thePopup->insertItem("Representation", aPresMenu);
2983 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2984 if(aType == VISU::TMESH){
2985 if(aRepresent == VISU::SURFACEFRAME){
2986 aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2987 aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2989 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2990 }else if(aType == VISU::TDEFORMEDSHAPE)
2991 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2993 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2994 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2995 if (aType != VISU::TVECTORS){
2996 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2997 thePopup->insertItem("Properties", aPropMenu);
2999 thePopup->insertSeparator();
3002 if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
3003 if (aType != VISU::TMESH) {
3004 //if (aType != VISU::TSCALARMAP)
3005 if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
3007 if (aType == VISU::TCUTLINES) {
3008 // Check: Does it has living children (tables)
3009 SALOMEDS::ChildIterator_var aIter =
3010 GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
3011 bool isPresent = false;
3012 for ( ;aIter->More(); aIter->Next()) {
3013 SALOMEDS::SObject_var aTblObj = aIter->Value();
3014 isPresent = !aTblObj->_is_nil();
3016 SALOMEDS::GenericAttribute_var anAttr;
3017 isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
3018 if (isPresent) break; // We have at least a one child
3021 if ((!isPresent) && (!aIsLocked) )
3022 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
3024 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
3028 if ( theParent == "Viewer" &&
3029 ( aType == VISU::TMESH ||
3030 aType == VISU::TSCALARMAP ||
3031 aType == VISU::TDEFORMEDSHAPE ) ) {
3032 thePopup->insertSeparator();
3033 thePopup->insertItem("Selection info...", visuGUI, SLOT(SelectionInfo()));
3035 thePopup->insertSeparator();
3037 if (visuGUI->IsDisplayed(aPrsObject) ){
3038 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
3041 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
3043 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
3045 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
3046 if ((aType != VISU::TMESH) && (!aIsLocked)) {
3047 thePopup->insertSeparator();
3048 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
3057 // possibly this is the MED field/mesh and support objects
3058 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
3059 if(!CORBA::is_nil(aMED))
3060 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
3061 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
3062 if(!CORBA::is_nil(aField))
3063 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
3064 if ( aParentComponent != parent->getActiveComponent() ) {
3065 //insert pre-defined Display/Erase items
3066 if ( thePopup->count() > 0 ) {
3067 thePopup->insertSeparator();
3069 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3070 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3071 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3076 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
3077 if(!aSObject->_is_nil()){
3079 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
3085 if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3088 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3089 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3091 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3092 // Available only for VTK viewer
3093 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3095 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3096 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3100 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
3101 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3103 case VISU::TTIMESTAMP: {
3104 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3105 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
3106 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3107 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
3108 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3109 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
3110 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3111 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
3112 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
3113 if(aNunComponent > 1){
3114 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
3115 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3116 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
3117 "Vectors...", visuGUI, SLOT(CreateVectors()));
3118 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
3119 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3127 if(IsSObjectTable(aSObject)){
3128 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
3129 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
3130 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
3131 thePopup->insertSeparator();
3132 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3136 CORBA::Long aTag = 1;
3137 SALOMEDS::SObject_var aSubObject;
3138 if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) {
3139 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3143 aSObject = aSObject->GetFather();
3144 if(aSObject->_is_nil()) return false;
3145 SALOMEDS::GenericAttribute_var anAttr;
3146 aSObject->FindAttribute(anAttr, "AttributeName");
3147 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
3148 if(aName->_is_nil()) return false;
3149 CORBA::String_var aValue = aName->Value();
3150 //if(strcmp(aValue.in(),"MEDMESH") == 0)
3151 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
3152 if(strcmp(aValue.in(),"MEDFIELD") == 0)
3153 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
3154 if ( aParentComponent != parent->getActiveComponent() ) {
3155 //insert pre-defined Display/Erase items
3156 if ( thePopup->count() > 0 ) {
3157 thePopup->insertSeparator();
3159 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3160 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3161 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3170 //===========================================================================
3171 // BuildPresentation
3172 //===========================================================================
3173 void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
3176 BEGIN_OF("VisuGUI::BuildPresentation");
3178 if (theIO.IsNull()) {
3179 if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3183 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3184 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3186 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK &&
3187 GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_PLOT2D) return;
3189 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3191 if (aSObj -> _is_nil() ) {
3192 if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3196 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3197 if(!CORBA::is_nil(anObject)) {
3198 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
3200 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3201 if(!SelectedActor) {
3203 SelectedActor = aPrsObject -> CreateActor();
3204 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3205 vf->AddActor(SelectedActor);
3206 }catch(std::runtime_error& exc){
3212 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
3215 PlotTable(aTable, VISU::eDisplay );
3217 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
3220 PlotContainer(aContainer, VISU::eDisplay );
3222 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
3225 PlotCurve(aCurve, VISU::eDisplay );
3228 if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3229 END_OF("VisuGUI::BuildPresentation");
3233 //===========================================================================
3234 // SupportedViewType
3235 //===========================================================================
3236 void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
3238 if (!buffer || !bufferSize) return;
3239 buffer[0] = (int)VIEW_VTK;
3240 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3245 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
3247 visuGUI = new VisuGUI( "" );
3253 //////////////////////////////////////////////////////////////////////////////////
3254 //////////////// CHANGE ACTOR COLOR ////////////////////////
3255 //////////////////////////////////////////////////////////////////////////////////
3256 ///////////////// /////////////////////////////////////////////////////////////////
3257 // change actor color
3258 // In : Name of Actor
3262 void VisuGUI::NewColor(VISU_Actor *theActor){
3263 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3264 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3265 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3266 SALOMEDS::Color anOldColor, aNewColor;
3267 int aRepresent = theActor->GetRepresentation();
3271 anOldColor = aMesh->GetNodeColor();
3273 case VISU::WIREFRAME :
3274 case VISU::INSIDEFRAME :
3275 anOldColor = aMesh->GetLinkColor();
3278 case VISU::SURFACEFRAME :
3279 anOldColor = aMesh->GetCellColor();
3282 else if(aDeformedShape)
3283 anOldColor = aDeformedShape->GetColor();
3286 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3287 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3288 if(aColorNew.isValid()){
3289 aNewColor.R = aColorNew.red()/255.;
3290 aNewColor.G = aColorNew.green()/255.;
3291 aNewColor.B = aColorNew.blue()/255.;
3295 aMesh->SetNodeColor(aNewColor);
3297 case VISU::WIREFRAME :
3298 case VISU::INSIDEFRAME :
3299 aMesh->SetLinkColor(aNewColor);
3302 case VISU::SURFACEFRAME :
3303 aMesh->SetCellColor(aNewColor);
3307 aDeformedShape->SetColor(aNewColor);
3308 RecreateActor(aPrs3d);
3313 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3314 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3315 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3316 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3317 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3318 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3319 if(aColorNew.isValid()){
3320 aNewColor.R = aColorNew.red()/255.;
3321 aNewColor.G = aColorNew.green()/255.;
3322 aNewColor.B = aColorNew.blue()/255.;
3323 aMesh->SetLinkColor(aNewColor);
3324 VisuGUI::RecreateActor(aMesh);
3330 //////////////////////////////////////////////////////////////////////////////////
3331 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3332 //////////////////////////////////////////////////////////////////////////////////
3333 //////////////////////////////////////////////////////////////////////////////////
3334 // change actor opacity
3335 // In : Name of Actor
3337 // Use CursorDlg to select a value between 0 and 100
3340 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3343 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3345 float oldopac,newopac;
3347 CursorDlg->Comment1->setText( tr( "Set value between") );
3348 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3349 oldopac=Actor->GetOpacity();
3350 intopac=int(oldopac*100.+0.5);
3351 CursorDlg->SpinBox1->setMinValue(0);
3352 CursorDlg->SpinBox1->setMaxValue(100);
3353 CursorDlg->SpinBox1->setValue(intopac);
3355 int ret = CursorDlg->exec();
3358 intopac = CursorDlg->SpinBox1->value() ;
3359 newopac = intopac/100.;
3360 Actor->SetOpacity(newopac);
3365 //////////////////////////////////////////////////////////////////////////////////
3366 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3367 //////////////////////////////////////////////////////////////////////////////////
3368 //////////////////////////////////////////////////////////////////////////////////
3369 // change actor linewidth
3370 // In : Name of Actor
3372 // Use CursorDlg to select a value between 0 and 10
3375 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3378 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3380 float oldlwid,newlwid;
3382 CursorDlg->Comment1->setText("Set value between");
3383 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3384 oldlwid=Actor->GetLineWidth();
3385 intlwid=int(oldlwid);
3386 CursorDlg->SpinBox1->setMinValue(1);
3387 CursorDlg->SpinBox1->setMaxValue(10);
3388 CursorDlg->SpinBox1->setValue(intlwid);
3390 int ret = CursorDlg->exec();
3392 intlwid = CursorDlg->SpinBox1->value() ;
3394 Actor->SetLineWidth(newlwid);
3399 /* ======================================================================================== */
3400 /* Setting parameters for Scalar Bar */
3401 /* ======================================================================================== */
3402 void VisuGUI::ChangeScalarBar()
3404 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3405 Scbar->initFromResources();
3406 int ret = Scbar->exec();
3408 Scbar->storeToResources();
3413 /* ======================================================================================== */
3414 /* Setting parameters for Sweeping */
3415 /* ======================================================================================== */
3416 void VisuGUI::SetSweepingPreferences()
3422 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3423 if ( !Tempo.isEmpty() )
3424 tempo = Tempo.toFloat();
3426 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3427 if ( !Cycles.isEmpty() )
3428 cycles = Cycles.toInt();
3430 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3431 if ( !Steps.isEmpty() )
3432 steps = Steps.toInt();
3434 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3436 Sweep->setTimeStep( tempo );
3437 Sweep->setNbCycles( cycles );
3438 Sweep->setNbSteps ( steps );
3440 if ( Sweep->exec() )
3442 tempo = Sweep->getTimeStep();
3443 cycles = Sweep->getNbCycles();
3444 steps = Sweep->getNbSteps();
3446 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3447 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3448 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3453 /* ======================================================================================== */
3454 /* Returns Visu input files directory (default is CSF_PATHData) */
3455 /* ======================================================================================== */
3456 QString VisuGUI::getVisuInputDir()
3458 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3459 if ( Tmp.isEmpty() )
3460 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3461 Tmp = QAD_Tools::addSlash(Tmp);
3465 /* ======================================================================================== */
3466 /* Returns Visu output files directory (default is InputDir) */
3467 /* ======================================================================================== */
3468 QString VisuGUI::getVisuOutputDir()
3470 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3471 if ( Tmp.isEmpty() )
3473 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3474 if ( Tmp2.isEmpty() )
3475 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3479 Tmp = QAD_Tools::addSlash(Tmp);
3484 /* ======================================================================================== */
3485 /* Global Method for Scalar Map */
3486 /* ======================================================================================== */
3487 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3488 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3489 SALOMEDS::SObject_var aSObj = theField->GetFather();
3490 if (CORBA::is_nil(aSObj)) return NULL;
3491 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3492 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3493 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3494 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3495 if(CORBA::is_nil(anObject)) return NULL;
3496 theResult = VISU::Result::_narrow(anObject);
3497 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
3499 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3500 tr ("WRN_NO_AVAILABLE_DATA"),
3501 tr ("VISU_BUT_OK"));
3505 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3506 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3507 const char* theMeshName, VISU::Entity theEntity, \
3508 const char* theFieldName, int theTimeId) {\
3509 VISU::Result_var aResult; \
3510 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3511 if(pResult != NULL){ \
3512 QApplication::setOverrideCursor( Qt::waitCursor ); \
3513 CORBA::Object_var anObject = \
3514 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3515 QApplication::restoreOverrideCursor(); \
3516 if(!CORBA::is_nil(anObject)) \
3517 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
3519 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3520 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3521 tr ("VISU_BUT_OK") ); \
3525 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3526 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3527 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3528 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3529 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3530 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3531 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3534 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3535 bool FNAME(SALOMEDS::SObject_var theField) { \
3536 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3538 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3539 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3540 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3541 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3542 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3543 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3544 Utils_Timer timer; \
3545 if(MYCHECKTIME) timer.Start(); \
3546 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3549 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
3553 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3554 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3555 DLGNAME* aDlg = new DLGNAME(); \
3556 aDlg->initFromPrsObject(pPresent); \
3557 if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
3560 DeletePresentation(pPresent); \
3566 CreateActor(pPresent); \
3574 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3575 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3576 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3577 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3578 //BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3579 //BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3580 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3583 bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
3585 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3587 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3588 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3589 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3590 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3591 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3592 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3594 if(MYCHECKTIME) timer.Start();
3595 VISU::CutPlanes_i* pPresent =
3596 CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
3599 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT");
3603 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3604 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3605 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
3606 aDlg->initFromPrsObject(pPresent);
3608 myActiveDialogBox = aDlg;
3609 // if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
3612 // DeletePresentation(pPresent);
3617 // CreateActor(pPresent);
3621 }catch (...){return false;}
3625 bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
3627 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3629 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3630 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3631 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3632 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3633 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3634 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3636 if(MYCHECKTIME) timer.Start();
3637 VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
3638 (VISU::Entity)anEntity.toInt(),
3639 aFieldName,aTimeStampId.toInt());
3642 MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT");
3646 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3647 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3648 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true);
3649 aDlg->initFromPrsObject(pPresent);
3651 myActiveDialogBox = aDlg;
3653 // if (aDlg->exec()) {
3654 // aDlg->storeToPrsObject(pPresent);
3655 // if (aDlg->isGenerateTable()) {
3656 // GetVisuGen()->CreateTable(pPresent->GetEntry());
3657 // if (aDlg->isGenerateCurves()) {
3658 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3659 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
3660 // if(!aSObject->_is_nil()) {
3661 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
3662 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
3663 // for ( ;aIter->More(); aIter->Next()) {
3664 // SALOMEDS::SObject_var aTblObj = aIter->Value();
3665 // if (!aTblObj->_is_nil()) {
3666 // SALOMEDS::GenericAttribute_var anAttr;
3667 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
3668 // CreatePlot(aTblObj);
3674 // GetActiveStudy()->updateObjBrowser();
3677 // DeletePresentation(pPresent);
3683 // CreateActor(pPresent);
3687 }catch (...){return false; }
3693 /* ======================================================================================== */
3694 /* Global Method to import tables from file */
3695 /* ======================================================================================== */
3696 void VisuGUI::ImportTablesFromFile(){
3697 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3699 flt.append( "Files (*.xls *.txt *.tab)" );
3700 flt.append( "All Files (*.*)" );
3701 QString aDir = getVisuInputDir();
3702 QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3703 aDir,flt,tr("Import From File"),true);
3705 if(aFileInfo.exists()){
3706 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3707 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3708 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3711 CORBA::Object_var anObject;
3717 anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3721 MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE");
3725 if(CORBA::is_nil(anObject)) {
3727 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3728 tr ("ERR_ERROR_IN_THE_FILE"),
3729 tr ("VISU_BUT_OK") );
3733 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3735 GetActiveStudy()->updateObjBrowser(); //update Object browser
3739 void VisuGUI::ExportTableToFile()
3741 QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
3742 SALOME_Selection* aSel = SALOME_Selection::Selection ( aQADStudy -> getSelection() );
3744 if( aSel->IObjectCount() > 0 ) {
3745 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
3746 if(anIO->hasEntry()){
3747 SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
3748 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
3749 if(CORBA::is_nil(aSObj)) return;
3752 SALOMEDS::GenericAttribute_var anAttr;
3754 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3755 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
3756 aSObj = aSObj->GetFather(); //if the current SObject is a table title
3757 // we take a father contaning the table
3758 if (!CORBA::is_nil(aSObj)) {
3759 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3760 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
3765 if (CORBA::is_nil(anAttr)) return;
3767 SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
3768 if (!CORBA::is_nil(aTabAttr))
3769 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3771 SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
3772 if (!CORBA::is_nil(aTabAttr))
3773 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3776 aTitle.simplifyWhiteSpace();
3778 flt.append("Table Files (*.xls)");
3780 QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
3781 aDlg -> setCaption("Export Table To File");
3782 aDlg -> setDir( getVisuOutputDir() );
3783 aDlg -> setFilters(flt);
3784 aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
3786 QString aFile = aDlg -> selectedFile();
3789 if(!aFile.isEmpty()){
3790 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3791 QString aDir = QAD_Tools::getDirFromPath(aFile);
3792 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3795 GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
3796 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3797 } catch(std::exception& ex) {
3799 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3800 tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
3801 tr ("VISU_BUT_OK") );
3803 INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
3804 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3805 tr ("ERR_ERROR_DURING_EXPORT"),
3806 tr ("VISU_BUT_OK") );
3812 /* ======================================================================================== */
3813 /* Global Method to import mesh results in MED and DAT format */
3814 /* ======================================================================================== */
3815 void VisuGUI::ImportFile(){
3816 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
3818 void VisuGUI::CopyAndImportFile(){
3819 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
3821 void VisuGUI::ImportFromFile(TImportFun theImportFun){
3822 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3824 //flt.append( "Exportable Files (*.med *.dat)" );
3825 //flt.append( "Dat Files (*.dat)" );
3826 flt.append( "Med Files (*.med)" );
3827 QString aDir = getVisuInputDir();
3828 QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3829 aDir,flt,tr("Import From File"),true);
3831 if(aFileInfo.exists()){
3832 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3833 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3834 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3837 VISU::Result_var aResult;
3843 QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3844 bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3845 if (VisuGUI_FileDlg::IsBuild){
3846 aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3847 if(!CORBA::is_nil(aResult.in()))
3848 if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
3849 if(!pResult->IsPossible())
3850 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3851 tr ("ERR_CANT_BUILD_PRESENTATION"),
3852 tr ("VISU_BUT_OK") );
3854 aResult->BuildAll();
3857 QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3858 //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
3859 aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1
3860 QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3864 MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
3868 if(CORBA::is_nil(aResult.in())) {
3870 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3871 tr ("ERR_ERROR_IN_THE_FILE"),
3872 tr ("VISU_BUT_OK") );
3876 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3878 GetActiveStudy()->updateObjBrowser(); //update Object browser
3882 void VisuGUI::ExportToFile(){
3883 CORBA::Object_var anObject = GetSelectedObj();
3884 if(CORBA::is_nil(anObject)) return;
3885 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
3886 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3888 flt.append( "Dat Files (*.dat)" );
3889 flt.append( "Med Files (*.med)" );
3890 QString aDir = getVisuOutputDir();
3891 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3892 aDir,flt,tr("Export To File"),false);
3893 if(!aFile.isEmpty()){
3894 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3895 aDir = QAD_Tools::getDirFromPath(aFile);
3896 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3897 if(dynamic_cast<VISU::Result_i*>(aBase)){
3899 //APO - aResult->GetInput()->ToFile(aFile.latin1());
3900 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3901 }catch(std::exception& ex) {
3903 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3904 tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
3905 tr ("VISU_BUT_OK") );
3908 INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
3909 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3910 tr ("ERR_ERROR_DURING_EXPORT"),
3911 tr ("VISU_BUT_OK") );
3916 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3917 tr ("WRN_NO_AVAILABLE_DATA"),
3918 tr ("VISU_BUT_OK"));
3921 /* ======================================================================================== */
3922 /* Test and Read Object Browser before display */
3923 /* ======================================================================================== */
3924 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3925 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3926 Handle(SALOME_InteractiveObject) anIO;
3927 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3928 if(!anIO.IsNull() && anIO->hasEntry()){
3929 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3930 QString aValue = getValue(objVisu,"myType");
3931 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3933 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3934 tr("WRN_NO_AVAILABLE_DATA"),
3935 tr("VISU_BUT_OK") );
3940 * Returns Actor of presentation if it exists
3942 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3943 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3944 if (!vf) return NULL;
3946 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3947 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3948 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3949 if(thePrs == anVISUActor->GetPrs3d())
3950 return anVISUActor->GetParent();
3955 * Displays only actor of given presentation
3956 * Creates it if it is abcent
3958 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3959 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3960 if (!vf) return NULL;
3962 vtkRenderer *aRen = vf->getRenderer();
3963 vtkActorCollection *anActColl = aRen->GetActors();
3966 VISU_Actor* anVISUActor = NULL;
3967 VISU_Actor* aResActor = NULL;
3968 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3969 if(!SALOME_Actor::SafeDownCast(anActor))
3971 if(anActor->IsA("VISU_Actor")){
3972 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3973 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
3974 if(aPrs == NULL) continue;
3975 if (thePrs == aPrs) {
3976 aResActor = anVISUActor->GetParent();
3977 thePrs->UpdateActor(aResActor);
3978 aResActor->VisibilityOn();
3980 } else if (theDispOnly) {
3981 anVISUActor->GetParent()->VisibilityOff();
3984 } else if (theDispOnly && anActor->GetVisibility()) {
3985 anActor->VisibilityOff();
3989 if (aResActor) return aResActor;
3991 anVISUActor = thePrs->CreateActor();
3992 vf->AddActor(anVISUActor);
3993 } catch ( std::runtime_error& exc ){
3995 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3996 tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
3997 tr ("VISU_BUT_OK") );
4005 * Returns TRUE if Presentation is displayed
4007 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
4008 VISU_Actor* anVISUActor = GetActor(thePrs);
4009 return (anVISUActor)? anVISUActor->GetVisibility() : false;
4013 * Erases Presentation
4015 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
4016 GetActiveStudy()->unHighlightAll();
4017 VISU_Actor* anVISUActor = GetActor(thePrs);
4019 anVISUActor->VisibilityOff();
4024 * Deletes given presentation from Data structure
4026 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
4027 if(checkLock(GetStudyDocument()) || !thePrs) return;
4028 GetActiveStudy()->unHighlightAll();
4029 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
4030 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
4031 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
4032 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
4033 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
4034 aViewFrame->RemoveActor(anActor);
4037 aViewFrame->unHighlightAll();
4040 thePrs->RemoveFromStudy();
4041 GetActiveStudy()->updateObjBrowser(); //update Object browser
4045 * Deletes given curve presentation from Data structure
4047 void VisuGUI::DeletePresentation(VISU::Curve_i* theCurve) {
4048 if(checkLock(GetStudyDocument()) || !theCurve) return;
4049 GetActiveStudy()->unHighlightAll();
4050 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
4051 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
4052 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
4053 if(Plot2d_ViewFrame* aViewFrame = dynamic_cast<Plot2d_ViewFrame*>(aVFrame)){
4054 QList<Plot2d_Curve> clist;
4055 aViewFrame->getCurves( clist );
4056 for ( int i = 0; i < clist.count(); i++ ) {
4057 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) )
4058 aViewFrame->eraseCurve( clist.at( i ) );
4060 aViewFrame->Repaint();
4061 aViewFrame->unHighlightAll();
4064 theCurve->RemoveFromStudy();
4065 GetActiveStudy()->updateObjBrowser(); //update Object browser
4069 * Creates new actor of presentation
4071 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
4072 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
4073 if (!thePrs) return;
4074 QApplication::setOverrideCursor( Qt::waitCursor );
4075 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
4081 MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4082 VISU_Actor* aActor = thePrs->CreateActor();
4083 vf->AddActor(aActor);
4084 }catch(std::runtime_error& exc) {
4085 INFOS("std::runtime_error "<<exc.what());
4086 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4087 QApplication::restoreOverrideCursor();
4088 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4089 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
4090 tr ("VISU_BUT_OK") );
4093 MESSAGE(" Unknown exception");
4094 QApplication::restoreOverrideCursor();
4095 INFOS("Unknown exception is caught in VisuGUI::CreateActor");
4096 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4097 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4098 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
4099 tr ("VISU_BUT_OK") );
4104 MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
4108 QApplication::restoreOverrideCursor();
4113 /* ======================================================================================== */
4114 /* Functions to State of VisuGUI and Dialog Box */
4115 /* ======================================================================================== */
4117 void VisuGUI::SetState(int aState )
4119 this->myState = aState ;
4124 void VisuGUI::ResetState()
4126 this->myState = -1 ;
4130 void VisuGUI::EmitSignalDeactivateDialog()
4132 emit this->SignalDeactivateActiveDialog() ;
4136 void VisuGUI::EmitSignalCloseAllDialogs()
4138 emit this->SignalCloseAllDialogs() ;
4142 QDialog* VisuGUI::GetActiveDialogBox()
4144 return this->myActiveDialogBox ;
4147 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
4149 this->myActiveDialogBox = (QDialog*)aDlg ;