1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 // Author : Laurent CORNABE
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_PrsObject_i.hh"
34 #include "VISU_ViewManager_i.hh"
36 #include "VISU_PipeLine.hxx"
38 #include "VISU_Prs3d_i.hh"
39 #include "VISU_Mesh_i.hh"
40 #include "VISU_ScalarMap_i.hh"
41 #include "VISU_IsoSurfaces_i.hh"
42 #include "VISU_DeformedShape_i.hh"
43 #include "VISU_CutPlanes_i.hh"
44 #include "VISU_CutLines_i.hh"
45 #include "VISU_Vectors_i.hh"
46 #include "VISU_StreamLines_i.hh"
47 #include "VISU_Table_i.hh"
49 #include "VISU_Actor.h"
50 #include "VISU_MeshAct.h"
52 #include "VisuGUI_MagnitudeDlg.h"
53 #include "VisuGUI_CursorDlg.h"
54 #include "VisuGUI_ScalarBarDlg.h"
55 #include "VisuGUI_SweepPrefDlg.h"
56 #include "VisuGUI_CutPlanesDlg.h"
57 #include "VisuGUI_CutLinesDlg.h"
58 #include "VisuGUI_VectorsDlg.h"
59 #include "VisuGUI_IsoSurfacesDlg.h"
60 #include "VisuGUI_StreamLinesDlg.h"
61 #include "VisuGUI_EditContainerDlg.h"
62 #include "VisuGUI_TimeAnimation.h"
64 #include "VisuGUI_Selection.h"
65 #include "VisuGUI_NonIsometricDlg.h"
67 #include "SALOMEGUI_ImportOperation.h"
68 #include "SALOMEGUI_QtCatchCorbaException.hxx"
69 #include "utilities.h"
71 #include "QAD_Config.h"
73 #include "QAD_Settings.h"
74 #include "QAD_Tools.h"
75 #include "QAD_LeftFrame.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_ObjectBrowser.h"
79 #include "QAD_ObjectBrowserItem.h"
80 #include "QAD_Menus.h"
81 #include "QAD_Resource.h"
82 #include "QAD_ResourceMgr.h"
83 #include "QAD_FileDlg.h"
84 #include "QAD_WaitCursor.h"
85 #include "SALOME_Selection.h"
86 #include "SALOMEGUI_NameDlg.h"
87 #include "SALOMEGUI_TableDlg.h"
88 #include "SALOMEGUI_SetupCurveDlg.h"
89 #include "SALOMEGUI_SetValueDlg.h"
90 #include "SALOMEGUI_Desktop.h"
91 #include "Plot2d_SetupPlot2dDlg.h"
92 #include "Plot2d_ViewFrame.h"
93 #include "VTKViewer_ViewFrame.h"
94 #include "VTKViewer_RenderWindow.h"
95 #include "VTKViewer_InteractorStyleSALOME.h"
96 #include "VTKViewer_RenderWindowInteractor.h"
97 #include "VisuGUI_FileDlg.h"
100 #define INCLUDE_MENUITEM_DEF
101 #include <qpopupmenu.h>
103 #include <qpainter.h>
105 #include <qapplication.h>
106 #include <qinputdialog.h>
107 #include <qcolordialog.h>
109 #include <qspinbox.h>
110 #include <qradiobutton.h>
112 #include <qlistbox.h>
113 #include <qcombobox.h>
116 //VRV: porting on Qt 3.0.5
117 #if QT_VERSION >= 0x030005
118 #include <qlistview.h>
120 //VRV: porting on Qt 3.0.5
121 #include <qmessagebox.h>
124 #include CORBA_CLIENT_HEADER(MED_Gen)
126 #include <vtkActor.h>
127 #include <vtkRenderer.h>
128 #include <vtkDataSetMapper.h>
129 #include <vtkActorCollection.h>
131 // Open CASCADE Include
132 #include <TCollection_AsciiString.hxx>
136 static int MYCHECKTIME = 1;
138 static int MYCHECKTIME = 0;
140 #include <Utils_Timer.hxx>
145 static int MYDEBUG = 0;
146 static int MYDEBUGWITHFILES = 0;
148 static int MYDEBUG = 0;
149 static int MYDEBUGWITHFILES = 0;
152 class CustomItem : public QCustomMenuItem{
154 CustomItem( const QString& s, const QFont& f )
155 : string( s ), font( f ){};
158 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
161 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
166 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
174 inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
175 if(!theSObject->_is_nil()) {
176 SALOMEDS::GenericAttribute_var anAttr;
177 if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
179 if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
186 static VisuGUI MYVISUGUI;
187 VisuGUI *visuGUI = &MYVISUGUI;
189 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
190 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
191 return VISU::VISU_Gen_i::GetVisuGenImpl();
194 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
195 const char* theActorClassName = "VISU_Actor")
197 vtkRenderer *aRen = theViewFrame->getRenderer();
198 vtkActorCollection *anActColl = aRen->GetActors();
201 int nothingVisible=1;
203 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
204 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
205 // loop through all props
206 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
207 // if it's invisible, or has no geometry, we can skip the rest
208 if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
209 bounds = prop->GetBounds();
210 // make sure we haven't got bogus bounds
211 if ( bounds != NULL &&
212 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
213 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
214 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
217 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
218 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
219 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
220 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
221 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
222 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
226 return nothingVisible;
229 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
230 static float PRECISION = 0.000001;
231 static float DEVIATION = 600;
233 if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
235 float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
237 float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
239 float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
241 CameraOrient aCameraOrient = e3D;
242 if(absX <= PRECISION) aCameraOrient = eFront;
243 else {if(absY <= PRECISION) aCameraOrient = eLeft;
244 else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
246 float dev_abs_XY = absX / absY;
247 float dev_abs_YZ = absY / absZ;
248 float dev_abs_XZ = absX / absZ;
249 if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
250 else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
251 else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
253 switch(aCameraOrient){
254 case eFront: theViewFrame->onViewFront(); break;
255 case eLeft: theViewFrame->onViewLeft(); break;
256 case eTop: theViewFrame->onViewTop(); break;
257 case e3D: theViewFrame->onViewReset(); break;
259 theViewFrame->getRenderer()->ResetCameraClippingRange();
260 theViewFrame->onViewFitAll();
261 return aCameraOrient;
264 QAD_Desktop* VisuGUI::GetDesktop(){
265 return QAD_Application::getDesktop() ;
268 QAD_Study* VisuGUI::GetActiveStudy(){
269 return GetDesktop()->getActiveStudy() ;
272 vtkRenderer* VisuGUI::GetRenderer(){
273 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
274 return aViewFrame->getRenderer();
278 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
279 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
280 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
283 static void UpdateViewFrame() {
284 QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
286 for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
287 if (aStudyFrame->getTypeView() == VIEW_VTK) {
288 QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
289 VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
290 if (!aVtkViewFrame) continue;
291 VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
293 anInteractor->SetSelectionProp();
294 anInteractor->SetSelectionTolerance();
295 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
297 aStyle->setPreselectionProp();
304 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
305 return GetActiveStudy()->getStudyDocument();
308 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
309 return GetStudyDocument()->NewBuilder();
314 * Finds value by given key
317 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
318 VISU::Storable::TRestoringMap aMap;
319 if(!theSObject->_is_nil()){
320 SALOMEDS::GenericAttribute_var anAttr;
321 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
322 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
323 CORBA::String_var aString = aComment->Value();
324 QString strIn(aString.in());
325 VISU::Storable::StrToMap(strIn,aMap);
331 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
333 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
335 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
340 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
341 VISU::Storable::TRestoringMap* pMap = NULL)
343 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
344 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
345 if(aSel->IObjectCount() > 0){
346 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
347 if(pIO != NULL) *pIO = anIO;
348 if(anIO->hasEntry()){
349 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
350 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
351 if(!aSObject->_is_nil()){
352 SALOMEDS::GenericAttribute_var anAttr;
353 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
354 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
355 string aComm = aComment->Value();
356 QString strIn(aComm.c_str());
357 VISU::Storable::StrToMap(strIn,*pMap);
359 return VISU::SObjectToObject(aSObject);
363 return CORBA::Object::_nil();
367 int IsTrihedronDisplayed(){
368 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
369 return aVTKViewFrame->isTrihedronDisplayed();
374 void RepaintCurrentView(){
375 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
379 VisuGUI::VisuGUI( const QString& theName, QObject* theParent ):
380 SALOMEGUI( theName, theParent )
385 /* ==================================================================================== */
386 /* ==================================================================================== */
388 /* ==================================================================================== */
389 /* ==================================================================================== */
391 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
392 return theStudy->GetProperties()->IsLocked();
395 static int checkLock(const SALOMEDS::Study_var& theStudy) {
396 if (isStudyLocked(theStudy)) {
397 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
398 QObject::tr("WRN_WARNING"),
399 QObject::tr("WRN_STUDY_LOCKED"),
400 QObject::tr("BUT_OK") );
408 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
411 QString VisuInputDir = getVisuInputDir();
412 QString VisuOutputDir = getVisuOutputDir();
413 vtkRenderer *theRenderer = GetRenderer();
415 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
416 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
417 SALOMEDS::GenericAttribute_var anAttr;
418 SALOMEDS::AttributeName_var aName;
419 SALOMEDS::AttributeIOR_var anIOR;
421 switch (theCommandID){
422 /* ======================================================================================== */
423 /* Import Table from file */
424 /* ======================================================================================== */
427 if(checkLock(aStudy)) break;
428 visuGUI->ImportTablesFromFile();
432 /* ======================================================================================== */
433 /* Import Mesh from MED, DAT file */
434 /* ======================================================================================== */
438 visuGUI->CopyAndImportFile();
443 visuGUI->ImportFile();
447 /* ======================================================================================== */
448 /* Export results and mesh into a file format */
449 /* ======================================================================================== */
453 //visuGUI->ExportToFile();
457 /* ========================================================================== */
458 /* Visualization of Results : */
459 /* 4011 : Scalar Map */
460 /* 4012 : Deformed Shape */
462 /* 4014 : Iso-Surfaces */
463 /* 4015 : Cut Planes */
464 /* 4016 : Stream Lines */
465 /* ========================================================================== */
468 visuGUI->CreateScalarMap();
471 visuGUI->CreateDeformedShape();
474 visuGUI->CreateVectors();
477 visuGUI->CreateIsoSurfaces();
480 visuGUI->CreateCutPlanes();
483 visuGUI->CreateCutLines();
486 visuGUI->CreateStreamLines();
490 visuGUI->SelectionInfo();
493 /* ========================================================================================================================= */
494 /* Visualization - Wireframe */
495 /* ========================================================================================================================= */
501 /* ========================================================================================================================= */
502 /* Visualization - Surface */
503 /* ========================================================================================================================= */
509 /* ========================================================================================================================= */
510 /* Visualization - Points */
511 /* ========================================================================================================================= */
517 /* ========================================================================================================================= */
518 /* Visualization - Erase */
519 /* ========================================================================================================================= */
525 /* ========================================================================================================================= */
526 /* Visualization - Global */
527 /* ========================================================================================================================= */
531 /* ========================================================================================================================= */
532 /* Visualization - Partial */
533 /* ========================================================================================================================= */
539 //Show dialog that allows to select scale function and corresponding scale factor
540 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
541 FALSE, Qt::WDestructiveClose );
546 /* ============================ */
547 /* POP-UP OBJECTS BROWSER */
548 /* ============================ */
550 case 900 : // Rename object
554 // ---------------- For Popup in Viewer
560 case 803 : // Display only
561 case 903 : // Display only
562 visuGUI->DisplayOnlyPrs();
565 case 901 : // Display
566 visuGUI->DisplayPrs();
569 case 8041 : // Object representation : Wireframe
570 case 9041 : // Object representation : Wireframe
571 visuGUI->ChangeRepresentation(VISU::WIREFRAME);
574 case 8042 : // Object representation : Surface
575 case 9042 : // Object representation : Surface
576 visuGUI->ChangeRepresentation(VISU::SHADED);
579 case 8043 : // Object representation : Points
580 case 9043 : // Object representation : Points
581 visuGUI->ChangeRepresentation(VISU::POINT);
584 case 8044 : // Object representation : Shrink/Unshrink
585 case 9044 : // Object representation : Shrink/Unshrink
586 visuGUI->ChangeRepresentation(VISU::SHRINK);
589 case 8051 : // Change object color
590 case 9051 : // Change object color
591 visuGUI->ChageColor();
594 case 8052 : // Change object opacity
595 case 9052 : // Change object opacity
596 visuGUI->ChangeOpacity();
599 case 8053 : // Change object line width
600 case 9053 : // Change object line width
601 visuGUI->ChangeLines();
604 case 808 : // Sweep IsoSurfaces or Cutplanes
605 case 908 : // Sweep IsoSurfaces or Cutplanes
609 /* ======================================================================================== */
610 /* Preferences for Scalar Bar */
611 /* ======================================================================================== */
618 /* ======================================================================================== */
619 /* Preferences for Sweeping */
620 /* ======================================================================================== */
623 SetSweepingPreferences();
627 /* ======================================================================================== */
628 /* Preferences for Full loading */
629 /* ======================================================================================== */
634 QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
635 bool check = !pp->isItemChecked(theCommandID);
636 pp->setItemChecked(theCommandID,check);
637 switch(theCommandID){
639 QAD_CONFIG->addSetting( "Visu:BuildResult", check );
642 QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
648 case 113: // Load MED using MED component
650 if (checkLock(GetStudyDocument())) break;
652 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
653 if (CORBA::is_nil(aMedComp)) return false;
654 SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
655 if (CORBA::is_nil(aMedGen)) return false;
657 QStringList filtersList ;
659 filtersList.append( tr("MED_MEN_IMPORT_MED") );
660 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
661 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
664 tr("MED_MEN_IMPORT"),
666 if (!aFileName.isEmpty()) {
667 QApplication::setOverrideCursor( Qt::waitCursor );
668 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
669 GetActiveStudy()->updateObjBrowser();
670 QApplication::restoreOverrideCursor();
676 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
677 tr ("MSG_NOT_IMPLEMENTED"),
678 tr ("VISU_BUT_OK") );
681 } catch (const std::bad_alloc& e ) {
682 INFOS("bad_alloc exception is caught "<<e.what());
683 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
684 tr("ERR_NO_MEMORY") + " " + tr(e.what()),
688 catch (std::exception& e){
690 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
693 }catch (const SALOME::SALOME_Exception& S_ex) {
694 INFOS("const SALOME::SALOME_Exception& S_ex");
695 QtCatchCorbaException(S_ex);
699 INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
700 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
701 tr("ERR_UNKNOWN_EXCEPTION"),
708 void VisuGUI::SelectionInfo() {
709 mySelectionDlg = new VisuGUI_SelectionDlg();
710 mySelectionDlg->show();
716 /* ********************************************************************************** */
717 /* Function ShowTrihedron */
718 /* ********************************************************************************** */
720 void VisuGUI::ShowTrihedron(bool ShowThd){
721 bool ThdIsVisible = true;
722 if( ShowThd && !ThdIsVisible)
723 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
724 if( !ShowThd && ThdIsVisible)
725 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
728 /* ********************************************************************************** */
730 /* Clear all tmp files used in VISU */
731 /* ********************************************************************************** */
734 if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
737 /* ********************************************************************************** */
738 /* Function ChangeViewer */
739 /* Change representation of all actors */
740 /* ********************************************************************************** */
742 void VisuGUI::ChangeViewer(int theType){
744 GetActiveStudy()->unHighlightAll();
745 if(vtkRenderer *aRen = GetRenderer()){
747 vtkActorCollection *anActColl = aRen->GetActors();
748 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
749 if(anActor->GetVisibility() > 0)
750 if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){
751 anVISUActor = anVISUActor->GetParent();
753 anVISUActor->SetRepresentation(theType);
755 anVISUActor->VisibilityOff();
758 RepaintCurrentView();
762 // -----------------------------------------------------------------------------------------
764 // -----------------------------------------------------------------------------------------
766 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
771 // ====================================================================================================================
773 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
778 // ===================================================================================================================
780 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
782 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
785 if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
791 if(MYDEBUG) MESSAGE("--> Key : Escape")
803 //=====================================================================================
804 // Slot-functions for presentations creation
805 //=====================================================================================
807 #define CREATEPRESENTATION(FunctionName) \
808 void FunctionName() { \
809 if (checkLock(GetStudyDocument())) return; \
810 SALOMEDS::SObject_var objVisu; \
811 if (!TestObjectBrowser(objVisu)) return; \
812 if(!FunctionName(objVisu)) return; \
813 GetActiveStudy()->updateObjBrowser(); \
814 GetDesktop()->putInfo("Ready"); \
815 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
817 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
818 vf->onViewFitAll(); \
823 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
824 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
825 CREATEPRESENTATION(VisuGUI::CreateVectors);
826 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
827 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
828 CREATEPRESENTATION(VisuGUI::CreateCutLines);
829 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
833 //=====================================================================================
834 // function : SetSettings()
836 //=====================================================================================
837 bool VisuGUI::SetSettings(QAD_Desktop* parent)
841 QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
842 QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
844 if(aValue.isEmpty()? 0 : aValue.toInt())
845 pp->setItemChecked(anId, true);
848 item = parent->menuBar()->findItem(anId,&pp);
849 aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
851 if(aValue.isEmpty()? 0 : aValue.toInt())
852 pp->setItemChecked(anId, true);
855 parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
862 //=====================================================================================
863 // function : DisplayPrs()
865 //=====================================================================================
866 void VisuGUI::DisplayPrs() {
867 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
868 Handle(SALOME_InteractiveObject) anIO;
869 CORBA::Object_var anObject = GetSelectedObj(&anIO);
870 if ( !CORBA::is_nil( anObject ) ) {
871 // is it Prs3d object ?
872 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
874 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
875 UpdateViewer(aPrsObject);
876 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
877 vf->getRenderer()->ResetCameraClippingRange();
879 vf->highlight(anIO, 1);
884 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
886 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
887 PlotCurve(aCurve, VISU::eDisplay );
891 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
893 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
894 PlotContainer(aContainer, VISU::eDisplay );
898 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
900 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
901 PlotTable(aTable, VISU::eDisplay );
907 //=====================================================================================
908 // function : DisplayOnlyPrs()
910 //=====================================================================================
911 void VisuGUI::DisplayOnlyPrs() {
912 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
913 CORBA::Object_var anObject = GetSelectedObj();
914 if ( !CORBA::is_nil( anObject ) ) {
915 // is it Prs3d object ?
916 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
917 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
918 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
919 UpdateViewer(aPrsObject, true);
920 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
922 vf->getRenderer()->ResetCameraClippingRange();
925 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
926 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
927 PlotCurve(aCurve, VISU::eDisplayOnly );
928 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
929 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
930 PlotContainer(aContainer, VISU::eDisplayOnly );
931 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
932 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
933 PlotTable(aTable, VISU::eDisplayOnly );
938 //=====================================================================================
939 // function : ErasePrs()
941 //=====================================================================================
942 static void ErasePrs(CORBA::Object_ptr theObject) {
943 if(MYDEBUG) MESSAGE("ErasePrs");
944 if ( !CORBA::is_nil( theObject ) ) {
945 VISU::Base_var aBase = VISU::Base::_narrow(theObject);
946 if ( CORBA::is_nil( aBase ) ) return;
947 VISU::VISUType aType = aBase->GetType();
950 if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
951 VisuGUI::PlotCurve(aCurve, VISU::eErase );
954 case VISU::TCONTAINER:{
955 if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
956 VisuGUI::PlotContainer(aContainer, VISU::eErase );
960 if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
961 VisuGUI::PlotTable(aTable, VISU::eErase );
965 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
966 VisuGUI::ErasePrs(aPrsObject);
967 if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame())
974 void VisuGUI::ErasePrs() {
975 ::ErasePrs(GetSelectedObj());
979 //=====================================================================================
980 // function : DisplayManyPrs()
982 //=====================================================================================
983 void VisuGUI::DisplayManyPrs()
985 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
986 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
987 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
988 for ( ; It.More(); It.Next() ) {
989 Handle(SALOME_InteractiveObject)& anIO = It.Value();
990 if ( anIO->hasEntry() ) {
991 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
992 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
993 VISU::Storable::TRestoringMap pMap;
994 if( !aSObject->_is_nil() ) {
995 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
996 if ( !CORBA::is_nil( aCORBAObject ) ) {
997 // is it Prs3d object ?
998 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1000 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
1001 UpdateViewer(aPrsObject);
1002 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1004 vf->getRenderer()->ResetCameraClippingRange();
1006 vf->highlight(anIO, 1);
1011 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1013 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
1014 PlotCurve(aCurve, VISU::eDisplay );
1017 // is it Container ?
1018 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1020 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
1021 PlotContainer(aContainer, VISU::eDisplay );
1025 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1027 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
1028 PlotTable(aTable, VISU::eDisplay );
1037 //=====================================================================================
1038 // function : DisplayOnlyManyPrs()
1040 //=====================================================================================
1041 void VisuGUI::DisplayOnlyManyPrs() {
1042 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
1043 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1044 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1045 bool aFirstElem = true;
1046 for ( ; It.More(); It.Next() ) {
1047 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1048 if ( anIO->hasEntry() ) {
1049 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1050 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1051 VISU::Storable::TRestoringMap pMap;
1052 if( !aSObject->_is_nil() ) {
1053 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1054 if ( !CORBA::is_nil( aCORBAObject ) ) {
1055 // is it Prs3d object ?
1056 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1058 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1059 UpdateViewer(aPrsObject, aFirstElem);
1060 if (aFirstElem) aFirstElem = false;
1061 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1063 vf->getRenderer()->ResetCameraClippingRange();
1065 vf->highlight(anIO, 1);
1070 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1072 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1074 PlotCurve(aCurve, VISU::eDisplayOnly );
1077 else PlotCurve(aCurve, VISU::eDisplay );
1080 // is it Container ?
1081 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1083 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1085 PlotContainer(aContainer, VISU::eDisplayOnly );
1088 else PlotContainer(aContainer, VISU::eDisplay );
1092 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1094 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1096 PlotTable(aTable, VISU::eDisplayOnly );
1099 else PlotTable(aTable, VISU::eDisplay );
1109 //=====================================================================================
1110 // function : EraseManyPrs()
1112 //=====================================================================================
1113 void VisuGUI::EraseManyPrs()
1115 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1116 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1117 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1118 SALOME_ListIteratorOfListIO It( LIO );
1119 for ( ; It.More(); It.Next() ) {
1120 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1121 if ( anIO->hasEntry() ) {
1122 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1123 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1124 VISU::Storable::TRestoringMap pMap;
1125 if( !aSObject->_is_nil() ) {
1126 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1127 if ( !CORBA::is_nil( aCORBAObject ) ) {
1128 // is it Prs3d object ?
1129 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1131 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1132 ErasePrs(aPrsObject);
1133 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1140 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1142 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1143 PlotCurve(aCurve, VISU::eErase );
1146 // is it Container ?
1147 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1149 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1150 PlotContainer(aContainer, VISU::eErase );
1154 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1156 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1157 PlotTable(aTable, VISU::eErase );
1166 //=====================================================================================
1167 // function : RecreateActor()
1169 //=====================================================================================
1170 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1171 QApplication::setOverrideCursor(Qt::waitCursor);
1174 //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
1175 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1176 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1177 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1178 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1179 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1180 thePrs->UpdateActor(anActor);
1182 }catch(std::runtime_error& ex){
1184 QApplication::restoreOverrideCursor();
1185 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1186 tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()),
1187 tr ("VISU_BUT_OK") );
1188 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1189 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1190 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1191 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
1192 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
1193 aViewFrame->RemoveActor(anActor);
1200 QApplication::restoreOverrideCursor();
1204 //=====================================================================================
1205 // function : EditPrs()
1207 //=====================================================================================
1208 #define EDITPRS(PrsName, DlgName) \
1210 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1212 DlgName* aDlg = new DlgName(); \
1213 aDlg->initFromPrsObject(aPrsObject); \
1214 if ( aDlg->exec() ) { \
1215 if(!(aDlg->storeToPrsObject(aPrsObject))){ \
1219 RecreateActor(aPrsObject); \
1220 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1221 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1222 vf->getRenderer()->ResetCameraClippingRange(); \
1231 void VisuGUI::EditPrs() {
1232 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1234 switch (aPrs3d->GetType()) {
1235 case VISU::TMESH: // Mesh 13
1238 case VISU::TSCALARMAP: // ScalarMap 18
1239 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1242 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1243 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1246 case VISU::TCUTPLANES: // Cut planes 42
1247 //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1249 VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
1251 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
1252 aDlg->initFromPrsObject(aPrsObject);
1254 myActiveDialogBox = aDlg;
1255 // if ( aDlg->exec() ) {
1256 // if(!(aDlg->storeToPrsObject(aPrsObject))){
1260 // RecreateActor(aPrsObject);
1261 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1262 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1263 // vf->getRenderer()->ResetCameraClippingRange();
1273 case VISU::TCUTLINES: // Cut planes 42
1274 //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1276 VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
1278 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false);
1279 aDlg->initFromPrsObject(aPrsObject);
1281 myActiveDialogBox = aDlg;
1282 // if ( aDlg->exec() ) {
1283 // aDlg->storeToPrsObject(aPrsObject);
1284 // RecreateActor(aPrsObject);
1285 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1286 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1287 // vf->getRenderer()->ResetCameraClippingRange();
1291 // // Remove old Table
1292 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1293 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
1294 // if(!aSObject->_is_nil()) {
1295 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1296 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1297 // for ( ;aIter->More(); aIter->Next()) {
1298 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1299 // if (!aTblObj->_is_nil()) {
1300 // SALOMEDS::GenericAttribute_var anAttr;
1301 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1302 // aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
1307 // if (aDlg->isGenerateTable()) {
1308 // GetVisuGen()->CreateTable(aSObject->GetID());
1309 // if (aDlg->isGenerateCurves()) {
1310 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1311 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1312 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1313 // for ( ;aIter->More(); aIter->Next()) {
1314 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1315 // if (!aTblObj->_is_nil()) {
1316 // SALOMEDS::GenericAttribute_var anAttr;
1317 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1318 // CreatePlot(aTblObj);
1325 // GetActiveStudy()->updateObjBrowser();
1333 case VISU::TISOSURFACE: // Iso surfaces
1334 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1336 case VISU::TVECTORS: // Vectors 64
1337 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1340 case VISU::TSTREAMLINES:
1341 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1347 Handle(SALOME_InteractiveObject) anIO;
1348 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1349 if ( !CORBA::is_nil( anObject ) )
1350 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1351 vf->highlight(anIO, 1);
1355 //=====================================================================================
1356 // function : CreateMesh()
1358 //=====================================================================================
1359 void VisuGUI::CreateMesh() {
1360 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1361 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1363 if (checkLock(GetStudyDocument())) return;
1365 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1366 aSObj = aSObj->GetFather();
1367 aSObj = aSObj->GetFather();
1368 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1369 if(CORBA::is_nil(anObject)) {
1370 aSObj = aSObj->GetFather();
1371 anObject = VISU::SObjectToObject(aSObj);
1373 VISU::Result_var aResult;
1374 if (!CORBA::is_nil(anObject)) {
1375 aResult = VISU::Result::_narrow(anObject);
1377 if(CORBA::is_nil(aResult)) {
1378 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1379 tr ("WRN_NO_AVAILABLE_DATA"),
1380 tr ("VISU_BUT_OK"));
1383 VISU::Storable::TRestoringMap aMap;
1384 SALOMEDS::GenericAttribute_var anAttr;
1385 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1386 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1387 string aComm = aComment->Value();
1388 QString strIn(aComm.c_str());
1389 VISU::Storable::StrToMap(strIn,aMap);
1392 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1393 if(!isExist) return;
1394 CORBA::Object_var aMesh;
1395 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1400 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
1401 if(aComment == "ENTITY"){
1402 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1403 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1404 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1405 }else if(aComment == "FAMILY"){
1406 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1407 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1408 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1409 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1410 }else if(aComment == "GROUP"){
1411 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1412 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1413 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1417 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1421 QApplication::restoreOverrideCursor();
1422 VISU::Mesh_i* pPresent = NULL;
1423 if(!CORBA::is_nil(aMesh))
1424 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1425 if (pPresent == NULL) {
1426 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1427 tr ("ERR_CANT_BUILD_PRESENTATION"),
1428 tr ("VISU_BUT_OK") );
1432 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1434 VISU_Actor *anActor = pPresent->CreateActor();
1439 vf->AddActor(anActor);
1443 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1446 //GetActiveStudy()->updateObjBrowser(); //not necessary
1447 GetDesktop()->putInfo("Ready");
1448 }catch(std::runtime_error& exc){
1450 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1451 tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
1452 tr ("VISU_BUT_OK") );
1457 //=====================================================================================
1458 // function : CreateManyMesh()
1460 //=====================================================================================
1461 void VisuGUI::CreateManyMesh(){
1462 if (checkLock(GetStudyDocument())) return;
1464 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1465 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1466 for ( ; It.More(); It.Next() ) {
1467 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1468 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1469 aSObj = aSObj->GetFather();
1470 aSObj = aSObj->GetFather();
1471 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1472 if(CORBA::is_nil(anObject)) {
1473 aSObj = aSObj->GetFather();
1474 anObject = VISU::SObjectToObject(aSObj);
1475 if(CORBA::is_nil(anObject)) return;
1477 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1478 if(CORBA::is_nil(aResult)) return;
1480 VISU::Storable::TRestoringMap aMap;
1481 SALOMEDS::GenericAttribute_var anAttr;
1482 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1483 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1484 string aComm = aComment->Value();
1485 QString strIn(aComm.c_str());
1486 VISU::Storable::StrToMap(strIn,aMap);
1489 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1490 if(!isExist) return;
1491 CORBA::Object_var aMesh;
1492 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1493 if(aComment == "ENTITY"){
1494 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1495 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1496 }else if(aComment == "FAMILY"){
1497 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1498 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1499 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1500 }else if(aComment == "GROUP"){
1501 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1502 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1504 QApplication::restoreOverrideCursor();
1505 if(CORBA::is_nil(aMesh)) return;
1507 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1509 VISU_Actor *anActor = pPresent->CreateActor();
1510 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1511 vf->AddActor(anActor);
1514 GetDesktop()->putInfo("Ready");
1515 }catch(std::runtime_error& exc){
1521 //=====================================================================================
1522 // function : ChangeRepresentation()
1524 //=====================================================================================
1526 static void ShrinkMesh(VISU_Actor *theActor){
1527 if(theActor->IsShrunk())
1528 theActor->UnShrink();
1530 theActor->SetShrink();
1533 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1534 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1535 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1538 ShrinkMesh(anActor);
1541 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1542 aMesh->SetPresentationType(theType);
1543 RecreateActor(aMesh);
1545 anActor->SetRepresentation(theType);
1547 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1553 void VisuGUI::MakeSurfaceframe() {
1554 ChangeRepresentation(VISU::SURFACEFRAME);
1557 void VisuGUI::MakeInsideframe() {
1558 ChangeRepresentation(VISU::INSIDEFRAME);
1561 void VisuGUI::MakeWireframe() {
1562 ChangeRepresentation(VISU::WIREFRAME);
1565 void VisuGUI::MakeSurface() {
1566 ChangeRepresentation(VISU::SHADED);
1569 void VisuGUI::MakePoints() {
1570 ChangeRepresentation(VISU::POINT);
1573 void VisuGUI::MakeShrink() {
1574 ChangeRepresentation(VISU::SHRINK);
1579 //=====================================================================================
1580 // functions : Change Propertise
1582 //=====================================================================================
1583 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1584 CORBA::Object_var anObject = GetSelectedObj(theIO);
1585 if(CORBA::is_nil(anObject)) return NULL;
1586 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1587 if(!aServant.in()) return NULL;
1588 return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1591 void VisuGUI::ChageColor() {
1592 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1593 if(!aPrsObject) return;
1595 VISU_Actor* anActor = GetActor(aPrsObject);
1596 if (!anActor) return;
1600 void VisuGUI::ChangeWireframeColor() {
1601 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1602 if(!aPrsObject) return;
1604 VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1605 if (!anActor) return;
1606 NewWireframeColor(anActor);
1610 void VisuGUI::ChangeOpacity() {
1611 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1612 if(!aPrsObject) return;
1614 VISU_Actor* anActor = GetActor(aPrsObject);
1615 if (!anActor) return;
1616 NewOpacity(anActor);
1620 void VisuGUI::ChangeLines() {
1621 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1622 if(!aPrsObject) return;
1624 VISU_Actor* anActor = GetActor(aPrsObject);
1625 if (!anActor) return;
1626 NewLinewidth(anActor);
1628 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1630 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1631 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1632 if ( theDisplaying == VISU::eDisplayOnly )
1634 QList<Plot2d_Curve> clist;
1635 aPlot->getCurves( clist );
1636 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1637 if ( !TableSO->_is_nil() ) {
1638 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1639 for ( ; Iter->More(); Iter->Next() ) {
1640 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1641 if( !CORBA::is_nil( childObject ) ) {
1642 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1643 if( !CORBA::is_nil( aCurve ) ) {
1644 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1645 Plot2d_Curve* plotCurve = 0;
1646 for ( int i = 0; i < clist.count(); i++ ) {
1647 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1648 plotCurve = clist.at( i );
1652 if ( theDisplaying == VISU::eErase ) {
1654 aPlot->eraseCurve( plotCurve, false );
1655 clist.remove( plotCurve );
1658 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1660 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1661 //plotCurve->setVerTitle( theCurve->GetVerTitle().c_str() );
1662 plotCurve->setVerTitle( theCurve->GetName() );
1663 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1664 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1665 /* - DATA NOT UPDATED */
1668 int nbPoints = theCurve->GetData( xList, yList );
1669 if ( nbPoints > 0 && xList && yList ) {
1670 plotCurve->setData( xList, yList, nbPoints );
1672 if ( !theCurve->IsAuto() ) {
1673 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1674 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1675 SALOMEDS::Color color = theCurve->GetColor();
1676 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1678 plotCurve->setAutoAssign( theCurve->IsAuto() );
1679 aPlot->displayCurve( plotCurve, false );
1682 Plot2d_Curve* crv = theCurve->CreatePresentation();
1684 aPlot->displayCurve( crv, false );
1685 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1686 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1687 SALOMEDS::Color newColor;
1688 newColor.R = crv->getColor().red()/255.;
1689 newColor.G = crv->getColor().green()/255.;
1690 newColor.B = crv->getColor().blue()/255.;
1691 theCurve->SetColor( newColor );
1692 crv->setAutoAssign( theCurve->IsAuto() );
1703 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1705 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1706 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1707 // if ( theDisplaying == VISU::eDisplayOnly )
1708 // aPlot->EraseAll();
1709 QList<Plot2d_Curve> clist;
1710 aPlot->getCurves( clist );
1711 Plot2d_Curve* plotCurve = 0;
1712 for ( int i = 0; i < clist.count(); i++ ) {
1713 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1714 plotCurve = clist.at( i );
1716 else if ( theDisplaying == VISU::eDisplayOnly ) {
1717 aPlot->eraseCurve( clist.at( i ) );
1720 if ( theDisplaying == VISU::eErase ) {
1722 aPlot->eraseCurve( plotCurve, false );
1724 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1726 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1727 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1728 plotCurve->setVerTitle( theCurve->GetName() );
1729 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1730 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1733 int nbPoints = theCurve->GetData( xList, yList );
1734 if ( nbPoints > 0 && xList && yList ) {
1735 plotCurve->setData( xList, yList, nbPoints );
1737 if ( !theCurve->IsAuto() ) {
1738 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1739 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1740 SALOMEDS::Color color = theCurve->GetColor();
1741 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1743 plotCurve->setAutoAssign( theCurve->IsAuto() );
1744 aPlot->displayCurve( plotCurve, false );
1747 Plot2d_Curve* crv = theCurve->CreatePresentation();
1749 aPlot->displayCurve( crv, false );
1750 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1751 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1752 SALOMEDS::Color newColor;
1753 newColor.R = crv->getColor().red()/255.;
1754 newColor.G = crv->getColor().green()/255.;
1755 newColor.B = crv->getColor().blue()/255.;
1756 theCurve->SetColor( newColor );
1757 crv->setAutoAssign( theCurve->IsAuto() );
1764 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1766 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1767 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1768 if ( theDisplaying == VISU::eDisplayOnly )
1770 QList<Plot2d_Curve> clist;
1771 aPlot->getCurves( clist );
1772 if ( container->GetNbCurves() > 0 ) {
1773 int nbCurves = container->GetNbCurves();
1774 for ( int k = 1; k <= nbCurves; k++ ) {
1775 VISU::Curve_i* theCurve = container->GetCurve( k );
1776 if ( theCurve && theCurve->IsValid() ) {
1777 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) );
1778 // for ( int i = 0; i < clist.count(); i++ ) {
1779 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1780 // plotCurve = clist.at( i );
1784 if ( theDisplaying == VISU::eErase ) {
1786 aPlot->eraseCurve( plotCurve, false );
1787 clist.remove( plotCurve );
1790 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1792 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1793 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1794 plotCurve->setVerTitle( theCurve->GetName() );
1795 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1796 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1799 int nbPoints = theCurve->GetData( xList, yList );
1800 if ( nbPoints > 0 && xList && yList ) {
1801 plotCurve->setData( xList, yList, nbPoints );
1803 if ( !theCurve->IsAuto() ) {
1804 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1805 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1806 SALOMEDS::Color color = theCurve->GetColor();
1807 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1809 plotCurve->setAutoAssign( theCurve->IsAuto() );
1810 aPlot->displayCurve( plotCurve, false );
1813 Plot2d_Curve* crv = theCurve->CreatePresentation();
1815 aPlot->displayCurve( crv, false );
1816 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1817 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1818 SALOMEDS::Color newColor;
1819 newColor.R = crv->getColor().red()/255.;
1820 newColor.G = crv->getColor().green()/255.;
1821 newColor.B = crv->getColor().blue()/255.;
1822 theCurve->SetColor( newColor );
1823 crv->setAutoAssign( theCurve->IsAuto() );
1835 Slot : opens Table view : for Table object or SObject with table attribute selected
1837 void VisuGUI::ShowTable() {
1838 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1839 if( Sel->IObjectCount() !=1 )
1841 Handle(SALOME_InteractiveObject) anIO;
1842 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1843 SALOMEDS::SObject_var SO;
1844 if ( !CORBA::is_nil( anObject ) ) {
1845 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1846 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1847 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1848 if( !CORBA::is_nil( aTable ) ) {
1849 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1851 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1856 // possibly this is Table SObject
1857 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1860 if(!IsSObjectTable(SO))
1863 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1866 //SAL2670 Orientation of show tables
1867 SALOMEGUI_TableDlg::ttAuto,
1874 Slot : opens Table view : for Table object or SObject with table attribute selected
1876 void VisuGUI::CreateTable() {
1877 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1878 if( aSel->IObjectCount() !=1 )
1881 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1882 if (anIO->hasEntry()){
1883 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1884 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1885 if(!aSObject->_is_nil()) {
1886 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1887 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1888 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1889 GetVisuGen()->CreateTable(aSObject->GetID());
1890 GetActiveStudy()->updateObjBrowser();
1898 Slot : deletes SObject with all subobjects
1900 void VisuGUI::DeleteObject() {
1901 SALOMEDS::Study_var aStudy = GetStudyDocument();
1902 if (checkLock(aStudy)) return;
1904 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1905 if( aSel->IObjectCount() !=1 )
1907 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1908 if (anIO->hasEntry()){
1909 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1910 if(!aSObject->_is_nil()){
1911 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1912 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1913 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1914 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1915 ::ErasePrs(aChildObj);
1917 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
1918 // There is a transaction
1919 aStudyBuilder->NewCommand();
1920 CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1921 if(!CORBA::is_nil(anObj)){
1922 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1923 if(!CORBA::is_nil(aBase)){
1924 VISU::VISUType aType = aBase->GetType();
1926 case VISU::TRESULT:{
1927 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1928 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1929 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1930 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1931 if(CORBA::is_nil(aChildObj)) continue;
1932 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1933 if(CORBA::is_nil(aPrs3d)) continue;
1934 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1935 DeletePresentation(pPrs3d);
1941 aStudyBuilder->RemoveObjectWithChildren(aSObject);
1942 aStudyBuilder->CommitCommand();
1943 GetActiveStudy()->unHighlightAll();
1944 GetActiveStudy()->updateObjBrowser(true);
1951 Slot : deletes empty container
1953 void VisuGUI::CreatePlot2dView() {
1954 if (checkLock(GetStudyDocument())) return;
1955 GetVisuGen()->CreateContainer();
1956 GetActiveStudy()->updateObjBrowser( true );
1962 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1964 void VisuGUI::PlotData() {
1965 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1966 if( Sel->IObjectCount() !=1 )
1968 CORBA::Object_var anObject = GetSelectedObj();
1969 SALOMEDS::SObject_var SO;
1970 if ( !CORBA::is_nil( anObject ) ) {
1971 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1972 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1973 // Table (VISU object) is selected
1974 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1975 if( !CORBA::is_nil( aTbl ) ) {
1976 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1978 SALOMEDS::GenericAttribute_var anAttr;
1979 SALOMEDS::AttributeName_var aName;
1981 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1982 if ( IsSObjectTable(SO) ) {
1983 // get name of SObject
1984 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1985 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1986 SOName = aName->Value();
1988 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1989 if ( dlg->exec() == QDialog::Accepted ) {
1990 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1991 // if study is not locked - create new container, create curves
1992 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1994 QValueList<int> verIndices;
1995 dlg->getCurvesSource( horIndex, verIndices );
1996 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1997 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1998 if( !CORBA::is_nil( aContainer ) ) {
1999 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2001 for ( int i = 0; i < verIndices.count(); i++ ) {
2002 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
2003 if( !CORBA::is_nil( aNewCurve ) ) {
2004 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2007 int marker, line, lineWidth;
2009 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2010 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2011 pCrv->SetColor( c );
2012 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2013 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2015 pContainer->AddCurve( pCrv->_this() );
2019 GetActiveStudy()->updateObjBrowser( true );
2020 PlotContainer( pContainer, VISU::eDisplay );
2026 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2027 Plot2d_CurveContainer container;
2028 dlg->getCurves( container );
2029 if ( !container.isEmpty() ) {
2030 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2031 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2032 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2033 getRightFrame()->getViewFrame()))->setTitle( SOName );
2044 // possibly this is Table SObject
2045 SALOMEDS::GenericAttribute_var anAttr;
2046 SALOMEDS::AttributeName_var aName;
2049 // check if Table SObject is selected
2050 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2051 if ( IsSObjectTable(SO) ) {
2052 // get name of SObject
2053 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2054 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2055 SOName = aName->Value();
2057 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2058 if ( dlg->exec() == QDialog::Accepted ) {
2059 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2060 // if study is not locked - create new table and container objects, create curves
2061 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2063 QValueList<int> verIndices;
2064 dlg->getCurvesSource( horIndex, verIndices );
2065 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2066 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
2067 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2068 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2069 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2070 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2072 if ( pContainer && pTable ) {
2073 for ( int i = 0; i < verIndices.count(); i++ ) {
2074 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2075 if( !CORBA::is_nil( aNewCurve ) ) {
2076 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2079 int marker, line, lineWidth;
2081 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2082 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2083 pCrv->SetColor( c );
2084 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2085 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2087 pContainer->AddCurve( pCrv->_this() );
2091 GetActiveStudy()->updateObjBrowser( true );
2092 PlotContainer( pContainer, VISU::eDisplay );
2097 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2098 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2099 Plot2d_CurveContainer container;
2100 dlg->getCurves( container );
2101 if ( !container.isEmpty() ) {
2102 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2103 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2104 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2105 getRightFrame()->getViewFrame()))->setTitle( SOName );
2116 void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
2117 SALOMEDS::GenericAttribute_var anAttr;
2118 SALOMEDS::AttributeName_var aName;
2120 if ( IsSObjectTable(theTableSO) ) {
2121 CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
2122 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2123 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2124 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
2125 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
2127 if ( pContainer && pTable ) {
2128 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
2129 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
2130 if( !CORBA::is_nil( aNewCurve ) ) {
2131 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
2133 pContainer->AddCurve( pCrv->_this() );
2137 GetActiveStudy()->updateObjBrowser( true );
2138 PlotContainer( pContainer, VISU::eDisplay );
2146 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2148 void VisuGUI::CurveProperties() {
2149 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2150 if( Sel->IObjectCount() !=1 )
2152 CORBA::Object_var anObject = GetSelectedObj();
2153 SALOMEDS::SObject_var SO;
2154 if (CORBA::is_nil( anObject )) return;
2156 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2157 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2159 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2160 if( !CORBA::is_nil( aCurve ) ) {
2161 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2162 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2163 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
2164 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2165 dlg->setMarker( (int)curve->GetMarker() );
2166 SALOMEDS::Color color = curve->GetColor();
2167 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2168 if( dlg->exec() == QDialog::Accepted ) {
2169 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2170 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2171 SALOMEDS::Color newColor;
2172 newColor.R = dlg->getColor().red()/255.;
2173 newColor.G = dlg->getColor().green()/255.;
2174 newColor.B = dlg->getColor().blue()/255.;
2175 curve->SetColor( newColor );
2176 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2177 if ( sfList.count() > 0 ) {
2178 QListIterator<QAD_StudyFrame> it( sfList );
2179 for ( ; it.current(); ++it ) {
2180 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2181 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2182 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2185 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2187 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2188 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2189 plotCurve->setColor( dlg->getColor() );
2190 aPlot->updateCurve( plotCurve, true );
2203 Slot : Clears container contents : for Container object selected
2205 void VisuGUI::ClearContainer() {
2206 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2207 if( Sel->IObjectCount() !=1 )
2210 CORBA::Object_var anObject = GetSelectedObj();
2211 SALOMEDS::SObject_var SO;
2212 if (CORBA::is_nil( anObject )) return;
2214 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2215 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2217 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2218 if( !CORBA::is_nil( aCnt ) ) {
2219 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2220 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2222 GetActiveStudy()->updateObjBrowser();
2229 Slot : Edit container contents : for Container object selected
2231 void VisuGUI::EditContainer() {
2232 CORBA::Object_var anObject = GetSelectedObj();
2233 if(CORBA::is_nil(anObject)) return;
2234 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
2235 if(!aServant.in()) return;
2236 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
2237 if(!aContainer) return;
2239 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
2240 aDlg->initFromPrsObject(aContainer);
2242 aDlg->storeToPrsObject(aContainer);
2243 GetActiveStudy()->updateObjBrowser( true );
2249 void VisuGUI::DeletePrs() {
2250 SALOMEDS::Study_var aStudy = GetStudyDocument();
2251 if (checkLock(aStudy)) return;
2253 // There is a transaction
2254 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
2255 aStudyBuilder->NewCommand();
2257 DeletePresentation(GetSelectedPrs3d());
2259 aStudyBuilder->CommitCommand();
2263 void VisuGUI::SaveViewParams()
2265 if (checkLock(GetStudyDocument())) return;
2266 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2267 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2268 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2270 if ( aSel->IObjectCount() == 0 ) {
2271 VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
2273 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2274 VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
2276 GetActiveStudy()->updateObjBrowser( true );
2280 void VisuGUI::RestoreViewParams()
2282 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2283 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2284 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2286 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2287 VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
2291 //=====================================================================================
2292 // function : DeleteViewParams()
2294 //=====================================================================================
2295 void VisuGUI::DeleteViewParams() {
2297 VISU::Storable::TRestoringMap aMap;
2298 Handle(SALOME_InteractiveObject) anIO;
2299 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2300 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2301 if(isExist && aType == VISU::TVIEW3D){
2302 SALOMEDS::Study_var aStudy = GetStudyDocument();
2303 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2304 aStudy->NewBuilder()->RemoveObject(aSObject);
2306 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2307 aSel->RemoveIObject(anIO, 0);
2309 GetActiveStudy()->updateObjBrowser( true );
2314 //=====================================================================================
2315 // function : Sweep()
2317 //=====================================================================================
2318 void VisuGUI::Sweep() {
2319 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2320 if (!aPrsObject) return;
2322 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2326 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2327 if ( !aTempoStr.isEmpty() )
2328 aTemp = int(1.E6*(aTempoStr.toFloat()));
2331 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2332 if ( !aCyclesStr.isEmpty() )
2333 aCycles = aCyclesStr.toInt();
2336 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2337 if ( !aStepsStr.isEmpty() )
2338 aSteps = aStepsStr.toInt();
2340 VISU_Actor* aActor = GetActor(aPrsObject);
2341 if (!aActor) return;
2343 if (!aActor->GetVisibility()) {
2344 aActor->VisibilityOn();
2347 QApplication::setOverrideCursor( Qt::waitCursor );
2349 for (int j=0 ; j<aCycles; j++) {
2350 for (int i=0 ; i<=aSteps; i++) {
2351 float aPercents = float(i)/aSteps;
2352 aPrsObject->SetMapScale(aPercents);
2353 aPrsObject->UpdateActor(aActor);
2354 vf->getRW()->getRenderWindow()->Render();
2358 }catch(std::exception& exc){
2359 INFOS("Follow exception was occured :\n"<<exc.what());
2361 INFOS("Unknown exception was occured!");
2363 QApplication::restoreOverrideCursor();
2368 void VisuGUI::TimeAnimation() {
2369 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2370 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2372 bool isDefined = false;
2374 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2375 for (; It.More(); It.Next()) {
2376 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2377 if (aSObject->_is_nil()) continue;
2378 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2379 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2383 aAnimationDlg->addField(aSObject);
2385 } else if (aNbTimes == aNumber) {
2386 aAnimationDlg->addField(aSObject);
2391 if (isDefined) aAnimationDlg->show();
2392 else delete aAnimationDlg;
2396 void VisuGUI::ImportMedField() {
2397 if (checkLock(GetStudyDocument())) return;
2398 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2399 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2400 QApplication::setOverrideCursor( Qt::waitCursor );
2401 for(;It.More();It.Next()) {
2402 Handle(SALOME_InteractiveObject) anIO = It.Value();
2403 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2404 if(!aSObject->_is_nil()){
2405 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2406 if(!CORBA::is_nil(anObject)){
2407 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2408 if(!CORBA::is_nil(aMED.in()))
2409 GetVisuGen()->ImportMed( aSObject );
2410 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2411 if(!CORBA::is_nil(aField.in()))
2412 GetVisuGen()->ImportMedField( aField );
2414 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2415 SALOMEDS::GenericAttribute_var anAttr;
2416 aSFather->FindAttribute(anAttr, "AttributeName");
2417 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2418 CORBA::String_var aValue = aName->Value();
2419 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2420 GetVisuGen()->ImportMed(aSObject);
2421 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2422 // VisuGUI::myComponent->ImportMed(aSObject);
2426 GetActiveStudy()->updateObjBrowser( true );
2427 QApplication::restoreOverrideCursor();
2430 //=====================================================================================
2431 // functions : Rename()
2433 //=====================================================================================
2434 void VisuGUI::Rename() {
2435 if (checkLock(GetStudyDocument())) return;
2436 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2437 if ( Sel->IObjectCount() != 1 )
2439 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2440 if( aSObj->_is_nil() ) return;
2442 VISU::Curve_i* curve = 0;
2443 CORBA::Object_var anObject = GetSelectedObj();
2444 if ( !CORBA::is_nil( anObject )) {
2445 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2446 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2448 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2449 if( !CORBA::is_nil( aCurve ) ) {
2450 curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2455 //TEST DU PARENT == VISU
2456 SALOMEDS::GenericAttribute_var anAttr;
2457 SALOMEDS::AttributeName_var aName;
2458 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2459 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2460 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2461 if ( !Name.isEmpty() ) {
2462 QApplication::setOverrideCursor( Qt::waitCursor );
2464 curve->SetName( Name.latin1() );
2465 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2466 QApplication::restoreOverrideCursor();
2468 //int TypeMode; bool InViewer;
2469 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2470 //ActorTmp->setName((Standard_CString)Name.latin1());
2475 //=====================================================================================
2476 // functions : RenameTable()
2478 //=====================================================================================
2479 void VisuGUI::RenameTable() {
2480 if (checkLock(GetStudyDocument())) return;
2481 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2482 if ( Sel->IObjectCount() != 1 )
2484 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2485 if( aSObj->_is_nil() ) return;
2487 VISU::Table_i* table = 0;
2488 CORBA::Object_var anObject = GetSelectedObj();
2489 if ( !CORBA::is_nil( anObject )) {
2490 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2491 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2493 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2494 if( !CORBA::is_nil( aTable ) ) {
2495 table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2500 //TEST DU PARENT == VISU
2501 SALOMEDS::GenericAttribute_var anAttr;
2502 SALOMEDS::AttributeName_var aName;
2503 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2504 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2505 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2506 if ( !Name.isEmpty() ) {
2507 QApplication::setOverrideCursor( Qt::waitCursor );
2509 table->SetName( Name.latin1() );
2510 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2511 QApplication::restoreOverrideCursor();
2513 //int TypeMode; bool InViewer;
2514 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2515 //ActorTmp->setName((Standard_CString)Name.latin1());
2522 //=====================================================================================
2523 // functions : RenameContainer()
2525 //=====================================================================================
2526 void VisuGUI::RenameContainer() {
2527 if (checkLock(GetStudyDocument())) return;
2528 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2529 if ( Sel->IObjectCount() != 1 )
2531 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2532 if( aSObj->_is_nil() ) return;
2534 VISU::Container_i* container = 0;
2535 CORBA::Object_var anObject = GetSelectedObj();
2536 if ( !CORBA::is_nil( anObject )) {
2537 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2538 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2540 CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2541 if( !CORBA::is_nil( aContainer ) ) {
2542 container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2547 //TEST DU PARENT == VISU
2548 SALOMEDS::GenericAttribute_var anAttr;
2549 SALOMEDS::AttributeName_var aName;
2550 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2551 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2552 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2553 if ( !Name.isEmpty() ) {
2554 QApplication::setOverrideCursor( Qt::waitCursor );
2556 container->SetName( Name.latin1() );
2557 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2558 QApplication::restoreOverrideCursor();
2560 //int TypeMode; bool InViewer;
2561 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2562 //ActorTmp->setName((Standard_CString)Name.latin1());
2569 //=====================================================================================
2570 // function : CopyPresentation()
2572 //=====================================================================================
2573 void VisuGUI::CopyPresentation(){
2574 if (checkLock(GetStudyDocument())) return;
2575 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2576 if (!aPrsObject) return;
2577 switch (aPrsObject->GetType()) {
2580 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2581 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2582 aSameMesh->SameAs(aMeshPrs);
2583 UpdateViewer(aSameMesh);
2586 case VISU::TSCALARMAP:
2588 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2589 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2590 aSameScalar->SameAs(aScalarPrs);
2591 UpdateViewer(aSameScalar);
2594 case VISU::TDEFORMEDSHAPE:
2596 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2597 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2598 aSameDeformed->SameAs(aDefPrs);
2599 UpdateViewer(aSameDeformed);
2602 case VISU::TCUTPLANES:
2604 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2605 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2606 aSameCut->SameAs(aCutPrs);
2607 UpdateViewer(aSameCut);
2610 case VISU::TCUTLINES:
2612 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2613 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2614 aSameCut->SameAs(aCutPrs);
2615 UpdateViewer(aSameCut);
2618 case VISU::TISOSURFACE:
2620 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2621 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2622 aSameIso->SameAs(aIsoPrs);
2623 UpdateViewer(aSameIso);
2626 case VISU::TSTREAMLINES:
2628 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2629 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2630 aSameLines->SameAs(aLinesPrs);
2631 UpdateViewer(aSameLines);
2634 case VISU::TVECTORS:
2636 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2637 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2638 aSameVectors->SameAs(aVectorsPrs);
2639 UpdateViewer(aSameVectors);
2643 GetActiveStudy()->updateObjBrowser();
2648 //=====================================================================================
2649 // function : DefinePopup()
2651 //=====================================================================================
2652 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2659 //=====================================================================================
2660 // function : checkHomoSelection()
2662 //=====================================================================================
2663 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2664 int VisuGUI::checkHomoSelection()
2666 int selMode = homoNone;
2667 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2668 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2669 for ( ; It.More(); It.Next() ) {
2670 int selNext = homoOther;
2671 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2672 if ( anIO->hasEntry() ) {
2673 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2674 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2675 VISU::Storable::TRestoringMap pMap;
2676 if( !aSObject->_is_nil() ) {
2677 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2678 if ( !CORBA::is_nil( aCORBAObject ) ) {
2679 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2680 if ( !CORBA::is_nil( aVisuObj ) ) {
2681 VISU::VISUType aType = aVisuObj->GetType();
2685 case VISU::TCONTAINER:
2686 selNext = homoCurves; break;
2688 case VISU::TSCALARMAP:
2689 case VISU::TISOSURFACE:
2690 case VISU::TDEFORMEDSHAPE:
2691 case VISU::TCUTPLANES:
2692 case VISU::TCUTLINES:
2693 case VISU::TVECTORS:
2694 case VISU::TSTREAMLINES:
2695 selNext = homoPresentations; break;
2697 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2698 selNext = homoAnimatable; break;
2700 selNext = homoOther; break;
2702 selNext = homoOther;
2707 SALOMEDS::GenericAttribute_var anAttr;
2708 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2709 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2710 string aComm = aComment->Value();
2711 QString strIn( aComm.c_str() );
2712 VISU::Storable::StrToMap( strIn, pMap );
2714 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2720 selNext = homoPresentable; break;
2722 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2723 selNext = homoAnimatable; break;
2725 selNext = homoOther; break;
2727 selNext = homoOther;
2734 if ( selMode == homoNone )
2737 if ( selMode != selNext )
2744 //=====================================================================================
2745 // function : GetNbChildren() [ static ]
2746 // purpose : get number of children
2747 //=====================================================================================
2748 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2750 if ( SO->_is_nil() )
2753 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2754 for ( ; Iter->More(); Iter->Next() ) {
2755 SALOMEDS::SObject_var refSO;
2756 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2762 //=====================================================================================
2763 // function : CustomPopup()
2765 //=====================================================================================
2766 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2767 const QString & theParent, const QString & theObject)
2769 int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2770 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2772 bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
2774 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2775 SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2776 QString aParentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
2777 int nbSel = aSelection->IObjectCount();
2782 if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
2783 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2787 int selMode = checkHomoSelection();
2788 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2789 if ( selMode == homoCurves ) {
2790 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2791 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2792 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2793 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2796 else if ( selMode == homoPresentations ) {
2798 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2799 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2802 else if ( selMode == homoPresentable ) {
2803 if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2805 else if ( selMode == homoAnimatable ) {
2806 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2810 VISU::Storable::TRestoringMap aMap;
2811 Handle(SALOME_InteractiveObject) anIO;
2812 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2813 if (!CORBA::is_nil(anObject)) {
2814 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2815 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2816 if (!CORBA::is_nil(aVisuObj)) {
2817 VISU::VISUType aType = aVisuObj->GetType();
2818 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2820 case VISU::TVISUGEN:
2821 thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
2822 thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
2823 thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
2827 if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
2831 if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2832 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2833 if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2834 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
2835 thePopup->insertSeparator();
2836 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2837 if ( GetNbChildren( aSObject, false ) > 0 ) {
2838 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2839 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2840 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2843 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2848 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2849 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2851 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2852 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2853 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2855 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2856 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2860 case VISU::TCONTAINER:
2861 // if( !CORBA::is_nil( anObject ) ) {
2862 // CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2863 // if( !CORBA::is_nil( aCnt ) ) {
2864 // VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2865 // if ( container ) {
2866 // if ( !aIsLocked ) {
2867 // thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2868 // thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2869 // if (container->GetNbCurves() > 0)
2870 // thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2872 // if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2873 // thePopup->insertSeparator();
2874 // thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2875 // thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2876 // thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2882 thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2883 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2884 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2886 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2887 thePopup->insertSeparator();
2888 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2889 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2890 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2892 if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2895 default: // Presentation
2897 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2900 // Add Presentation menu
2901 if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2902 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2903 int aRepresent = anVISUActor->GetRepresentation();
2906 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2907 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2908 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2909 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2910 if (aType == VISU::TMESH)
2911 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2913 case VISU::WIREFRAME :
2914 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2915 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2916 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2917 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2918 if (aType == VISU::TMESH)
2919 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2922 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2923 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2924 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2925 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2926 if (aType == VISU::TMESH)
2927 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2929 case VISU::INSIDEFRAME :
2930 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2931 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2932 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2933 if (aType == VISU::TMESH)
2934 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2936 case VISU::SURFACEFRAME :
2937 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2938 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2939 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2940 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2943 if(anVISUActor->IsShrunkable())
2944 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2945 if (anVISUActor->IsShrunk())
2946 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2948 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2950 thePopup->insertItem("Representation", aPresMenu);
2953 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2954 if(aType == VISU::TMESH){
2955 if(aRepresent == VISU::SURFACEFRAME){
2956 aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2957 aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2959 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2960 }else if(aType == VISU::TDEFORMEDSHAPE)
2961 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2963 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2964 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2965 if (aType != VISU::TVECTORS){
2966 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2967 thePopup->insertItem("Properties", aPropMenu);
2969 thePopup->insertSeparator();
2972 if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
2973 if (aType != VISU::TMESH) {
2974 //if (aType != VISU::TSCALARMAP)
2975 if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
2977 if (aType == VISU::TCUTLINES) {
2978 // Check: Does it has living children (tables)
2979 SALOMEDS::ChildIterator_var aIter =
2980 GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
2981 bool isPresent = false;
2982 for ( ;aIter->More(); aIter->Next()) {
2983 SALOMEDS::SObject_var aTblObj = aIter->Value();
2984 isPresent = !aTblObj->_is_nil();
2986 SALOMEDS::GenericAttribute_var anAttr;
2987 isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
2988 if (isPresent) break; // We have at least a one child
2991 if ((!isPresent) && (!aIsLocked) )
2992 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
2994 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
2998 if ( theParent == "Viewer" &&
2999 ( aType == VISU::TMESH ||
3000 aType == VISU::TSCALARMAP ||
3001 aType == VISU::TDEFORMEDSHAPE ) ) {
3002 thePopup->insertSeparator();
3003 thePopup->insertItem("Selection info...", visuGUI, SLOT(SelectionInfo()));
3005 thePopup->insertSeparator();
3007 if (visuGUI->IsDisplayed(aPrsObject) ){
3008 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
3011 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
3013 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
3015 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
3016 if ((aType != VISU::TMESH) && (!aIsLocked)) {
3017 thePopup->insertSeparator();
3018 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
3027 // possibly this is the MED field/mesh and support objects
3028 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
3029 if(!CORBA::is_nil(aMED))
3030 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
3031 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
3032 if(!CORBA::is_nil(aField))
3033 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
3034 if ( aParentComponent != parent->getActiveComponent() ) {
3035 //insert pre-defined Display/Erase items
3036 if ( thePopup->count() > 0 ) {
3037 thePopup->insertSeparator();
3039 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3040 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3041 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3046 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
3047 if(!aSObject->_is_nil()){
3049 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
3055 if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3058 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3059 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3061 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3062 // Available only for VTK viewer
3063 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3065 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3066 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3070 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
3071 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3073 case VISU::TTIMESTAMP: {
3074 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3075 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
3076 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3077 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
3078 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3079 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
3080 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3081 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
3082 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
3083 if(aNunComponent > 1){
3084 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
3085 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3086 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
3087 "Vectors...", visuGUI, SLOT(CreateVectors()));
3088 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
3089 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3097 if(IsSObjectTable(aSObject)){
3098 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
3099 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
3100 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
3101 thePopup->insertSeparator();
3102 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3106 CORBA::Long aTag = 1;
3107 SALOMEDS::SObject_var aSubObject;
3108 if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) {
3109 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3113 aSObject = aSObject->GetFather();
3114 if(aSObject->_is_nil()) return false;
3115 SALOMEDS::GenericAttribute_var anAttr;
3116 aSObject->FindAttribute(anAttr, "AttributeName");
3117 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
3118 if(aName->_is_nil()) return false;
3119 CORBA::String_var aValue = aName->Value();
3120 //if(strcmp(aValue.in(),"MEDMESH") == 0)
3121 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
3122 if(strcmp(aValue.in(),"MEDFIELD") == 0)
3123 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
3124 if ( aParentComponent != parent->getActiveComponent() ) {
3125 //insert pre-defined Display/Erase items
3126 if ( thePopup->count() > 0 ) {
3127 thePopup->insertSeparator();
3129 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3130 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3131 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3140 //===========================================================================
3141 // BuildPresentation
3142 //===========================================================================
3143 void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
3146 BEGIN_OF("VisuGUI::BuildPresentation");
3148 if (theIO.IsNull()) {
3149 if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3153 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3154 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3156 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
3158 vtkRenderer *Renderer = GetRenderer();
3160 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3162 if (aSObj -> _is_nil() ) {
3163 if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3167 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3168 if(!CORBA::is_nil(anObject)) {
3169 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
3170 if ( !aPrsObject ) {
3171 if(MYDEBUG) MESSAGE("The object is not VISU::Prs3d_i");
3174 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3177 SelectedActor = aPrsObject -> CreateActor();
3178 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3179 vf->AddActor(SelectedActor);
3180 }catch(std::runtime_error& exc){
3185 if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3186 END_OF("VisuGUI::BuildPresentation");
3190 //===========================================================================
3191 // SupportedViewType
3192 //===========================================================================
3193 void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
3195 if (!buffer || !bufferSize) return;
3196 buffer[0] = (int)VIEW_VTK;
3197 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3202 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
3204 visuGUI = new VisuGUI( "" );
3210 //////////////////////////////////////////////////////////////////////////////////
3211 //////////////// CHANGE ACTOR COLOR ////////////////////////
3212 //////////////////////////////////////////////////////////////////////////////////
3213 ///////////////// /////////////////////////////////////////////////////////////////
3214 // change actor color
3215 // In : Name of Actor
3219 void VisuGUI::NewColor(VISU_Actor *theActor){
3220 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3221 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3222 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3223 SALOMEDS::Color anOldColor, aNewColor;
3224 int aRepresent = theActor->GetRepresentation();
3228 anOldColor = aMesh->GetNodeColor();
3230 case VISU::WIREFRAME :
3231 case VISU::INSIDEFRAME :
3232 anOldColor = aMesh->GetLinkColor();
3235 case VISU::SURFACEFRAME :
3236 anOldColor = aMesh->GetCellColor();
3239 else if(aDeformedShape)
3240 anOldColor = aDeformedShape->GetColor();
3243 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3244 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3245 if(aColorNew.isValid()){
3246 aNewColor.R = aColorNew.red()/255.;
3247 aNewColor.G = aColorNew.green()/255.;
3248 aNewColor.B = aColorNew.blue()/255.;
3252 aMesh->SetNodeColor(aNewColor);
3254 case VISU::WIREFRAME :
3255 case VISU::INSIDEFRAME :
3256 aMesh->SetLinkColor(aNewColor);
3259 case VISU::SURFACEFRAME :
3260 aMesh->SetCellColor(aNewColor);
3264 aDeformedShape->SetColor(aNewColor);
3265 RecreateActor(aPrs3d);
3270 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3271 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3272 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3273 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3274 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3275 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3276 if(aColorNew.isValid()){
3277 aNewColor.R = aColorNew.red()/255.;
3278 aNewColor.G = aColorNew.green()/255.;
3279 aNewColor.B = aColorNew.blue()/255.;
3280 aMesh->SetLinkColor(aNewColor);
3281 VisuGUI::RecreateActor(aMesh);
3287 //////////////////////////////////////////////////////////////////////////////////
3288 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3289 //////////////////////////////////////////////////////////////////////////////////
3290 //////////////////////////////////////////////////////////////////////////////////
3291 // change actor opacity
3292 // In : Name of Actor
3294 // Use CursorDlg to select a value between 0 and 100
3297 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3300 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3302 float oldopac,newopac;
3304 CursorDlg->Comment1->setText( tr( "Set value between") );
3305 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3306 oldopac=Actor->GetOpacity();
3307 intopac=int(oldopac*100.+0.5);
3308 CursorDlg->SpinBox1->setMinValue(0);
3309 CursorDlg->SpinBox1->setMaxValue(100);
3310 CursorDlg->SpinBox1->setValue(intopac);
3312 int ret = CursorDlg->exec();
3315 intopac = CursorDlg->SpinBox1->value() ;
3316 newopac = intopac/100.;
3317 Actor->SetOpacity(newopac);
3322 //////////////////////////////////////////////////////////////////////////////////
3323 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3324 //////////////////////////////////////////////////////////////////////////////////
3325 //////////////////////////////////////////////////////////////////////////////////
3326 // change actor linewidth
3327 // In : Name of Actor
3329 // Use CursorDlg to select a value between 0 and 10
3332 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3335 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3337 float oldlwid,newlwid;
3339 CursorDlg->Comment1->setText("Set value between");
3340 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3341 oldlwid=Actor->GetLineWidth();
3342 intlwid=int(oldlwid);
3343 CursorDlg->SpinBox1->setMinValue(1);
3344 CursorDlg->SpinBox1->setMaxValue(10);
3345 CursorDlg->SpinBox1->setValue(intlwid);
3347 int ret = CursorDlg->exec();
3349 intlwid = CursorDlg->SpinBox1->value() ;
3351 Actor->SetLineWidth(newlwid);
3356 /* ======================================================================================== */
3357 /* Setting parameters for Scalar Bar */
3358 /* ======================================================================================== */
3359 void VisuGUI::ChangeScalarBar()
3361 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3362 Scbar->initFromResources();
3363 int ret = Scbar->exec();
3365 Scbar->storeToResources();
3370 /* ======================================================================================== */
3371 /* Setting parameters for Sweeping */
3372 /* ======================================================================================== */
3373 void VisuGUI::SetSweepingPreferences()
3379 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3380 if ( !Tempo.isEmpty() )
3381 tempo = Tempo.toFloat();
3383 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3384 if ( !Cycles.isEmpty() )
3385 cycles = Cycles.toInt();
3387 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3388 if ( !Steps.isEmpty() )
3389 steps = Steps.toInt();
3391 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3393 Sweep->setTimeStep( tempo );
3394 Sweep->setNbCycles( cycles );
3395 Sweep->setNbSteps ( steps );
3397 if ( Sweep->exec() )
3399 tempo = Sweep->getTimeStep();
3400 cycles = Sweep->getNbCycles();
3401 steps = Sweep->getNbSteps();
3403 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3404 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3405 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3410 /* ======================================================================================== */
3411 /* Returns Visu input files directory (default is CSF_PATHData) */
3412 /* ======================================================================================== */
3413 QString VisuGUI::getVisuInputDir()
3415 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3416 if ( Tmp.isEmpty() )
3417 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3418 Tmp = QAD_Tools::addSlash(Tmp);
3422 /* ======================================================================================== */
3423 /* Returns Visu output files directory (default is InputDir) */
3424 /* ======================================================================================== */
3425 QString VisuGUI::getVisuOutputDir()
3427 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3428 if ( Tmp.isEmpty() )
3430 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3431 if ( Tmp2.isEmpty() )
3432 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3436 Tmp = QAD_Tools::addSlash(Tmp);
3441 /* ======================================================================================== */
3442 /* Global Method for Scalar Map */
3443 /* ======================================================================================== */
3444 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3445 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3446 SALOMEDS::SObject_var aSObj = theField->GetFather();
3447 if (CORBA::is_nil(aSObj)) return NULL;
3448 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3449 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3450 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3451 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3452 if(CORBA::is_nil(anObject)) return NULL;
3453 theResult = VISU::Result::_narrow(anObject);
3454 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
3456 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3457 tr ("WRN_NO_AVAILABLE_DATA"),
3458 tr ("VISU_BUT_OK"));
3462 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3463 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3464 const char* theMeshName, VISU::Entity theEntity, \
3465 const char* theFieldName, int theTimeId) {\
3466 VISU::Result_var aResult; \
3467 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3468 if(pResult != NULL){ \
3469 QApplication::setOverrideCursor( Qt::waitCursor ); \
3470 CORBA::Object_var anObject = \
3471 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3472 QApplication::restoreOverrideCursor(); \
3473 if(!CORBA::is_nil(anObject)) \
3474 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
3476 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3477 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3478 tr ("VISU_BUT_OK") ); \
3482 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3483 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3484 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3485 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3486 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3487 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3488 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3491 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3492 bool FNAME(SALOMEDS::SObject_var theField) { \
3493 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3495 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3496 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3497 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3498 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3499 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3500 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3501 Utils_Timer timer; \
3502 if(MYCHECKTIME) timer.Start(); \
3503 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3506 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
3510 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3511 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3512 DLGNAME* aDlg = new DLGNAME(); \
3513 aDlg->initFromPrsObject(pPresent); \
3514 if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
3517 DeletePresentation(pPresent); \
3523 CreateActor(pPresent); \
3531 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3532 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3533 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3534 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3535 //BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3536 //BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3537 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3540 bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
3542 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3544 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3545 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3546 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3547 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3548 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3549 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3551 if(MYCHECKTIME) timer.Start();
3552 VISU::CutPlanes_i* pPresent =
3553 CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
3556 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT");
3560 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3561 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3562 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
3563 aDlg->initFromPrsObject(pPresent);
3565 myActiveDialogBox = aDlg;
3566 // if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
3569 // DeletePresentation(pPresent);
3574 // CreateActor(pPresent);
3578 }catch (...){return false;}
3582 bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
3584 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3586 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3587 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3588 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3589 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3590 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3591 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3593 if(MYCHECKTIME) timer.Start();
3594 VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
3595 (VISU::Entity)anEntity.toInt(),
3596 aFieldName,aTimeStampId.toInt());
3599 MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT");
3603 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3604 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3605 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true);
3606 aDlg->initFromPrsObject(pPresent);
3608 myActiveDialogBox = aDlg;
3610 // if (aDlg->exec()) {
3611 // aDlg->storeToPrsObject(pPresent);
3612 // if (aDlg->isGenerateTable()) {
3613 // GetVisuGen()->CreateTable(pPresent->GetEntry());
3614 // if (aDlg->isGenerateCurves()) {
3615 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3616 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
3617 // if(!aSObject->_is_nil()) {
3618 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
3619 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
3620 // for ( ;aIter->More(); aIter->Next()) {
3621 // SALOMEDS::SObject_var aTblObj = aIter->Value();
3622 // if (!aTblObj->_is_nil()) {
3623 // SALOMEDS::GenericAttribute_var anAttr;
3624 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
3625 // CreatePlot(aTblObj);
3631 // GetActiveStudy()->updateObjBrowser();
3634 // DeletePresentation(pPresent);
3640 // CreateActor(pPresent);
3644 }catch (...){return false; }
3650 /* ======================================================================================== */
3651 /* Global Method to import tables from file */
3652 /* ======================================================================================== */
3653 void VisuGUI::ImportTablesFromFile(){
3654 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3656 flt.append( "Files (*.xls *.txt *.tab)" );
3657 flt.append( "All Files (*.*)" );
3658 QString aDir = getVisuInputDir();
3659 QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3660 aDir,flt,tr("Import From File"),true);
3662 if(aFileInfo.exists()){
3663 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3664 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3665 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3668 CORBA::Object_var anObject;
3674 anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3678 MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE");
3682 if(CORBA::is_nil(anObject)) {
3684 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3685 tr ("ERR_ERROR_IN_THE_FILE"),
3686 tr ("VISU_BUT_OK") );
3690 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3692 GetActiveStudy()->updateObjBrowser(); //update Object browser
3696 void VisuGUI::ExportTableToFile()
3698 QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
3699 SALOME_Selection* aSel = SALOME_Selection::Selection ( aQADStudy -> getSelection() );
3701 if( aSel->IObjectCount() > 0 ) {
3702 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
3703 if(anIO->hasEntry()){
3704 SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
3705 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
3706 if(CORBA::is_nil(aSObj)) return;
3709 SALOMEDS::GenericAttribute_var anAttr;
3711 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3712 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
3713 aSObj = aSObj->GetFather(); //if the current SObject is a table title
3714 // we take a father contaning the table
3715 if (!CORBA::is_nil(aSObj)) {
3716 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3717 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
3722 if (CORBA::is_nil(anAttr)) return;
3724 SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
3725 if (!CORBA::is_nil(aTabAttr))
3726 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3728 SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
3729 if (!CORBA::is_nil(aTabAttr))
3730 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3733 aTitle.simplifyWhiteSpace();
3735 flt.append("Table Files (*.xls)");
3737 QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
3738 aDlg -> setCaption("Export Table To File");
3739 aDlg -> setDir( getVisuOutputDir() );
3740 aDlg -> setFilters(flt);
3741 aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
3743 QString aFile = aDlg -> selectedFile();
3746 if(!aFile.isEmpty()){
3747 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3748 QString aDir = QAD_Tools::getDirFromPath(aFile);
3749 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3752 GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
3753 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3754 } catch(std::exception& ex) {
3756 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3757 tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
3758 tr ("VISU_BUT_OK") );
3760 INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
3761 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3762 tr ("ERR_ERROR_DURING_EXPORT"),
3763 tr ("VISU_BUT_OK") );
3769 /* ======================================================================================== */
3770 /* Global Method to import mesh results in MED and DAT format */
3771 /* ======================================================================================== */
3772 void VisuGUI::ImportFile(){
3773 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
3775 void VisuGUI::CopyAndImportFile(){
3776 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
3778 void VisuGUI::ImportFromFile(TImportFun theImportFun){
3779 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3781 //flt.append( "Exportable Files (*.med *.dat)" );
3782 //flt.append( "Dat Files (*.dat)" );
3783 flt.append( "Med Files (*.med)" );
3784 QString aDir = getVisuInputDir();
3785 QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3786 aDir,flt,tr("Import From File"),true);
3788 if(aFileInfo.exists()){
3789 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3790 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3791 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3794 VISU::Result_var aResult;
3800 if(aFileInfo.extension(false) == "med"){
3801 QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3802 bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3803 if (VisuGUI_FileDlg::IsBuild){
3804 aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3805 if(!CORBA::is_nil(aResult.in()))
3806 if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
3807 if(!pResult->IsPossible())
3808 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3809 tr ("ERR_CANT_BUILD_PRESENTATION"),
3810 tr ("VISU_BUT_OK") );
3812 aResult->BuildAll();
3815 QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3816 //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
3817 aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1
3818 QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3823 MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
3827 if(CORBA::is_nil(aResult.in())) {
3829 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3830 tr ("ERR_ERROR_IN_THE_FILE"),
3831 tr ("VISU_BUT_OK") );
3835 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3837 GetActiveStudy()->updateObjBrowser(); //update Object browser
3841 void VisuGUI::ExportToFile(){
3842 CORBA::Object_var anObject = GetSelectedObj();
3843 if(CORBA::is_nil(anObject)) return;
3844 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
3845 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3847 flt.append( "Dat Files (*.dat)" );
3848 flt.append( "Med Files (*.med)" );
3849 QString aDir = getVisuOutputDir();
3850 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3851 aDir,flt,tr("Export To File"),false);
3852 if(!aFile.isEmpty()){
3853 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3854 aDir = QAD_Tools::getDirFromPath(aFile);
3855 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3856 if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3858 //APO - aResult->GetInput()->ToFile(aFile.latin1());
3859 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3860 }catch(std::exception& ex) {
3862 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3863 tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
3864 tr ("VISU_BUT_OK") );
3867 INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
3868 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3869 tr ("ERR_ERROR_DURING_EXPORT"),
3870 tr ("VISU_BUT_OK") );
3875 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3876 tr ("WRN_NO_AVAILABLE_DATA"),
3877 tr ("VISU_BUT_OK"));
3880 /* ======================================================================================== */
3881 /* Test and Read Object Browser before display */
3882 /* ======================================================================================== */
3883 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3884 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3885 Handle(SALOME_InteractiveObject) anIO;
3886 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3887 if(!anIO.IsNull() && anIO->hasEntry()){
3888 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3889 QString aValue = getValue(objVisu,"myType");
3890 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3892 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3893 tr("WRN_NO_AVAILABLE_DATA"),
3894 tr("VISU_BUT_OK") );
3899 * Returns Actor of presentation if it exists
3901 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3902 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3903 if (!vf) return NULL;
3905 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3906 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3907 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3908 if(thePrs == anVISUActor->GetPrs3d())
3909 return anVISUActor->GetParent();
3914 * Displays only actor of given presentation
3915 * Creates it if it is abcent
3917 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3918 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3919 if (!vf) return NULL;
3921 vtkRenderer *aRen = vf->getRenderer();
3922 vtkActorCollection *anActColl = aRen->GetActors();
3925 VISU_Actor* anVISUActor = NULL;
3926 VISU_Actor* aResActor = NULL;
3927 VISU::Prs3d_i* aSrcAddr = thePrs;
3928 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3929 if(anActor->IsA("VISU_Actor")){
3930 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3931 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
3932 if(aPrs == NULL) continue;
3933 if (thePrs == aPrs) {
3934 aResActor = anVISUActor->GetParent();
3935 thePrs->UpdateActor(aResActor);
3936 aResActor->VisibilityOn();
3938 } else if (theDispOnly) {
3939 anVISUActor->GetParent()->VisibilityOff();
3942 } else if (theDispOnly && anActor->GetVisibility()) {
3943 anActor->VisibilityOff();
3947 if (aResActor) return aResActor;
3949 anVISUActor = thePrs->CreateActor();
3950 vf->AddActor(anVISUActor);
3951 } catch ( std::runtime_error& exc ){
3953 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3954 tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
3955 tr ("VISU_BUT_OK") );
3963 * Returns TRUE if Presentation is displayed
3965 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
3966 VISU_Actor* anVISUActor = GetActor(thePrs);
3967 return (anVISUActor)? anVISUActor->GetVisibility() : false;
3971 * Erases Presentation
3973 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
3974 GetActiveStudy()->unHighlightAll();
3975 VISU_Actor* anVISUActor = GetActor(thePrs);
3977 anVISUActor->VisibilityOff();
3982 * Deletes given presentation from Data structure
3984 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
3985 if(checkLock(GetStudyDocument()) || !thePrs) return;
3986 GetActiveStudy()->unHighlightAll();
3987 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
3988 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
3989 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
3990 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
3991 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
3992 aViewFrame->RemoveActor(anActor);
3995 aViewFrame->unHighlightAll();
3998 thePrs->RemoveFromStudy();
3999 GetActiveStudy()->updateObjBrowser(); //update Object browser
4003 * Creates new actor of presentation
4005 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
4006 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
4007 if (!thePrs) return;
4008 QApplication::setOverrideCursor( Qt::waitCursor );
4009 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
4015 MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4016 VISU_Actor* aActor = thePrs->CreateActor();
4017 vf->AddActor(aActor);
4018 }catch(std::runtime_error& exc) {
4019 INFOS("std::runtime_error "<<exc.what());
4020 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4021 QApplication::restoreOverrideCursor();
4022 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4023 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
4024 tr ("VISU_BUT_OK") );
4027 MESSAGE(" Unknown exception");
4028 QApplication::restoreOverrideCursor();
4029 INFOS("Unknown exception is caught in VisuGUI::CreateActor");
4030 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4031 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4032 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
4033 tr ("VISU_BUT_OK") );
4038 MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
4042 QApplication::restoreOverrideCursor();
4047 /* ======================================================================================== */
4048 /* Functions to State of VisuGUI and Dialog Box */
4049 /* ======================================================================================== */
4051 void VisuGUI::SetState(int aState )
4053 this->myState = aState ;
4058 void VisuGUI::ResetState()
4060 this->myState = -1 ;
4064 void VisuGUI::EmitSignalDeactivateDialog()
4066 emit this->SignalDeactivateActiveDialog() ;
4070 void VisuGUI::EmitSignalCloseAllDialogs()
4072 emit this->SignalCloseAllDialogs() ;
4076 QDialog* VisuGUI::GetActiveDialogBox()
4078 return this->myActiveDialogBox ;
4081 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
4083 this->myActiveDialogBox = (QDialog*)aDlg ;