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 "VisuGUI_PhaseDlg.h"
32 #include "VisuGUI_MagnitudeDlg.h"
33 #include "VisuGUI_PhaseMagnitudeDlg.h"
34 #include "VisuGUI_PartialScaDlg.h"
35 #include "VisuGUI_CursorDlg.h"
36 #include "VisuGUI_ScalarBarDlg.h"
37 #include "VisuGUI_SweepPrefDlg.h"
38 #include "VisuGUI_CutPlanesDlg.h"
39 #include "VisuGUI_CutLinesDlg.h"
40 #include "VisuGUI_VectorsDlg.h"
41 #include "VisuGUI_IsoSurfacesDlg.h"
42 #include "VisuGUI_StreamLinesDlg.h"
43 #include "VisuGUI_TimeAnimation.h"
45 #include "VisuGUI_Selection.h"
46 #include "VisuGUI_VisuAsDlg.h"
47 #include "VisuGUI_SelVectCompDlg.h"
48 #include "VisuGUI_NonIsometricDlg.h"
50 #include "VISU_Gen_i.hh"
51 #include "VISU_Result_i.hh"
52 #include "VISU_Extractor.hxx"
53 #include "VISU_Table_i.hh"
54 #include "VISU_ViewManager_i.hh"
55 #include "VISU_LookupTable.hxx"
56 #include "VISU_ScalarBarActor.hxx"
58 #include "SALOMEGUI_ImportOperation.h"
59 #include "SALOMEGUI_QtCatchCorbaException.hxx"
60 #include "utilities.h"
62 #include "QAD_Config.h"
64 #include "QAD_Settings.h"
65 #include "QAD_Tools.h"
66 #include "QAD_LeftFrame.h"
67 #include "QAD_RightFrame.h"
68 #include "QAD_MessageBox.h"
69 #include "QAD_ObjectBrowser.h"
70 #include "QAD_ObjectBrowserItem.h"
71 #include "QAD_Menus.h"
72 #include "QAD_Resource.h"
73 #include "QAD_ResourceMgr.h"
74 #include "QAD_FileDlg.h"
75 #include "QAD_WaitCursor.h"
76 #include "SALOME_Selection.h"
77 #include "SALOMEGUI_NameDlg.h"
78 #include "SALOMEGUI_TableDlg.h"
79 #include "SALOMEGUI_SetupCurveDlg.h"
80 #include "SALOMEGUI_SetValueDlg.h"
81 #include "Plot2d_SetupPlot2dDlg.h"
82 #include "Plot2d_ViewFrame.h"
83 #include "VTKViewer_ViewFrame.h"
86 #define INCLUDE_MENUITEM_DEF
87 #include <qpopupmenu.h>
91 #include <qapplication.h>
92 #include <qinputdialog.h>
93 #include <qcolordialog.h>
96 #include <qradiobutton.h>
99 #include <qcombobox.h>
101 //VRV: porting on Qt 3.0.5
102 #if QT_VERSION >= 0x030005
103 #include <qlistview.h>
105 //VRV: porting on Qt 3.0.5
106 #include <qmessagebox.h>
109 #include CORBA_CLIENT_HEADER(Med_Gen)
111 #include <vtkActor.h>
112 #include <vtkDataSetMapper.h>
114 // Open CASCADE Include
115 #include <TCollection_AsciiString.hxx>
119 static int MYCHECKTIME = 1;
121 static int MYCHECKTIME = 0;
123 #include <Utils_Timer.hxx>
126 static int MYDEBUG = 0;
127 static int MYDEBUGWITHFILES = 0;
129 static int MYDEBUG = 0;
130 static int MYDEBUGWITHFILES = 0;
133 class CustomItem : public QCustomMenuItem{
135 CustomItem( const QString& s, const QFont& f )
136 : string( s ), font( f ){};
139 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
142 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
147 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
154 static VisuGUI MYVISUGUI;
155 static VisuGUI *visuGUI = &MYVISUGUI;
157 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
158 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
159 return VISU::VISU_Gen_i::GetVisuGenImpl();
162 QAD_Desktop* VisuGUI::GetDesktop(){
163 return QAD_Application::getDesktop() ;
166 QAD_Study* VisuGUI::GetActiveStudy(){
167 return GetDesktop()->getActiveStudy() ;
170 vtkRenderer* VisuGUI::GetRenderer(){
171 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
172 return aViewFrame->getRenderer();
176 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
177 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
178 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
181 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
182 return GetActiveStudy()->getStudyDocument();
185 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
186 return GetStudyDocument()->NewBuilder();
191 * Finds value by given key
194 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
195 VISU::Storable::TRestoringMap aMap;
196 if(!theSObject->_is_nil()){
197 SALOMEDS::GenericAttribute_var anAttr;
198 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
199 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
200 CORBA::String_var aString = aComment->Value();
201 QString strIn(aString.in());
202 VISU::Storable::StrToMap(strIn,aMap);
208 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
210 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
212 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
217 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
218 VISU::Storable::TRestoringMap* pMap = NULL)
220 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
221 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
222 if(aSel->IObjectCount() > 0){
223 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
224 if(pIO != NULL) *pIO = anIO;
225 if(anIO->hasEntry()){
226 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
227 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
228 if(!aSObject->_is_nil()){
229 SALOMEDS::GenericAttribute_var anAttr;
230 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
231 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
232 string aComm = aComment->Value();
233 QString strIn(aComm.c_str());
234 VISU::Storable::StrToMap(strIn,*pMap);
236 return VISU::SObjectToObject(aSObject);
240 return CORBA::Object::_nil();
244 int IsTrihedronDisplayed(){
245 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
246 return aVTKViewFrame->isTrihedronDisplayed();
251 void RepaintCurrentView(){
252 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
256 * Returns selected sclalar mode or -1 if it was cancelled
258 int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){
260 // const VISU::TField* aField = theResult->GetInput()->GetField(theFieldName);
261 // if(aField->myNbComp > 1){
262 // VisuGUI_SelVectCompDlg* SelCompDlg = new VisuGUI_SelVectCompDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
263 // if(SelCompDlg->exec()){
264 // aScalarMode = SelCompDlg->whatIsChecked();
268 // delete SelCompDlg;
277 VisuGUI* VisuGUI::GetOrCreateVisuGUI( QAD_Desktop* desktop ){
279 static VisuGUI VISUGUI;
285 /* ********************************************************************************* */
286 /* Function to return VisuGUI object */
287 /* ********************************************************************************* */
288 VisuGUI* VisuGUI::GetVisuGUI( )
290 return VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
293 /* ==================================================================================== */
294 /* ==================================================================================== */
296 /* ==================================================================================== */
297 /* ==================================================================================== */
299 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
300 return theStudy->GetProperties()->IsLocked();
303 static int checkLock(const SALOMEDS::Study_var& theStudy) {
304 if (isStudyLocked(theStudy)) {
305 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
306 QObject::tr("WARNING"),
307 QObject::tr("WRN_STUDY_LOCKED"),
308 QObject::tr("BUT_OK") );
316 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
319 VisuGUI::GetOrCreateVisuGUI(parent);
320 QString VisuInputDir = getVisuInputDir();
321 QString VisuOutputDir = getVisuOutputDir();
322 vtkRenderer *theRenderer = GetRenderer();
324 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
325 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
326 SALOMEDS::GenericAttribute_var anAttr;
327 SALOMEDS::AttributeName_var aName;
328 SALOMEDS::AttributeIOR_var anIOR;
330 switch (theCommandID)
332 /* ======================================================================================== */
333 /* Define Selection Mode */
334 /* ======================================================================================== */
340 QApplication::setOverrideCursor( Qt::waitCursor );
341 int mode = theCommandID - 100; // Point, Edge, Cell, Actor
342 parent->SetSelectionMode( mode );
343 QApplication::restoreOverrideCursor();
347 /* ======================================================================================== */
348 /* Import Table from file */
349 /* ======================================================================================== */
353 if(checkLock(aStudy)) break;
354 visuGUI->ImportTablesFromFile();
358 /* ======================================================================================== */
359 /* Import Mesh from MED, DAT file */
360 /* ======================================================================================== */
364 visuGUI->ImportFromFile();
368 /* ======================================================================================== */
369 /* Export results and mesh into a file format */
370 /* ======================================================================================== */
374 visuGUI->ExportToFile();
378 /* ========================================================================== */
379 /* Visualization of Results : */
380 /* 4011 : Scalar Map */
381 /* 4012 : Deformed Shape */
383 /* 4014 : Iso-Surfaces */
384 /* 4015 : Cut Planes */
385 /* 4016 : Stream Lines */
386 /* ========================================================================== */
389 visuGUI->CreateScalarMap();
392 visuGUI->CreateDeformedShape();
395 visuGUI->CreateVectors();
398 visuGUI->CreateIsoSurfaces();
401 visuGUI->CreateCutPlanes();
404 visuGUI->CreateCutLines();
407 visuGUI->CreateStreamLines();
410 /* ======================================================================================================================= */
411 /* View Scalar Animation (Animation/scalar) */
413 /* ======================================================================================================================= */
419 /* ========================================================================================================================= */
420 /* Selection - Cell by number */
421 /* ========================================================================================================================= */
424 visuGUI->SelectCell();
427 /* ========================================================================================================================= */
428 /* Selection - Cell - information attribute */
429 /* ========================================================================================================================= */
432 visuGUI->InfoOnCell();
435 /* ========================================================================================================================= */
436 /* Selection - Point - information number */
437 /* ========================================================================================================================= */
440 visuGUI->SelectPoint();
443 /* ========================================================================================================================= */
444 /* Selection - Point - information attribute */
445 /* ========================================================================================================================= */
448 visuGUI->InfoOnPoint();
451 /* ========================================================================================================================= */
452 /* Selection - Shape */
453 /* ========================================================================================================================= */
457 /* ========================================================================================================================= */
458 /* Visualization - Wireframe */
459 /* ========================================================================================================================= */
465 /* ========================================================================================================================= */
466 /* Visualization - Surface */
467 /* ========================================================================================================================= */
473 /* ========================================================================================================================= */
474 /* Visualization - Points */
475 /* ========================================================================================================================= */
481 /* ========================================================================================================================= */
482 /* Visualization - Erase */
483 /* ========================================================================================================================= */
489 /* ========================================================================================================================= */
490 /* Visualization - Global */
491 /* ========================================================================================================================= */
495 /* ========================================================================================================================= */
496 /* Visualization - Partial */
497 /* ========================================================================================================================= */
503 //Show dialog that allows to select scale function and corresponding scale factor
504 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
505 FALSE, Qt::WDestructiveClose );
510 /* ============================ */
511 /* POP-UP OBJECTS BROWSER */
512 /* ============================ */
514 case 900 : // Rename object
518 // ---------------- For Popup in Viewer
524 case 803 : // Display only
525 case 903 : // Display only
526 visuGUI->DisplayOnlyPrs();
529 case 901 : // Display
530 visuGUI->DisplayPrs();
533 case 8041 : // Object representation : Wireframe
534 case 9041 : // Object representation : Wireframe
535 visuGUI->ChangeRepresentation(WIREFRAME);
538 case 8042 : // Object representation : Surface
539 case 9042 : // Object representation : Surface
540 visuGUI->ChangeRepresentation(SURFACE);
543 case 8043 : // Object representation : Points
544 case 9043 : // Object representation : Points
545 visuGUI->ChangeRepresentation(POINTS);
548 case 8044 : // Object representation : Shrink/Unshrink
549 case 9044 : // Object representation : Shrink/Unshrink
550 visuGUI->ChangeRepresentation(SHRINK);
553 case 8051 : // Change object color
554 case 9051 : // Change object color
555 visuGUI->ChageColor();
558 case 8052 : // Change object opacity
559 case 9052 : // Change object opacity
560 visuGUI->ChangeOpacity();
563 case 8053 : // Change object line width
564 case 9053 : // Change object line width
565 visuGUI->ChangeLines();
568 case 808 : // Sweep IsoSurfaces or Cutplanes
569 case 908 : // Sweep IsoSurfaces or Cutplanes
573 /* ======================================================================================== */
574 /* Preferences for Scalar Bar */
575 /* ======================================================================================== */
582 /* ======================================================================================== */
583 /* Preferences for Sweeping */
584 /* ======================================================================================== */
587 SetSweepingPreferences();
592 case 113: // Load MED using MED component
594 if (checkLock(GetStudyDocument())) break;
596 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "Med");
597 if (CORBA::is_nil(aMedComp)) return false;
598 Engines::Med_Gen_var aMedGen = Engines::Med_Gen::_narrow(aMedComp);
599 if (CORBA::is_nil(aMedGen)) return false;
601 QStringList filtersList ;
603 filtersList.append( tr("MED_MEN_IMPORT_MED") );
604 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
605 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
608 tr("MED_MEN_IMPORT"),
610 if (!aFileName.isEmpty()) {
611 QApplication::setOverrideCursor( Qt::waitCursor );
612 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
613 GetActiveStudy()->updateObjBrowser();
614 QApplication::restoreOverrideCursor();
620 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
621 tr ("MSG_NOT_IMPLEMENTED"),
622 tr ("VISU_BUT_OK") );
625 }catch (const SALOME::SALOME_Exception& S_ex) {
626 QtCatchCorbaException(S_ex);
630 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
631 tr("ERR_UNKNOWN_EXCEPTION"),
639 /* ********************************************************************************* */
640 /* Function to find Actor in Viewer */
641 /* ********************************************************************************* */
644 VISU_Actor *VisuGUI::GetActor(int* theSelectionType){
645 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
646 if (!aPrs3d) return NULL;
648 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
651 if(theSelectionType){
652 QAD_Study *aStudy = QAD_Application::getDesktop()->getActiveStudy();
653 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
654 *theSelectionType = aSel->SelectionMode();
657 return GetActor(aPrs3d,vf);
660 /* ********************************************************************************** */
661 /* Function ShowTrihedron */
662 /* ********************************************************************************** */
664 void VisuGUI::ShowTrihedron(bool ShowThd){
665 bool ThdIsVisible = true;
666 if( ShowThd && !ThdIsVisible)
667 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
668 if( !ShowThd && ThdIsVisible)
669 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
672 /* ********************************************************************************** */
674 /* Clear all tmp files used in VISU */
675 /* ********************************************************************************** */
678 MESSAGE("VisuGUI::~VisuGUI");
681 /* ********************************************************************************** */
682 /* Function ChangeViewer */
683 /* Change representation of all actors */
684 /* ********************************************************************************** */
686 void VisuGUI::ChangeViewer(int theType){
687 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
691 vtkRenderer *aRen = vf->getRenderer();
692 vtkActorCollection *anActColl = aRen->GetActors();
693 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
694 if(anActor->IsA("VISU_Actor")){
695 VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor);
696 if(anVISUActor->GetVisibility() > 0)
698 anVISUActor->SetRepresentation(theType);
699 else if(theType == -1)
700 anVISUActor->VisibilityOff();
702 anVISUActor->VisibilityOn();
708 // -----------------------------------------------------------------------------------------
710 // -----------------------------------------------------------------------------------------
712 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
714 VisuGUI::GetOrCreateVisuGUI(parent);
718 // ====================================================================================================================
720 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
722 VisuGUI::GetOrCreateVisuGUI(parent);
726 // ===================================================================================================================
728 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
730 VisuGUI::GetOrCreateVisuGUI(parent);
731 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
734 MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() )
740 MESSAGE("--> Key : Escape")
752 //=====================================================================================
753 // Slot-functions for presentations creation
754 //=====================================================================================
757 #define CREATEPRESENTATION(FunctionName) \
758 void FunctionName() { \
759 if (checkLock(GetStudyDocument())) return; \
760 SALOMEDS::SObject_var objVisu; \
761 if (!TestObjectBrowser(objVisu)) return; \
762 if(!FunctionName(objVisu)) return; \
763 GetActiveStudy()->updateObjBrowser(); \
764 GetDesktop()->putInfo("Ready"); \
765 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
767 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
768 vf->onViewFitAll(); \
773 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
774 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
775 CREATEPRESENTATION(VisuGUI::CreateVectors);
776 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
777 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
778 CREATEPRESENTATION(VisuGUI::CreateCutLines);
779 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
784 //=====================================================================================
785 // function : setSettings()
787 //=====================================================================================
788 bool VisuGUI::setSettings(QAD_Desktop* parent)
790 VisuGUI::GetOrCreateVisuGUI(parent);
794 //=====================================================================================
795 // function : DisplayPrs()
797 //=====================================================================================
798 void VisuGUI::DisplayPrs() {
799 MESSAGE("VisuGUI::DisplayPrs");
800 Handle(SALOME_InteractiveObject) anIO;
801 CORBA::Object_var anObject = GetSelectedObj(&anIO);
802 if ( !CORBA::is_nil( anObject ) ) {
803 // is it Prs3d object ?
804 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
806 MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
807 UpdateViewer(aPrsObject);
808 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
809 vf->getRenderer()->ResetCameraClippingRange();
811 vf->highlight(anIO, 1);
816 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
818 MESSAGE("VisuGUI::DisplayPrs : Curve object");
819 PlotCurve(aCurve, VISU::eDisplay );
823 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
825 MESSAGE("VisuGUI::DisplayPrs : Container object");
826 PlotContainer(aContainer, VISU::eDisplay );
830 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
832 MESSAGE("VisuGUI::DisplayPrs : Table object");
833 PlotTable(aTable, VISU::eDisplay );
839 //=====================================================================================
840 // function : DisplayOnlyPrs()
842 //=====================================================================================
843 void VisuGUI::DisplayOnlyPrs() {
844 MESSAGE("VisuGUI::DisplayOnlyPrs");
845 CORBA::Object_var anObject = GetSelectedObj();
846 if ( !CORBA::is_nil( anObject ) ) {
847 // is it Prs3d object ?
848 PortableServer::Servant aServant = VISU::GetServant(anObject);
849 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant)){
850 MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
851 UpdateViewer(aPrsObject, true);
852 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
854 vf->getRenderer()->ResetCameraClippingRange();
857 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant)){
858 MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
859 PlotCurve(aCurve, VISU::eDisplayOnly );
860 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant)){
861 MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
862 PlotContainer(aContainer, VISU::eDisplayOnly );
863 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant)){
864 MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
865 PlotTable(aTable, VISU::eDisplayOnly );
870 //=====================================================================================
871 // function : ErasePrs()
873 //=====================================================================================
874 void VisuGUI::ErasePrs() {
875 MESSAGE("VisuGUI::ErasePrs");
876 CORBA::Object_var anObject = GetSelectedObj();
877 if ( !CORBA::is_nil( anObject ) ) {
878 // is it Prs3d object ?
879 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
881 MESSAGE("VisuGUI::ErasePrs : Prs3d object");
882 ErasePrs(aPrsObject);
883 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
889 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
891 MESSAGE("VisuGUI::ErasePrs : Curve object");
892 PlotCurve(aCurve, VISU::eErase );
895 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
897 MESSAGE("VisuGUI::ErasePrs : Container object");
898 PlotContainer(aContainer, VISU::eErase );
901 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
903 MESSAGE("VisuGUI::ErasePrs : Table object");
904 PlotTable(aTable, VISU::eErase );
909 //=====================================================================================
910 // function : DisplayManyPrs()
912 //=====================================================================================
913 void VisuGUI::DisplayManyPrs()
915 MESSAGE("VisuGUI::DisplayManyPrs");
916 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
917 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
918 for ( ; It.More(); It.Next() ) {
919 Handle(SALOME_InteractiveObject)& anIO = It.Value();
920 if ( anIO->hasEntry() ) {
921 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
922 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
923 VISU::Storable::TRestoringMap pMap;
924 if( !aSObject->_is_nil() ) {
925 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
926 if ( !CORBA::is_nil( aCORBAObject ) ) {
927 // is it Prs3d object ?
928 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject));
930 MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
931 UpdateViewer(aPrsObject);
932 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
934 vf->getRenderer()->ResetCameraClippingRange();
936 vf->highlight(anIO, 1);
941 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject));
943 MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
944 PlotCurve(aCurve, VISU::eDisplay );
948 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject));
950 MESSAGE("VisuGUI::DisplayManyPrs : Container object");
951 PlotContainer(aContainer, VISU::eDisplay );
955 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject));
957 MESSAGE("VisuGUI::DisplayManyPrs : Table object");
958 PlotTable(aTable, VISU::eDisplay );
967 //=====================================================================================
968 // function : EraseManyPrs()
970 //=====================================================================================
971 void VisuGUI::EraseManyPrs()
973 MESSAGE("VisuGUI::EraseManyPrs");
974 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
975 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
976 SALOME_ListIteratorOfListIO It( LIO );
977 for ( ; It.More(); It.Next() ) {
978 Handle(SALOME_InteractiveObject)& anIO = It.Value();
979 if ( anIO->hasEntry() ) {
980 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
981 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
982 VISU::Storable::TRestoringMap pMap;
983 if( !aSObject->_is_nil() ) {
984 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
985 if ( !CORBA::is_nil( aCORBAObject ) ) {
986 // is it Prs3d object ?
987 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject));
989 MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
990 ErasePrs(aPrsObject);
991 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
998 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject));
1000 MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1001 PlotCurve(aCurve, VISU::eErase );
1004 // is it Container ?
1005 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject));
1007 MESSAGE("VisuGUI::EraseManyPrs : Container object");
1008 PlotContainer(aContainer, VISU::eErase );
1012 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject));
1014 MESSAGE("VisuGUI::EraseManyPrs : Table object");
1015 PlotTable(aTable, VISU::eErase );
1024 //=====================================================================================
1025 // function : RecreateActor()
1027 //=====================================================================================
1028 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1029 QApplication::setOverrideCursor(Qt::waitCursor);
1031 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1032 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1033 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1034 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1035 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1036 thePrs->UpdateActor(anActor);
1038 QApplication::restoreOverrideCursor();
1042 //=====================================================================================
1043 // function : EditPrs()
1045 //=====================================================================================
1046 #define EDITPRS(PrsName, DlgName) \
1048 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1050 DlgName* aDlg = new DlgName(); \
1051 aDlg->initFromPrsObject(aPrsObject); \
1052 if ( aDlg->exec() ) { \
1053 aDlg->storeToPrsObject(aPrsObject); \
1054 RecreateActor(aPrsObject); \
1055 /*RepaintCurrentView();*/ \
1056 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
1058 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1059 vf->getRenderer()->ResetCameraClippingRange(); \
1060 vf->onViewFitAll(); \
1070 void VisuGUI::EditPrs() {
1071 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1073 switch (aPrs3d->GetType()) {
1074 case VISU::TMESH: // Mesh 13
1077 case VISU::TSCALARMAP: // ScalarMap 18
1078 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1081 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1082 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1085 case VISU::TCUTPLANES: // Cut planes 42
1086 EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1089 case VISU::TCUTLINES: // Cut planes 42
1090 EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1093 case VISU::TISOSURFACE: // Iso surfaces
1094 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1096 case VISU::TVECTORS: // Vectors 64
1097 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1100 case VISU::TSTREAMLINES:
1101 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1106 //=====================================================================================
1107 // function : EditScalarBar()
1109 //=====================================================================================
1110 void VisuGUI::EditScalarBar() {
1111 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1112 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
1114 VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false);
1115 aDlg->initFromPrsObject(aPrsObject);
1116 if ( aDlg->exec() ) {
1117 aDlg->storeToPrsObject(aPrsObject);
1118 RecreateActor(aPrsObject);
1120 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1124 if (aDlg->isToSave())
1125 aDlg->storeToResources();
1133 //=====================================================================================
1134 // function : CreateMesh()
1136 //=====================================================================================
1137 void VisuGUI::CreateMesh() {
1138 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1139 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1141 if (checkLock(GetStudyDocument())) return;
1143 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1144 aSObj = aSObj->GetFather();
1145 aSObj = aSObj->GetFather();
1146 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1147 if(CORBA::is_nil(anObject)) {
1148 aSObj = aSObj->GetFather();
1149 anObject = VISU::SObjectToObject(aSObj);
1151 VISU::Result_var aResult;
1152 if (!CORBA::is_nil(anObject)) {
1153 aResult = VISU::Result::_narrow(anObject);
1155 if(CORBA::is_nil(aResult)) {
1156 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1157 tr ("WRN_NO_AVAILABLE_DATA"),
1158 tr ("VISU_BUT_OK"));
1162 VISU::Storable::TRestoringMap aMap;
1163 SALOMEDS::GenericAttribute_var anAttr;
1164 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1165 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1166 string aComm = aComment->Value();
1167 QString strIn(aComm.c_str());
1168 VISU::Storable::StrToMap(strIn,aMap);
1171 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1172 if(!isExist) return;
1173 CORBA::Object_var aMesh;
1174 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1179 if(aComment == "ENTITY"){
1180 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1181 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1182 }else if(aComment == "FAMILY"){
1183 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1184 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1185 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1186 }else if(aComment == "GROUP"){
1187 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1188 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1192 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1196 QApplication::restoreOverrideCursor();
1197 VISU::Mesh_i* pPresent = NULL;
1198 if(!CORBA::is_nil(aMesh))
1199 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
1200 if (pPresent == NULL) {
1201 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1202 tr ("ERR_CANT_BUILD_PRESENTATION"),
1203 tr ("VISU_BUT_OK") );
1207 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1208 VISU_Actor *anActor = pPresent->CreateActor();
1210 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1211 tr ("ERR_CANT_CREATE_ACTOR"),
1212 tr ("VISU_BUT_OK") );
1219 vf->AddActor(anActor);
1220 vf->getRenderer()->ResetCameraClippingRange();
1224 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1228 //GetActiveStudy()->updateObjBrowser(); //not necessary
1229 GetDesktop()->putInfo("Ready");
1232 //=====================================================================================
1233 // function : CreateManyMesh()
1235 //=====================================================================================
1236 void VisuGUI::CreateManyMesh()
1238 if (checkLock(GetStudyDocument())) return;
1240 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1241 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1242 for ( ; It.More(); It.Next() ) {
1243 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( It.Value()->getEntry() );
1245 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1246 aSObj = aSObj->GetFather();
1247 aSObj = aSObj->GetFather();
1248 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1249 if(CORBA::is_nil(anObject)) {
1250 aSObj = aSObj->GetFather();
1251 anObject = VISU::SObjectToObject(aSObj);
1252 if(CORBA::is_nil(anObject)) return;
1254 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1255 if(CORBA::is_nil(aResult)) return;
1257 VISU::Storable::TRestoringMap aMap;
1258 SALOMEDS::GenericAttribute_var anAttr;
1259 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1260 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1261 string aComm = aComment->Value();
1262 QString strIn(aComm.c_str());
1263 VISU::Storable::StrToMap(strIn,aMap);
1266 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1267 if(!isExist) return;
1268 CORBA::Object_var aMesh;
1269 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1270 if(aComment == "ENTITY"){
1271 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1272 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1273 }else if(aComment == "FAMILY"){
1274 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1275 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1276 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1277 }else if(aComment == "GROUP"){
1278 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1279 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1281 QApplication::restoreOverrideCursor();
1282 if(CORBA::is_nil(aMesh)) return;
1284 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
1285 VISU_Actor *anActor = pPresent->CreateActor();
1286 if (! anActor ) return;
1287 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1288 vf->AddActor(anActor);
1289 vf->getRenderer()->ResetCameraClippingRange();
1293 GetDesktop()->putInfo("Ready");
1296 //=====================================================================================
1297 // function : ChangeRepresentation()
1299 //=====================================================================================
1301 static void ShrinkMesh(VISU_Actor *theActor){
1302 if(theActor->isShrunk())
1303 theActor->unShrink();
1305 theActor->setShrink(0.8);
1308 void VisuGUI::ChangeRepresentation(RepresentType theType) {
1309 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d()){
1310 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1315 anActor->SetRepresentation(theType);
1318 ShrinkMesh(anActor);
1321 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1327 void VisuGUI::MakeWireframe() {
1328 ChangeRepresentation(WIREFRAME);
1332 void VisuGUI::MakeSurface() {
1333 ChangeRepresentation(SURFACE);
1337 void VisuGUI::MakePoints() {
1338 ChangeRepresentation(POINTS);
1342 void VisuGUI::MakeShrink() {
1343 ChangeRepresentation(SHRINK);
1348 //=====================================================================================
1349 // functions : Change Propertise
1351 //=====================================================================================
1352 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1353 CORBA::Object_var anObject = GetSelectedObj(theIO);
1354 if(CORBA::is_nil(anObject)) return NULL;
1355 return dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
1358 void VisuGUI::ChageColor() {
1359 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1360 if(!aPrsObject) return;
1362 VISU_Actor* anActor = GetActor(aPrsObject);
1363 if (!anActor) return;
1367 void VisuGUI::ChangeOutlineColor() {
1368 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1369 if(!aPrsObject) return;
1371 VISUMesh_Actor* anActor = dynamic_cast<VISUMesh_Actor*>(GetActor(aPrsObject));
1372 if (!anActor) return;
1373 NewOutlineColor(anActor);
1377 void VisuGUI::ChangeOpacity() {
1378 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1379 if(!aPrsObject) return;
1381 VISU_Actor* anActor = GetActor(aPrsObject);
1382 if (!anActor) return;
1383 NewOpacity(anActor);
1387 void VisuGUI::ChangeLines() {
1388 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1389 if(!aPrsObject) return;
1391 VISU_Actor* anActor = GetActor(aPrsObject);
1392 if (!anActor) return;
1393 NewLinewidth(anActor);
1395 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1397 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1398 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1399 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1400 if ( theDisplaying == VISU::eDisplayOnly )
1402 QList<Plot2d_Curve> clist;
1403 aPlot->getCurves( clist );
1404 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1405 if ( !TableSO->_is_nil() ) {
1406 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1407 for ( ; Iter->More(); Iter->Next() ) {
1408 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1409 if( !CORBA::is_nil( childObject ) ) {
1410 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1411 if( !CORBA::is_nil( aCurve ) ) {
1412 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
1413 Plot2d_Curve* plotCurve = 0;
1414 for ( int i = 0; i < clist.count(); i++ ) {
1415 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1416 plotCurve = clist.at( i );
1420 if ( theDisplaying == VISU::eErase ) {
1422 aPlot->eraseCurve( plotCurve, false );
1423 clist.remove( plotCurve );
1426 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1428 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1429 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1430 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1431 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1432 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1433 /* - DATA NOT UPDATED */
1434 if ( !plotCurve->isAutoAssign() ) {
1435 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1436 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1437 SALOMEDS::Color color = theCurve->GetColor();
1438 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1439 plotCurve->setAutoAssign( theCurve->IsAuto() );
1441 aPlot->displayCurve( plotCurve, false );
1444 Plot2d_Curve* crv = theCurve->CreatePresentation();
1446 aPlot->displayCurve( crv, false );
1447 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1448 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1449 SALOMEDS::Color newColor;
1450 newColor.R = crv->getColor().red()/255.;
1451 newColor.G = crv->getColor().green()/255.;
1452 newColor.B = crv->getColor().blue()/255.;
1453 theCurve->SetColor( newColor );
1464 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1466 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1467 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1468 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1469 // if ( theDisplaying == VISU::eDisplayOnly )
1470 // aPlot->EraseAll();
1471 QList<Plot2d_Curve> clist;
1472 aPlot->getCurves( clist );
1473 Plot2d_Curve* plotCurve = 0;
1474 for ( int i = 0; i < clist.count(); i++ ) {
1475 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1476 plotCurve = clist.at( i );
1478 else if ( theDisplaying == VISU::eDisplayOnly ) {
1479 aPlot->eraseCurve( clist.at( i ) );
1482 if ( theDisplaying == VISU::eErase ) {
1484 aPlot->eraseCurve( plotCurve, false );
1486 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1488 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1489 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1490 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1491 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1492 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1493 /* DATA NOT UPDATED */
1494 if ( !plotCurve->isAutoAssign() ) {
1495 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1496 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1497 SALOMEDS::Color color = theCurve->GetColor();
1498 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1499 plotCurve->setAutoAssign( theCurve->IsAuto() );
1501 aPlot->displayCurve( plotCurve, false );
1504 Plot2d_Curve* crv = theCurve->CreatePresentation();
1506 aPlot->displayCurve( crv, false );
1507 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1508 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1509 SALOMEDS::Color newColor;
1510 newColor.R = crv->getColor().red()/255.;
1511 newColor.G = crv->getColor().green()/255.;
1512 newColor.B = crv->getColor().blue()/255.;
1513 theCurve->SetColor( newColor );
1520 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1522 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1523 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1524 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1525 if ( theDisplaying == VISU::eDisplayOnly )
1527 QList<Plot2d_Curve> clist;
1528 aPlot->getCurves( clist );
1529 if ( container->GetNbCurves() > 0 ) {
1530 int nbCurves = container->GetNbCurves();
1531 for ( int k = 1; k <= nbCurves; k++ ) {
1532 VISU::Curve_i* theCurve = container->GetCurve( k );
1533 if ( theCurve && theCurve->IsValid() ) {
1534 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) );
1535 // for ( int i = 0; i < clist.count(); i++ ) {
1536 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1537 // plotCurve = clist.at( i );
1541 if ( theDisplaying == VISU::eErase ) {
1543 aPlot->eraseCurve( plotCurve, false );
1544 clist.remove( plotCurve );
1547 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1549 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1550 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1551 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1552 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1553 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1554 /* - DATA NOT UPDATED */
1555 if ( !plotCurve->isAutoAssign() ) {
1556 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1557 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1558 SALOMEDS::Color color = theCurve->GetColor();
1559 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1560 plotCurve->setAutoAssign( theCurve->IsAuto() );
1562 aPlot->displayCurve( plotCurve, false );
1565 Plot2d_Curve* crv = theCurve->CreatePresentation();
1567 aPlot->displayCurve( crv, false );
1568 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1569 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1570 SALOMEDS::Color newColor;
1571 newColor.R = crv->getColor().red()/255.;
1572 newColor.G = crv->getColor().green()/255.;
1573 newColor.B = crv->getColor().blue()/255.;
1574 theCurve->SetColor( newColor );
1586 Slot : opens Table view : for Table object or SObject with table attribute selected
1588 void VisuGUI::ShowTable() {
1589 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1590 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1591 if( Sel->IObjectCount() !=1 )
1593 Handle(SALOME_InteractiveObject) anIO;
1594 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1595 SALOMEDS::SObject_var SO;
1596 if ( !CORBA::is_nil( anObject ) ) {
1597 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1598 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1599 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1600 if( !CORBA::is_nil( aTable ) ) {
1601 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
1603 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1608 // possibly this is Table SObject
1609 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1611 SALOMEDS::GenericAttribute_var anAttr;
1612 if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" )
1613 && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) )
1615 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1618 //SAL2670 Orientation of show tables
1619 SALOMEGUI_TableDlg::ttAuto,
1625 Slot : opens Table view : for Table object or SObject with table attribute selected
1627 void VisuGUI::CreateTable() {
1628 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1629 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1630 if( aSel->IObjectCount() !=1 )
1633 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1634 if (anIO->hasEntry()){
1635 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1636 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1637 if(!aSObject->_is_nil()) {
1638 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1639 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1640 SALOMEDS::GenericAttribute_var anAttr;
1641 if(!aCutLines->_is_nil() ||
1642 aSObject->FindAttribute( anAttr, "AttributeTableOfInteger") ||
1643 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ){
1644 GetVisuGen()->CreateTable(aSObject->GetID());
1645 GetActiveStudy()->updateObjBrowser();
1652 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1654 void VisuGUI::PlotData() {
1655 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1656 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1657 if( Sel->IObjectCount() !=1 )
1659 CORBA::Object_var anObject = GetSelectedObj();
1660 SALOMEDS::SObject_var SO;
1661 if ( !CORBA::is_nil( anObject ) ) {
1662 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1663 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1664 // Table (VISU object) is selected
1665 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1666 if( !CORBA::is_nil( aTbl ) ) {
1667 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTbl ) );
1669 SALOMEDS::GenericAttribute_var anAttr;
1670 SALOMEDS::AttributeName_var aName;
1672 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1673 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
1674 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
1675 // get name of SObject
1676 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1677 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1678 SOName = strdup( aName->Value() );
1680 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1681 if ( dlg->exec() == QDialog::Accepted ) {
1682 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1683 // if study is not locked - create new container, create curves
1684 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1686 QValueList<int> verIndices;
1687 dlg->getCurvesSource( horIndex, verIndices );
1688 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1689 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1690 if( !CORBA::is_nil( aContainer ) ) {
1691 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
1693 for ( int i = 0; i < verIndices.count(); i++ ) {
1694 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1695 if( !CORBA::is_nil( aNewCurve ) ) {
1696 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
1699 int marker, line, lineWidth;
1701 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1702 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1703 pCrv->SetColor( c );
1704 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1705 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1707 pContainer->AddCurve( pCrv->_this() );
1711 GetActiveStudy()->updateObjBrowser( true );
1712 PlotContainer( pContainer, VISU::eDisplay );
1718 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
1719 Plot2d_CurveContainer container;
1720 dlg->getCurves( container );
1721 if ( !container.isEmpty() ) {
1722 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1723 getRightFrame()->getViewFrame()))->displayCurves( container, true );
1724 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1725 getRightFrame()->getViewFrame()))->setTitle( SOName );
1736 // possibly this is Table SObject
1737 SALOMEDS::GenericAttribute_var anAttr;
1738 SALOMEDS::AttributeName_var aName;
1741 // check if Table SObject is selected
1742 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1743 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
1744 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
1745 // get name of SObject
1746 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1747 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1748 SOName = strdup( aName->Value() );
1750 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1751 if ( dlg->exec() == QDialog::Accepted ) {
1752 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1753 // if study is not locked - create new table and container objects, create curves
1754 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1756 QValueList<int> verIndices;
1757 dlg->getCurvesSource( horIndex, verIndices );
1758 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1759 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
1760 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1761 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1762 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
1763 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
1765 if ( pContainer && pTable ) {
1766 for ( int i = 0; i < verIndices.count(); i++ ) {
1767 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
1768 if( !CORBA::is_nil( aNewCurve ) ) {
1769 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
1772 int marker, line, lineWidth;
1774 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1775 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1776 pCrv->SetColor( c );
1777 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1778 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1780 pContainer->AddCurve( pCrv->_this() );
1784 GetActiveStudy()->updateObjBrowser( true );
1785 PlotContainer( pContainer, VISU::eDisplay );
1791 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
1792 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1793 Plot2d_CurveContainer container;
1794 dlg->getCurves( container );
1795 if ( !container.isEmpty() ) {
1796 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1797 getRightFrame()->getViewFrame()))->displayCurves( container, true );
1798 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1799 getRightFrame()->getViewFrame()))->setTitle( SOName );
1809 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
1811 void VisuGUI::CurveProperties() {
1812 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1813 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1814 if( Sel->IObjectCount() !=1 )
1816 CORBA::Object_var anObject = GetSelectedObj();
1817 SALOMEDS::SObject_var SO;
1818 if (CORBA::is_nil( anObject )) return;
1820 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1821 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1823 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1824 if( !CORBA::is_nil( aCurve ) ) {
1825 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
1826 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1827 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
1828 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
1829 dlg->setMarker( (int)curve->GetMarker() );
1830 SALOMEDS::Color color = curve->GetColor();
1831 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1832 if( dlg->exec() == QDialog::Accepted ) {
1833 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
1834 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
1835 SALOMEDS::Color newColor;
1836 newColor.R = dlg->getColor().red()/255.;
1837 newColor.G = dlg->getColor().green()/255.;
1838 newColor.B = dlg->getColor().blue()/255.;
1839 curve->SetColor( newColor );
1840 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
1841 if ( sfList.count() > 0 ) {
1842 QListIterator<QAD_StudyFrame> it( sfList );
1843 for ( ; it.current(); ++it ) {
1844 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
1845 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
1846 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
1849 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
1851 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
1852 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
1853 plotCurve->setColor( dlg->getColor() );
1854 aPlot->updateCurve( plotCurve, true );
1867 Slot : Clears container contents : for Container object selected
1869 void VisuGUI::ClearContainer() {
1870 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1871 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1872 if( Sel->IObjectCount() !=1 )
1875 CORBA::Object_var anObject = GetSelectedObj();
1876 SALOMEDS::SObject_var SO;
1877 if (CORBA::is_nil( anObject )) return;
1879 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1880 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1882 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
1883 if( !CORBA::is_nil( aCnt ) ) {
1884 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
1885 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1887 GetActiveStudy()->updateObjBrowser();
1894 void VisuGUI::DeletePrs() {
1895 DeletePresentation(GetSelectedPrs3d());
1899 void VisuGUI::SaveViewParams()
1901 if (checkLock(GetStudyDocument())) return;
1902 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1903 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1904 if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1906 VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
1907 if(!CORBA::is_nil(aVM.in())){
1908 VISU::View_var aView = aVM->GetCurrentView();
1909 if(!CORBA::is_nil(aView.in())){
1910 VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
1911 if(CORBA::is_nil(aView3D.in())) return;
1912 if ( Sel->IObjectCount() == 0 ) {
1913 // Save view parameters by new name
1914 aView3D->SaveViewParams( 0 );
1915 GetActiveStudy()->updateObjBrowser( true );
1918 VISU::Storable::TRestoringMap aMap;
1919 Handle(SALOME_InteractiveObject) anIO;
1920 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
1921 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1922 if(isExist && aType == VISU::TVIEW3D){
1923 aView3D->SaveViewParams( anIO->getName() );
1924 GetActiveStudy()->updateObjBrowser( true );
1932 void VisuGUI::RestoreViewParams()
1934 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1935 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1936 if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1938 VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
1939 if(!CORBA::is_nil(aVM.in())){
1940 VISU::View_var aView = aVM->GetCurrentView();
1941 if(!CORBA::is_nil(aView.in())){
1942 VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
1943 if(CORBA::is_nil(aView3D.in())) return;
1945 VISU::Storable::TRestoringMap aMap;
1946 Handle(SALOME_InteractiveObject) anIO;
1947 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
1948 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1949 if(isExist && aType == VISU::TVIEW3D)
1950 aView3D->RestoreViewParams( anIO->getName() );
1955 //=====================================================================================
1956 // function : DeleteViewParams()
1958 //=====================================================================================
1959 void VisuGUI::DeleteViewParams() {
1961 VISU::Storable::TRestoringMap aMap;
1962 Handle(SALOME_InteractiveObject) anIO;
1963 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
1964 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1965 if(isExist && aType == VISU::TVIEW3D){
1966 SALOMEDS::Study_var aStudy = GetStudyDocument();
1967 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1968 aStudy->NewBuilder()->RemoveObject(aSObject);
1970 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1971 aSel->RemoveIObject(anIO, 0);
1973 GetActiveStudy()->updateObjBrowser( true );
1978 //=====================================================================================
1979 // function : Sweep()
1981 //=====================================================================================
1982 void VisuGUI::Sweep() {
1983 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
1984 if (!aPrsObject) return;
1986 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
1990 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
1991 if ( !aTempoStr.isEmpty() )
1992 aTemp = int(1.E6*(aTempoStr.toFloat()));
1995 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
1996 if ( !aCyclesStr.isEmpty() )
1997 aCycles = aCyclesStr.toInt();
2000 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2001 if ( !aStepsStr.isEmpty() )
2002 aSteps = aStepsStr.toInt();
2004 VISU_Actor* aActor = GetActor(aPrsObject);
2005 if (!aActor) return;
2007 if (!aActor->GetVisibility()) {
2008 aActor->VisibilityOn();
2011 QApplication::setOverrideCursor( Qt::waitCursor );
2012 for (int j=0 ; j<aCycles; j++) {
2013 for (int i=0 ; i<=aSteps; i++) {
2014 float aPercents = float(i)/aSteps;
2015 aPrsObject->SetMapScale(aPercents);
2016 aPrsObject->UpdateActor(aActor);
2017 vf->getRW()->getRenderWindow()->Render();
2021 QApplication::restoreOverrideCursor();
2026 void VisuGUI::TimeAnimation() {
2027 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2028 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2030 bool isDefined = false;
2032 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2033 for (; It.More(); It.Next()) {
2034 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2035 if (aSObject->_is_nil()) continue;
2036 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2037 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2041 aAnimationDlg->addField(aSObject);
2043 } else if (aNbTimes == aNumber) {
2044 aAnimationDlg->addField(aSObject);
2049 if (isDefined) aAnimationDlg->show();
2050 else delete aAnimationDlg;
2054 void VisuGUI::ImportMedField() {
2055 if (checkLock(GetStudyDocument())) return;
2056 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2057 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2058 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2059 QApplication::setOverrideCursor( Qt::waitCursor );
2060 for(;It.More();It.Next()) {
2061 Handle(SALOME_InteractiveObject) anIO = It.Value();
2062 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2063 if(!aSObject->_is_nil()){
2064 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2065 if(!CORBA::is_nil(anObject)){
2066 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2067 if(!CORBA::is_nil(aMED.in()))
2068 GetVisuGen()->ImportMed( aSObject );
2069 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2070 if(!CORBA::is_nil(aField.in()))
2071 GetVisuGen()->ImportMedField( aField );
2073 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2074 SALOMEDS::GenericAttribute_var anAttr;
2075 aSFather->FindAttribute(anAttr, "AttributeName");
2076 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2077 CORBA::String_var aValue = aName->Value();
2078 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2079 GetVisuGen()->ImportMed(aSObject);
2080 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2081 // VisuGUI::myComponent->ImportMed(aSObject);
2085 GetActiveStudy()->updateObjBrowser( true );
2086 QApplication::restoreOverrideCursor();
2089 void VisuGUI::ImportMedMesh() {
2090 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2091 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2092 if ( Sel->IObjectCount() != 1 )
2095 Handle(SALOME_InteractiveObject) anIO;
2096 CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, GetActiveStudy());
2097 if ( !CORBA::is_nil( anObject ) ) {
2098 SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject );
2099 if( !CORBA::is_nil( aMesh ) ) {
2100 GetVisuGen->ImportMedMesh( aMesh );
2101 GetActiveStudy()->updateObjBrowser( true );
2103 SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject );
2104 if( !CORBA::is_nil( aSupport ) ) {
2105 GetVisuGen->ImportMedSupport( aSupport );
2106 GetActiveStudy()->updateObjBrowser( true );
2111 //=====================================================================================
2112 // functions : Rename()
2114 //=====================================================================================
2115 void VisuGUI::Rename() {
2116 if (checkLock(GetStudyDocument())) return;
2117 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2118 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2119 if ( Sel->IObjectCount() != 1 )
2121 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2122 if( aSObj->_is_nil() ) return;
2124 VISU::Curve_i* curve = 0;
2125 CORBA::Object_var anObject = GetSelectedObj();
2126 if ( !CORBA::is_nil( anObject )) {
2127 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2128 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2130 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2131 if( !CORBA::is_nil( aCurve ) ) {
2132 curve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
2137 //TEST DU PARENT == VISU
2138 SALOMEDS::GenericAttribute_var anAttr;
2139 SALOMEDS::AttributeName_var aName;
2140 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2141 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2142 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2143 if ( !Name.isEmpty() ) {
2144 QApplication::setOverrideCursor( Qt::waitCursor );
2146 curve->SetName( Name.latin1() );
2147 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2148 QApplication::restoreOverrideCursor();
2150 //int TypeMode; bool InViewer;
2151 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2152 //ActorTmp->setName((Standard_CString)Name.latin1());
2158 //=====================================================================================
2159 // function : CopyPresentation()
2161 //=====================================================================================
2162 void VisuGUI::CopyPresentation(){
2163 if (checkLock(GetStudyDocument())) return;
2164 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2165 if (!aPrsObject) return;
2166 switch (aPrsObject->GetType()) {
2169 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2170 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2171 aSameMesh->SameAs(aMeshPrs);
2172 UpdateViewer(aSameMesh);
2175 case VISU::TSCALARMAP:
2177 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2178 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2179 aSameScalar->SameAs(aScalarPrs);
2180 UpdateViewer(aSameScalar);
2183 case VISU::TDEFORMEDSHAPE:
2185 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2186 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2187 aSameDeformed->SameAs(aDefPrs);
2188 UpdateViewer(aSameDeformed);
2191 case VISU::TCUTPLANES:
2193 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2194 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2195 aSameCut->SameAs(aCutPrs);
2196 UpdateViewer(aSameCut);
2199 case VISU::TCUTLINES:
2201 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2202 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2203 aSameCut->SameAs(aCutPrs);
2204 UpdateViewer(aSameCut);
2207 case VISU::TISOSURFACE:
2209 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2210 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2211 aSameIso->SameAs(aIsoPrs);
2212 UpdateViewer(aSameIso);
2215 case VISU::TSTREAMLINES:
2217 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2218 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2219 aSameLines->SameAs(aLinesPrs);
2220 UpdateViewer(aSameLines);
2223 case VISU::TVECTORS:
2225 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2226 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2227 aSameVectors->SameAs(aVectorsPrs);
2228 UpdateViewer(aSameVectors);
2232 GetActiveStudy()->updateObjBrowser();
2235 //=====================================================================================
2236 // function : InfoOnPoint() [ slot ]
2238 //=====================================================================================
2239 void VisuGUI::InfoOnPoint(){
2240 SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2241 int aTypeMode = aSel->SelectionMode();
2242 if ( aTypeMode == SelectionPoint ){
2243 if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){
2244 vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput();
2245 VisuGUI_Selection::PickingPoint( GetActiveStudy(), aDataSet);
2248 QAD_MessageBox::warn1( GetDesktop(),
2250 tr ("ERR_WRONG_SELECTION_MODE"),
2251 tr ("VISU_BUT_OK") );
2254 //=====================================================================================
2255 // function : InfoOnCell() [ slot ]
2257 //=====================================================================================
2258 void VisuGUI::InfoOnCell(){
2259 SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2260 int aTypeMode = aSel->SelectionMode();
2261 if( aTypeMode == SelectionCell){
2262 if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){
2263 vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput();
2264 VisuGUI_Selection::PickingCell( GetActiveStudy(), aDataSet);
2267 QAD_MessageBox::warn1( GetDesktop(),
2269 tr ("ERR_WRONG_SELECTION_MODE"),
2270 tr ("VISU_BUT_OK") );
2273 //=====================================================================================
2274 // function : SelectPoint() [ slot ]
2276 //=====================================================================================
2277 void VisuGUI::SelectPoint(){
2278 SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2279 if ( aSel->SelectionMode() != SelectionPoint ) {
2280 QAD_MessageBox::warn1( GetDesktop(),
2282 tr ("ERR_WRONG_SELECTION_MODE"),
2283 tr ("VISU_BUT_OK") );
2286 Handle(SALOME_InteractiveObject) anIO;
2287 if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){
2289 int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"),
2290 tr("Point number:" ),
2294 vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput();
2295 int aMaxId = aDataSet->GetNumberOfPoints();
2296 if (ok && 0 < anId && anId <= aMaxId )
2297 VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId );
2301 //=====================================================================================
2302 // function : SelectCell() [ slot ]
2304 //=====================================================================================
2305 void VisuGUI::SelectCell(){
2306 SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2307 if ( aSel->SelectionMode() != SelectionCell) {
2308 QAD_MessageBox::warn1( GetDesktop(),
2310 tr ("ERR_WRONG_SELECTION_MODE"),
2311 tr ("VISU_BUT_OK") );
2314 Handle(SALOME_InteractiveObject) anIO;
2315 if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){
2317 int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"),
2318 tr("Cell number:" ),
2322 vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput();
2323 int aMaxId = aDataSet->GetNumberOfCells();
2324 if (ok && 0 < anId && anId <= aMaxId )
2325 VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId );
2329 //=====================================================================================
2330 // function : DefinePopup()
2332 //=====================================================================================
2333 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2335 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
2341 //=====================================================================================
2342 // function : checkHomoSelection()
2344 //=====================================================================================
2345 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2346 int VisuGUI::checkHomoSelection()
2348 int selMode = homoNone;
2349 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2350 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2351 for ( ; It.More(); It.Next() ) {
2352 int selNext = homoOther;
2353 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2354 if ( anIO->hasEntry() ) {
2355 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2356 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2357 VISU::Storable::TRestoringMap pMap;
2358 if( !aSObject->_is_nil() ) {
2359 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2360 if ( !CORBA::is_nil( aCORBAObject ) ) {
2361 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2362 if ( !CORBA::is_nil( aVisuObj ) ) {
2363 VISU::VISUType aType = aVisuObj->GetType();
2367 case VISU::TCONTAINER:
2368 selNext = homoCurves; break;
2370 case VISU::TSCALARMAP:
2371 case VISU::TISOSURFACE:
2372 case VISU::TDEFORMEDSHAPE:
2373 case VISU::TCUTPLANES:
2374 case VISU::TCUTLINES:
2375 case VISU::TVECTORS:
2376 case VISU::TSTREAMLINES:
2377 selNext = homoPresentations; break;
2379 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2380 selNext = homoAnimatable; break;
2382 selNext = homoOther; break;
2384 selNext = homoOther;
2389 SALOMEDS::GenericAttribute_var anAttr;
2390 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2391 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2392 string aComm = aComment->Value();
2393 QString strIn( aComm.c_str() );
2394 VISU::Storable::StrToMap( strIn, pMap );
2396 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2402 selNext = homoPresentable; break;
2404 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2405 selNext = homoAnimatable; break;
2407 selNext = homoOther; break;
2409 selNext = homoOther;
2416 if ( selMode == homoNone )
2419 if ( selMode != selNext )
2426 //=====================================================================================
2427 // function : GetNbChildren() [ static ]
2428 // purpose : get number of children
2429 //=====================================================================================
2430 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2432 if ( SO->_is_nil() )
2435 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2436 for ( ; Iter->More(); Iter->Next() ) {
2437 SALOMEDS::SObject_var refSO;
2438 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2444 //=====================================================================================
2445 // function : CustomPopup()
2447 //=====================================================================================
2448 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2449 const QString & theParent, const QString & theObject)
2451 int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2452 VisuGUI::GetOrCreateVisuGUI(parent);
2453 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2455 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2458 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2459 if ( Sel->IObjectCount() == 0 ) {
2460 if ( theParent == "Viewer" && isVTKViewer)
2461 // Available only for VTK viewer
2462 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2466 if( Sel->IObjectCount() > 1 ) {
2467 int selMode = checkHomoSelection();
2468 MESSAGE( "VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2469 if ( selMode == homoCurves ) {
2470 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2471 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2472 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2475 else if ( selMode == homoPresentations ) {
2477 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2478 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2481 else if ( selMode == homoPresentable ) {
2482 thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2484 else if ( selMode == homoAnimatable ) {
2485 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2490 VISU::Storable::TRestoringMap aMap;
2491 Handle(SALOME_InteractiveObject) anIO;
2492 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2493 if (!CORBA::is_nil(anObject)) {
2494 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2495 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2496 if (!CORBA::is_nil(aVisuObj)) {
2497 VISU::VISUType aType = aVisuObj->GetType();
2498 MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2500 case VISU::TVISUGEN:
2501 thePopup->insertItem("Import From File", visuGUI, SLOT(ImportFromFile()));
2505 //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh()));
2506 thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile()));
2507 //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2511 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2512 thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2513 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2514 if ( GetNbChildren( aSObject, false ) > 0 ) {
2515 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2516 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2517 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2523 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2524 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2525 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2527 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2528 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2529 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2531 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2532 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2536 case VISU::TCONTAINER:
2537 if( !CORBA::is_nil( anObject ) ) {
2538 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2539 if( !CORBA::is_nil( aCnt ) ) {
2540 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
2541 if ( container && container->GetNbCurves() > 0 ) {
2542 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) )
2543 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2544 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2545 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2546 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2547 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2554 default: // Presentation
2556 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
2558 VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject);
2560 // Add Presentation menu
2561 if ((aType != VISU::TSTREAMLINES) && anVISUActor) {
2562 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2563 int aRepresent = anVISUActor->GetRepresentation();
2566 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2567 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2570 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2571 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2574 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2575 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2578 if (anVISUActor->GetShrinkable()) {
2579 if (anVISUActor->isShrunk())
2580 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2582 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2584 thePopup->insertItem("Representation", aPresMenu);
2588 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2589 if ((aType == VISU::TMESH) ||
2590 (aType == VISU::TDEFORMEDSHAPE) ||
2591 (aType == VISU::TVECTORS) ||
2592 (aType == VISU::TSTREAMLINES))
2593 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2594 if (aType == VISU::TMESH)
2595 aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor()));
2597 if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES))
2598 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2599 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2600 thePopup->insertItem("Properties", aPropMenu);
2602 thePopup->insertSeparator();
2604 thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
2605 if (aType != VISU::TMESH) {
2606 if (aType != VISU::TSCALARMAP)
2607 thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
2608 thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar()));
2610 if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES)
2611 && (aType != VISU::TCUTLINES) && isVTKViewer)
2612 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
2614 if (aType == VISU::TCUTLINES)
2615 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
2618 if ( theParent == "Viewer" &&
2619 ( aType == VISU::TMESH ||
2620 aType == VISU::TSCALARMAP ||
2621 aType == VISU::TDEFORMEDSHAPE ) ) {
2622 thePopup->insertSeparator();
2623 if ( Sel->SelectionMode() == SelectionPoint ) {
2624 thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint()));
2625 thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint()));
2627 else if ( Sel->SelectionMode() == SelectionCell) {
2628 thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell()));
2629 thePopup->insertItem("Select a Cell", visuGUI, SLOT(SelectCell()));
2632 thePopup->insertSeparator();
2633 if (visuGUI->IsDisplayed(aPrsObject) )
2634 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
2636 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
2638 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
2640 if (aType != VISU::TMESH) {
2641 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2642 thePopup->insertSeparator();
2643 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
2651 // possibly this is the MED field/mesh and suppot objects
2652 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
2653 if(!CORBA::is_nil(aMED))
2654 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
2655 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2656 if(!CORBA::is_nil(aField))
2657 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
2661 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2662 if(!aSObject->_is_nil()){
2664 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2670 thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
2673 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2674 // Available only for VTK viewer
2675 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2676 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
2678 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
2679 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
2682 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
2683 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2685 case VISU::TTIMESTAMP: {
2686 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
2687 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_SCALAR_MAP") ),
2688 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
2689 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ),
2690 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
2691 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ),
2692 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
2693 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_LINES") ),
2694 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
2695 if(aNunComponent > 1){
2696 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ),
2697 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
2698 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ),
2699 "Vectors...", visuGUI, SLOT(CreateVectors()));
2700 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ),
2701 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
2708 SALOMEDS::GenericAttribute_var anAttr;
2709 if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
2710 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){
2711 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
2712 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
2715 aSObject = aSObject->GetFather();
2716 aSObject->FindAttribute(anAttr, "AttributeName");
2717 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2718 CORBA::String_var aValue = aName->Value();
2719 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2720 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
2721 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2722 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
2729 //===========================================================================
2730 // BuildPresentation
2731 //===========================================================================
2732 void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2734 BEGIN_OF("VisuGUI::BuildPresentation");
2736 if (theIO.IsNull()) {
2737 MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
2741 /* Create or retrieve an object VisuGUI */
2743 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
2745 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2746 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2748 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
2750 vtkRenderer *Renderer = GetRenderer();
2752 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
2754 if (aSObj -> _is_nil() ) {
2755 MESSAGE("No SObject for interacative object is found");
2759 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
2760 if(!CORBA::is_nil(anObject)) {
2762 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
2763 if ( !aPrsObject ) {
2764 MESSAGE("The object is not VISU::Prs3d_i");
2767 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
2768 if ( ! SelectedActor )
2769 SelectedActor = aPrsObject -> CreateActor();
2770 SCRUTE(SelectedActor);
2771 if ( SelectedActor == NULL ) {
2772 MESSAGE("VisuGUI::BuildPresentation(): actor doesn't exist in Render");
2775 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
2776 vf->AddActor(SelectedActor);
2779 MESSAGE("CORBA::is_nil(anObject) = true");
2781 END_OF("VisuGUI::BuildPresentation");
2788 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
2790 //MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID);
2791 return VisuGUI::OnGUIEvent(theCommandID, parent);
2794 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
2796 MESSAGE("VisuGUI::OnKeyPress ");
2797 return VisuGUI::OnKeyPress (pe, parent, studyFrame);
2800 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
2802 //MESSAGE("VisuGUI::OnMousePress ");
2803 return VisuGUI::OnMousePress (pe, parent, studyFrame);
2806 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
2808 //MESSAGE("VisuGUI::OnMouseMove ");
2809 return VisuGUI::OnMouseMove (pe, parent, studyFrame);
2812 bool SetSettings ( QAD_Desktop* parent )
2814 return VisuGUI::setSettings( parent );
2817 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
2818 const QString & theParent, const QString & theObject )
2820 return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
2823 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
2825 VisuGUI::DefinePopup( theContext, theParent, theObject );
2828 bool activeStudyChanged ( QAD_Desktop* parent )
2830 //VisuGUI::activeStudyChanged( parent );
2832 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
2834 VisuGUI::BuildPresentation(theIO);
2837 void supportedViewType(int* buffer, int bufferSize)
2839 if (!buffer || !bufferSize) return;
2840 buffer[0] = (int)VIEW_VTK;
2841 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
2846 //////////////////////////////////////////////////////////////////////////////////
2847 //////////////// CHANGE ACTOR COLOR ////////////////////////
2848 //////////////////////////////////////////////////////////////////////////////////
2849 ///////////////// /////////////////////////////////////////////////////////////////
2850 // change actor color
2851 // In : Name of Actor
2855 void VisuGUI::NewColor(VISU_Actor *theActor){
2856 if(VISU::Prs3d_i* aPrs3d = theActor->getPrs3d()){
2857 SALOMEDS::Color anOldColor = aPrs3d->GetColor(), aNewColor;
2858 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
2859 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
2860 if(aColorNew.isValid()){
2861 aNewColor.R = aColorNew.red()/255.;
2862 aNewColor.G = aColorNew.green()/255.;
2863 aNewColor.B = aColorNew.blue()/255.;
2864 aPrs3d->SetColor(aNewColor);
2866 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
2867 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
2868 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
2869 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
2870 if(VISU_Actor* anActor = GetActor(aPrs3d,aViewFrame))
2871 aPrs3d->UpdateActor(anActor);
2877 void VisuGUI::NewOutlineColor(VISUMesh_Actor *theActor){
2878 if(VISU::Mesh_i* aPrs3d = dynamic_cast<VISU::Mesh_i*>(theActor->getPrs3d())){
2879 SALOMEDS::Color anOldColor = aPrs3d->GetColor(), aNewColor;
2880 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
2881 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
2882 if(aColorNew.isValid()){
2883 aNewColor.R = aColorNew.red()/255.;
2884 aNewColor.G = aColorNew.green()/255.;
2885 aNewColor.B = aColorNew.blue()/255.;
2886 aPrs3d->SetLinkColor(aNewColor);
2887 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
2888 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
2889 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
2890 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
2891 if(VISU_Actor* anActor = GetActor(aPrs3d,aViewFrame))
2892 aPrs3d->UpdateActor(anActor);
2898 //////////////////////////////////////////////////////////////////////////////////
2899 //////////////// CHANGE ACTOR OPACITY ////////////////////////
2900 //////////////////////////////////////////////////////////////////////////////////
2901 //////////////////////////////////////////////////////////////////////////////////
2902 // change actor opacity
2903 // In : Name of Actor
2905 // Use CursorDlg to select a value between 0 and 100
2908 void VisuGUI::NewOpacity(VISU_Actor *Actor)
2911 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
2913 float oldopac,newopac;
2915 CursorDlg->Comment1->setText( tr( "Set value between") );
2916 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
2917 oldopac=Actor->GetProperty()->GetOpacity();
2918 intopac=int(oldopac*100.);
2919 CursorDlg->SpinBox1->setMinValue(0);
2920 CursorDlg->SpinBox1->setMaxValue(100);
2921 CursorDlg->SpinBox1->setValue(intopac);
2923 int ret = CursorDlg->exec();
2926 intopac = CursorDlg->SpinBox1->value() ;
2927 newopac = intopac/100.;
2928 Actor->GetProperty()->SetOpacity(newopac);
2933 //////////////////////////////////////////////////////////////////////////////////
2934 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
2935 //////////////////////////////////////////////////////////////////////////////////
2936 //////////////////////////////////////////////////////////////////////////////////
2937 // change actor linewidth
2938 // In : Name of Actor
2940 // Use CursorDlg to select a value between 0 and 10
2943 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
2946 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
2948 float oldlwid,newlwid;
2950 CursorDlg->Comment1->setText("Set value between");
2951 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
2952 oldlwid=Actor->GetLineWidth();
2953 intlwid=int(oldlwid);
2954 CursorDlg->SpinBox1->setMinValue(1);
2955 CursorDlg->SpinBox1->setMaxValue(10);
2956 CursorDlg->SpinBox1->setValue(intlwid);
2958 int ret = CursorDlg->exec();
2960 intlwid = CursorDlg->SpinBox1->value() ;
2962 Actor->SetLineWidth(newlwid);
2967 /* ======================================================================================== */
2968 /* Setting parameters for Scalar Bar */
2969 /* ======================================================================================== */
2970 void VisuGUI::ChangeScalarBar()
2972 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
2973 Scbar->initFromResources();
2974 int ret = Scbar->exec();
2976 Scbar->storeToResources();
2981 /* ======================================================================================== */
2982 /* Setting parameters for Sweeping */
2983 /* ======================================================================================== */
2984 void VisuGUI::SetSweepingPreferences()
2990 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
2991 if ( !Tempo.isEmpty() )
2992 tempo = Tempo.toFloat();
2994 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
2995 if ( !Cycles.isEmpty() )
2996 cycles = Cycles.toInt();
2998 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
2999 if ( !Steps.isEmpty() )
3000 steps = Steps.toInt();
3002 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3004 Sweep->setTimeStep( tempo );
3005 Sweep->setNbCycles( cycles );
3006 Sweep->setNbSteps ( steps );
3008 if ( Sweep->exec() )
3010 tempo = Sweep->getTimeStep();
3011 cycles = Sweep->getNbCycles();
3012 steps = Sweep->getNbSteps();
3014 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3015 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3016 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3021 /* ======================================================================================== */
3022 /* Returns Visu input files directory (default is CSF_PATHData) */
3023 /* ======================================================================================== */
3024 QString VisuGUI::getVisuInputDir()
3026 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3027 if ( Tmp.isEmpty() )
3028 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3029 Tmp = QAD_Tools::addSlash(Tmp);
3033 /* ======================================================================================== */
3034 /* Returns Visu output files directory (default is InputDir) */
3035 /* ======================================================================================== */
3036 QString VisuGUI::getVisuOutputDir()
3038 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3039 if ( Tmp.isEmpty() )
3041 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3042 if ( Tmp2.isEmpty() )
3043 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3047 Tmp = QAD_Tools::addSlash(Tmp);
3052 /* ======================================================================================== */
3053 /* Global Method for Scalar Map */
3054 /* ======================================================================================== */
3055 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3056 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3057 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
3058 SALOMEDS::SObject_var aSObj = theField->GetFather();
3059 if (CORBA::is_nil(aSObj)) return NULL;
3060 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3061 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3062 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3063 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3064 if(CORBA::is_nil(anObject)) return NULL;
3065 theResult = VISU::Result::_narrow(anObject);
3066 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject));
3068 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3069 tr ("WRN_NO_AVAILABLE_DATA"),
3070 tr ("VISU_BUT_OK"));
3074 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3075 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3076 const char* theMeshName, VISU::Entity theEntity, \
3077 const char* theFieldName, double theTimeId) {\
3078 VISU::Result_var aResult; \
3079 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3080 if(pResult != NULL){ \
3081 if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \
3082 QApplication::setOverrideCursor( Qt::waitCursor ); \
3083 CORBA::Object_var anObject = \
3084 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3085 QApplication::restoreOverrideCursor(); \
3086 if(!CORBA::is_nil(anObject)) \
3087 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject)); \
3090 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3091 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3092 tr ("VISU_BUT_OK") ); \
3096 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3097 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3098 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3099 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3100 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3101 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3102 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3105 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3106 bool FNAME(SALOMEDS::SObject_var theField) { \
3107 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3109 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3110 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3111 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3112 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3113 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3114 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3115 Utils_Timer timer; \
3116 if(MYCHECKTIME) timer.Start(); \
3117 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toDouble()); \
3120 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
3124 DLGNAME* aDlg = new DLGNAME(); \
3125 aDlg->initFromPrsObject(pPresent); \
3126 if (aDlg->exec()) { \
3127 aDlg->storeToPrsObject(pPresent); \
3129 DeletePresentation(pPresent); \
3134 CreateActor(pPresent); \
3140 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3141 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3142 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3143 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3144 BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3145 BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3146 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3150 /* ======================================================================================== */
3151 /* Global Method to import tables from file */
3152 /* ======================================================================================== */
3153 void VisuGUI::ImportTablesFromFile(){
3155 flt.append( "Files (*.xls *.txt *.tab)" );
3156 flt.append( "All Files (*.*)" );
3157 QString aDir = getVisuInputDir();
3158 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3159 aDir,flt,tr("Import From File"),true);
3160 if(!aFile.isEmpty()){
3161 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." );
3162 aDir = QAD_Tools::getDirFromPath(aFile);
3163 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3164 QApplication::setOverrideCursor( Qt::waitCursor );
3165 QAD_PyInterp* myPyInterp = GetActiveStudy()->get_PyInterp();
3166 myPyInterp->run("import VisuGUI");
3167 myPyInterp->run("reload(VisuGUI)");
3168 myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')");
3169 // VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1());
3170 // if(aResult->_is_nil())
3171 // QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3172 // tr ("There is an error in imported file"),
3173 // tr ("VISU_BUT_OK") );
3175 // QAD_Application::getDesktop()->putInfo(aFile+" imported.");
3176 GetActiveStudy()->updateObjBrowser(); //update Object browser
3177 QApplication::restoreOverrideCursor();
3181 /* ======================================================================================== */
3182 /* Global Method to import mesh results in MED and DAT format */
3183 /* ======================================================================================== */
3184 void VisuGUI::ImportFromFile(){
3185 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3187 //flt.append( "Exportable Files (*.med *.dat)" );
3188 //flt.append( "Dat Files (*.dat)" );
3189 flt.append( "Med Files (*.med)" );
3190 QString aDir = getVisuInputDir();
3191 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3192 aDir,flt,tr("Import From File"),true);
3193 if(!aFile.isEmpty()){
3194 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." );
3195 aDir = QAD_Tools::getDirFromPath(aFile);
3196 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3199 CORBA::Object_var anObject;
3204 if(aFileInfo.extension(false) == "med")
3205 anObject = GetVisuGen()->ImportFile(aFileInfo.filePath());
3206 else if(aFileInfo.extension(false) == "xls")
3207 anObject = GetVisuGen()->ImportTables(aFileInfo.filePath());
3210 MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
3214 if(CORBA::is_nil(anObject)) {
3216 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3217 tr ("ERR_ERROR_IN_THE_FILE"),
3218 tr ("VISU_BUT_OK") );
3222 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3224 GetActiveStudy()->updateObjBrowser(); //update Object browser
3228 void VisuGUI::ExportToFile(){
3229 CORBA::Object_var anObject = GetSelectedObj();
3230 if(CORBA::is_nil(anObject)) return;
3231 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject));
3232 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3234 flt.append( "Dat Files (*.dat)" );
3235 flt.append( "Med Files (*.med)" );
3236 QString aDir = getVisuOutputDir();
3237 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3238 aDir,flt,tr("Export To File"),false);
3239 if(!aFile.isEmpty()){
3240 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3241 aDir = QAD_Tools::getDirFromPath(aFile);
3242 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3243 if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3245 aResult->GetInput()->ToFile(aFile.latin1());
3246 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3248 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3249 tr ("ERR_ERROR_DURING_EXPORT"),
3250 tr ("VISU_BUT_OK") );
3255 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3256 tr ("WRN_NO_AVAILABLE_DATA"),
3257 tr ("VISU_BUT_OK"));
3260 /* ======================================================================================== */
3261 /* Test and Read Object Browser before display */
3262 /* ======================================================================================== */
3263 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3264 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3265 Handle(SALOME_InteractiveObject) anIO;
3266 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3267 if(anIO->hasEntry()){
3268 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3269 QString aValue = getValue(objVisu,"myType");
3270 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3272 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3273 tr("WRN_NO_AVAILABLE_DATA"),
3274 tr("VISU_BUT_OK") );
3279 * Returns Actor of presentation if it exists
3281 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3282 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3283 if (!vf) return NULL;
3285 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3286 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3287 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3288 if(thePrs == anVISUActor->getPrs3d())
3289 return anVISUActor->GetParent();
3294 * Displays only actor of given presentation
3295 * Creates it if it is abcent
3297 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3298 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3299 if (!vf) return NULL;
3301 vtkRenderer *aRen = vf->getRenderer();
3302 vtkActorCollection *anActColl = aRen->GetActors();
3305 VISU_Actor* anVISUActor = NULL;
3306 VISU_Actor* aResActor = NULL;
3307 VISU::Prs3d_i* aSrcAddr = thePrs;
3308 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3309 if(anActor->IsA("VISU_Actor")){
3310 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3311 VISU::Prs3d_i* aPrs = anVISUActor->getPrs3d();
3312 if(aPrs == NULL) continue;
3313 if (thePrs == aPrs) {
3314 aResActor = anVISUActor->GetParent();
3315 thePrs->UpdateActor(aResActor);
3316 aResActor->VisibilityOn();
3317 } else if (theDispOnly) {
3318 anVISUActor->VisibilityOff();
3322 if (aResActor) return aResActor;
3323 anVISUActor = thePrs->CreateActor();
3324 MESSAGE("UpdateViewer - thePrs->CreateActor() = "<<anVISUActor);
3325 if ( anVISUActor ) {
3326 vf->AddActor(anVISUActor);
3328 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3329 tr ("ERR_CANT_VISUALIZE_OBJECT"),
3330 tr ("VISU_BUT_OK") );
3336 * Returns TRUE if Presentation is displayed
3338 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
3339 VISU_Actor* anVISUActor = GetActor(thePrs);
3340 return (anVISUActor)? anVISUActor->GetVisibility() : false;
3344 * Erases Presentation
3346 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
3347 GetActiveStudy()->unHighlightAll();
3348 VISU_Actor* anVISUActor = GetActor(thePrs);
3350 anVISUActor->VisibilityOff();
3355 * Deletes given presentation from Data structure
3357 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
3358 if(checkLock(GetStudyDocument()) || !thePrs) return;
3359 GetActiveStudy()->unHighlightAll();
3360 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
3361 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
3362 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
3363 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
3364 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
3365 aViewFrame->RemoveActor(anActor);
3370 GetActiveStudy()->updateObjBrowser(); //update Object browser
3374 * Creates new actor of presentation
3376 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
3377 if (!thePrs) return;
3378 QApplication::setOverrideCursor( Qt::waitCursor );
3379 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3385 VISU_Actor* aActor = thePrs->CreateActor();
3387 QApplication::restoreOverrideCursor();
3388 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3389 tr ("WRN_CANT_VISUALIZE_PRS"),
3390 tr ("VISU_BUT_OK") );
3393 vf->AddActor(aActor);
3396 MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
3400 QApplication::restoreOverrideCursor();
3405 /* ======================================================================================== */
3406 /* Functions to State of VisuGUI and Dialog Box */
3407 /* ======================================================================================== */
3409 void VisuGUI::SetState(int aState )
3411 this->myState = aState ;
3416 void VisuGUI::ResetState()
3418 this->myState = -1 ;
3422 void VisuGUI::EmitSignalDeactivateDialog()
3424 emit this->SignalDeactivateActiveDialog() ;
3428 void VisuGUI::EmitSignalCloseAllDialogs()
3430 emit this->SignalCloseAllDialogs() ;
3434 QDialog* VisuGUI::GetActiveDialogBox()
3436 return this->myActiveDialogBox ;
3439 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
3441 this->myActiveDialogBox = (QDialog*)aDlg ;