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 "Plot2d_SetupPlot2dDlg.h"
91 #include "Plot2d_ViewFrame.h"
92 #include "VTKViewer_ViewFrame.h"
93 #include "VTKViewer_InteractorStyleSALOME.h"
94 #include "VisuGUI_FileDlg.h"
97 #define INCLUDE_MENUITEM_DEF
98 #include <qpopupmenu.h>
100 #include <qpainter.h>
102 #include <qapplication.h>
103 #include <qinputdialog.h>
104 #include <qcolordialog.h>
106 #include <qspinbox.h>
107 #include <qradiobutton.h>
109 #include <qlistbox.h>
110 #include <qcombobox.h>
113 //VRV: porting on Qt 3.0.5
114 #if QT_VERSION >= 0x030005
115 #include <qlistview.h>
117 //VRV: porting on Qt 3.0.5
118 #include <qmessagebox.h>
121 #include CORBA_CLIENT_HEADER(MED_Gen)
123 #include <vtkActor.h>
124 #include <vtkDataSetMapper.h>
126 // Open CASCADE Include
127 #include <TCollection_AsciiString.hxx>
131 static int MYCHECKTIME = 1;
133 static int MYCHECKTIME = 0;
135 #include <Utils_Timer.hxx>
140 static int MYDEBUG = 0;
141 static int MYDEBUGWITHFILES = 0;
143 static int MYDEBUG = 0;
144 static int MYDEBUGWITHFILES = 0;
147 class CustomItem : public QCustomMenuItem{
149 CustomItem( const QString& s, const QFont& f )
150 : string( s ), font( f ){};
153 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
156 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
161 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
168 static VisuGUI MYVISUGUI("");
169 VisuGUI *visuGUI = &MYVISUGUI;
171 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
172 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
173 return VISU::VISU_Gen_i::GetVisuGenImpl();
176 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
177 const char* theActorClassName = "VISU_Actor")
179 vtkRenderer *aRen = theViewFrame->getRenderer();
180 vtkActorCollection *anActColl = aRen->GetActors();
183 int nothingVisible=1;
185 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
186 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
187 // loop through all props
188 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
189 // if it's invisible, or has no geometry, we can skip the rest
190 if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
191 bounds = prop->GetBounds();
192 // make sure we haven't got bogus bounds
193 if ( bounds != NULL &&
194 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
195 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
196 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
199 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
200 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
201 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
202 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
203 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
204 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
208 return nothingVisible;
211 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
212 static float PRECISION = 0.000001;
213 static float DEVIATION = 600;
215 if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
217 float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
219 float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
221 float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
223 CameraOrient aCameraOrient = e3D;
224 if(absX <= PRECISION) aCameraOrient = eFront;
225 else {if(absY <= PRECISION) aCameraOrient = eLeft;
226 else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
228 float dev_abs_XY = absX / absY;
229 float dev_abs_YZ = absY / absZ;
230 float dev_abs_XZ = absX / absZ;
231 if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
232 else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
233 else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
235 switch(aCameraOrient){
236 case eFront: theViewFrame->onViewFront(); break;
237 case eLeft: theViewFrame->onViewLeft(); break;
238 case eTop: theViewFrame->onViewTop(); break;
239 case e3D: theViewFrame->onViewReset(); break;
241 theViewFrame->getRenderer()->ResetCameraClippingRange();
242 theViewFrame->onViewFitAll();
245 QAD_Desktop* VisuGUI::GetDesktop(){
246 return QAD_Application::getDesktop() ;
249 QAD_Study* VisuGUI::GetActiveStudy(){
250 return GetDesktop()->getActiveStudy() ;
253 vtkRenderer* VisuGUI::GetRenderer(){
254 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
255 return aViewFrame->getRenderer();
259 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
260 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
261 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
264 static void UpdateViewFrame() {
265 QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
267 for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
268 if (aStudyFrame->getTypeView() == VIEW_VTK) {
269 QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
270 VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
271 if (!aVtkViewFrame) continue;
272 VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
274 anInteractor->SetSelectionProp();
275 anInteractor->SetSelectionTolerance();
276 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
278 aStyle->setPreselectionProp();
285 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
286 return GetActiveStudy()->getStudyDocument();
289 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
290 return GetStudyDocument()->NewBuilder();
295 * Finds value by given key
298 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
299 VISU::Storable::TRestoringMap aMap;
300 if(!theSObject->_is_nil()){
301 SALOMEDS::GenericAttribute_var anAttr;
302 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
303 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
304 CORBA::String_var aString = aComment->Value();
305 QString strIn(aString.in());
306 VISU::Storable::StrToMap(strIn,aMap);
312 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
314 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
316 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
321 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
322 VISU::Storable::TRestoringMap* pMap = NULL)
324 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
325 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
326 if(aSel->IObjectCount() > 0){
327 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
328 if(pIO != NULL) *pIO = anIO;
329 if(anIO->hasEntry()){
330 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
331 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
332 if(!aSObject->_is_nil()){
333 SALOMEDS::GenericAttribute_var anAttr;
334 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
335 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
336 string aComm = aComment->Value();
337 QString strIn(aComm.c_str());
338 VISU::Storable::StrToMap(strIn,*pMap);
340 return VISU::SObjectToObject(aSObject);
344 return CORBA::Object::_nil();
348 int IsTrihedronDisplayed(){
349 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
350 return aVTKViewFrame->isTrihedronDisplayed();
355 void RepaintCurrentView(){
356 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
360 VisuGUI::VisuGUI( const QString& theName, QObject* theParent ):
361 SALOMEGUI( theName, theParent )
366 /* ==================================================================================== */
367 /* ==================================================================================== */
369 /* ==================================================================================== */
370 /* ==================================================================================== */
372 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
373 return theStudy->GetProperties()->IsLocked();
376 static int checkLock(const SALOMEDS::Study_var& theStudy) {
377 if (isStudyLocked(theStudy)) {
378 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
379 QObject::tr("WRN_WARNING"),
380 QObject::tr("WRN_STUDY_LOCKED"),
381 QObject::tr("BUT_OK") );
389 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
392 QString VisuInputDir = getVisuInputDir();
393 QString VisuOutputDir = getVisuOutputDir();
394 vtkRenderer *theRenderer = GetRenderer();
396 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
397 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
398 SALOMEDS::GenericAttribute_var anAttr;
399 SALOMEDS::AttributeName_var aName;
400 SALOMEDS::AttributeIOR_var anIOR;
402 switch (theCommandID){
403 /* ======================================================================================== */
404 /* Import Table from file */
405 /* ======================================================================================== */
408 if(checkLock(aStudy)) break;
409 visuGUI->ImportTablesFromFile();
413 /* ======================================================================================== */
414 /* Import Mesh from MED, DAT file */
415 /* ======================================================================================== */
419 visuGUI->CopyAndImportFile();
424 visuGUI->ImportFile();
428 /* ======================================================================================== */
429 /* Export results and mesh into a file format */
430 /* ======================================================================================== */
434 //visuGUI->ExportToFile();
438 /* ========================================================================== */
439 /* Visualization of Results : */
440 /* 4011 : Scalar Map */
441 /* 4012 : Deformed Shape */
443 /* 4014 : Iso-Surfaces */
444 /* 4015 : Cut Planes */
445 /* 4016 : Stream Lines */
446 /* ========================================================================== */
449 visuGUI->CreateScalarMap();
452 visuGUI->CreateDeformedShape();
455 visuGUI->CreateVectors();
458 visuGUI->CreateIsoSurfaces();
461 visuGUI->CreateCutPlanes();
464 visuGUI->CreateCutLines();
467 visuGUI->CreateStreamLines();
471 visuGUI->SelectionInfo();
474 /* ========================================================================================================================= */
475 /* Visualization - Wireframe */
476 /* ========================================================================================================================= */
482 /* ========================================================================================================================= */
483 /* Visualization - Surface */
484 /* ========================================================================================================================= */
490 /* ========================================================================================================================= */
491 /* Visualization - Points */
492 /* ========================================================================================================================= */
498 /* ========================================================================================================================= */
499 /* Visualization - Erase */
500 /* ========================================================================================================================= */
506 /* ========================================================================================================================= */
507 /* Visualization - Global */
508 /* ========================================================================================================================= */
512 /* ========================================================================================================================= */
513 /* Visualization - Partial */
514 /* ========================================================================================================================= */
520 //Show dialog that allows to select scale function and corresponding scale factor
521 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
522 FALSE, Qt::WDestructiveClose );
527 /* ============================ */
528 /* POP-UP OBJECTS BROWSER */
529 /* ============================ */
531 case 900 : // Rename object
535 // ---------------- For Popup in Viewer
541 case 803 : // Display only
542 case 903 : // Display only
543 visuGUI->DisplayOnlyPrs();
546 case 901 : // Display
547 visuGUI->DisplayPrs();
550 case 8041 : // Object representation : Wireframe
551 case 9041 : // Object representation : Wireframe
552 visuGUI->ChangeRepresentation(VISU::WIREFRAME);
555 case 8042 : // Object representation : Surface
556 case 9042 : // Object representation : Surface
557 visuGUI->ChangeRepresentation(VISU::SHADED);
560 case 8043 : // Object representation : Points
561 case 9043 : // Object representation : Points
562 visuGUI->ChangeRepresentation(VISU::POINT);
565 case 8044 : // Object representation : Shrink/Unshrink
566 case 9044 : // Object representation : Shrink/Unshrink
567 visuGUI->ChangeRepresentation(VISU::SHRINK);
570 case 8051 : // Change object color
571 case 9051 : // Change object color
572 visuGUI->ChageColor();
575 case 8052 : // Change object opacity
576 case 9052 : // Change object opacity
577 visuGUI->ChangeOpacity();
580 case 8053 : // Change object line width
581 case 9053 : // Change object line width
582 visuGUI->ChangeLines();
585 case 808 : // Sweep IsoSurfaces or Cutplanes
586 case 908 : // Sweep IsoSurfaces or Cutplanes
590 /* ======================================================================================== */
591 /* Preferences for Scalar Bar */
592 /* ======================================================================================== */
599 /* ======================================================================================== */
600 /* Preferences for Sweeping */
601 /* ======================================================================================== */
604 SetSweepingPreferences();
608 /* ======================================================================================== */
609 /* Preferences for Full loading */
610 /* ======================================================================================== */
615 QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
616 bool check = !pp->isItemChecked(theCommandID);
617 pp->setItemChecked(theCommandID,check);
618 switch(theCommandID){
620 QAD_CONFIG->addSetting( "Visu:BuildResult", check );
623 QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
629 case 113: // Load MED using MED component
631 if (checkLock(GetStudyDocument())) break;
633 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
634 if (CORBA::is_nil(aMedComp)) return false;
635 SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
636 if (CORBA::is_nil(aMedGen)) return false;
638 QStringList filtersList ;
640 filtersList.append( tr("MED_MEN_IMPORT_MED") );
641 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
642 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
645 tr("MED_MEN_IMPORT"),
647 if (!aFileName.isEmpty()) {
648 QApplication::setOverrideCursor( Qt::waitCursor );
649 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
650 GetActiveStudy()->updateObjBrowser();
651 QApplication::restoreOverrideCursor();
657 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
658 tr ("MSG_NOT_IMPLEMENTED"),
659 tr ("VISU_BUT_OK") );
662 } catch (const std::bad_alloc& e ) {
663 INFOS("bad_alloc exception is caught "<<e.what());
664 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
665 tr("ERR_NO_MEMORY") + " " + tr(e.what()),
669 catch (std::exception& e){
671 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
674 }catch (const SALOME::SALOME_Exception& S_ex) {
675 INFOS("const SALOME::SALOME_Exception& S_ex");
676 QtCatchCorbaException(S_ex);
680 INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
681 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
682 tr("ERR_UNKNOWN_EXCEPTION"),
689 void VisuGUI::SelectionInfo() {
690 mySelectionDlg = new VisuGUI_SelectionDlg();
691 mySelectionDlg->show();
697 /* ********************************************************************************** */
698 /* Function ShowTrihedron */
699 /* ********************************************************************************** */
701 void VisuGUI::ShowTrihedron(bool ShowThd){
702 bool ThdIsVisible = true;
703 if( ShowThd && !ThdIsVisible)
704 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
705 if( !ShowThd && ThdIsVisible)
706 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
709 /* ********************************************************************************** */
711 /* Clear all tmp files used in VISU */
712 /* ********************************************************************************** */
715 if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
718 /* ********************************************************************************** */
719 /* Function ChangeViewer */
720 /* Change representation of all actors */
721 /* ********************************************************************************** */
723 void VisuGUI::ChangeViewer(int theType){
725 GetActiveStudy()->unHighlightAll();
726 if(vtkRenderer *aRen = GetRenderer()){
728 vtkActorCollection *anActColl = aRen->GetActors();
729 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
730 if(anActor->GetVisibility() > 0)
731 if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){
732 anVISUActor = anVISUActor->GetParent();
734 anVISUActor->SetRepresentation(theType);
736 anVISUActor->VisibilityOff();
739 RepaintCurrentView();
743 // -----------------------------------------------------------------------------------------
745 // -----------------------------------------------------------------------------------------
747 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
752 // ====================================================================================================================
754 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
759 // ===================================================================================================================
761 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
763 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
766 if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
772 if(MYDEBUG) MESSAGE("--> Key : Escape")
784 //=====================================================================================
785 // Slot-functions for presentations creation
786 //=====================================================================================
788 #define CREATEPRESENTATION(FunctionName) \
789 void FunctionName() { \
790 if (checkLock(GetStudyDocument())) return; \
791 SALOMEDS::SObject_var objVisu; \
792 if (!TestObjectBrowser(objVisu)) return; \
793 if(!FunctionName(objVisu)) return; \
794 GetActiveStudy()->updateObjBrowser(); \
795 GetDesktop()->putInfo("Ready"); \
796 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
798 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
799 vf->onViewFitAll(); \
804 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
805 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
806 CREATEPRESENTATION(VisuGUI::CreateVectors);
807 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
808 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
809 CREATEPRESENTATION(VisuGUI::CreateCutLines);
810 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
814 //=====================================================================================
815 // function : SetSettings()
817 //=====================================================================================
818 bool VisuGUI::SetSettings(QAD_Desktop* parent)
822 QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
823 QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
825 if(aValue.isEmpty()? 0 : aValue.toInt())
826 pp->setItemChecked(anId, true);
829 item = parent->menuBar()->findItem(anId,&pp);
830 aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
832 if(aValue.isEmpty()? 0 : aValue.toInt())
833 pp->setItemChecked(anId, true);
836 parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
843 //=====================================================================================
844 // function : DisplayPrs()
846 //=====================================================================================
847 void VisuGUI::DisplayPrs() {
848 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
849 Handle(SALOME_InteractiveObject) anIO;
850 CORBA::Object_var anObject = GetSelectedObj(&anIO);
851 if ( !CORBA::is_nil( anObject ) ) {
852 // is it Prs3d object ?
853 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
855 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
856 UpdateViewer(aPrsObject);
857 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
858 vf->getRenderer()->ResetCameraClippingRange();
860 vf->highlight(anIO, 1);
865 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
867 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
868 PlotCurve(aCurve, VISU::eDisplay );
872 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
874 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
875 PlotContainer(aContainer, VISU::eDisplay );
879 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
881 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
882 PlotTable(aTable, VISU::eDisplay );
888 //=====================================================================================
889 // function : DisplayOnlyPrs()
891 //=====================================================================================
892 void VisuGUI::DisplayOnlyPrs() {
893 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
894 CORBA::Object_var anObject = GetSelectedObj();
895 if ( !CORBA::is_nil( anObject ) ) {
896 // is it Prs3d object ?
897 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
898 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
899 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
900 UpdateViewer(aPrsObject, true);
901 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
903 vf->getRenderer()->ResetCameraClippingRange();
906 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
907 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
908 PlotCurve(aCurve, VISU::eDisplayOnly );
909 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
910 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
911 PlotContainer(aContainer, VISU::eDisplayOnly );
912 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
913 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
914 PlotTable(aTable, VISU::eDisplayOnly );
919 //=====================================================================================
920 // function : ErasePrs()
922 //=====================================================================================
923 void VisuGUI::ErasePrs() {
924 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs");
925 CORBA::Object_var anObject = GetSelectedObj();
926 if ( !CORBA::is_nil( anObject ) ) {
927 // is it Prs3d object ?
928 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
930 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Prs3d object");
931 ErasePrs(aPrsObject);
932 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
938 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
940 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Curve object");
941 PlotCurve(aCurve, VISU::eErase );
944 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
946 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Container object");
947 PlotContainer(aContainer, VISU::eErase );
950 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
952 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Table object");
953 PlotTable(aTable, VISU::eErase );
958 //=====================================================================================
959 // function : DisplayManyPrs()
961 //=====================================================================================
962 void VisuGUI::DisplayManyPrs()
964 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
965 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
966 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
967 for ( ; It.More(); It.Next() ) {
968 Handle(SALOME_InteractiveObject)& anIO = It.Value();
969 if ( anIO->hasEntry() ) {
970 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
971 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
972 VISU::Storable::TRestoringMap pMap;
973 if( !aSObject->_is_nil() ) {
974 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
975 if ( !CORBA::is_nil( aCORBAObject ) ) {
976 // is it Prs3d object ?
977 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
979 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
980 UpdateViewer(aPrsObject);
981 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
983 vf->getRenderer()->ResetCameraClippingRange();
985 vf->highlight(anIO, 1);
990 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
992 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
993 PlotCurve(aCurve, VISU::eDisplay );
997 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
999 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
1000 PlotContainer(aContainer, VISU::eDisplay );
1004 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1006 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
1007 PlotTable(aTable, VISU::eDisplay );
1016 //=====================================================================================
1017 // function : DisplayOnlyManyPrs()
1019 //=====================================================================================
1020 void VisuGUI::DisplayOnlyManyPrs() {
1021 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
1022 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1023 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1024 bool aFirstElem = true;
1025 for ( ; It.More(); It.Next() ) {
1026 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1027 if ( anIO->hasEntry() ) {
1028 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1029 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1030 VISU::Storable::TRestoringMap pMap;
1031 if( !aSObject->_is_nil() ) {
1032 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1033 if ( !CORBA::is_nil( aCORBAObject ) ) {
1034 // is it Prs3d object ?
1035 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1037 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1038 UpdateViewer(aPrsObject, aFirstElem);
1039 if (aFirstElem) aFirstElem = false;
1040 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1042 vf->getRenderer()->ResetCameraClippingRange();
1044 vf->highlight(anIO, 1);
1049 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1051 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1053 PlotCurve(aCurve, VISU::eDisplayOnly );
1056 else PlotCurve(aCurve, VISU::eDisplay );
1059 // is it Container ?
1060 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1062 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1064 PlotContainer(aContainer, VISU::eDisplayOnly );
1067 else PlotContainer(aContainer, VISU::eDisplay );
1071 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1073 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1075 PlotTable(aTable, VISU::eDisplayOnly );
1078 else PlotTable(aTable, VISU::eDisplay );
1088 //=====================================================================================
1089 // function : EraseManyPrs()
1091 //=====================================================================================
1092 void VisuGUI::EraseManyPrs()
1094 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1095 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1096 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1097 SALOME_ListIteratorOfListIO It( LIO );
1098 for ( ; It.More(); It.Next() ) {
1099 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1100 if ( anIO->hasEntry() ) {
1101 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1102 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1103 VISU::Storable::TRestoringMap pMap;
1104 if( !aSObject->_is_nil() ) {
1105 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1106 if ( !CORBA::is_nil( aCORBAObject ) ) {
1107 // is it Prs3d object ?
1108 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1110 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1111 ErasePrs(aPrsObject);
1112 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1119 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1121 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1122 PlotCurve(aCurve, VISU::eErase );
1125 // is it Container ?
1126 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1128 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1129 PlotContainer(aContainer, VISU::eErase );
1133 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1135 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1136 PlotTable(aTable, VISU::eErase );
1145 //=====================================================================================
1146 // function : RecreateActor()
1148 //=====================================================================================
1149 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1150 QApplication::setOverrideCursor(Qt::waitCursor);
1153 //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
1154 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1155 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1156 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1157 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1158 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1159 thePrs->UpdateActor(anActor);
1161 }catch(std::runtime_error& ex){
1163 QApplication::restoreOverrideCursor();
1164 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1165 tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()),
1166 tr ("VISU_BUT_OK") );
1167 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1168 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1169 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1170 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
1171 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
1172 aViewFrame->RemoveActor(anActor);
1179 QApplication::restoreOverrideCursor();
1183 //=====================================================================================
1184 // function : EditPrs()
1186 //=====================================================================================
1187 #define EDITPRS(PrsName, DlgName) \
1189 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1191 DlgName* aDlg = new DlgName(); \
1192 aDlg->initFromPrsObject(aPrsObject); \
1193 if ( aDlg->exec() ) { \
1194 if(!(aDlg->storeToPrsObject(aPrsObject))){ \
1198 RecreateActor(aPrsObject); \
1199 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1200 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1201 vf->getRenderer()->ResetCameraClippingRange(); \
1210 void VisuGUI::EditPrs() {
1211 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1213 switch (aPrs3d->GetType()) {
1214 case VISU::TMESH: // Mesh 13
1217 case VISU::TSCALARMAP: // ScalarMap 18
1218 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1221 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1222 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1225 case VISU::TCUTPLANES: // Cut planes 42
1226 //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1228 VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
1230 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
1231 aDlg->initFromPrsObject(aPrsObject);
1233 myActiveDialogBox = aDlg;
1234 // if ( aDlg->exec() ) {
1235 // if(!(aDlg->storeToPrsObject(aPrsObject))){
1239 // RecreateActor(aPrsObject);
1240 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1241 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1242 // vf->getRenderer()->ResetCameraClippingRange();
1252 case VISU::TCUTLINES: // Cut planes 42
1253 //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1255 VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
1257 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false);
1258 aDlg->initFromPrsObject(aPrsObject);
1260 myActiveDialogBox = aDlg;
1261 // if ( aDlg->exec() ) {
1262 // aDlg->storeToPrsObject(aPrsObject);
1263 // RecreateActor(aPrsObject);
1264 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1265 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1266 // vf->getRenderer()->ResetCameraClippingRange();
1270 // // Remove old Table
1271 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1272 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
1273 // if(!aSObject->_is_nil()) {
1274 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1275 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1276 // for ( ;aIter->More(); aIter->Next()) {
1277 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1278 // if (!aTblObj->_is_nil()) {
1279 // SALOMEDS::GenericAttribute_var anAttr;
1280 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1281 // aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
1286 // if (aDlg->isGenerateTable()) {
1287 // GetVisuGen()->CreateTable(aSObject->GetID());
1288 // if (aDlg->isGenerateCurves()) {
1289 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1290 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1291 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1292 // for ( ;aIter->More(); aIter->Next()) {
1293 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1294 // if (!aTblObj->_is_nil()) {
1295 // SALOMEDS::GenericAttribute_var anAttr;
1296 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1297 // CreatePlot(aTblObj);
1304 // GetActiveStudy()->updateObjBrowser();
1312 case VISU::TISOSURFACE: // Iso surfaces
1313 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1315 case VISU::TVECTORS: // Vectors 64
1316 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1319 case VISU::TSTREAMLINES:
1320 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1326 Handle(SALOME_InteractiveObject) anIO;
1327 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1328 if ( !CORBA::is_nil( anObject ) )
1329 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1330 vf->highlight(anIO, 1);
1334 //=====================================================================================
1335 // function : CreateMesh()
1337 //=====================================================================================
1338 void VisuGUI::CreateMesh() {
1339 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1340 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1342 if (checkLock(GetStudyDocument())) return;
1344 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1345 aSObj = aSObj->GetFather();
1346 aSObj = aSObj->GetFather();
1347 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1348 if(CORBA::is_nil(anObject)) {
1349 aSObj = aSObj->GetFather();
1350 anObject = VISU::SObjectToObject(aSObj);
1352 VISU::Result_var aResult;
1353 if (!CORBA::is_nil(anObject)) {
1354 aResult = VISU::Result::_narrow(anObject);
1356 if(CORBA::is_nil(aResult)) {
1357 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1358 tr ("WRN_NO_AVAILABLE_DATA"),
1359 tr ("VISU_BUT_OK"));
1362 VISU::Storable::TRestoringMap aMap;
1363 SALOMEDS::GenericAttribute_var anAttr;
1364 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1365 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1366 string aComm = aComment->Value();
1367 QString strIn(aComm.c_str());
1368 VISU::Storable::StrToMap(strIn,aMap);
1371 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1372 if(!isExist) return;
1373 CORBA::Object_var aMesh;
1374 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1379 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
1380 if(aComment == "ENTITY"){
1381 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1382 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1383 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1384 }else if(aComment == "FAMILY"){
1385 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1386 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1387 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1388 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1389 }else if(aComment == "GROUP"){
1390 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1391 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1392 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1396 cout<<"VisuGUI::CreateMesh() - CREATE MESH\n";
1400 QApplication::restoreOverrideCursor();
1401 VISU::Mesh_i* pPresent = NULL;
1402 if(!CORBA::is_nil(aMesh))
1403 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1404 if (pPresent == NULL) {
1405 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1406 tr ("ERR_CANT_BUILD_PRESENTATION"),
1407 tr ("VISU_BUT_OK") );
1411 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1413 VISU_Actor *anActor = pPresent->CreateActor();
1418 vf->AddActor(anActor);
1422 cout<<"VisuGUI::CreateMesh() - DISPLAY MESH\n";
1425 //GetActiveStudy()->updateObjBrowser(); //not necessary
1426 GetDesktop()->putInfo("Ready");
1427 }catch(std::runtime_error& exc){
1429 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1430 tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
1431 tr ("VISU_BUT_OK") );
1436 //=====================================================================================
1437 // function : CreateManyMesh()
1439 //=====================================================================================
1440 void VisuGUI::CreateManyMesh(){
1441 if (checkLock(GetStudyDocument())) return;
1443 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1444 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1445 for ( ; It.More(); It.Next() ) {
1446 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1447 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1448 aSObj = aSObj->GetFather();
1449 aSObj = aSObj->GetFather();
1450 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1451 if(CORBA::is_nil(anObject)) {
1452 aSObj = aSObj->GetFather();
1453 anObject = VISU::SObjectToObject(aSObj);
1454 if(CORBA::is_nil(anObject)) return;
1456 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1457 if(CORBA::is_nil(aResult)) return;
1459 VISU::Storable::TRestoringMap aMap;
1460 SALOMEDS::GenericAttribute_var anAttr;
1461 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1462 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1463 string aComm = aComment->Value();
1464 QString strIn(aComm.c_str());
1465 VISU::Storable::StrToMap(strIn,aMap);
1468 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1469 if(!isExist) return;
1470 CORBA::Object_var aMesh;
1471 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1472 if(aComment == "ENTITY"){
1473 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1474 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1475 }else if(aComment == "FAMILY"){
1476 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1477 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1478 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1479 }else if(aComment == "GROUP"){
1480 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1481 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1483 QApplication::restoreOverrideCursor();
1484 if(CORBA::is_nil(aMesh)) return;
1486 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1488 VISU_Actor *anActor = pPresent->CreateActor();
1489 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1490 vf->AddActor(anActor);
1493 GetDesktop()->putInfo("Ready");
1494 }catch(std::runtime_error& exc){
1500 //=====================================================================================
1501 // function : ChangeRepresentation()
1503 //=====================================================================================
1505 static void ShrinkMesh(VISU_Actor *theActor){
1506 if(theActor->IsShrunk())
1507 theActor->UnShrink();
1509 theActor->SetShrink(0.8);
1512 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1513 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1514 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1517 ShrinkMesh(anActor);
1520 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1521 aMesh->SetPresentationType(theType);
1522 RecreateActor(aMesh);
1524 anActor->SetRepresentation(theType);
1526 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1532 void VisuGUI::MakeSurfaceframe() {
1533 ChangeRepresentation(VISU::SURFACEFRAME);
1536 void VisuGUI::MakeInsideframe() {
1537 ChangeRepresentation(VISU::INSIDEFRAME);
1540 void VisuGUI::MakeWireframe() {
1541 ChangeRepresentation(VISU::WIREFRAME);
1544 void VisuGUI::MakeSurface() {
1545 ChangeRepresentation(VISU::SHADED);
1548 void VisuGUI::MakePoints() {
1549 ChangeRepresentation(VISU::POINT);
1552 void VisuGUI::MakeShrink() {
1553 ChangeRepresentation(VISU::SHRINK);
1558 //=====================================================================================
1559 // functions : Change Propertise
1561 //=====================================================================================
1562 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1563 CORBA::Object_var anObject = GetSelectedObj(theIO);
1564 if(CORBA::is_nil(anObject)) return NULL;
1565 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1566 if(!aServant.in()) return NULL;
1567 return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1570 void VisuGUI::ChageColor() {
1571 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1572 if(!aPrsObject) return;
1574 VISU_Actor* anActor = GetActor(aPrsObject);
1575 if (!anActor) return;
1579 void VisuGUI::ChangeWireframeColor() {
1580 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1581 if(!aPrsObject) return;
1583 VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1584 if (!anActor) return;
1585 NewWireframeColor(anActor);
1589 void VisuGUI::ChangeOpacity() {
1590 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1591 if(!aPrsObject) return;
1593 VISU_Actor* anActor = GetActor(aPrsObject);
1594 if (!anActor) return;
1595 NewOpacity(anActor);
1599 void VisuGUI::ChangeLines() {
1600 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1601 if(!aPrsObject) return;
1603 VISU_Actor* anActor = GetActor(aPrsObject);
1604 if (!anActor) return;
1605 NewLinewidth(anActor);
1607 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1609 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1610 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1611 if ( theDisplaying == VISU::eDisplayOnly )
1613 QList<Plot2d_Curve> clist;
1614 aPlot->getCurves( clist );
1615 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1616 if ( !TableSO->_is_nil() ) {
1617 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1618 for ( ; Iter->More(); Iter->Next() ) {
1619 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1620 if( !CORBA::is_nil( childObject ) ) {
1621 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1622 if( !CORBA::is_nil( aCurve ) ) {
1623 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1624 Plot2d_Curve* plotCurve = 0;
1625 for ( int i = 0; i < clist.count(); i++ ) {
1626 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1627 plotCurve = clist.at( i );
1631 if ( theDisplaying == VISU::eErase ) {
1633 aPlot->eraseCurve( plotCurve, false );
1634 clist.remove( plotCurve );
1637 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1639 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1640 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1641 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1642 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1643 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1644 /* - DATA NOT UPDATED */
1645 if ( !plotCurve->isAutoAssign() ) {
1646 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1647 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1648 SALOMEDS::Color color = theCurve->GetColor();
1649 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1650 plotCurve->setAutoAssign( theCurve->IsAuto() );
1652 aPlot->displayCurve( plotCurve, false );
1655 Plot2d_Curve* crv = theCurve->CreatePresentation();
1657 aPlot->displayCurve( crv, false );
1658 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1659 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1660 SALOMEDS::Color newColor;
1661 newColor.R = crv->getColor().red()/255.;
1662 newColor.G = crv->getColor().green()/255.;
1663 newColor.B = crv->getColor().blue()/255.;
1664 theCurve->SetColor( newColor );
1675 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1677 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1678 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1679 // if ( theDisplaying == VISU::eDisplayOnly )
1680 // aPlot->EraseAll();
1681 QList<Plot2d_Curve> clist;
1682 aPlot->getCurves( clist );
1683 Plot2d_Curve* plotCurve = 0;
1684 for ( int i = 0; i < clist.count(); i++ ) {
1685 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1686 plotCurve = clist.at( i );
1688 else if ( theDisplaying == VISU::eDisplayOnly ) {
1689 aPlot->eraseCurve( clist.at( i ) );
1692 if ( theDisplaying == VISU::eErase ) {
1694 aPlot->eraseCurve( plotCurve, false );
1696 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1698 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1699 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1700 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1701 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1702 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1703 /* DATA NOT UPDATED */
1704 if ( !plotCurve->isAutoAssign() ) {
1705 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1706 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1707 SALOMEDS::Color color = theCurve->GetColor();
1708 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1709 plotCurve->setAutoAssign( theCurve->IsAuto() );
1711 aPlot->displayCurve( plotCurve, false );
1714 Plot2d_Curve* crv = theCurve->CreatePresentation();
1716 aPlot->displayCurve( crv, false );
1717 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1718 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1719 SALOMEDS::Color newColor;
1720 newColor.R = crv->getColor().red()/255.;
1721 newColor.G = crv->getColor().green()/255.;
1722 newColor.B = crv->getColor().blue()/255.;
1723 theCurve->SetColor( newColor );
1730 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1732 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1733 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1734 if ( theDisplaying == VISU::eDisplayOnly )
1736 QList<Plot2d_Curve> clist;
1737 aPlot->getCurves( clist );
1738 if ( container->GetNbCurves() > 0 ) {
1739 int nbCurves = container->GetNbCurves();
1740 for ( int k = 1; k <= nbCurves; k++ ) {
1741 VISU::Curve_i* theCurve = container->GetCurve( k );
1742 if ( theCurve && theCurve->IsValid() ) {
1743 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) );
1744 // for ( int i = 0; i < clist.count(); i++ ) {
1745 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1746 // plotCurve = clist.at( i );
1750 if ( theDisplaying == VISU::eErase ) {
1752 aPlot->eraseCurve( plotCurve, false );
1753 clist.remove( plotCurve );
1756 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1758 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1759 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1760 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1761 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1762 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1763 /* - DATA NOT UPDATED */
1764 if ( !plotCurve->isAutoAssign() ) {
1765 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1766 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1767 SALOMEDS::Color color = theCurve->GetColor();
1768 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1769 plotCurve->setAutoAssign( theCurve->IsAuto() );
1771 aPlot->displayCurve( plotCurve, false );
1774 Plot2d_Curve* crv = theCurve->CreatePresentation();
1776 aPlot->displayCurve( crv, false );
1777 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1778 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1779 SALOMEDS::Color newColor;
1780 newColor.R = crv->getColor().red()/255.;
1781 newColor.G = crv->getColor().green()/255.;
1782 newColor.B = crv->getColor().blue()/255.;
1783 theCurve->SetColor( newColor );
1795 Slot : opens Table view : for Table object or SObject with table attribute selected
1797 void VisuGUI::ShowTable() {
1798 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1799 if( Sel->IObjectCount() !=1 )
1801 Handle(SALOME_InteractiveObject) anIO;
1802 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1803 SALOMEDS::SObject_var SO;
1804 if ( !CORBA::is_nil( anObject ) ) {
1805 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1806 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1807 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1808 if( !CORBA::is_nil( aTable ) ) {
1809 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1811 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1816 // possibly this is Table SObject
1817 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1819 SALOMEDS::GenericAttribute_var anAttr;
1820 if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" )
1821 && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) )
1823 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1826 //SAL2670 Orientation of show tables
1827 SALOMEGUI_TableDlg::ttAuto,
1834 Slot : opens Table view : for Table object or SObject with table attribute selected
1836 void VisuGUI::CreateTable() {
1837 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1838 if( aSel->IObjectCount() !=1 )
1841 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1842 if (anIO->hasEntry()){
1843 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1844 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1845 if(!aSObject->_is_nil()) {
1846 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1847 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1848 SALOMEDS::GenericAttribute_var anAttr;
1849 if(!aCutLines->_is_nil() ||
1850 aSObject->FindAttribute( anAttr, "AttributeTableOfInteger") ||
1851 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )) {
1852 GetVisuGen()->CreateTable(aSObject->GetID());
1853 GetActiveStudy()->updateObjBrowser();
1861 Slot : deletes SObject with all subobjects
1863 void VisuGUI::DeleteObject() {
1864 SALOMEDS::Study_var aStudy = GetStudyDocument();
1865 if (checkLock(aStudy)) return;
1867 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1868 if( aSel->IObjectCount() !=1 )
1870 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1871 if (anIO->hasEntry()){
1872 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1873 if(!aSObject->_is_nil()){
1874 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
1875 // There is a transaction
1876 aStudyBuilder->NewCommand();
1877 CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1878 if(!CORBA::is_nil(anObj)){
1879 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1880 if(!CORBA::is_nil(aBase)){
1881 VISU::VISUType aType = aBase->GetType();
1883 case VISU::TRESULT:{
1884 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1885 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1886 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1887 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1888 if(CORBA::is_nil(aChildObj)) continue;
1889 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1890 if(CORBA::is_nil(aPrs3d)) continue;
1891 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1892 DeletePresentation(pPrs3d);
1898 aStudyBuilder->RemoveObjectWithChildren(aSObject);
1899 aStudyBuilder->CommitCommand();
1900 GetActiveStudy()->unHighlightAll();
1901 GetActiveStudy()->updateObjBrowser(true);
1908 Slot : deletes empty container
1910 void VisuGUI::CreatePlot2dView() {
1911 if (checkLock(GetStudyDocument())) return;
1912 GetVisuGen()->CreateContainer();
1913 GetActiveStudy()->updateObjBrowser( true );
1919 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1921 void VisuGUI::PlotData() {
1922 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1923 if( Sel->IObjectCount() !=1 )
1925 CORBA::Object_var anObject = GetSelectedObj();
1926 SALOMEDS::SObject_var SO;
1927 if ( !CORBA::is_nil( anObject ) ) {
1928 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1929 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1930 // Table (VISU object) is selected
1931 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1932 if( !CORBA::is_nil( aTbl ) ) {
1933 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1935 SALOMEDS::GenericAttribute_var anAttr;
1936 SALOMEDS::AttributeName_var aName;
1938 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1939 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
1940 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
1941 // get name of SObject
1942 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1943 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1944 SOName = strdup( aName->Value() );
1946 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1947 if ( dlg->exec() == QDialog::Accepted ) {
1948 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1949 // if study is not locked - create new container, create curves
1950 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1952 QValueList<int> verIndices;
1953 dlg->getCurvesSource( horIndex, verIndices );
1954 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1955 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1956 if( !CORBA::is_nil( aContainer ) ) {
1957 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1959 for ( int i = 0; i < verIndices.count(); i++ ) {
1960 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1961 if( !CORBA::is_nil( aNewCurve ) ) {
1962 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1965 int marker, line, lineWidth;
1967 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1968 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1969 pCrv->SetColor( c );
1970 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1971 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1973 pContainer->AddCurve( pCrv->_this() );
1977 GetActiveStudy()->updateObjBrowser( true );
1978 PlotContainer( pContainer, VISU::eDisplay );
1984 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
1985 Plot2d_CurveContainer container;
1986 dlg->getCurves( container );
1987 if ( !container.isEmpty() ) {
1988 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1989 getRightFrame()->getViewFrame()))->displayCurves( container, true );
1990 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1991 getRightFrame()->getViewFrame()))->setTitle( SOName );
2002 // possibly this is Table SObject
2003 SALOMEDS::GenericAttribute_var anAttr;
2004 SALOMEDS::AttributeName_var aName;
2007 // check if Table SObject is selected
2008 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2009 if ( !SO->_is_nil() &&
2010 ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
2011 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
2012 // get name of SObject
2013 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2014 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2015 SOName = strdup( aName->Value() );
2017 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2018 if ( dlg->exec() == QDialog::Accepted ) {
2019 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2020 // if study is not locked - create new table and container objects, create curves
2021 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2023 QValueList<int> verIndices;
2024 dlg->getCurvesSource( horIndex, verIndices );
2025 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2026 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
2027 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2028 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2029 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2030 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2032 if ( pContainer && pTable ) {
2033 for ( int i = 0; i < verIndices.count(); i++ ) {
2034 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2035 if( !CORBA::is_nil( aNewCurve ) ) {
2036 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2039 int marker, line, lineWidth;
2041 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2042 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2043 pCrv->SetColor( c );
2044 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2045 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2047 pContainer->AddCurve( pCrv->_this() );
2051 GetActiveStudy()->updateObjBrowser( true );
2052 PlotContainer( pContainer, VISU::eDisplay );
2057 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2058 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2059 Plot2d_CurveContainer container;
2060 dlg->getCurves( container );
2061 if ( !container.isEmpty() ) {
2062 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2063 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2064 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2065 getRightFrame()->getViewFrame()))->setTitle( SOName );
2076 void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
2077 SALOMEDS::GenericAttribute_var anAttr;
2078 SALOMEDS::AttributeName_var aName;
2080 if ( !theTableSO->_is_nil() &&
2081 ( theTableSO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
2082 theTableSO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
2083 CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
2084 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2085 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2086 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
2087 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
2089 if ( pContainer && pTable ) {
2090 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
2091 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
2092 if( !CORBA::is_nil( aNewCurve ) ) {
2093 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
2095 pContainer->AddCurve( pCrv->_this() );
2099 GetActiveStudy()->updateObjBrowser( true );
2100 PlotContainer( pContainer, VISU::eDisplay );
2108 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2110 void VisuGUI::CurveProperties() {
2111 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2112 if( Sel->IObjectCount() !=1 )
2114 CORBA::Object_var anObject = GetSelectedObj();
2115 SALOMEDS::SObject_var SO;
2116 if (CORBA::is_nil( anObject )) return;
2118 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2119 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2121 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2122 if( !CORBA::is_nil( aCurve ) ) {
2123 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2124 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2125 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
2126 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2127 dlg->setMarker( (int)curve->GetMarker() );
2128 SALOMEDS::Color color = curve->GetColor();
2129 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2130 if( dlg->exec() == QDialog::Accepted ) {
2131 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2132 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2133 SALOMEDS::Color newColor;
2134 newColor.R = dlg->getColor().red()/255.;
2135 newColor.G = dlg->getColor().green()/255.;
2136 newColor.B = dlg->getColor().blue()/255.;
2137 curve->SetColor( newColor );
2138 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2139 if ( sfList.count() > 0 ) {
2140 QListIterator<QAD_StudyFrame> it( sfList );
2141 for ( ; it.current(); ++it ) {
2142 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2143 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2144 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2147 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2149 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2150 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2151 plotCurve->setColor( dlg->getColor() );
2152 aPlot->updateCurve( plotCurve, true );
2165 Slot : Clears container contents : for Container object selected
2167 void VisuGUI::ClearContainer() {
2168 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2169 if( Sel->IObjectCount() !=1 )
2172 CORBA::Object_var anObject = GetSelectedObj();
2173 SALOMEDS::SObject_var SO;
2174 if (CORBA::is_nil( anObject )) return;
2176 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2177 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2179 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2180 if( !CORBA::is_nil( aCnt ) ) {
2181 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2182 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2184 GetActiveStudy()->updateObjBrowser();
2191 Slot : Edit container contents : for Container object selected
2193 void VisuGUI::EditContainer() {
2194 CORBA::Object_var anObject = GetSelectedObj();
2195 if(CORBA::is_nil(anObject)) return;
2196 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
2197 if(!aServant.in()) return;
2198 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
2199 if(!aContainer) return;
2201 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
2202 aDlg->initFromPrsObject(aContainer);
2204 aDlg->storeToPrsObject(aContainer);
2205 GetActiveStudy()->updateObjBrowser( true );
2211 void VisuGUI::DeletePrs() {
2212 SALOMEDS::Study_var aStudy = GetStudyDocument();
2213 if (checkLock(aStudy)) return;
2215 // There is a transaction
2216 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
2217 aStudyBuilder->NewCommand();
2219 DeletePresentation(GetSelectedPrs3d());
2221 aStudyBuilder->CommitCommand();
2225 void VisuGUI::SaveViewParams()
2227 if (checkLock(GetStudyDocument())) return;
2228 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2229 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2230 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2232 if ( aSel->IObjectCount() == 0 ) {
2233 VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
2235 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2236 VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
2238 GetActiveStudy()->updateObjBrowser( true );
2242 void VisuGUI::RestoreViewParams()
2244 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2245 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2246 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2248 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2249 VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
2253 //=====================================================================================
2254 // function : DeleteViewParams()
2256 //=====================================================================================
2257 void VisuGUI::DeleteViewParams() {
2259 VISU::Storable::TRestoringMap aMap;
2260 Handle(SALOME_InteractiveObject) anIO;
2261 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2262 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2263 if(isExist && aType == VISU::TVIEW3D){
2264 SALOMEDS::Study_var aStudy = GetStudyDocument();
2265 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2266 aStudy->NewBuilder()->RemoveObject(aSObject);
2268 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2269 aSel->RemoveIObject(anIO, 0);
2271 GetActiveStudy()->updateObjBrowser( true );
2276 //=====================================================================================
2277 // function : Sweep()
2279 //=====================================================================================
2280 void VisuGUI::Sweep() {
2281 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2282 if (!aPrsObject) return;
2284 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2288 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2289 if ( !aTempoStr.isEmpty() )
2290 aTemp = int(1.E6*(aTempoStr.toFloat()));
2293 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2294 if ( !aCyclesStr.isEmpty() )
2295 aCycles = aCyclesStr.toInt();
2298 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2299 if ( !aStepsStr.isEmpty() )
2300 aSteps = aStepsStr.toInt();
2302 VISU_Actor* aActor = GetActor(aPrsObject);
2303 if (!aActor) return;
2305 if (!aActor->GetVisibility()) {
2306 aActor->VisibilityOn();
2309 QApplication::setOverrideCursor( Qt::waitCursor );
2311 for (int j=0 ; j<aCycles; j++) {
2312 for (int i=0 ; i<=aSteps; i++) {
2313 float aPercents = float(i)/aSteps;
2314 aPrsObject->SetMapScale(aPercents);
2315 aPrsObject->UpdateActor(aActor);
2316 vf->getRW()->getRenderWindow()->Render();
2320 }catch(std::exception& exc){
2321 INFOS("Follow exception was accured :\n"<<exc.what());
2323 INFOS("Unknown exception was accured!");
2325 QApplication::restoreOverrideCursor();
2330 void VisuGUI::TimeAnimation() {
2331 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2332 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2334 bool isDefined = false;
2336 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2337 for (; It.More(); It.Next()) {
2338 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2339 if (aSObject->_is_nil()) continue;
2340 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2341 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2345 aAnimationDlg->addField(aSObject);
2347 } else if (aNbTimes == aNumber) {
2348 aAnimationDlg->addField(aSObject);
2353 if (isDefined) aAnimationDlg->show();
2354 else delete aAnimationDlg;
2358 void VisuGUI::ImportMedField() {
2359 if (checkLock(GetStudyDocument())) return;
2360 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2361 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2362 QApplication::setOverrideCursor( Qt::waitCursor );
2363 for(;It.More();It.Next()) {
2364 Handle(SALOME_InteractiveObject) anIO = It.Value();
2365 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2366 if(!aSObject->_is_nil()){
2367 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2368 if(!CORBA::is_nil(anObject)){
2369 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2370 if(!CORBA::is_nil(aMED.in()))
2371 GetVisuGen()->ImportMed( aSObject );
2372 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2373 if(!CORBA::is_nil(aField.in()))
2374 GetVisuGen()->ImportMedField( aField );
2376 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2377 SALOMEDS::GenericAttribute_var anAttr;
2378 aSFather->FindAttribute(anAttr, "AttributeName");
2379 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2380 CORBA::String_var aValue = aName->Value();
2381 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2382 GetVisuGen()->ImportMed(aSObject);
2383 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2384 // VisuGUI::myComponent->ImportMed(aSObject);
2388 GetActiveStudy()->updateObjBrowser( true );
2389 QApplication::restoreOverrideCursor();
2392 //=====================================================================================
2393 // functions : Rename()
2395 //=====================================================================================
2396 void VisuGUI::Rename() {
2397 if (checkLock(GetStudyDocument())) return;
2398 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2399 if ( Sel->IObjectCount() != 1 )
2401 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2402 if( aSObj->_is_nil() ) return;
2404 VISU::Curve_i* curve = 0;
2405 CORBA::Object_var anObject = GetSelectedObj();
2406 if ( !CORBA::is_nil( anObject )) {
2407 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2408 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2410 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2411 if( !CORBA::is_nil( aCurve ) ) {
2412 curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2417 //TEST DU PARENT == VISU
2418 SALOMEDS::GenericAttribute_var anAttr;
2419 SALOMEDS::AttributeName_var aName;
2420 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2421 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2422 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2423 if ( !Name.isEmpty() ) {
2424 QApplication::setOverrideCursor( Qt::waitCursor );
2426 curve->SetName( Name.latin1() );
2427 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2428 QApplication::restoreOverrideCursor();
2430 //int TypeMode; bool InViewer;
2431 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2432 //ActorTmp->setName((Standard_CString)Name.latin1());
2437 //=====================================================================================
2438 // functions : RenameTable()
2440 //=====================================================================================
2441 void VisuGUI::RenameTable() {
2442 if (checkLock(GetStudyDocument())) return;
2443 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2444 if ( Sel->IObjectCount() != 1 )
2446 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2447 if( aSObj->_is_nil() ) return;
2449 VISU::Table_i* table = 0;
2450 CORBA::Object_var anObject = GetSelectedObj();
2451 if ( !CORBA::is_nil( anObject )) {
2452 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2453 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2455 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2456 if( !CORBA::is_nil( aTable ) ) {
2457 table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2462 //TEST DU PARENT == VISU
2463 SALOMEDS::GenericAttribute_var anAttr;
2464 SALOMEDS::AttributeName_var aName;
2465 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2466 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2467 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2468 if ( !Name.isEmpty() ) {
2469 QApplication::setOverrideCursor( Qt::waitCursor );
2471 table->SetName( Name.latin1() );
2472 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2473 QApplication::restoreOverrideCursor();
2475 //int TypeMode; bool InViewer;
2476 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2477 //ActorTmp->setName((Standard_CString)Name.latin1());
2484 //=====================================================================================
2485 // functions : RenameContainer()
2487 //=====================================================================================
2488 void VisuGUI::RenameContainer() {
2489 if (checkLock(GetStudyDocument())) return;
2490 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2491 if ( Sel->IObjectCount() != 1 )
2493 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2494 if( aSObj->_is_nil() ) return;
2496 VISU::Container_i* container = 0;
2497 CORBA::Object_var anObject = GetSelectedObj();
2498 if ( !CORBA::is_nil( anObject )) {
2499 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2500 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2502 CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2503 if( !CORBA::is_nil( aContainer ) ) {
2504 container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2509 //TEST DU PARENT == VISU
2510 SALOMEDS::GenericAttribute_var anAttr;
2511 SALOMEDS::AttributeName_var aName;
2512 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2513 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2514 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2515 if ( !Name.isEmpty() ) {
2516 QApplication::setOverrideCursor( Qt::waitCursor );
2518 container->SetName( Name.latin1() );
2519 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2520 QApplication::restoreOverrideCursor();
2522 //int TypeMode; bool InViewer;
2523 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2524 //ActorTmp->setName((Standard_CString)Name.latin1());
2531 //=====================================================================================
2532 // function : CopyPresentation()
2534 //=====================================================================================
2535 void VisuGUI::CopyPresentation(){
2536 if (checkLock(GetStudyDocument())) return;
2537 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2538 if (!aPrsObject) return;
2539 switch (aPrsObject->GetType()) {
2542 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2543 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2544 aSameMesh->SameAs(aMeshPrs);
2545 UpdateViewer(aSameMesh);
2548 case VISU::TSCALARMAP:
2550 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2551 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2552 aSameScalar->SameAs(aScalarPrs);
2553 UpdateViewer(aSameScalar);
2556 case VISU::TDEFORMEDSHAPE:
2558 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2559 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2560 aSameDeformed->SameAs(aDefPrs);
2561 UpdateViewer(aSameDeformed);
2564 case VISU::TCUTPLANES:
2566 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2567 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2568 aSameCut->SameAs(aCutPrs);
2569 UpdateViewer(aSameCut);
2572 case VISU::TCUTLINES:
2574 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2575 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2576 aSameCut->SameAs(aCutPrs);
2577 UpdateViewer(aSameCut);
2580 case VISU::TISOSURFACE:
2582 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2583 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2584 aSameIso->SameAs(aIsoPrs);
2585 UpdateViewer(aSameIso);
2588 case VISU::TSTREAMLINES:
2590 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2591 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2592 aSameLines->SameAs(aLinesPrs);
2593 UpdateViewer(aSameLines);
2596 case VISU::TVECTORS:
2598 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2599 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2600 aSameVectors->SameAs(aVectorsPrs);
2601 UpdateViewer(aSameVectors);
2605 GetActiveStudy()->updateObjBrowser();
2610 //=====================================================================================
2611 // function : DefinePopup()
2613 //=====================================================================================
2614 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2621 //=====================================================================================
2622 // function : checkHomoSelection()
2624 //=====================================================================================
2625 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2626 int VisuGUI::checkHomoSelection()
2628 int selMode = homoNone;
2629 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2630 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2631 for ( ; It.More(); It.Next() ) {
2632 int selNext = homoOther;
2633 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2634 if ( anIO->hasEntry() ) {
2635 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2636 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2637 VISU::Storable::TRestoringMap pMap;
2638 if( !aSObject->_is_nil() ) {
2639 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2640 if ( !CORBA::is_nil( aCORBAObject ) ) {
2641 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2642 if ( !CORBA::is_nil( aVisuObj ) ) {
2643 VISU::VISUType aType = aVisuObj->GetType();
2647 case VISU::TCONTAINER:
2648 selNext = homoCurves; break;
2650 case VISU::TSCALARMAP:
2651 case VISU::TISOSURFACE:
2652 case VISU::TDEFORMEDSHAPE:
2653 case VISU::TCUTPLANES:
2654 case VISU::TCUTLINES:
2655 case VISU::TVECTORS:
2656 case VISU::TSTREAMLINES:
2657 selNext = homoPresentations; break;
2659 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2660 selNext = homoAnimatable; break;
2662 selNext = homoOther; break;
2664 selNext = homoOther;
2669 SALOMEDS::GenericAttribute_var anAttr;
2670 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2671 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2672 string aComm = aComment->Value();
2673 QString strIn( aComm.c_str() );
2674 VISU::Storable::StrToMap( strIn, pMap );
2676 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2682 selNext = homoPresentable; break;
2684 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2685 selNext = homoAnimatable; break;
2687 selNext = homoOther; break;
2689 selNext = homoOther;
2696 if ( selMode == homoNone )
2699 if ( selMode != selNext )
2706 //=====================================================================================
2707 // function : GetNbChildren() [ static ]
2708 // purpose : get number of children
2709 //=====================================================================================
2710 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2712 if ( SO->_is_nil() )
2715 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2716 for ( ; Iter->More(); Iter->Next() ) {
2717 SALOMEDS::SObject_var refSO;
2718 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2724 //=====================================================================================
2725 // function : CustomPopup()
2727 //=====================================================================================
2728 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2729 const QString & theParent, const QString & theObject)
2731 int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2732 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2734 bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
2736 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2738 SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2739 if ( aSelection->IObjectCount() == 0 ) {
2740 if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
2741 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2744 if( aSelection->IObjectCount() > 1 ) {
2745 int selMode = checkHomoSelection();
2746 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2747 if ( selMode == homoCurves ) {
2748 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2749 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2750 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2751 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2754 else if ( selMode == homoPresentations ) {
2756 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2757 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2760 else if ( selMode == homoPresentable ) {
2761 if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2763 else if ( selMode == homoAnimatable ) {
2764 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2768 VISU::Storable::TRestoringMap aMap;
2769 Handle(SALOME_InteractiveObject) anIO;
2770 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2771 if (!CORBA::is_nil(anObject)) {
2772 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2773 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2774 if (!CORBA::is_nil(aVisuObj)) {
2775 VISU::VISUType aType = aVisuObj->GetType();
2776 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2778 case VISU::TVISUGEN:
2779 thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
2780 thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
2781 thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
2785 if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
2789 if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2790 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2791 if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2792 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
2793 thePopup->insertSeparator();
2794 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2795 if ( GetNbChildren( aSObject, false ) > 0 ) {
2796 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2797 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2798 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2801 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2806 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2807 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2809 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2810 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2811 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2813 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2814 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2818 case VISU::TCONTAINER:
2819 // if( !CORBA::is_nil( anObject ) ) {
2820 // CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2821 // if( !CORBA::is_nil( aCnt ) ) {
2822 // VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2823 // if ( container ) {
2824 // if ( !aIsLocked ) {
2825 // thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2826 // thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2827 // if (container->GetNbCurves() > 0)
2828 // thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2830 // if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2831 // thePopup->insertSeparator();
2832 // thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2833 // thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2834 // thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2840 thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2841 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2842 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2844 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2845 thePopup->insertSeparator();
2846 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2847 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2848 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2850 if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2853 default: // Presentation
2855 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2858 // Add Presentation menu
2859 if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2860 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2861 int aRepresent = anVISUActor->GetRepresentation();
2864 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2865 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2866 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2867 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2868 if (aType == VISU::TMESH)
2869 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2871 case VISU::WIREFRAME :
2872 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2873 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2874 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2875 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2876 if (aType == VISU::TMESH)
2877 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2880 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2881 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2882 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2883 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2884 if (aType == VISU::TMESH)
2885 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2887 case VISU::INSIDEFRAME :
2888 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2889 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2890 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2891 if (aType == VISU::TMESH)
2892 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2894 case VISU::SURFACEFRAME :
2895 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2896 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2897 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2898 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2901 if(anVISUActor->GetShrinkable())
2902 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2903 if (anVISUActor->IsShrunk())
2904 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2906 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2908 thePopup->insertItem("Representation", aPresMenu);
2911 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2912 if(aType == VISU::TMESH){
2913 if(aRepresent == VISU::SURFACEFRAME){
2914 aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2915 aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2917 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2918 }else if(aType == VISU::TDEFORMEDSHAPE)
2919 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2921 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2922 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2923 if (aType != VISU::TVECTORS){
2924 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2925 thePopup->insertItem("Properties", aPropMenu);
2927 thePopup->insertSeparator();
2930 if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
2931 if (aType != VISU::TMESH) {
2932 //if (aType != VISU::TSCALARMAP)
2933 if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
2935 if (aType == VISU::TCUTLINES) {
2936 // Check: Does it has living children (tables)
2937 SALOMEDS::ChildIterator_var aIter =
2938 GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
2939 bool isPresent = false;
2940 for ( ;aIter->More(); aIter->Next()) {
2941 SALOMEDS::SObject_var aTblObj = aIter->Value();
2942 isPresent = !aTblObj->_is_nil();
2944 SALOMEDS::GenericAttribute_var anAttr;
2945 isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
2946 if (isPresent) break; // We have at least a one child
2949 if ((!isPresent) && (!aIsLocked) )
2950 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
2952 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
2956 if ( theParent == "Viewer" &&
2957 ( aType == VISU::TMESH ||
2958 aType == VISU::TSCALARMAP ||
2959 aType == VISU::TDEFORMEDSHAPE ) ) {
2960 thePopup->insertSeparator();
2961 thePopup->insertItem("Selection info...", visuGUI, SLOT(SelectionInfo()));
2963 thePopup->insertSeparator();
2965 if (visuGUI->IsDisplayed(aPrsObject) ){
2966 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
2969 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
2971 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
2973 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2974 if ((aType != VISU::TMESH) && (!aIsLocked)) {
2975 thePopup->insertSeparator();
2976 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
2985 // possibly this is the MED field/mesh and support objects
2986 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
2987 if(!CORBA::is_nil(aMED))
2988 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
2989 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2990 if(!CORBA::is_nil(aField))
2991 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
2995 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2996 if(!aSObject->_is_nil()){
2998 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
3004 if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3007 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3008 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3010 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3011 // Available only for VTK viewer
3012 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3014 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3015 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3019 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
3020 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3022 case VISU::TTIMESTAMP: {
3023 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3024 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
3025 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3026 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
3027 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3028 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
3029 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3030 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
3031 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
3032 if(aNunComponent > 1){
3033 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
3034 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3035 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
3036 "Vectors...", visuGUI, SLOT(CreateVectors()));
3037 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
3038 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3045 SALOMEDS::GenericAttribute_var anAttr;
3046 if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
3047 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){
3048 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
3049 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
3050 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
3053 aSObject = aSObject->GetFather();
3054 if(aSObject->_is_nil()) return false;
3055 aSObject->FindAttribute(anAttr, "AttributeName");
3056 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
3057 if(aName->_is_nil()) return false;
3058 CORBA::String_var aValue = aName->Value();
3059 //if(strcmp(aValue.in(),"MEDMESH") == 0)
3060 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
3061 if(strcmp(aValue.in(),"MEDFIELD") == 0)
3062 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
3069 //===========================================================================
3070 // BuildPresentation
3071 //===========================================================================
3072 void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3074 BEGIN_OF("VisuGUI::BuildPresentation");
3076 if (theIO.IsNull()) {
3077 if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3081 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3082 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3084 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
3086 vtkRenderer *Renderer = GetRenderer();
3088 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3090 if (aSObj -> _is_nil() ) {
3091 if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3095 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3096 if(!CORBA::is_nil(anObject)) {
3097 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
3098 if ( !aPrsObject ) {
3099 if(MYDEBUG) MESSAGE("The object is not VISU::Prs3d_i");
3102 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3105 SelectedActor = aPrsObject -> CreateActor();
3106 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3107 vf->AddActor(SelectedActor);
3108 }catch(std::runtime_error& exc){
3113 if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3114 END_OF("VisuGUI::BuildPresentation");
3118 //===========================================================================
3119 // SupportedViewType
3120 //===========================================================================
3121 void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
3123 if (!buffer || !bufferSize) return;
3124 buffer[0] = (int)VIEW_VTK;
3125 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3130 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
3132 visuGUI = new VisuGUI( "" );
3138 //////////////////////////////////////////////////////////////////////////////////
3139 //////////////// CHANGE ACTOR COLOR ////////////////////////
3140 //////////////////////////////////////////////////////////////////////////////////
3141 ///////////////// /////////////////////////////////////////////////////////////////
3142 // change actor color
3143 // In : Name of Actor
3147 void VisuGUI::NewColor(VISU_Actor *theActor){
3148 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3149 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3150 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3151 SALOMEDS::Color anOldColor, aNewColor;
3152 int aRepresent = theActor->GetRepresentation();
3156 anOldColor = aMesh->GetNodeColor();
3158 case VISU::WIREFRAME :
3159 case VISU::INSIDEFRAME :
3160 anOldColor = aMesh->GetLinkColor();
3163 case VISU::SURFACEFRAME :
3164 anOldColor = aMesh->GetCellColor();
3167 else if(aDeformedShape)
3168 anOldColor = aDeformedShape->GetColor();
3171 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3172 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3173 if(aColorNew.isValid()){
3174 aNewColor.R = aColorNew.red()/255.;
3175 aNewColor.G = aColorNew.green()/255.;
3176 aNewColor.B = aColorNew.blue()/255.;
3180 aMesh->SetNodeColor(aNewColor);
3182 case VISU::WIREFRAME :
3183 case VISU::INSIDEFRAME :
3184 aMesh->SetLinkColor(aNewColor);
3187 case VISU::SURFACEFRAME :
3188 aMesh->SetCellColor(aNewColor);
3192 aDeformedShape->SetColor(aNewColor);
3193 RecreateActor(aPrs3d);
3198 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3199 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3200 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3201 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3202 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3203 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3204 if(aColorNew.isValid()){
3205 aNewColor.R = aColorNew.red()/255.;
3206 aNewColor.G = aColorNew.green()/255.;
3207 aNewColor.B = aColorNew.blue()/255.;
3208 aMesh->SetLinkColor(aNewColor);
3209 VisuGUI::RecreateActor(aMesh);
3215 //////////////////////////////////////////////////////////////////////////////////
3216 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3217 //////////////////////////////////////////////////////////////////////////////////
3218 //////////////////////////////////////////////////////////////////////////////////
3219 // change actor opacity
3220 // In : Name of Actor
3222 // Use CursorDlg to select a value between 0 and 100
3225 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3228 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3230 float oldopac,newopac;
3232 CursorDlg->Comment1->setText( tr( "Set value between") );
3233 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3234 oldopac=Actor->GetOpacity();
3235 intopac=int(oldopac*100.+0.5);
3236 CursorDlg->SpinBox1->setMinValue(0);
3237 CursorDlg->SpinBox1->setMaxValue(100);
3238 CursorDlg->SpinBox1->setValue(intopac);
3240 int ret = CursorDlg->exec();
3243 intopac = CursorDlg->SpinBox1->value() ;
3244 newopac = intopac/100.;
3245 Actor->SetOpacity(newopac);
3250 //////////////////////////////////////////////////////////////////////////////////
3251 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3252 //////////////////////////////////////////////////////////////////////////////////
3253 //////////////////////////////////////////////////////////////////////////////////
3254 // change actor linewidth
3255 // In : Name of Actor
3257 // Use CursorDlg to select a value between 0 and 10
3260 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3263 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3265 float oldlwid,newlwid;
3267 CursorDlg->Comment1->setText("Set value between");
3268 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3269 oldlwid=Actor->GetLineWidth();
3270 intlwid=int(oldlwid);
3271 CursorDlg->SpinBox1->setMinValue(1);
3272 CursorDlg->SpinBox1->setMaxValue(10);
3273 CursorDlg->SpinBox1->setValue(intlwid);
3275 int ret = CursorDlg->exec();
3277 intlwid = CursorDlg->SpinBox1->value() ;
3279 Actor->SetLineWidth(newlwid);
3284 /* ======================================================================================== */
3285 /* Setting parameters for Scalar Bar */
3286 /* ======================================================================================== */
3287 void VisuGUI::ChangeScalarBar()
3289 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3290 Scbar->initFromResources();
3291 int ret = Scbar->exec();
3293 Scbar->storeToResources();
3298 /* ======================================================================================== */
3299 /* Setting parameters for Sweeping */
3300 /* ======================================================================================== */
3301 void VisuGUI::SetSweepingPreferences()
3307 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3308 if ( !Tempo.isEmpty() )
3309 tempo = Tempo.toFloat();
3311 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3312 if ( !Cycles.isEmpty() )
3313 cycles = Cycles.toInt();
3315 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3316 if ( !Steps.isEmpty() )
3317 steps = Steps.toInt();
3319 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3321 Sweep->setTimeStep( tempo );
3322 Sweep->setNbCycles( cycles );
3323 Sweep->setNbSteps ( steps );
3325 if ( Sweep->exec() )
3327 tempo = Sweep->getTimeStep();
3328 cycles = Sweep->getNbCycles();
3329 steps = Sweep->getNbSteps();
3331 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3332 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3333 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3338 /* ======================================================================================== */
3339 /* Returns Visu input files directory (default is CSF_PATHData) */
3340 /* ======================================================================================== */
3341 QString VisuGUI::getVisuInputDir()
3343 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3344 if ( Tmp.isEmpty() )
3345 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3346 Tmp = QAD_Tools::addSlash(Tmp);
3350 /* ======================================================================================== */
3351 /* Returns Visu output files directory (default is InputDir) */
3352 /* ======================================================================================== */
3353 QString VisuGUI::getVisuOutputDir()
3355 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3356 if ( Tmp.isEmpty() )
3358 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3359 if ( Tmp2.isEmpty() )
3360 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3364 Tmp = QAD_Tools::addSlash(Tmp);
3369 /* ======================================================================================== */
3370 /* Global Method for Scalar Map */
3371 /* ======================================================================================== */
3372 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3373 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3374 SALOMEDS::SObject_var aSObj = theField->GetFather();
3375 if (CORBA::is_nil(aSObj)) return NULL;
3376 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3377 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3378 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3379 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3380 if(CORBA::is_nil(anObject)) return NULL;
3381 theResult = VISU::Result::_narrow(anObject);
3382 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
3384 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3385 tr ("WRN_NO_AVAILABLE_DATA"),
3386 tr ("VISU_BUT_OK"));
3390 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3391 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3392 const char* theMeshName, VISU::Entity theEntity, \
3393 const char* theFieldName, int theTimeId) {\
3394 VISU::Result_var aResult; \
3395 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3396 if(pResult != NULL){ \
3397 QApplication::setOverrideCursor( Qt::waitCursor ); \
3398 CORBA::Object_var anObject = \
3399 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3400 QApplication::restoreOverrideCursor(); \
3401 if(!CORBA::is_nil(anObject)) \
3402 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
3404 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3405 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3406 tr ("VISU_BUT_OK") ); \
3410 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3411 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3412 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3413 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3414 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3415 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3416 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3419 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3420 bool FNAME(SALOMEDS::SObject_var theField) { \
3421 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3423 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3424 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3425 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3426 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3427 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3428 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3429 Utils_Timer timer; \
3430 if(MYCHECKTIME) timer.Start(); \
3431 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3434 cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n"; \
3438 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3439 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3440 DLGNAME* aDlg = new DLGNAME(); \
3441 aDlg->initFromPrsObject(pPresent); \
3442 if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
3445 DeletePresentation(pPresent); \
3451 CreateActor(pPresent); \
3459 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3460 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3461 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3462 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3463 //BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3464 //BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3465 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3468 bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
3470 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3472 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3473 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3474 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3475 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3476 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3477 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3479 if(MYCHECKTIME) timer.Start();
3480 VISU::CutPlanes_i* pPresent =
3481 CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
3484 cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n";
3488 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3489 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3490 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
3491 aDlg->initFromPrsObject(pPresent);
3493 myActiveDialogBox = aDlg;
3494 // if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
3497 // DeletePresentation(pPresent);
3502 // CreateActor(pPresent);
3506 }catch (...){return false;}
3510 bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
3512 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3514 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3515 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3516 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3517 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3518 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3519 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3521 if(MYCHECKTIME) timer.Start();
3522 VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
3523 (VISU::Entity)anEntity.toInt(),
3524 aFieldName,aTimeStampId.toInt());
3527 cout<<"BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT\n";
3531 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3532 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3533 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true);
3534 aDlg->initFromPrsObject(pPresent);
3536 myActiveDialogBox = aDlg;
3538 // if (aDlg->exec()) {
3539 // aDlg->storeToPrsObject(pPresent);
3540 // if (aDlg->isGenerateTable()) {
3541 // GetVisuGen()->CreateTable(pPresent->GetEntry());
3542 // if (aDlg->isGenerateCurves()) {
3543 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3544 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
3545 // if(!aSObject->_is_nil()) {
3546 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
3547 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
3548 // for ( ;aIter->More(); aIter->Next()) {
3549 // SALOMEDS::SObject_var aTblObj = aIter->Value();
3550 // if (!aTblObj->_is_nil()) {
3551 // SALOMEDS::GenericAttribute_var anAttr;
3552 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
3553 // CreatePlot(aTblObj);
3559 // GetActiveStudy()->updateObjBrowser();
3562 // DeletePresentation(pPresent);
3568 // CreateActor(pPresent);
3572 }catch (...){return false; }
3578 /* ======================================================================================== */
3579 /* Global Method to import tables from file */
3580 /* ======================================================================================== */
3581 void VisuGUI::ImportTablesFromFile(){
3582 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3584 flt.append( "Files (*.xls *.txt *.tab)" );
3585 flt.append( "All Files (*.*)" );
3586 QString aDir = getVisuInputDir();
3587 QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3588 aDir,flt,tr("Import From File"),true);
3590 if(aFileInfo.exists()){
3591 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3592 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3593 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3596 CORBA::Object_var anObject;
3602 anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3606 cout<<"VisuGUI::ImportTablesFromFile() - IMPORT FILE\n";
3610 if(CORBA::is_nil(anObject)) {
3612 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3613 tr ("ERR_ERROR_IN_THE_FILE"),
3614 tr ("VISU_BUT_OK") );
3618 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3620 GetActiveStudy()->updateObjBrowser(); //update Object browser
3624 void VisuGUI::ExportTableToFile()
3626 QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
3627 SALOME_Selection* aSel = SALOME_Selection::Selection ( aQADStudy -> getSelection() );
3629 if( aSel->IObjectCount() > 0 ) {
3630 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
3631 if(anIO->hasEntry()){
3632 SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
3633 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
3634 if(CORBA::is_nil(aSObj)) return;
3637 SALOMEDS::GenericAttribute_var anAttr;
3639 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3640 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
3641 aSObj = aSObj->GetFather(); //if the current SObject is a table title
3642 // we take a father contaning the table
3643 if (!CORBA::is_nil(aSObj)) {
3644 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3645 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
3650 if (CORBA::is_nil(anAttr)) return;
3652 SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
3653 if (!CORBA::is_nil(aTabAttr))
3654 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3656 SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
3657 if (!CORBA::is_nil(aTabAttr))
3658 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3661 aTitle.simplifyWhiteSpace();
3663 flt.append("Table Files (*.xls)");
3665 QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
3666 aDlg -> setCaption("Export Table To File");
3667 aDlg -> setDir( getVisuOutputDir() );
3668 aDlg -> setFilters(flt);
3669 aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
3671 QString aFile = aDlg -> selectedFile();
3674 if(!aFile.isEmpty()){
3675 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3676 QString aDir = QAD_Tools::getDirFromPath(aFile);
3677 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3680 GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
3681 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3682 } catch(std::exception& ex) {
3684 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3685 tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
3686 tr ("VISU_BUT_OK") );
3688 INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
3689 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3690 tr ("ERR_ERROR_DURING_EXPORT"),
3691 tr ("VISU_BUT_OK") );
3697 /* ======================================================================================== */
3698 /* Global Method to import mesh results in MED and DAT format */
3699 /* ======================================================================================== */
3700 void VisuGUI::ImportFile(){
3701 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
3703 void VisuGUI::CopyAndImportFile(){
3704 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
3706 void VisuGUI::ImportFromFile(TImportFun theImportFun){
3707 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3709 //flt.append( "Exportable Files (*.med *.dat)" );
3710 //flt.append( "Dat Files (*.dat)" );
3711 flt.append( "Med Files (*.med)" );
3712 QString aDir = getVisuInputDir();
3713 QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3714 aDir,flt,tr("Import From File"),true);
3716 if(aFileInfo.exists()){
3717 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3718 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3719 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3722 VISU::Result_var aResult;
3728 if(aFileInfo.extension(false) == "med"){
3729 QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3730 bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3731 if (VisuGUI_FileDlg::IsBuild){
3732 aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3733 if(!CORBA::is_nil(aResult.in()))
3734 if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
3735 if(!pResult->IsPossible())
3736 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3737 tr ("ERR_CANT_BUILD_PRESENTATION"),
3738 tr ("VISU_BUT_OK") );
3740 aResult->BuildAll();
3743 QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3744 //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
3745 aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1
3746 QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3751 cout<<"VisuGUI::ImportFromFile() - IMPORT FILE\n";
3755 if(CORBA::is_nil(aResult.in())) {
3757 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3758 tr ("ERR_ERROR_IN_THE_FILE"),
3759 tr ("VISU_BUT_OK") );
3763 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3765 GetActiveStudy()->updateObjBrowser(); //update Object browser
3769 void VisuGUI::ExportToFile(){
3770 CORBA::Object_var anObject = GetSelectedObj();
3771 if(CORBA::is_nil(anObject)) return;
3772 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
3773 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3775 flt.append( "Dat Files (*.dat)" );
3776 flt.append( "Med Files (*.med)" );
3777 QString aDir = getVisuOutputDir();
3778 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3779 aDir,flt,tr("Export To File"),false);
3780 if(!aFile.isEmpty()){
3781 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3782 aDir = QAD_Tools::getDirFromPath(aFile);
3783 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3784 if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3786 //APO - aResult->GetInput()->ToFile(aFile.latin1());
3787 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3788 }catch(std::exception& ex) {
3790 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3791 tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
3792 tr ("VISU_BUT_OK") );
3795 INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
3796 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3797 tr ("ERR_ERROR_DURING_EXPORT"),
3798 tr ("VISU_BUT_OK") );
3803 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3804 tr ("WRN_NO_AVAILABLE_DATA"),
3805 tr ("VISU_BUT_OK"));
3808 /* ======================================================================================== */
3809 /* Test and Read Object Browser before display */
3810 /* ======================================================================================== */
3811 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3812 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3813 Handle(SALOME_InteractiveObject) anIO;
3814 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3815 if(!anIO.IsNull() && anIO->hasEntry()){
3816 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3817 QString aValue = getValue(objVisu,"myType");
3818 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3820 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3821 tr("WRN_NO_AVAILABLE_DATA"),
3822 tr("VISU_BUT_OK") );
3827 * Returns Actor of presentation if it exists
3829 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3830 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3831 if (!vf) return NULL;
3833 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3834 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3835 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3836 if(thePrs == anVISUActor->GetPrs3d())
3837 return anVISUActor->GetParent();
3842 * Displays only actor of given presentation
3843 * Creates it if it is abcent
3845 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3846 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3847 if (!vf) return NULL;
3849 vtkRenderer *aRen = vf->getRenderer();
3850 vtkActorCollection *anActColl = aRen->GetActors();
3853 VISU_Actor* anVISUActor = NULL;
3854 VISU_Actor* aResActor = NULL;
3855 VISU::Prs3d_i* aSrcAddr = thePrs;
3856 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3857 if(anActor->IsA("VISU_Actor")){
3858 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3859 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
3860 if(aPrs == NULL) continue;
3861 if (thePrs == aPrs) {
3862 aResActor = anVISUActor->GetParent();
3863 thePrs->UpdateActor(aResActor);
3864 aResActor->VisibilityOn();
3866 } else if (theDispOnly) {
3867 anVISUActor->GetParent()->VisibilityOff();
3871 if (aResActor) return aResActor;
3873 anVISUActor = thePrs->CreateActor();
3874 vf->AddActor(anVISUActor);
3875 } catch ( std::runtime_error& exc ){
3877 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3878 tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
3879 tr ("VISU_BUT_OK") );
3887 * Returns TRUE if Presentation is displayed
3889 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
3890 VISU_Actor* anVISUActor = GetActor(thePrs);
3891 return (anVISUActor)? anVISUActor->GetVisibility() : false;
3895 * Erases Presentation
3897 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
3898 GetActiveStudy()->unHighlightAll();
3899 VISU_Actor* anVISUActor = GetActor(thePrs);
3901 anVISUActor->VisibilityOff();
3906 * Deletes given presentation from Data structure
3908 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
3909 if(checkLock(GetStudyDocument()) || !thePrs) return;
3910 GetActiveStudy()->unHighlightAll();
3911 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
3912 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
3913 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
3914 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
3915 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
3916 aViewFrame->RemoveActor(anActor);
3919 aViewFrame->unHighlightAll();
3922 thePrs->RemoveFromStudy();
3923 GetActiveStudy()->updateObjBrowser(); //update Object browser
3927 * Creates new actor of presentation
3929 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
3930 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
3931 if (!thePrs) return;
3932 QApplication::setOverrideCursor( Qt::waitCursor );
3933 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
3939 MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
3940 VISU_Actor* aActor = thePrs->CreateActor();
3941 vf->AddActor(aActor);
3942 }catch(std::runtime_error& exc) {
3943 INFOS("std::runtime_error "<<exc.what());
3944 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
3945 QApplication::restoreOverrideCursor();
3946 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3947 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
3948 tr ("VISU_BUT_OK") );
3951 cout<<" Unknown exception"<<endl;
3952 QApplication::restoreOverrideCursor();
3953 INFOS("Unknown exception is caught in VisuGUI::CreateActor");
3954 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
3955 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3956 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
3957 tr ("VISU_BUT_OK") );
3962 cout<<"VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR\n";
3966 QApplication::restoreOverrideCursor();
3971 /* ======================================================================================== */
3972 /* Functions to State of VisuGUI and Dialog Box */
3973 /* ======================================================================================== */
3975 void VisuGUI::SetState(int aState )
3977 this->myState = aState ;
3982 void VisuGUI::ResetState()
3984 this->myState = -1 ;
3988 void VisuGUI::EmitSignalDeactivateDialog()
3990 emit this->SignalDeactivateActiveDialog() ;
3994 void VisuGUI::EmitSignalCloseAllDialogs()
3996 emit this->SignalCloseAllDialogs() ;
4000 QDialog* VisuGUI::GetActiveDialogBox()
4002 return this->myActiveDialogBox ;
4005 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
4007 this->myActiveDialogBox = (QDialog*)aDlg ;