3 // Created : Wed Aug 01 10:20:18 2001
4 // Author : Laurent CORNABE
7 // Copyright : PRINCIPIA
11 #include "VisuGUI_PhaseDlg.h"
12 #include "VisuGUI_MagnitudeDlg.h"
13 #include "VisuGUI_PhaseMagnitudeDlg.h"
14 #include "VisuGUI_PartialScaDlg.h"
15 #include "VisuGUI_CursorDlg.h"
16 #include "VisuGUI_ScalarBarDlg.h"
17 #include "VisuGUI_SweepPrefDlg.h"
18 #include "VisuGUI_CutPlanesDlg.h"
19 #include "VisuGUI_VectorsDlg.h"
20 #include "VisuGUI_IsoSurfacesDlg.h"
21 #include "VisuGUI_StreamLinesDlg.h"
22 #include "VisuGUI_TimeAnimation.h"
24 #include "VisuGUI_Selection.h"
25 #include "VisuGUI_VisuAsDlg.h"
26 #include "VisuGUI_SelVectCompDlg.h"
27 #include "VisuGUI_NonIsometricDlg.h"
29 #include "VISU_Gen_i.hh"
30 #include "VISU_Result_i.hh"
31 #include "VISU_Extractor.hxx"
32 #include "VISU_Table_i.hh"
33 #include "VISU_ViewManager_i.hh"
34 #include "VISU_LookupTable.hxx"
35 #include "VISU_ScalarBarActor.hxx"
37 #include "SALOMEGUI_ImportOperation.h"
38 #include "SALOMEGUI_QtCatchCorbaException.hxx"
39 #include "utilities.h"
41 #include "QAD_Config.h"
43 #include "QAD_Settings.h"
44 #include "QAD_Tools.h"
45 #include "QAD_LeftFrame.h"
46 #include "QAD_RightFrame.h"
47 #include "QAD_MessageBox.h"
48 #include "QAD_ObjectBrowser.h"
49 #include "QAD_ObjectBrowserItem.h"
50 #include "QAD_Menus.h"
51 #include "QAD_Resource.h"
52 #include "QAD_ResourceMgr.h"
53 #include "QAD_FileDlg.h"
54 #include "SALOME_Selection.h"
55 #include "SALOMEGUI_NameDlg.h"
56 #include "SALOMEGUI_TableDlg.h"
57 #include "SALOMEGUI_SetupCurveDlg.h"
58 #include "SALOMEGUI_SetValueDlg.h"
59 #include "Plot2d_SetupPlot2dDlg.h"
60 #include "Plot2d_ViewFrame.h"
61 #include "VTKViewer_ViewFrame.h"
64 #define INCLUDE_MENUITEM_DEF
65 #include <qpopupmenu.h>
69 #include <qapplication.h>
70 #include <qinputdialog.h>
71 #include <qcolordialog.h>
74 #include <qradiobutton.h>
77 #include <qcombobox.h>
79 //VRV: porting on Qt 3.0.5
80 #if QT_VERSION >= 0x030005
81 #include <qlistview.h>
83 //VRV: porting on Qt 3.0.5
84 #include <qmessagebox.h>
87 #include CORBA_CLIENT_HEADER(Med_Gen)
90 #include <vtkCellCenters.h>
91 //#include <vtkOutlineFilter.h>
92 #include <vtkDataSetMapper.h>
93 #include <vtkWarpVector.h>
94 #include <vtkContourFilter.h>
95 #include <vtkCellDataToPointData.h>
96 #include <vtkShrinkFilter.h>
98 // Open CASCADE Include
99 #include <TCollection_AsciiString.hxx>
103 #include <OSD_Timer.hxx>
107 static int MYDEBUG = 1;
108 static int MYDEBUGWITHFILES = 0;
110 static int MYDEBUG = 0;
111 static int MYDEBUGWITHFILES = 0;
114 // unique name visu entity
115 //static bool localContext = false;
116 static VisuGUI_Selection *Selection;
117 static int VISU_POINT_SIZE = 5;
119 QAD_Study* VisuGUI::myActiveStudy = NULL;
120 VISU::VISU_Gen_var VisuGUI::myComponent = VISU::VISU_Gen::_nil();
121 SALOMEDS::Study_var VisuGUI::myStudy = SALOMEDS::Study::_nil();
122 SALOMEDS::StudyBuilder_var VisuGUI::myStudyBuilder = SALOMEDS::StudyBuilder::_nil();
123 QAD_Desktop* VisuGUI::myDesktop = NULL;
125 QAD_Study* MYActiveStudy = NULL;
126 SALOMEDS::StudyBuilder_var MYStudyBuilder = SALOMEDS::StudyBuilder::_nil();
127 SALOMEDS::Study_var MYStudyDocument = SALOMEDS::Study::_nil();
129 const QString ObjectTypes("FIELD VIEW3D MESH TIMESTAMP ENTITY FAMILY GROUP");
132 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 *visuGUI = 0;
155 static QString PREFIX = QString(getenv("USER")) + "-VISU-";
159 vtkRenderer* VisuGUI::GetRenderer(QAD_Study* theStudy){
160 if (theStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
163 return ((VTKViewer_ViewFrame*)theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
168 * Finds value by given key
171 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
172 VISU::Storable::TRestoringMap aMap;
173 if(!theSObject->_is_nil()){
174 SALOMEDS::GenericAttribute_var anAttr;
175 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
176 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
177 CORBA::String_var aString = aComment->Value();
178 QString strIn(aString.in());
179 VISU::Storable::StrToMap(strIn,aMap);
185 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
187 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
189 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
194 CORBA::Object_var GetSelectedObj(string& theComment, Handle(SALOME_InteractiveObject)& theIO, QAD_Study* theStudy){
195 SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection());
196 if( Sel->IObjectCount() > 0 ) {
197 theIO = Sel->firstIObject();
198 if (theIO->hasEntry()){
199 SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(theIO->getEntry());
200 if(!aSObject->_is_nil()){
201 SALOMEDS::GenericAttribute_var anAttr;
202 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
203 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
204 theComment = aComment->Value();
205 QString strIn(theComment.c_str());
206 VISU::Storable::TRestoringMap aMap;
207 VISU::Storable::StrToMap(strIn,aMap);
209 theComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
210 if(!isExist) theComment = "NONE";
214 aSObject->FindAttribute(anAttr, "AttributeIOR");
215 if(!anAttr->_is_nil()){
216 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
217 if(!anIOR->_is_nil()){
218 CORBA::String_var aValue = anIOR->Value();
219 if(strcmp(aValue,"") != 0){
220 CORBA::ORB_var anORB = VISU::GetORB();
221 CORBA::Object_var anObject = anORB->string_to_object(aValue);
229 return CORBA::Object::_nil();
232 CORBA::Object_var GetSelectedObj(QAD_Study* theStudy, Handle(SALOME_InteractiveObject)* pIO = NULL,
233 VISU::Storable::TRestoringMap* pMap = NULL)
235 SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection());
236 if( Sel->IObjectCount() > 0 ) {
237 Handle(SALOME_InteractiveObject)& anIO = (*pIO) = Sel->firstIObject();
238 if (anIO->hasEntry()){
239 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
240 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
241 if(!aSObject->_is_nil()){
242 SALOMEDS::GenericAttribute_var anAttr;
243 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
244 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
245 string aComm = aComment->Value();
246 QString strIn(aComm.c_str());
247 VISU::Storable::StrToMap(strIn,*pMap);
249 return VISU::SObjectToObject(aSObject);
253 return CORBA::Object::_nil();
256 int IsTrihedronDisplayed(){
257 QAD_ViewFrame* aViewFrame = MYActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
258 VTKViewer_ViewFrame* aVTKViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
259 return aVTKViewFrame->isTrihedronDisplayed();
263 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
264 QAD_ViewFrame* aViewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
265 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
269 void RepaintCurrentView(){
270 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
276 VISU_Actor* GetActorByIO(const Handle(SALOME_InteractiveObject)& theIO, vtkRenderer* theRen) {
277 vtkActorCollection* aActors = theRen->GetActors();
279 VISU_Actor* aVisuActor;
280 for (aActors->InitTraversal(); (anActor = aActors->GetNextActor())!=NULL;) {
281 if (anActor->IsA("VISU_Actor")) {
282 aVisuActor = VISU_Actor::SafeDownCast(anActor);
283 if (aVisuActor->hasIO()) {
284 if (theIO->isSame(aVisuActor->getIO()))
292 VISU::Base_i* GetSelectedVisuObj(){
293 SALOME_Selection* Sel = SALOME_Selection::Selection(MYActiveStudy->getSelection());
294 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
296 Handle(SALOME_InteractiveObject) IObject = It.Value();
297 if (IObject->hasEntry()){
298 SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(IObject->getEntry());
299 if(!aSObject->_is_nil()){
300 CORBA::Object_var aObject = VISU::SObjectToObject(aSObject);
301 if(!CORBA::is_nil(aObject))
302 return dynamic_cast<VISU::Base_i*>(VISU::GetServant(aObject));
310 * Returns selected sclalar mode or -1 if it was cancelled
312 int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){
314 // const VISU::TField* aField = theResult->GetInput()->GetField(theFieldName);
315 // if(aField->myNbComp > 1){
316 // VisuGUI_SelVectCompDlg* SelCompDlg = new VisuGUI_SelVectCompDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
317 // if(SelCompDlg->exec()){
318 // aScalarMode = SelCompDlg->whatIsChecked();
322 // delete SelCompDlg;
332 VisuGUI* VisuGUI::GetOrCreateVisuGUI( QAD_Desktop* desktop ){
334 static VisuGUI VISUGUI;
336 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Visu");
337 myComponent = VISU::VISU_Gen::_narrow(comp);
339 /* study may have changed */
341 myActiveStudy = myDesktop->getActiveStudy();
342 myStudy = myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
343 myComponent->SetCurrentStudy(myStudy);
344 myStudyBuilder = myStudy->NewBuilder();
346 MYActiveStudy = myActiveStudy;
347 MYStudyDocument = myStudy;
348 MYStudyBuilder = myStudyBuilder;
352 /* ********************************************************************************* */
353 /* Function to return VisuGUI object */
354 /* ********************************************************************************* */
355 VisuGUI* VisuGUI::GetVisuGUI( )
357 return VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
360 /* ==================================================================================== */
361 /* ==================================================================================== */
363 /* ==================================================================================== */
364 /* ==================================================================================== */
366 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
367 return theStudy->GetProperties()->IsLocked();
370 static int checkLock(const SALOMEDS::Study_var& theStudy) {
371 if (isStudyLocked(theStudy)) {
372 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
373 QObject::tr("WARNING"),
374 QObject::tr("WRN_STUDY_LOCKED"),
375 QObject::tr("BUT_OK") );
383 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
386 VisuGUI::GetOrCreateVisuGUI(parent);
387 // get Visu directories from configuration file. Default values are enabled.
388 /* if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) { // BugID: SAL931
389 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
390 tr ("Not available in Non-VTK viewers"),
391 tr ("VISU_BUT_OK") );
393 QString VisuInputDir = getVisuInputDir();
394 QString VisuOutputDir = getVisuOutputDir();
395 vtkRenderer *theRenderer = GetRenderer(visuGUI->myActiveStudy);
397 //vtkActorCollection* aActors = theRenderer->GetActors();
398 //cout<<"### Actors Nb="<<aActors->GetNumberOfItems()<<endl;
400 SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
401 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
402 SALOMEDS::GenericAttribute_var anAttr;
403 SALOMEDS::AttributeName_var aName;
404 SALOMEDS::AttributeIOR_var anIOR;
406 switch (theCommandID)
408 /* ======================================================================================== */
409 /* Define Selection Mode */
410 /* ======================================================================================== */
416 QApplication::setOverrideCursor( Qt::waitCursor );
417 int mode = theCommandID - 100; // Point, Edge, Cell, Actor
418 parent->SetSelectionMode( mode );
419 QApplication::restoreOverrideCursor();
423 /* ======================================================================================== */
424 /* Import Table from file */
425 /* ======================================================================================== */
429 if(checkLock(aStudy)) break;
430 visuGUI->ImportTablesFromFile();
434 /* ======================================================================================== */
435 /* Import Mesh from MED, DAT file */
436 /* ======================================================================================== */
440 visuGUI->ImportFromFile();
444 /* ======================================================================================== */
445 /* Export results and mesh into a file format */
446 /* ======================================================================================== */
450 visuGUI->ExportToFile();
454 /* ========================================================================================================================= */
455 /* Print to printer (132) or in file (131) */
456 /* ========================================================================================================================= */
462 if (theCommandID == 131) { // save the file
463 prFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
468 if ( prFile.isEmpty() )
471 VisuOutputDir = QAD_Tools::getDirFromPath(prFile); // set VisuOutputDir
472 QAD_CONFIG->addSetting("Visu:OutputDir",VisuOutputDir);
474 visuGUI->PrintRW(prFile, false);
476 prFile=VisuOutputDir+"SalomeVisu.tif";
477 visuGUI->PrintRW(prFile, true);
482 /* ========================================================================== */
483 /* Visualization of Results : */
484 /* 4011 : Scalar Map */
485 /* 4012 : Deformed Shape */
487 /* 4014 : Iso-Surfaces */
488 /* 4015 : Cut Planes */
489 /* 4016 : Stream Lines */
490 /* ========================================================================== */
493 visuGUI->CreateScalarMap();
496 visuGUI->CreateDeformedShape();
499 visuGUI->CreateVectors();
502 visuGUI->CreateIsoSurfaces();
505 visuGUI->CreateCutPlanes();
508 visuGUI->CreateStreamLines();
511 /* ======================================================================================================================= */
512 /* View Scalar Animation (Animation/scalar) */
514 /* ======================================================================================================================= */
520 /* ========================================================================================================================= */
521 /* Selection - Cell by number */
522 /* ========================================================================================================================= */
526 visuGUI->SelectCell();
528 /* VSR 12/03/03: see VisuGUI::SelectCell()
530 VISU_Actor *ActorTmp;
532 Handle(SALOME_InteractiveObject) anIO;
533 CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy);
534 //srn: Added check if anObject is Null, then break
535 // if(CORBA::is_nil(anObject)) break;
537 VISU::ScalarMap_i* aPrsObject = NULL;
538 if(!CORBA::is_nil(anObject))
539 aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(VISU::GetServant(anObject));
541 //aPrsObject->SetIO(anIO);
542 //ActorTmp = aPrsObject->GetActor();
543 //UpdateViewer(ActorTmp);
544 ActorTmp = visuGUI->UpdateViewer(aPrsObject);
546 ActorTmp = ActorSelected(parent,true,&TypeMode);
552 vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
553 Mapper->SetInput(ActorTmp->DataSource);
554 vtkDataSet *Data=Mapper->GetInput();
555 int nbCells=Data->GetNumberOfCells();
556 int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,"");
557 if (ok && theRenderer)
558 Selection->HighlightCell(selectedCell , ActorTmp , theRenderer);
563 /* ========================================================================================================================= */
564 /* Selection - Cell - information attribute */
565 /* ========================================================================================================================= */
569 visuGUI->InfoOnCell();
571 /* VSR 12/03/03: see VisuGUI::InfoOnCell()
573 VISU_Actor *ActorTmp;
574 ActorTmp = ActorSelected(parent,true,&TypeMode);
578 if ((TypeMode == SelectionCell) || (TypeMode == SelectionEdge))
579 Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp);
581 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"),
582 tr ("Not Selected View - Cell Selection Mode"),
583 tr ("VISU_BUT_OK") );
588 /* ========================================================================================================================= */
589 /* Selection - Point - information number */
590 /* ========================================================================================================================= */
594 visuGUI->SelectPoint();
596 /* VSR 12/03/03: see VisuGUI::SelectPoint()
598 VISU_Actor *ActorTmp;
599 ActorTmp = ActorSelected(parent,true,&TypeMode);
604 vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
605 Mapper->SetInput(ActorTmp->DataSource);
606 vtkDataSet *Data=Mapper->GetInput();
607 int nbPoints=Data->GetNumberOfPoints();
608 int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,"");
609 if (ok && theRenderer)
610 Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer);
615 /* ========================================================================================================================= */
616 /* Selection - Point - information attribute */
617 /* ========================================================================================================================= */
621 visuGUI->InfoOnPoint();
623 /* VSR 12/03/03: see VisuGUI::InfoOnPoint()
625 VISU_Actor *ActorTmp;
626 ActorTmp = ActorSelected(parent,true,&TypeMode);
630 if (TypeMode == SelectionPoint)
631 Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp);
633 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"),
634 tr ("Not Selected View - Point Selection Mode"),
635 tr ("VISU_BUT_OK") );
640 /* ========================================================================================================================= */
641 /* Selection - Shape */
642 /* ========================================================================================================================= */
646 /* ========================================================================================================================= */
647 /* Visualization - Wireframe */
648 /* ========================================================================================================================= */
651 ChangeViewer(parent, theRenderer, true, 1);
654 /* ========================================================================================================================= */
655 /* Visualization - Surface */
656 /* ========================================================================================================================= */
659 ChangeViewer(parent, theRenderer, true, 2);
662 /* ========================================================================================================================= */
663 /* Visualization - Points */
664 /* ========================================================================================================================= */
667 ChangeViewer(parent, theRenderer, true, 0);
670 /* ========================================================================================================================= */
671 /* Visualization - Erase */
672 /* ========================================================================================================================= */
675 if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
676 ClearViewer(parent, theRenderer, -1);
679 /* ========================================================================================================================= */
680 /* Visualization - Global */
681 /* ========================================================================================================================= */
685 /* ========================================================================================================================= */
686 /* Visualization - Partial */
687 /* ========================================================================================================================= */
693 //Show dialog that allows to select scale function and corresponding scale factor
694 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
695 FALSE, Qt::WDestructiveClose );
700 /* ============================ */
701 /* POP-UP OBJECTS BROWSER */
702 /* ============================ */
704 case 900 : // Rename object
708 // ---------------- For Popup in Viewer
714 case 803 : // Display only
715 case 903 : // Display only
716 visuGUI->DisplayOnlyPrs();
719 case 901 : // Display
720 visuGUI->DisplayPrs();
723 case 8041 : // Object representation : Wireframe
724 case 9041 : // Object representation : Wireframe
725 visuGUI->ChangeRepresentation(WIREFRAME);
728 case 8042 : // Object representation : Surface
729 case 9042 : // Object representation : Surface
730 visuGUI->ChangeRepresentation(SURFACE);
733 case 8043 : // Object representation : Points
734 case 9043 : // Object representation : Points
735 visuGUI->ChangeRepresentation(POINTS);
738 case 8044 : // Object representation : Shrink/Unshrink
739 case 9044 : // Object representation : Shrink/Unshrink
740 visuGUI->ChangeRepresentation(SHRINK);
743 case 8051 : // Change object color
744 case 9051 : // Change object color
745 visuGUI->ChageColor();
748 case 8052 : // Change object opacity
749 case 9052 : // Change object opacity
750 visuGUI->ChangeOpacity();
753 case 8053 : // Change object line width
754 case 9053 : // Change object line width
755 visuGUI->ChangeLines();
758 case 808 : // Sweep IsoSurfaces or Cutplanes
759 case 908 : // Sweep IsoSurfaces or Cutplanes
763 case 807 : // Modify visualization
764 case 809 : // Return Cell Id
765 case 810 : // Highlight Cell parameter
766 // ---------------- For Popup in ObjectBrowser
767 case 907 : // Modify visualization
772 VISU_Actor *ActorTmp;
774 Handle(SALOME_InteractiveObject) anIO;
775 CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy);
776 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(VISU::GetServant(anObject));
778 ActorTmp = visuGUI->UpdateViewer(aPrsObject);
780 if ( ((theCommandID >= 801) && (theCommandID <= 809)) || ((theCommandID >= 8041) && (theCommandID <= 8059)) )
782 else if ( ((theCommandID >= 901) && (theCommandID <= 909)) || ((theCommandID >= 9041) && (theCommandID <= 9059)) )
785 ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
791 if (theCommandID == 809) // return results of object picked, in the message box
793 Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp);
794 MESSAGE("Valeur : " << Selection->getId())
797 if (theCommandID == 810) // Highlight Cell or point with parameter
800 vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
801 Mapper->SetInput(ActorTmp->DataSource);
802 vtkDataSet *Data=Mapper->GetInput();
803 if (TypeMode == SelectionPoint)
805 int nbPoints=Data->GetNumberOfPoints();
806 int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,"");
808 Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer);
810 if ( (TypeMode == SelectionCell) || (TypeMode == SelectionEdge) )
812 int nbCells=Data->GetNumberOfCells()-1;
813 int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,"");
815 Selection->HighlightCell(selectedCell , ActorTmp , theRenderer);
822 /* ======================================================================================== */
823 /* Preferences for Scalar Bar */
824 /* ======================================================================================== */
832 /* ======================================================================================== */
833 /* Preferences for Sweeping */
834 /* ======================================================================================== */
837 SetSweepingPreferences();
842 case 113: // Load MED using MED component
844 if (checkLock(myStudy)) break;
846 Engines::Component_var aMedComp = myDesktop->getEngine("FactoryServer", "Med");
847 if (CORBA::is_nil(aMedComp)) return false;
848 Engines::Med_Gen_var aMedGen = Engines::Med_Gen::_narrow(aMedComp);
849 if (CORBA::is_nil(aMedGen)) return false;
851 QStringList filtersList ;
853 filtersList.append( tr("MED_MEN_IMPORT_MED") );
854 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
855 QString aFileName = QAD_FileDlg::getFileName(myDesktop,
858 tr("MED_MEN_IMPORT"),
860 if (!aFileName.isEmpty()) {
861 QApplication::setOverrideCursor( Qt::waitCursor );
862 aMedGen->readStructFileWithFieldType(aFileName.latin1(), myActiveStudy->getTitle());
863 myActiveStudy->updateObjBrowser();
864 QApplication::restoreOverrideCursor();
870 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
871 tr ("Not Yet Implemented"),
872 tr ("VISU_BUT_OK") );
877 catch(SALOMEDS::GenericAttribute::LockProtection&) {
878 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
879 QObject::tr("WARNING"),
880 QObject::tr("WRN_STUDY_LOCKED"),
881 QObject::tr("BUT_OK") );
885 catch (const SALOME::SALOME_Exception& S_ex) {
886 QtCatchCorbaException(S_ex);
890 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
891 tr("Unknown exception was caught in VISU module"),
899 /* ********************************************************************************* */
900 /* Function to find Actor in ObjectBrowser */
901 /* ********************************************************************************* */
903 VISU_Actor *VisuGUI::GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren)
905 SALOMEDS::GenericAttribute_var anAttr;
906 SALOMEDS::AttributeName_var aName;
907 if ( objVisu->FindAttribute(anAttr, "AttributeName") ) {
908 aName = SALOMEDS::AttributeName::_narrow(anAttr);
910 MESSAGE("GetActor == > Name : " << aName->Value());
912 vtkActorCollection *ac;
914 ac = ren->GetActors();
916 for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) {
917 if (actor->IsA("VISU_Actor")) {
918 VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(actor);
919 if (strcmp(VISUActor->getName(), aName->Value()) == 0)
928 /* ********************************************************************************* */
929 /* Function to find Actor in Viewer */
930 /* ********************************************************************************* */
933 VISU_Actor *VisuGUI::GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren)
935 VisuGUI::GetOrCreateVisuGUI(parent);
937 QString theEntry = IO->getEntry();
938 Standard_CString aComment;
939 Standard_CString Persistent;
940 //Standard_CString aName = IO->getName();
944 SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument();
946 SALOMEDS::SObject_var objlocal = aStudy->FindObjectID(theEntry.latin1());
947 SALOMEDS::GenericAttribute_var anAttr;
948 SALOMEDS::AttributeComment_var aCmnt;
949 SALOMEDS::AttributePersistentRef_var aPRef;
951 if (objlocal->FindAttribute(anAttr, "AttributeComment")) {
952 aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
953 aComment = aCmnt->Value();
955 if (objlocal->FindAttribute(anAttr, "AttributePersistentRef")) {
956 aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
957 Persistent = aPRef->Value();
960 vtkActorCollection *aclocal;
961 vtkActor *actorlocal;
962 aclocal = ren->GetActors();
964 // =============================================================================
965 // Test if Actor exists in theRenderer
966 for (aclocal->InitTraversal();(actorlocal = aclocal->GetNextActor())!=NULL;)
968 if (actorlocal->IsA("VISU_Actor"))
970 anActor = VISU_Actor::SafeDownCast(actorlocal);
971 MESSAGE(" getIO de anActor : " << anActor->getIO())
972 if (anActor->hasIO())
974 if (IO->isSame(anActor->getIO()))
983 // =============================================================================
984 // If Actor doesn't exist in theRenderer => create same actor in new renderer
985 /* int nbSf = visuGUI->myActiveStudy->getStudyFramesCount();
986 SALOMEDS::SObject_var TheMeshObject= objlocal->GetFather();
987 for ( int i = 0; i < nbSf; i++ )
989 QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i);
990 if ( sf->getTypeView() == VIEW_VTK )
992 vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
993 vtkActorCollection* ac = aRenderer->GetActors();
995 for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;)
997 if (actor->IsA("VISU_Actor"))
999 anActor = VISU_Actor::SafeDownCast(actor);
1000 if (anActor->hasIO())
1002 if (IO->isSame(anActor->getIO()))
1004 if (aRenderer != ren)
1006 return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment));
1015 //return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment));
1018 /* ********************************************************************************** */
1019 /* Function ActorSelected */
1020 /* To return the Actor selected in Viewer or in ObjectBrowser */
1021 /* ********************************************************************************** */
1023 VISU_Actor *VisuGUI::ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode)
1025 VisuGUI::GetOrCreateVisuGUI(parent);
1026 SALOME_Selection *Sel;
1027 QAD_ObjectBrowserItem* item;
1028 VISU_Actor *ActorTmp;
1029 Standard_CString PersRef = "";
1030 Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection());
1031 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
1035 *Mode=Sel->SelectionMode();
1037 SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
1038 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1039 //SALOMEDS::SComponent_var father = aStudy->FindComponent("VISU");
1040 SALOMEDS::GenericAttribute_var anAttr;
1041 SALOMEDS::AttributeName_var aName;
1042 SALOMEDS::AttributePersistentRef_var aPRef;
1045 if (Sel->IObjectCount()==0)
1047 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1048 Handle(SALOME_InteractiveObject) IObject = It.Value();
1049 ActorTmp=GetActor(parent,IObject,theRenderer);
1053 item = (QAD_ObjectBrowserItem*)(visuGUI->myActiveStudy->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser()->getListView()->currentItem());
1056 // Test if a selected visu object
1057 QString theEntry = item->getEntry();
1059 MESSAGE("==================== TheEntry : " << theEntry)
1060 if ( theEntry.isEmpty() )
1062 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1063 tr ("Bad Type for Selected Item in Popup Menu"),
1064 tr ("VISU_BUT_OK") );
1068 SALOMEDS::SObject_var objVisu = aStudy->FindObjectID(theEntry.latin1());
1069 if (objVisu->FindAttribute(anAttr, "AttributePersistentRef")) {
1070 aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
1071 PersRef = aPRef->Value();
1074 if ( objVisu->_is_nil() )
1076 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1078 tr ("VISU_BUT_OK") );
1081 ActorTmp=GetActorObjBrowser(objVisu,theRenderer);
1089 /* ********************************************************************************** */
1090 /* Function ClearViewer - Erase the actors displayed on the viewer */
1091 /* ********************************************************************************** */
1093 void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor)
1095 // TypeOfActor = -1 : All
1097 // = 2 : ScalarBarActor
1098 // = 4 : Other Actor2D
1100 vtkActorCollection *ac;
1101 vtkActor2DCollection *ac2D;
1103 vtkActor2D *actor2D;
1104 ac = ren->GetActors();
1105 ac2D = ren->GetActors2D();
1107 if(TypeOfActor == -1 || TypeOfActor == 1) {
1108 bool TrhVisible = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->
1109 getActiveStudyFrame()->getRightFrame()->getViewFrame())->isTrihedronDisplayed();
1110 for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) {
1111 if (actor->IsA("VISU_Actor") || actor->IsA("vtkActor") )
1112 actor->VisibilityOff();
1114 if (TrhVisible) ShowTrihedron(false);
1117 if(TypeOfActor == -1 || TypeOfActor == 2) {
1118 for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;)
1119 if (actor2D->IsA("vtkScalarBarActor"))
1120 actor2D->VisibilityOff();
1123 if(TypeOfActor == -1 || TypeOfActor == 4) {
1124 for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;)
1125 if (!(actor2D->IsA("vtkScalarBarActor"))) // it's a plot2d
1127 actor2D->VisibilityOff();
1128 //actor2D->Delete();
1133 /* ********************************************************************************** */
1134 /* Function ShowTrihedron */
1135 /* ********************************************************************************** */
1137 void VisuGUI::ShowTrihedron(bool ShowThd){
1138 bool ThdIsVisible = true;
1139 if( ShowThd && !ThdIsVisible)
1140 ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
1141 if( !ShowThd && ThdIsVisible)
1142 ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
1145 /* ********************************************************************************** */
1147 /* Clear all tmp files used in VISU */
1148 /* ********************************************************************************** */
1150 VisuGUI::~VisuGUI(){
1151 MESSAGE("VisuGUI::~VisuGUI");
1154 /* ********************************************************************************** */
1155 /* Function ChangeViewer */
1156 /* Change representation of all actors */
1157 /* ********************************************************************************** */
1159 void VisuGUI::ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type)
1162 VisuGUI::GetOrCreateVisuGUI(parent);
1163 vtkActorCollection *ac;
1165 ac = ren->GetActors();
1167 for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;)
1168 actor->GetProperty()->SetRepresentation(Type);
1172 // -----------------------------------------------------------------------------------------
1174 // -----------------------------------------------------------------------------------------
1176 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
1178 VisuGUI::GetOrCreateVisuGUI(parent);
1182 // ====================================================================================================================
1184 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
1186 VisuGUI::GetOrCreateVisuGUI(parent);
1190 // ===================================================================================================================
1192 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
1194 VisuGUI::GetOrCreateVisuGUI(parent);
1195 if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
1198 MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() )
1200 switch ( pe->key() )
1204 MESSAGE("--> Key : Escape")
1216 //=====================================================================================
1217 // Slot-functions for presentations creation
1218 //=====================================================================================
1221 #define CREATEPRESENTATION(FunctionName) \
1222 void FunctionName() { \
1223 if (checkLock(myStudy)) return; \
1224 SALOMEDS::SObject_var objVisu; \
1225 if (!TestObjectBrowser(&objVisu)) return; \
1226 if(!FunctionName(objVisu)) return; \
1227 visuGUI->myActiveStudy->updateObjBrowser(); \
1228 myDesktop->putInfo("Ready"); \
1229 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
1231 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
1232 vf->onViewFitAll(); \
1237 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
1238 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
1239 CREATEPRESENTATION(VisuGUI::CreateVectors);
1240 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
1241 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
1242 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
1247 //=====================================================================================
1248 // function : setSettings()
1250 //=====================================================================================
1251 bool VisuGUI::setSettings(QAD_Desktop* parent)
1253 VisuGUI::GetOrCreateVisuGUI(parent);
1257 //=====================================================================================
1258 // function : DisplayPrs()
1260 //=====================================================================================
1261 void VisuGUI::DisplayPrs() {
1262 MESSAGE("VisuGUI::DisplayPrs");
1264 Handle(SALOME_InteractiveObject) anIO;
1265 CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
1266 if ( !CORBA::is_nil( anObject ) ) {
1267 // is it Prs3d object ?
1268 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
1270 MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
1271 UpdateViewer(aPrsObject);
1272 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1274 vf->getRenderer()->ResetCameraClippingRange();
1280 vf->highlight(anIO, 1);
1283 MESSAGE("Check time on VisuGUI::DisplayPrs - vf->Repaint + vf->highlight");
1290 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
1292 MESSAGE("VisuGUI::DisplayPrs : Curve object");
1293 PlotCurve(aCurve, VISU::eDisplay );
1296 // is it Container ?
1297 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
1299 MESSAGE("VisuGUI::DisplayPrs : Container object");
1300 PlotContainer(aContainer, VISU::eDisplay );
1304 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
1306 MESSAGE("VisuGUI::DisplayPrs : Table object");
1307 PlotTable(aTable, VISU::eDisplay );
1313 //=====================================================================================
1314 // function : DisplayOnlyPrs()
1316 //=====================================================================================
1317 void VisuGUI::DisplayOnlyPrs() {
1318 MESSAGE("VisuGUI::DisplayOnlyPrs");
1320 Handle(SALOME_InteractiveObject) anIO;
1321 CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
1322 if ( !CORBA::is_nil( anObject ) ) {
1323 // is it Prs3d object ?
1324 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
1326 MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
1327 UpdateViewer(aPrsObject, true);
1328 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1330 vf->getRenderer()->ResetCameraClippingRange();
1336 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
1338 MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
1339 PlotCurve(aCurve, VISU::eDisplayOnly );
1342 // is it Container ?
1343 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
1345 MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
1346 PlotContainer(aContainer, VISU::eDisplayOnly );
1350 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
1352 MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
1353 PlotTable(aTable, VISU::eDisplayOnly );
1359 //=====================================================================================
1360 // function : ErasePrs()
1362 //=====================================================================================
1363 void VisuGUI::ErasePrs() {
1364 MESSAGE("VisuGUI::ErasePrs");
1366 Handle(SALOME_InteractiveObject) anIO;
1367 CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
1368 if ( !CORBA::is_nil( anObject ) ) {
1369 // is it Prs3d object ?
1370 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
1372 MESSAGE("VisuGUI::ErasePrs : Prs3d object");
1373 ErasePrs(aPrsObject);
1374 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1380 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
1382 MESSAGE("VisuGUI::ErasePrs : Curve object");
1383 PlotCurve(aCurve, VISU::eErase );
1385 // is it Container ?
1386 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
1388 MESSAGE("VisuGUI::ErasePrs : Container object");
1389 PlotContainer(aContainer, VISU::eErase );
1392 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
1394 MESSAGE("VisuGUI::ErasePrs : Table object");
1395 PlotTable(aTable, VISU::eErase );
1401 //=====================================================================================
1402 // function : RecreateActor()
1404 //=====================================================================================
1405 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1406 /* BEGIN_OF("VisuGUI::RecreateActor");
1408 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1410 QApplication::setOverrideCursor( Qt::waitCursor );
1411 vtkRenderer *aRen = vf->getRenderer();
1412 VISU_Actor* anVISUActor = GetActor(thePrs);
1414 if(anVISUActor == NULL){
1415 anVISUActor= thePrs->CreateActor();
1416 anVISUActor->SetVisibility(true);
1417 vf->AddActor(anVISUActor);
1418 if (anVISUActor->HasScalarBar()) {
1419 anVISUActor->getScalarBar()->SetVisibility(true);
1420 aRen->AddActor2D(anVISUActor->getScalarBar());
1425 QApplication::restoreOverrideCursor();
1427 END_OF("VisuGUI::RecreateActor") */
1428 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1431 VISU_Actor* anVISUActor = GetActor(thePrs);
1432 int isVisible = false;
1434 QApplication::setOverrideCursor( Qt::waitCursor );
1435 vtkRenderer *aRen = vf->getRenderer();
1437 isVisible = anVISUActor->GetVisibility();
1438 Handle(SALOME_InteractiveObject) anIO = anVISUActor->getIO();
1439 if (anVISUActor->HasScalarBar())
1440 aRen->RemoveActor(anVISUActor->getScalarBar());
1441 aRen->RemoveActor(anVISUActor);
1442 anVISUActor->Delete();
1443 anVISUActor = thePrs->CreateActor(anIO);
1445 anVISUActor = thePrs->CreateActor();
1446 QApplication::restoreOverrideCursor();
1448 if (!anVISUActor) return;
1449 anVISUActor->SetVisibility(isVisible);
1450 aRen->AddActor(anVISUActor);
1451 if (anVISUActor->HasScalarBar()) {
1452 anVISUActor->getScalarBar()->SetVisibility(isVisible);
1453 aRen->AddActor2D(anVISUActor->getScalarBar());
1458 //=====================================================================================
1459 // function : EditPrs()
1461 //=====================================================================================
1462 #define EDITPRS(PrsName, DlgName) \
1464 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1466 DlgName* aDlg = new DlgName(); \
1467 aDlg->initFromPrsObject(aPrsObject); \
1468 if ( aDlg->exec() ) { \
1469 aDlg->storeToPrsObject(aPrsObject); \
1470 RecreateActor(aPrsObject); \
1471 /*RepaintCurrentView();*/ \
1472 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
1474 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1475 vf->getRenderer()->ResetCameraClippingRange(); \
1476 vf->onViewFitAll(); \
1485 void VisuGUI::EditPrs() {
1486 VISU::Prs3d_i* aPrs3d = GetSelectedPrs();
1488 switch (aPrs3d->GetType()) {
1489 case VISU::TMESH: // Mesh 13
1492 case VISU::TSCALARMAP: // ScalarMap 18
1493 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1496 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1497 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1500 case VISU::TCUTPLANES: // Cut planes 42
1501 EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1504 case VISU::TISOSURFACE: // Iso surfaces
1505 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1507 case VISU::TVECTORS: // Vectors 64
1508 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1511 case VISU::TSTREAMLINES:
1512 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1517 //=====================================================================================
1518 // function : EditScalarBar()
1520 //=====================================================================================
1521 void VisuGUI::EditScalarBar() {
1522 VISU::Prs3d_i* aPrs3d = GetSelectedPrs();
1523 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
1525 VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false);
1526 aDlg->initFromPrsObject(aPrsObject);
1527 if ( aDlg->exec() ) {
1528 aDlg->storeToPrsObject(aPrsObject);
1529 RecreateActor(aPrsObject);
1531 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1535 if (aDlg->isToSave())
1536 aDlg->storeToResources();
1544 //=====================================================================================
1545 // function : CreateMesh()
1547 //=====================================================================================
1548 void VisuGUI::CreateMesh() {
1551 //Handle(SALOME_InteractiveObject) anIO;
1552 //CORBA::Object_var anObject = GetSelectedObj(aComment,anIO, VisuGUI::myActiveStudy);
1553 SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1554 SALOMEDS::SObject_var aSObject = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1556 if (checkLock(myStudy)) return;
1558 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1559 aSObj = aSObj->GetFather();
1560 aSObj = aSObj->GetFather();
1561 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1562 if(CORBA::is_nil(anObject)) {
1563 aSObj = aSObj->GetFather();
1564 anObject = VISU::SObjectToObject(aSObj);
1565 if(CORBA::is_nil(anObject)) return;
1567 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1568 if(CORBA::is_nil(aResult)) return;
1570 VISU::Storable::TRestoringMap aMap;
1571 SALOMEDS::GenericAttribute_var anAttr;
1572 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1573 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1574 string aComm = aComment->Value();
1575 QString strIn(aComm.c_str());
1576 VISU::Storable::StrToMap(strIn,aMap);
1579 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1580 if(!isExist) return;
1581 CORBA::Object_var aMesh;
1582 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1583 if(aComment == "ENTITY"){
1584 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1585 aMesh = myComponent->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1586 }else if(aComment == "FAMILY"){
1587 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1588 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1589 aMesh = myComponent->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1590 }else if(aComment == "GROUP"){
1591 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1592 aMesh = myComponent->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1594 QApplication::restoreOverrideCursor();
1595 if(CORBA::is_nil(aMesh)) return;
1597 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
1602 VISU_Actor *anActor = pPresent->CreateActor();
1603 if (! anActor ) return;
1606 MESSAGE("Check time on VisuGUI::CreateMesh - pPresent->CreateActor");
1609 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1610 vtkRenderer *aRenderer = vf->getRenderer();
1611 //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1);
1612 //visuGUI->ShowTrihedron(true);
1617 vf->AddActor(anActor);
1618 vf->getRenderer()->AddActor(anActor->EdgeDevice);
1619 vf->getRenderer()->ResetCameraClippingRange();
1623 MESSAGE("Check time on VisuGUI::CreateMesh - vf->AddActor + vf->onViewFitAll");
1627 myActiveStudy->updateObjBrowser(); //update Object browser
1628 myDesktop->putInfo("Ready");
1632 //=====================================================================================
1633 // function : ChangeRepresentation()
1635 //=====================================================================================
1637 static void ShrinkMesh(VISU_Actor *Actor){
1638 if (!(Actor->IsShrunk)){
1639 vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper());
1640 vtkShrinkFilter *shrink = vtkShrinkFilter::New();
1641 shrink->SetInput(mapper->GetInput());
1642 shrink->SetShrinkFactor(0.8);
1643 mapper->SetInput(shrink->GetOutput());
1644 Actor->IsShrunk = true;
1646 Actor->EdgeDevice->VisibilityOff();
1648 vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper());
1649 // mpv: we wish to remove shrink filter only instead of all filters ignore
1650 // mapper->SetInput(Actor->DataSource);
1651 vtkDataObject* anObject = mapper->GetInput();
1652 vtkSource* aPrevSource = (vtkSource*)mapper;
1653 while(anObject != Actor->DataSource) {
1654 vtkShrinkFilter* aShrink = vtkShrinkFilter::SafeDownCast(anObject->GetSource());
1656 vtkSource* aSource = aShrink->GetInput()->GetSource();
1657 vtkDataObject** Inputs = aPrevSource->GetInputs();
1658 vtkDataObject** Outputs = aSource->GetOutputs();
1659 Outputs[0]->UnRegister(aShrink);
1660 Inputs[0]->UnRegister(aShrink);
1661 Outputs[0]->Register(aPrevSource);
1662 Inputs[0]->Register(aSource);
1663 Inputs[0] = aSource->GetOutputs()[0];
1664 aSource->Modified();
1670 aPrevSource = anObject->GetSource();
1671 anObject = aPrevSource->GetInputs()[0];
1675 Actor->IsShrunk = false;
1676 if ( Actor->GetProperty()->GetRepresentation() == 2 )
1677 Actor->EdgeDevice->VisibilityOn();
1681 void VisuGUI::ChangeRepresentation(RepresentType theType) {
1682 VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
1683 if(!aPrsObject) return;
1689 VISU_Actor* anActor = GetActor(aPrsObject);
1690 if (!anActor) return;
1693 anActor->EdgeDevice->VisibilityOff();
1694 anActor->GetProperty()->SetRepresentation(0);
1695 anActor->GetProperty()->SetPointSize(VISU_POINT_SIZE);
1698 anActor->EdgeDevice->VisibilityOff();
1699 anActor->GetProperty()->SetRepresentation(1);
1702 if ( !anActor->IsShrunk )
1703 anActor->EdgeDevice->VisibilityOn();
1704 anActor->GetProperty()->SetRepresentation(2);
1707 ShrinkMesh(anActor);
1710 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1715 MESSAGE("Cheking time in VisuGUI::ChangeRepresentation - anActor->GetProperty()->SetRepresentation + vf->Repaint");
1720 void VisuGUI::MakeWireframe() {
1721 ChangeRepresentation(WIREFRAME);
1725 void VisuGUI::MakeSurface() {
1726 ChangeRepresentation(SURFACE);
1730 void VisuGUI::MakePoints() {
1731 ChangeRepresentation(POINTS);
1735 void VisuGUI::MakeShrink() {
1736 ChangeRepresentation(SHRINK);
1741 //=====================================================================================
1742 // functions : Change Propertise
1744 //=====================================================================================
1745 VISU::Prs3d_i* VisuGUI::GetSelectedPrs() {
1747 Handle(SALOME_InteractiveObject) anIO;
1748 CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
1749 return dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
1752 void VisuGUI::ChageColor() {
1753 VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
1754 if(!aPrsObject) return;
1756 VISU_Actor* anActor = GetActor(aPrsObject);
1757 if (!anActor) return;
1761 void VisuGUI::ChangeOutlineColor() {
1762 VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
1763 if(!aPrsObject) return;
1765 VISU_Actor* anActor = GetActor(aPrsObject);
1766 if (!anActor) return;
1767 NewOutlineColor(anActor);
1771 void VisuGUI::ChangeOpacity() {
1772 VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
1773 if(!aPrsObject) return;
1775 VISU_Actor* anActor = GetActor(aPrsObject);
1776 if (!anActor) return;
1777 NewOpacity(anActor);
1781 void VisuGUI::ChangeLines() {
1782 VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
1783 if(!aPrsObject) return;
1785 VISU_Actor* anActor = GetActor(aPrsObject);
1786 if (!anActor) return;
1787 NewLinewidth(anActor);
1789 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1791 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1792 if ( table && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1793 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1794 if ( theDisplaying == VISU::eDisplayOnly )
1796 QList<Plot2d_Curve> clist;
1797 aPlot->getCurves( clist );
1798 SALOMEDS::SObject_var TableSO = visuGUI->myActiveStudy->getStudyDocument()->FindObjectID( table->GetEntry() );
1799 if ( !TableSO->_is_nil() ) {
1800 SALOMEDS::ChildIterator_var Iter = visuGUI->myActiveStudy->getStudyDocument()->NewChildIterator( TableSO );
1801 for ( ; Iter->More(); Iter->Next() ) {
1802 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1803 if( !CORBA::is_nil( childObject ) ) {
1804 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1805 if( !CORBA::is_nil( aCurve ) ) {
1806 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
1807 Plot2d_Curve* plotCurve = 0;
1808 for ( int i = 0; i < clist.count(); i++ ) {
1809 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1810 plotCurve = clist.at( i );
1814 if ( theDisplaying == VISU::eErase ) {
1816 aPlot->eraseCurve( plotCurve, false );
1817 clist.remove( plotCurve );
1820 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1822 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1823 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1824 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1825 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1826 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1827 /* - DATA NOT UPDATED */
1828 if ( !plotCurve->isAutoAssign() ) {
1829 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1830 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1831 SALOMEDS::Color color = theCurve->GetColor();
1832 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1833 plotCurve->setAutoAssign( theCurve->IsAuto() );
1835 aPlot->displayCurve( plotCurve, false );
1838 Plot2d_Curve* crv = theCurve->CreatePresentation();
1840 aPlot->displayCurve( crv, false );
1850 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1852 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1853 if ( theCurve && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1854 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1855 // if ( theDisplaying == VISU::eDisplayOnly )
1856 // aPlot->EraseAll();
1857 QList<Plot2d_Curve> clist;
1858 aPlot->getCurves( clist );
1859 Plot2d_Curve* plotCurve = 0;
1860 for ( int i = 0; i < clist.count(); i++ ) {
1861 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1862 plotCurve = clist.at( i );
1864 else if ( theDisplaying == VISU::eDisplayOnly ) {
1865 aPlot->eraseCurve( clist.at( i ) );
1868 if ( theDisplaying == VISU::eErase ) {
1870 aPlot->eraseCurve( plotCurve, false );
1872 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1874 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1875 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1876 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1877 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1878 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1879 /* DATA NOT UPDATED */
1880 if ( !plotCurve->isAutoAssign() ) {
1881 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1882 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1883 SALOMEDS::Color color = theCurve->GetColor();
1884 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1885 plotCurve->setAutoAssign( theCurve->IsAuto() );
1887 aPlot->displayCurve( plotCurve, false );
1890 Plot2d_Curve* crv = theCurve->CreatePresentation();
1892 aPlot->displayCurve( crv, false );
1899 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1901 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1902 if ( container && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1903 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1904 if ( theDisplaying == VISU::eDisplayOnly )
1906 QList<Plot2d_Curve> clist;
1907 aPlot->getCurves( clist );
1908 if ( container->GetNbCurves() > 0 ) {
1909 int nbCurves = container->GetNbCurves();
1910 for ( int k = 1; k <= nbCurves; k++ ) {
1911 VISU::Curve_i* theCurve = container->GetCurve( k );
1912 if ( theCurve && theCurve->IsValid() ) {
1913 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) );
1914 // for ( int i = 0; i < clist.count(); i++ ) {
1915 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1916 // plotCurve = clist.at( i );
1920 if ( theDisplaying == VISU::eErase ) {
1922 aPlot->eraseCurve( plotCurve, false );
1923 clist.remove( plotCurve );
1926 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1928 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1929 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1930 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1931 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1932 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1933 /* - DATA NOT UPDATED */
1934 if ( !plotCurve->isAutoAssign() ) {
1935 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1936 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1937 SALOMEDS::Color color = theCurve->GetColor();
1938 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1939 plotCurve->setAutoAssign( theCurve->IsAuto() );
1941 aPlot->displayCurve( plotCurve, false );
1944 Plot2d_Curve* crv = theCurve->CreatePresentation();
1946 aPlot->displayCurve( crv, false );
1956 Slot : opens Table view : for Table object or SObject with table attribute selected
1958 void VisuGUI::ShowTable() {
1959 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1960 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
1961 if( Sel->IObjectCount() !=1 )
1964 Handle(SALOME_InteractiveObject) anIO;
1965 CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
1966 SALOMEDS::SObject_var SO;
1967 if ( !CORBA::is_nil( anObject ) ) {
1968 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1969 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1970 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1971 if( !CORBA::is_nil( aTable ) ) {
1972 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
1974 SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1979 // possibly this is Table SObject
1980 SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( anIO->getEntry() );
1982 SALOMEDS::GenericAttribute_var anAttr;
1983 if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" )
1984 && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) )
1986 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1992 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1994 void VisuGUI::PlotData() {
1995 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
1996 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
1997 if( Sel->IObjectCount() !=1 )
2000 Handle(SALOME_InteractiveObject) anIO;
2001 CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
2002 SALOMEDS::SObject_var SO;
2003 if ( !CORBA::is_nil( anObject ) ) {
2004 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2005 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2006 // Table (VISU object) is selected
2007 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
2008 if( !CORBA::is_nil( aTbl ) ) {
2009 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTbl ) );
2011 SALOMEDS::GenericAttribute_var anAttr;
2012 SALOMEDS::AttributeName_var aName;
2014 SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
2015 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
2016 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
2017 // get name of SObject
2018 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2019 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2020 SOName = strdup( aName->Value() );
2022 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2023 if ( dlg->exec() == QDialog::Accepted ) {
2024 if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
2025 // if study is not locked - create new container, create curves
2026 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2028 QValueList<int> verIndices;
2029 dlg->getCurvesSource( horIndex, verIndices );
2030 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2031 CORBA::Object_var aContainer = myComponent->CreateContainer();
2032 if( !CORBA::is_nil( aContainer ) ) {
2033 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
2035 for ( int i = 0; i < verIndices.count(); i++ ) {
2036 CORBA::Object_var aNewCurve = myComponent->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
2037 if( !CORBA::is_nil( aNewCurve ) ) {
2038 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
2041 int marker, line, lineWidth;
2043 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2044 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2045 pCrv->SetColor( c );
2046 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2047 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2049 pContainer->AddCurve( pCrv->_this() );
2053 VisuGUI::myActiveStudy->updateObjBrowser( true );
2054 PlotContainer( pContainer, VISU::eDisplay );
2060 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2061 Plot2d_CurveContainer container;
2062 dlg->getCurves( container );
2063 if ( !container.isEmpty() ) {
2064 ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
2065 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2066 ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
2067 getRightFrame()->getViewFrame()))->setTitle( SOName );
2078 // possibly this is Table SObject
2079 SALOMEDS::GenericAttribute_var anAttr;
2080 SALOMEDS::AttributeName_var aName;
2083 // check if Table SObject is selected
2084 SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2085 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
2086 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
2087 // get name of SObject
2088 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2089 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2090 SOName = strdup( aName->Value() );
2092 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2093 if ( dlg->exec() == QDialog::Accepted ) {
2094 if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
2095 // if study is not locked - create new table and container objects, create curves
2096 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2098 QValueList<int> verIndices;
2099 dlg->getCurvesSource( horIndex, verIndices );
2100 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2101 CORBA::Object_var aTable = myComponent->CreateTable( SO->GetID() );
2102 CORBA::Object_var aContainer = myComponent->CreateContainer();
2103 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2104 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
2105 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
2107 if ( pContainer && pTable ) {
2108 for ( int i = 0; i < verIndices.count(); i++ ) {
2109 CORBA::Object_var aNewCurve = myComponent->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2110 if( !CORBA::is_nil( aNewCurve ) ) {
2111 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
2114 int marker, line, lineWidth;
2116 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2117 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2118 pCrv->SetColor( c );
2119 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2120 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2122 pContainer->AddCurve( pCrv->_this() );
2126 VisuGUI::myActiveStudy->updateObjBrowser( true );
2127 PlotContainer( pContainer, VISU::eDisplay );
2133 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2134 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2135 Plot2d_CurveContainer container;
2136 dlg->getCurves( container );
2137 if ( !container.isEmpty() ) {
2138 ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
2139 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2140 ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
2141 getRightFrame()->getViewFrame()))->setTitle( SOName );
2151 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2153 void VisuGUI::CurveProperties() {
2154 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2155 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2156 if( Sel->IObjectCount() !=1 )
2159 Handle(SALOME_InteractiveObject) anIO;
2160 CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
2161 SALOMEDS::SObject_var SO;
2162 if (CORBA::is_nil( anObject )) return;
2164 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2165 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2167 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2168 if( !CORBA::is_nil( aCurve ) ) {
2169 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
2170 if ( curve && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
2171 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
2172 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2173 dlg->setMarker( (int)curve->GetMarker() );
2174 SALOMEDS::Color color = curve->GetColor();
2175 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2176 if( dlg->exec() == QDialog::Accepted ) {
2177 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2178 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2179 SALOMEDS::Color newColor;
2180 newColor.R = dlg->getColor().red()/255.;
2181 newColor.G = dlg->getColor().green()/255.;
2182 newColor.B = dlg->getColor().blue()/255.;
2183 curve->SetColor( newColor );
2184 QList<QAD_StudyFrame> sfList = VisuGUI::myActiveStudy->getStudyFrames();
2185 if ( sfList.count() > 0 ) {
2186 QListIterator<QAD_StudyFrame> it( sfList );
2187 for ( ; it.current(); ++it ) {
2188 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2189 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2190 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2193 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2195 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2196 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2197 plotCurve->setColor( dlg->getColor() );
2198 aPlot->updateCurve( plotCurve, true );
2211 Slot : Clears container contents : for Container object selected
2213 void VisuGUI::ClearContainer() {
2214 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2215 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2216 if( Sel->IObjectCount() !=1 )
2220 Handle(SALOME_InteractiveObject) anIO;
2221 CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
2222 SALOMEDS::SObject_var SO;
2223 if (CORBA::is_nil( anObject )) return;
2225 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2226 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2228 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2229 if( !CORBA::is_nil( aCnt ) ) {
2230 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
2231 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
2233 VisuGUI::myActiveStudy->updateObjBrowser();
2240 void VisuGUI::DeletePrs() {
2241 DeletePresentation(GetSelectedPrs());
2244 void VisuGUI::SaveViewParams()
2246 if (checkLock(myStudy)) return;
2247 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2248 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2249 if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2251 // getting view manager
2252 CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager();
2253 if( CORBA::is_nil( aVM ) )
2255 VISU::ViewManager_i* pVM = dynamic_cast<VISU::ViewManager_i*>( VISU::GetServant( aVM ) );
2258 // getting current 3d view
2259 CORBA::Object_var aView = pVM->GetCurrentView();
2260 if( CORBA::is_nil( aView ) )
2262 VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>( VISU::GetServant( aView ) );
2265 if ( Sel->IObjectCount() == 0 ) {
2266 // Save view parameters by new name
2267 pView->SaveViewParams( 0 );
2268 VisuGUI::myActiveStudy->updateObjBrowser( true );
2271 // Try to save view parameters by selected object's name
2273 Handle(SALOME_InteractiveObject) anIO;
2274 CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
2275 // QString strIn( aComment.c_str() );
2276 // VISU::Storable::RestoringMapType aMap;
2277 // VISU::Storable::StrToMap( strIn,aMap );
2278 // QString aCmt = VISU::Storable::FindValue( aMap, "myComment" );
2279 if (ObjectTypes.find( aComment.c_str() ) == 6 ) {
2280 pView->SaveViewParams( anIO->getName() );
2281 VisuGUI::myActiveStudy->updateObjBrowser( true );
2285 void VisuGUI::RestoreViewParams()
2287 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2288 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2289 if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2291 // getting view manager
2292 CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager();
2293 if( CORBA::is_nil( aVM ) )
2295 VISU::ViewManager_i* pVM = dynamic_cast<VISU::ViewManager_i*>( VISU::GetServant( aVM ) );
2298 // getting current 3d view
2299 CORBA::Object_var aView = pVM->GetCurrentView();
2300 if( CORBA::is_nil( aView ) )
2302 VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>( VISU::GetServant( aView ) );
2306 Handle(SALOME_InteractiveObject) anIO;
2307 CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
2308 QString aCmt = aComment.c_str();
2309 if ( !aCmt.isEmpty() && ObjectTypes.find( aCmt ) == 6 ) {
2310 pView->RestoreViewParams( anIO->getName() );
2314 //=====================================================================================
2315 // function : DeleteViewParams()
2317 //=====================================================================================
2318 void VisuGUI::DeleteViewParams() {
2319 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2320 SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection());
2321 if( Sel->IObjectCount() > 0 ) {
2322 SALOME_ListIteratorOfListIO aSelectionIterator(Sel->StoredIObjects());
2323 for(;aSelectionIterator.More(); aSelectionIterator.Next()) {
2324 Handle(SALOME_InteractiveObject) anIO = aSelectionIterator.Value();
2325 if (anIO->hasEntry()){
2326 SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry());
2327 if(!aSObject->_is_nil()){
2328 SALOMEDS::GenericAttribute_var anAttr;
2329 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2330 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
2332 // possibly this is view params
2333 QString strIn(aComment->Value());
2334 VISU::Storable::TRestoringMap aMap;
2335 VISU::Storable::StrToMap( strIn, aMap );
2338 aCmt = VISU::Storable::FindValue( aMap, "myComment", &isExist );
2339 if ( isExist ) aType = ObjectTypes.find( aCmt );
2341 MYStudyDocument->NewBuilder()->RemoveObject(aSObject);
2342 Sel->RemoveIObject(anIO, 0);
2349 VisuGUI::myActiveStudy->updateObjBrowser( true );
2353 //=====================================================================================
2354 // function : Sweep()
2356 //=====================================================================================
2357 void VisuGUI::Sweep() {
2358 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs());
2359 if (!aPrsObject) return;
2362 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2363 if ( !aTempoStr.isEmpty() )
2364 aTemp = int(1.E6*(aTempoStr.toFloat()));
2367 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2368 if ( !aCyclesStr.isEmpty() )
2369 aCycles = aCyclesStr.toInt();
2372 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2373 if ( !aStepsStr.isEmpty() )
2374 aSteps = aStepsStr.toInt();
2376 VISU_Actor* aActor = GetActor(aPrsObject);
2377 if (!aActor) return;
2379 if (!aActor->GetVisibility()) {
2380 aActor->VisibilityOn();
2381 if (aActor->HasScalarBar())
2382 aActor->getScalarBar()->VisibilityOn();
2384 vtkDataSetMapper* aMapper = (vtkDataSetMapper*) aActor->GetMapper();
2385 VISU_LookupTable* aLookupTbl = (VISU_LookupTable*) aMapper->GetLookupTable();
2387 QApplication::setOverrideCursor( Qt::waitCursor );
2389 switch (aPrsObject->GetType()) {
2390 case VISU::TCUTPLANES: // Cut planes 42
2391 case VISU::TSCALARMAP: // ScalarMap 18
2392 for (int j=0 ; j<aCycles; j++) {
2393 for (int i=0 ; i<=aSteps; i++) {
2394 aLookupTbl->SetMapScale(float(i)/float(aSteps));
2395 RepaintCurrentView();
2401 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
2403 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2405 float aScale = aDefPrs->GetScale();
2406 bool isColored = aDefPrs->isColored();
2408 vtkWarpVector* aWarp = vtkWarpVector::New();
2409 if((VISU::Entity)aDefPrs->GetField()->myEntity == VISU::CELL) {
2410 vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
2411 aFilter->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput());
2412 aFilter->PassCellDataOn();
2413 aWarp->SetInput(aFilter->GetUnstructuredGridOutput());
2416 aWarp->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput());
2417 for (int j=0 ; j<aCycles; j++) {
2418 for (int i=0 ; i<=aSteps; i++) {
2419 aWarp->SetScaleFactor(aScale*float(i)/float(aSteps));
2420 aMapper->SetInput(aWarp->GetOutput());
2423 aLookupTbl->SetMapScale(float(i)/float(aSteps));
2424 RepaintCurrentView();
2433 case VISU::TISOSURFACE: // Iso surfaces
2435 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2437 int nbIso = aIsoPrs->GetNbSurfaces();
2438 if (nbIso <= 1) break;
2439 vtkContourFilter* aContourFilter = vtkContourFilter::New();
2440 if ((VISU::Entity)aIsoPrs->GetField()->myEntity == VISU::CELL) {
2441 vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
2442 aFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput());
2443 aFilter->PassCellDataOn();
2444 aContourFilter->SetInput(aFilter->GetOutput());
2447 aContourFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput());
2449 for (int j=0 ; j<aCycles; j++){
2450 for (int i=0 ; i<aSteps; i++){
2451 aMul = float(i)/float(aSteps);
2452 aLookupTbl->SetMapScale(aMul);
2453 aContourFilter->GenerateValues(nbIso*(i+1)/aSteps,aIsoPrs->GetRangeMin(),aIsoPrs->GetRangeMax());
2454 aMapper->SetInput(aContourFilter->GetOutput());
2455 RepaintCurrentView();
2459 aContourFilter->Delete();
2464 QApplication::restoreOverrideCursor();
2469 void VisuGUI::TimeAnimation() {
2470 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(myStudy);
2471 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2473 bool isDefined = false;
2475 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2476 for (; It.More(); It.Next()) {
2477 SALOMEDS::SObject_var aSObject = myStudy->FindObjectID( It.Value()->getEntry() );
2478 if (aSObject->_is_nil()) continue;
2479 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2480 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2484 aAnimationDlg->addField(aSObject);
2486 } else if (aNbTimes == aNumber) {
2487 aAnimationDlg->addField(aSObject);
2492 if (isDefined) aAnimationDlg->show();
2493 else delete aAnimationDlg;
2498 void VisuGUI::ImportMedField() {
2499 if (checkLock(myStudy)) return;
2501 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2502 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2503 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2504 QApplication::setOverrideCursor( Qt::waitCursor );
2505 for(;It.More();It.Next()) {
2506 Handle(SALOME_InteractiveObject) anIO = It.Value();
2507 SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry());
2508 if(!aSObject->_is_nil()){
2509 SALOMEDS::GenericAttribute_var anAttr;
2510 aSObject->FindAttribute(anAttr, "AttributeIOR");
2511 if(!anAttr->_is_nil()){
2512 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2513 if(!anIOR->_is_nil()){
2514 CORBA::String_var aValue = anIOR->Value();
2515 if(strcmp(aValue,"") != 0){
2516 CORBA::ORB_var anORB = VISU::GetORB();
2517 CORBA::Object_var anObject = anORB->string_to_object(aValue);
2518 if ( !CORBA::is_nil( anObject ) ) {
2519 SALOME_MED::FIELD_ptr aField = SALOME_MED::FIELD::_narrow( anObject );
2520 if( !CORBA::is_nil( aField ) ) {
2521 VisuGUI::myComponent->ImportMed( aField );
2524 SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject );
2525 if( !CORBA::is_nil( aMesh ) ) {
2526 VisuGUI::myComponent->ImportMedMesh( aMesh );
2529 SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject );
2530 if( !CORBA::is_nil( aSupport ) ) {
2531 VisuGUI::myComponent->ImportMedSupport( aSupport );
2540 VisuGUI::myActiveStudy->updateObjBrowser( true );
2541 QApplication::restoreOverrideCursor();
2544 void VisuGUI::ImportMedMesh() {
2545 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2546 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2547 if ( Sel->IObjectCount() != 1 )
2550 Handle(SALOME_InteractiveObject) anIO;
2551 CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, VisuGUI::myActiveStudy);
2552 if ( !CORBA::is_nil( anObject ) ) {
2553 SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject );
2554 if( !CORBA::is_nil( aMesh ) ) {
2555 VisuGUI::myComponent->ImportMedMesh( aMesh );
2556 VisuGUI::myActiveStudy->updateObjBrowser( true );
2558 SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject );
2559 if( !CORBA::is_nil( aSupport ) ) {
2560 VisuGUI::myComponent->ImportMedSupport( aSupport );
2561 VisuGUI::myActiveStudy->updateObjBrowser( true );
2566 //=====================================================================================
2567 // functions : Rename()
2569 //=====================================================================================
2570 void VisuGUI::Rename() {
2571 if (checkLock(myStudy)) return;
2572 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
2573 SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
2574 if ( Sel->IObjectCount() != 1 )
2576 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( Sel->firstIObject()->getEntry() );
2577 if( aSObj->_is_nil() ) return;
2579 //TEST DU PARENT == VISU
2580 SALOMEDS::GenericAttribute_var anAttr;
2581 SALOMEDS::AttributeName_var aName;
2582 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2583 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2584 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2585 if ( !Name.isEmpty() ) {
2586 QApplication::setOverrideCursor( Qt::waitCursor );
2587 VisuGUI::myActiveStudy->renameIObject( Sel->firstIObject(), Name );
2588 QApplication::restoreOverrideCursor();
2590 //int TypeMode; bool InViewer;
2591 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2592 //ActorTmp->setName((Standard_CString)Name.latin1());
2598 //=====================================================================================
2599 // function : CopyPresentation()
2601 //=====================================================================================
2602 void VisuGUI::CopyPresentation(){
2603 if (checkLock(myStudy)) return;
2604 VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
2605 if (!aPrsObject) return;
2606 switch (aPrsObject->GetType()) {
2609 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2610 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2611 aSameMesh->SameAs(aMeshPrs);
2612 UpdateViewer(aSameMesh, true);
2615 case VISU::TSCALARMAP:
2617 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2618 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2619 aSameScalar->SameAs(aScalarPrs);
2620 UpdateViewer(aSameScalar, true);
2623 case VISU::TDEFORMEDSHAPE:
2625 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2626 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2627 aSameDeformed->SameAs(aDefPrs);
2628 UpdateViewer(aSameDeformed, true);
2631 case VISU::TCUTPLANES:
2633 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2634 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2635 aSameCut->SameAs(aCutPrs);
2636 UpdateViewer(aSameCut, true);
2639 case VISU::TISOSURFACE:
2641 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2642 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2643 aSameIso->SameAs(aIsoPrs);
2644 UpdateViewer(aSameIso, true);
2647 case VISU::TSTREAMLINES:
2649 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2650 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2651 aSameLines->SameAs(aLinesPrs);
2652 UpdateViewer(aSameLines, true);
2655 case VISU::TVECTORS:
2657 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2658 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2659 aSameVectors->SameAs(aVectorsPrs);
2660 UpdateViewer(aSameVectors, true);
2664 myActiveStudy->updateObjBrowser();
2667 //=====================================================================================
2668 // function : InfoOnPoint() [ slot ]
2670 //=====================================================================================
2671 void VisuGUI::InfoOnPoint()
2673 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
2674 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2677 VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode );
2681 if ( TypeMode == SelectionPoint )
2682 Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp );
2684 QAD_MessageBox::warn1( visuGUI->myDesktop,
2686 tr ("Not Point selection mode"),
2687 tr ("VISU_BUT_OK") );
2690 //=====================================================================================
2691 // function : InfoOnCell() [ slot ]
2693 //=====================================================================================
2694 void VisuGUI::InfoOnCell()
2696 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
2697 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2700 VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode );
2704 if ( TypeMode == SelectionCell || TypeMode == SelectionEdge )
2705 Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp );
2707 QAD_MessageBox::warn1( visuGUI->myDesktop,
2709 tr ("Not Cell/Edge selection mode"),
2710 tr ("VISU_BUT_OK") );
2713 //=====================================================================================
2714 // function : SelectPoint() [ slot ]
2716 //=====================================================================================
2717 void VisuGUI::SelectPoint()
2719 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
2720 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2722 vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy );
2724 VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode );
2727 if ( TypeMode != SelectionPoint ) {
2728 QAD_MessageBox::warn1( visuGUI->myDesktop,
2730 tr ("Not Point selection mode"),
2731 tr ("VISU_BUT_OK") );
2736 vtkDataSetMapper* Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
2737 Mapper->SetInput(ActorTmp->DataSource);
2738 vtkDataSet *Data=Mapper->GetInput();
2739 int nbPoints=Data->GetNumberOfPoints();
2740 int selectedPoint = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"),
2741 tr("Point number:" ),
2744 visuGUI->myDesktop );
2745 if ( ok && theRenderer && selectedPoint > 0 && selectedPoint <= nbPoints )
2746 Selection->HighlightPoint( selectedPoint, nbPoints, ActorTmp, theRenderer );
2749 //=====================================================================================
2750 // function : SelectCell() [ slot ]
2752 //=====================================================================================
2753 void VisuGUI::SelectCell()
2755 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
2756 SALOME_Selection* Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection());
2757 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2759 vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy );
2760 int TypeMode=Sel->SelectionMode();
2761 if ( TypeMode != SelectionCell && TypeMode != SelectionEdge ) {
2762 QAD_MessageBox::warn1( visuGUI->myDesktop,
2764 tr ("Not Cell/Edge selection mode"),
2765 tr ("VISU_BUT_OK") );
2768 VISU_Actor* ActorTmp;
2770 Handle(SALOME_InteractiveObject) anIO;
2771 CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy);
2772 //srn: Added check if anObject is Null, then break
2773 // if(CORBA::is_nil(anObject)) break;
2775 VISU::Prs3d_i* aPrsObject = NULL;
2776 if(!CORBA::is_nil(anObject))
2777 aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
2779 //aPrsObject->SetIO(anIO);
2780 //ActorTmp = aPrsObject->GetActor();
2781 //UpdateViewer(ActorTmp);
2782 ActorTmp = visuGUI->UpdateViewer(aPrsObject);
2784 ActorTmp = ActorSelected(visuGUI->myDesktop,true,&TypeMode);
2790 vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
2791 Mapper->SetInput(ActorTmp->DataSource);
2792 vtkDataSet *Data=Mapper->GetInput();
2793 int nbCells=Data->GetNumberOfCells();
2794 int selectedCell = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"),
2795 tr("Cell number:" ),
2798 visuGUI->myDesktop );
2799 if ( ok && theRenderer && selectedCell > 0 && selectedCell <= nbCells )
2800 if (ok && theRenderer )
2801 Selection->HighlightCell(selectedCell , ActorTmp , theRenderer);
2804 //=====================================================================================
2805 // function : DefinePopup()
2807 //=====================================================================================
2808 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2810 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
2816 //=====================================================================================
2817 // function : CustomPopup()
2819 //=====================================================================================
2820 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2821 const QString & theParent, const QString & theObject)
2823 int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2824 VisuGUI::GetOrCreateVisuGUI(parent);
2825 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2827 bool isVTKViewer = (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2830 SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection());
2831 if ( Sel->IObjectCount() == 0 ) {
2832 if ( theParent == "Viewer" && isVTKViewer)
2833 // Available only for VTK viewer
2834 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2838 VISU::Storable::TRestoringMap aMap;
2839 Handle(SALOME_InteractiveObject) anIO;
2840 CORBA::Object_var anObject = GetSelectedObj(VisuGUI::myActiveStudy,&anIO,&aMap);
2842 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
2843 if(!isExist) aComment = "NONE";
2844 SALOMEDS::GenericAttribute_var anAttr;
2846 if (!CORBA::is_nil(anObject)) {
2847 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2848 if (!CORBA::is_nil(aVisuObj)) {
2849 if( Sel->IObjectCount() > 1) return false;
2851 VISU::VISUType aType = aVisuObj->GetType();
2852 MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2854 case VISU::TVISUGEN:
2855 thePopup->insertItem("Import From File", visuGUI, SLOT(ImportFromFile()));
2859 //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh()));
2860 thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile()));
2861 //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2865 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2866 thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2867 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2868 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2869 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2870 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2875 if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) )
2876 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2877 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2878 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2879 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2881 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2882 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2886 case VISU::TCONTAINER:
2887 if( !CORBA::is_nil( anObject ) ) {
2888 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2889 if( !CORBA::is_nil( aCnt ) ) {
2890 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
2891 if ( container && container->GetNbCurves() > 0 ) {
2892 if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) )
2893 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2894 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2895 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2896 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2897 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2904 default: // Presentation
2906 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
2908 VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject);
2910 // Add Presentation menu
2911 if ((aType != VISU::TSTREAMLINES) && anVISUActor) {
2912 QPopupMenu* aPresMenu = new QPopupMenu(VisuGUI::myDesktop);
2913 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2914 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2915 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2916 if (anVISUActor->IsShrinkable) {
2917 if (anVISUActor->IsShrunk)
2918 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2920 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2922 thePopup->insertItem("Representation", aPresMenu);
2926 QPopupMenu* aPropMenu = new QPopupMenu(VisuGUI::myDesktop);
2927 if ((aType == VISU::TMESH) ||
2928 (aType == VISU::TDEFORMEDSHAPE) ||
2929 (aType == VISU::TVECTORS) ||
2930 (aType == VISU::TSTREAMLINES)) // Mesh, deformed shape, vectors
2931 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2932 if (aType == VISU::TMESH)
2933 aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor()));
2935 if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES))
2936 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2937 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2938 thePopup->insertItem("Properties", aPropMenu);
2940 thePopup->insertSeparator();
2942 thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
2943 if (aType != VISU::TMESH) {
2944 if (aType != VISU::TSCALARMAP)
2945 thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
2946 thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar()));
2948 if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) && isVTKViewer)
2949 thePopup->insertItem("Animate", visuGUI, SLOT(Sweep()));
2952 if ( theParent == "Viewer" &&
2953 ( aType == VISU::TMESH ||
2954 aType == VISU::TSCALARMAP ||
2955 aType == VISU::TDEFORMEDSHAPE ) ) {
2956 thePopup->insertSeparator();
2957 if ( Sel->SelectionMode() == SelectionPoint ) {
2958 thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint()));
2959 thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint()));
2961 else if ( Sel->SelectionMode() == SelectionCell || Sel->SelectionMode() == SelectionEdge ) {
2962 thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell()));
2963 thePopup->insertItem("Select a Cell", visuGUI, SLOT(SelectCell()));
2966 thePopup->insertSeparator();
2967 if (visuGUI->IsDisplayed(aPrsObject) )
2968 thePopup->insertItem("Hide", visuGUI, SLOT(ErasePrs()));
2970 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
2972 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
2974 if (aType != VISU::TMESH)
2975 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2976 thePopup->insertSeparator();
2977 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
2984 // possibly this is the MED field/mesh and suppot objects
2985 /*CORBA::Object_var anObj = SALOME_MED::FIELD::_narrow( anObject );
2986 if( !CORBA::is_nil( anObj ) ) {
2987 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
2990 anObj = SALOME_MED::MESH::_narrow( anObject );
2991 if( !CORBA::is_nil( anObj ) ) {
2992 thePopup->insertItem( "Import Mesh", visuGUI, SLOT( ImportMedField() ) );
2995 anObj = SALOME_MED::GROUP::_narrow( anObject );
2996 if( !CORBA::is_nil( anObj ) ) {
2997 thePopup->insertItem( "Import Group", visuGUI, SLOT( ImportMedField() ) );
3000 anObj = SALOME_MED::FAMILY::_narrow( anObject );
3001 if( !CORBA::is_nil( anObj ) ) {
3002 thePopup->insertItem( "Import Family", visuGUI, SLOT( ImportMedField() ) );
3005 anObj = SALOME_MED::SUPPORT::_narrow( anObject );
3006 if( !CORBA::is_nil( anObj ) ) {
3007 thePopup->insertItem( "Import Support", visuGUI, SLOT( ImportMedField() ) );
3012 int aType = ObjectTypes.find( aComment.c_str() );
3013 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - aComment = "<<aComment<<"; aType = "<<aType);
3014 SALOMEDS::SObject_var obj = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
3016 // possibly this is Table SObject
3017 if ( !obj->_is_nil() && ( obj->FindAttribute( anAttr, "AttributeTableOfInteger" )
3018 || obj->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
3019 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
3020 thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
3024 if(aComment == "ENTITY" || aComment == "FAMILY" || aComment == "GROUP")
3025 thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3028 if (getValue(obj, "myNbTimeStamps").toLong() > 1)
3029 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3032 case 6: // VIEW3D node
3033 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3034 // Available only for VTK viewer
3035 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3036 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3038 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3039 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3042 //case 13: // Mesh node
3043 //thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3046 case 18: { // Timestamp
3047 // if( isStudyLocked(VisuGUI::myActiveStudy->getStudyDocument()))
3049 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3050 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_SCALAR_MAP") ),
3051 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3052 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ),
3053 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3054 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ),
3055 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3056 if(aNunComponent > 1){
3057 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ),
3058 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3059 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ),
3060 "Vectors...", visuGUI, SLOT(CreateVectors()));
3061 thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ),
3062 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3069 //===========================================================================
3070 // BuildPresentation
3071 //===========================================================================
3072 void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3074 BEGIN_OF("VisuGUI::BuildPresentation");
3076 if (theIO.IsNull()) {
3077 MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3081 /* Create or retrieve an object VisuGUI */
3083 VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
3085 SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument();
3086 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3088 if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
3090 vtkRenderer *Renderer = GetRenderer(visuGUI->myActiveStudy);
3092 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3094 if (aSObj -> _is_nil() ) {
3095 MESSAGE("No SObject for interacative object is found");
3099 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3100 if(!CORBA::is_nil(anObject)) {
3102 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
3103 if ( !aPrsObject ) {
3104 MESSAGE("The object is not VISU::Prs3d_i");
3107 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3108 if ( ! SelectedActor )
3109 SelectedActor = aPrsObject -> CreateActor();
3110 SCRUTE(SelectedActor);
3111 if ( SelectedActor == NULL ) {
3112 MESSAGE("VisuGUI::BuildPresentation(): actor doesn't exist in Render");
3115 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3116 vf->AddActor(SelectedActor);
3117 if(SelectedActor->HasScalarBar()){
3118 Renderer->AddActor2D(SelectedActor->getScalarBar());
3122 MESSAGE("CORBA::is_nil(anObject) = true");
3124 END_OF("VisuGUI::BuildPresentation");
3131 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
3133 //MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID);
3134 return VisuGUI::OnGUIEvent(theCommandID, parent);
3137 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3139 MESSAGE("VisuGUI::OnKeyPress ");
3140 return VisuGUI::OnKeyPress (pe, parent, studyFrame);
3143 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3145 //MESSAGE("VisuGUI::OnMousePress ");
3146 return VisuGUI::OnMousePress (pe, parent, studyFrame);
3149 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3151 //MESSAGE("VisuGUI::OnMouseMove ");
3152 return VisuGUI::OnMouseMove (pe, parent, studyFrame);
3155 bool SetSettings ( QAD_Desktop* parent )
3157 return VisuGUI::setSettings( parent );
3160 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
3161 const QString & theParent, const QString & theObject )
3163 return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
3166 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
3168 VisuGUI::DefinePopup( theContext, theParent, theObject );
3171 bool activeStudyChanged ( QAD_Desktop* parent )
3173 //VisuGUI::activeStudyChanged( parent );
3175 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
3177 VisuGUI::BuildPresentation(theIO);
3182 // ====================================================================================================================
3183 // ===================================================================================================================
3185 bool VisuGUI::getObjectRef( QAD_Desktop* parent, SALOMEDS::SObject_ptr obj,
3186 _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres,
3189 VisuGUI::GetOrCreateVisuGUI(parent);
3190 SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument();
3191 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(obj);
3192 SALOMEDS::SObject_var RefObj;
3194 for (; it->More();it->Next()) {
3195 SALOMEDS::SObject_var Fils = it->Value();
3197 if ( Fils->ReferencedObject( RefObj ) ) {
3198 SALOMEDS::SComponent_var theComponent = RefObj->GetFatherComponent();
3199 Standard_CString nameComponent = theComponent->ComponentDataType();
3201 if ( TCollection_AsciiString(nameComponent).IsEqual(strdup(Type)) ) {
3202 objres = SALOMEDS::SObject::_narrow(RefObj);
3210 //////////////////////////////////////////////////////////////////////////////////
3211 //////////////// CHANGE ACTOR COLOR ////////////////////////
3212 //////////////////////////////////////////////////////////////////////////////////
3213 //////////////////////////////////////////////////////////////////////////////////
3214 // change actor color
3215 // In : Name of Actor
3219 void VisuGUI::NewColor(VISU_Actor *Actor)
3221 float oldcolor[3],newcolor[3];
3222 Actor->GetProperty()->GetColor(oldcolor);
3224 colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255);
3225 QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() );
3227 if (!colornew.isValid()) return;
3229 newcolor[0]=colornew.red()/255.;
3230 newcolor[1]=colornew.green()/255.;
3231 newcolor[2]=colornew.blue()/255.;
3232 Actor->GetProperty()->SetColor(newcolor);
3233 if (Actor->getPrs3d())
3234 Actor->getPrs3d()->SetColor(newcolor);
3237 void VisuGUI::NewOutlineColor(VISU_Actor *Actor)
3239 float oldcolor[3],newcolor[3];
3240 Actor->EdgeDevice->GetProperty()->GetColor(oldcolor);
3242 colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255);
3243 QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() );
3245 if (!colornew.isValid()) return;
3247 SALOMEDS::Color aColor;
3248 aColor.R = newcolor[0]=colornew.red()/255.;
3249 aColor.G = newcolor[1]=colornew.green()/255.;
3250 aColor.B = newcolor[2]=colornew.blue()/255.;
3251 Actor->EdgeDevice->GetProperty()->SetColor(newcolor);
3252 if (Actor->getPrs3d())
3253 dynamic_cast<VISU::Mesh_i*>(Actor->getPrs3d())->SetLinkColor(aColor);
3256 //////////////////////////////////////////////////////////////////////////////////
3257 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3258 //////////////////////////////////////////////////////////////////////////////////
3259 //////////////////////////////////////////////////////////////////////////////////
3260 // change actor opacity
3261 // In : Name of Actor
3263 // Use CursorDlg to select a value between 0 and 100
3266 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3269 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3271 float oldopac,newopac;
3273 CursorDlg->Comment1->setText( tr( "Set value between") );
3274 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3275 oldopac=Actor->GetProperty()->GetOpacity();
3276 intopac=int(oldopac*100.);
3277 CursorDlg->SpinBox1->setMinValue(0);
3278 CursorDlg->SpinBox1->setMaxValue(100);
3279 CursorDlg->SpinBox1->setValue(intopac);
3281 int ret = CursorDlg->exec();
3284 intopac = CursorDlg->SpinBox1->value() ;
3285 newopac = intopac/100.;
3286 Actor->GetProperty()->SetOpacity(newopac);
3291 //////////////////////////////////////////////////////////////////////////////////
3292 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3293 //////////////////////////////////////////////////////////////////////////////////
3294 //////////////////////////////////////////////////////////////////////////////////
3295 // change actor linewidth
3296 // In : Name of Actor
3298 // Use CursorDlg to select a value between 0 and 10
3301 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3304 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3306 float oldlwid,newlwid;
3308 CursorDlg->Comment1->setText("Set value between");
3309 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3310 oldlwid=Actor->GetProperty()->GetLineWidth();
3311 intlwid=int(oldlwid);
3312 CursorDlg->SpinBox1->setMinValue(1);
3313 CursorDlg->SpinBox1->setMaxValue(10);
3314 CursorDlg->SpinBox1->setValue(intlwid);
3316 int ret = CursorDlg->exec();
3318 intlwid = CursorDlg->SpinBox1->value() ;
3320 Actor->GetProperty()->SetLineWidth(newlwid);
3325 /* ======================================================================================== */
3326 /* Setting parameters for Scalar Bar */
3327 /* ======================================================================================== */
3328 void VisuGUI::ChangeScalarBar()
3330 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3331 Scbar->initFromResources();
3332 int ret = Scbar->exec();
3334 Scbar->storeToResources();
3339 /* ======================================================================================== */
3340 /* Setting parameters for Sweeping */
3341 /* ======================================================================================== */
3342 void VisuGUI::SetSweepingPreferences()
3348 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3349 if ( !Tempo.isEmpty() )
3350 tempo = Tempo.toFloat();
3352 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3353 if ( !Cycles.isEmpty() )
3354 cycles = Cycles.toInt();
3356 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3357 if ( !Steps.isEmpty() )
3358 steps = Steps.toInt();
3360 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3362 Sweep->setTimeStep( tempo );
3363 Sweep->setNbCycles( cycles );
3364 Sweep->setNbSteps ( steps );
3366 if ( Sweep->exec() )
3368 tempo = Sweep->getTimeStep();
3369 cycles = Sweep->getNbCycles();
3370 steps = Sweep->getNbSteps();
3372 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3373 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3374 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3379 /* ======================================================================================== */
3380 /* Returns Visu input files directory (default is CSF_PATHData) */
3381 /* ======================================================================================== */
3382 QString VisuGUI::getVisuInputDir()
3384 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3385 if ( Tmp.isEmpty() )
3386 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3387 Tmp = QAD_Tools::addSlash(Tmp);
3391 /* ======================================================================================== */
3392 /* Returns Visu output files directory (default is InputDir) */
3393 /* ======================================================================================== */
3394 QString VisuGUI::getVisuOutputDir()
3396 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3397 if ( Tmp.isEmpty() )
3399 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3400 if ( Tmp2.isEmpty() )
3401 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3405 Tmp = QAD_Tools::addSlash(Tmp);
3410 /* ======================================================================================== */
3411 /* Global Method for Scalar Map */
3412 /* ======================================================================================== */
3413 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3414 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3415 VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
3416 SALOMEDS::SObject_var aSObj = theField->GetFather();
3417 aSObj = aSObj->GetFather();
3418 aSObj = aSObj->GetFather();
3419 aSObj = aSObj->GetFather();
3420 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3421 if(CORBA::is_nil(anObject)) return NULL;
3422 theResult = VISU::Result::_narrow(anObject);
3423 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject));
3425 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3426 tr ("No Available data in selection"),
3427 tr ("VISU_BUT_OK"));
3431 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3432 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3433 const char* theMeshName, VISU::Entity theEntity, \
3434 const char* theFieldName, double theTimeId) {\
3435 VISU::Result_var aResult; \
3436 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3438 if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \
3439 QApplication::setOverrideCursor( Qt::waitCursor ); \
3440 VISU::VISU_Gen_var aVisuGen = VISU::GetVisu(); \
3441 CORBA::Object_var anObject = \
3442 aVisuGen->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3443 QApplication::restoreOverrideCursor(); \
3444 if(CORBA::is_nil(anObject)) return NULL; \
3445 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject)); \
3448 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3449 tr ("The presentation can't be builded."), \
3450 tr ("VISU_BUT_OK") ); \
3455 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3456 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3457 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3458 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3459 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3460 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3463 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3464 bool FNAME(SALOMEDS::SObject_var theField) { \
3465 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3467 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3468 if(!isExist && aType.toInt() != VISU::TTIMESTAMP) return false; \
3469 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3470 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3471 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3472 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3473 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toDouble()); \
3475 DLGNAME* aDlg = new DLGNAME(); \
3476 aDlg->initFromPrsObject(pPresent); \
3477 if (aDlg->exec()) { \
3478 aDlg->storeToPrsObject(pPresent); \
3480 DeletePresentation(pPresent); \
3485 CreateActor(pPresent); \
3491 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3492 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3493 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3494 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3495 BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3496 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3500 /* ======================================================================================== */
3501 /* Global Method to import tables from file */
3502 /* ======================================================================================== */
3503 void VisuGUI::ImportTablesFromFile(){
3505 flt.append( "Files (*.xls *.txt *.tab)" );
3506 flt.append( "All Files (*.*)" );
3507 QString aDir = getVisuInputDir();
3508 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3509 aDir,flt,tr("Import From File"),true);
3510 if(!aFile.isEmpty()){
3511 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." );
3512 aDir = QAD_Tools::getDirFromPath(aFile);
3513 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3514 QApplication::setOverrideCursor( Qt::waitCursor );
3515 QAD_PyInterp* myPyInterp = myActiveStudy->get_PyInterp();
3516 myPyInterp->run("import VisuGUI");
3517 myPyInterp->run("reload(VisuGUI)");
3518 myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')");
3519 // VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1());
3520 // if(aResult->_is_nil())
3521 // QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3522 // tr ("There is an error in imported file"),
3523 // tr ("VISU_BUT_OK") );
3525 // QAD_Application::getDesktop()->putInfo(aFile+" imported.");
3526 myActiveStudy->updateObjBrowser(); //update Object browser
3527 QApplication::restoreOverrideCursor();
3531 /* ======================================================================================== */
3532 /* Global Method to import mesh results in MED and DAT format */
3533 /* ======================================================================================== */
3534 void VisuGUI::ImportFromFile(){
3535 if (checkLock(myActiveStudy->getStudyDocument())) return;
3537 //flt.append( "Exportable Files (*.med *.dat)" );
3538 //flt.append( "Dat Files (*.dat)" );
3539 flt.append( "Med Files (*.med)" );
3540 QString aDir = getVisuInputDir();
3541 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3542 aDir,flt,tr("Import From File"),true);
3543 if(!aFile.isEmpty()){
3544 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." );
3545 aDir = QAD_Tools::getDirFromPath(aFile);
3546 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3547 QApplication::setOverrideCursor( Qt::waitCursor );
3548 VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1());
3549 if(aResult->_is_nil())
3550 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3551 tr ("There is an error in imported file"),
3552 tr ("VISU_BUT_OK") );
3554 QAD_Application::getDesktop()->putInfo(aFile+" imported.");
3555 myActiveStudy->updateObjBrowser(); //update Object browser
3556 QApplication::restoreOverrideCursor();
3560 void VisuGUI::ExportToFile(){
3561 VISU::Base_i* aBase = GetSelectedVisuObj();
3562 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3564 flt.append( "Dat Files (*.dat)" );
3565 flt.append( "Med Files (*.med)" );
3566 QString aDir = getVisuOutputDir();
3567 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3568 aDir,flt,tr("Export To File"),false);
3569 if(!aFile.isEmpty()){
3570 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3571 aDir = QAD_Tools::getDirFromPath(aFile);
3572 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3573 if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3575 aResult->GetInput()->ToFile(aFile.latin1());
3576 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3578 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3579 tr ("There is an error during exporting to file"),
3580 tr ("VISU_BUT_OK") );
3585 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3586 tr ("No Available data in selection"),
3587 tr ("VISU_BUT_OK"));
3591 /* ======================================================================================== */
3592 /* Find an Actor to be the reference for a new visualization */
3593 /* ======================================================================================== */
3594 VISU_Actor *VisuGUI::ReferenceActor(QAD_Desktop* parent)
3596 bool exiDS = false, exiVE = false, exiSM = false, exiIS = false, exiCP = false;
3597 int nbSf = visuGUI->myActiveStudy->getStudyFramesCount();
3599 for ( int i = 0; i < nbSf; i++ ) {
3600 QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i);
3601 if ( sf->getTypeView() == VIEW_VTK ) {
3602 vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
3603 vtkActorCollection* ac = aRenderer->GetActors();
3605 for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) {
3606 if ( anActor->IsA( "VISU_Actor" ) ) {
3607 VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor);
3608 if (VisuGUI_VisuAsDlg::ActorTypeIsValid(VISUActor,-1)) {
3609 // VisuAs->ListObjects->insertItem(VISUActor->getName());
3611 int test = VISUActor->VisuActorType;
3612 if(test == VisuActorType_DeformedShape)
3614 else if(test == VisuActorType_Vectors)
3616 else if(test == VisuActorType_ScalarMap)
3618 else if(test == VisuActorType_IsoSurfaces)
3620 else if(test == VisuActorType_CutPlanes)
3629 VisuGUI_VisuAsDlg * VisuAs = new VisuGUI_VisuAsDlg(QAD_Application::getDesktop(), 0, true, 0 );
3632 VisuAs->addType( tr( "Deformed Shape" ) );
3634 VisuAs->addType( tr( "Vectors" ) );
3636 VisuAs->addType( tr( "Scalar Map" ) );
3638 VisuAs->addType( tr( "Iso-Surfaces" ) );
3640 VisuAs->addType( tr( "Cut Planes" ) );
3642 if ( VisuAs->exec() ) {
3643 QString nameActor = VisuAs->getObject();
3644 if ( !nameActor.isNull() ) {
3645 MESSAGE("Actor --> "<<nameActor.latin1());
3646 for ( int i = 0; i < nbSf; i++ ) {
3647 QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i);
3648 if ( sf->getTypeView() == VIEW_VTK ) {
3649 vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
3650 vtkActorCollection* ac = aRenderer->GetActors();
3652 for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) {
3653 if ( anActor->IsA( "VISU_Actor" ) ) {
3654 VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor);
3655 if (strcmp(VISUActor->getName(),nameActor) == 0)
3667 /* ======================================================================================== */
3668 /* Test and Read Object Browser before display */
3669 /* ======================================================================================== */
3670 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var *objVisu ){
3671 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3672 SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
3673 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3675 Handle(SALOME_InteractiveObject) IObject = It.Value();
3676 SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
3677 if (IObject->hasEntry()){
3678 *objVisu = aStudy->FindObjectID(IObject->getEntry());
3679 if(!(*objVisu)->_is_nil()) return true;
3682 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3683 tr("No Available data in selection"),
3684 tr("VISU_BUT_OK") );
3688 /* ======================================================================================== */
3689 /* Print the render window */
3690 /* ======================================================================================== */
3691 void VisuGUI::PrintRW( QString prFile, bool toPrinter)
3693 ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->Repaint();
3695 vtkRenderWindow *renwin = vtkRenderWindow::New();
3696 vtkRenderWindowInteractor *theInteractor = vtkRenderWindowInteractor::New();
3697 theInteractor = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3698 //visuGUI->myActiveStudy->getActiveStudyFrame()->getVTKRWInteractor();
3700 renwin=theInteractor->GetRenderWindow();
3701 vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New();
3702 vtkTIFFWriter *rttiffw = vtkTIFFWriter::New();
3703 w2if->SetInput(renwin);
3704 rttiffw->SetInput(w2if->GetOutput());
3705 rttiffw->SetFileName(prFile);
3708 if (toPrinter) // print the file
3710 QString printer = QAD_CONFIG->getSetting("Visu:Printer");
3711 if (printer.isEmpty())
3713 system(printer + " " + prFile);
3718 * Returns Actor of presentation if it exists
3720 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs){
3721 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3722 if (!vf) return NULL;
3724 vtkRenderer *aRen = vf->getRenderer();
3725 vtkActorCollection *anActColl = aRen->GetActors();
3727 VISU_Actor* anVISUActor = NULL;
3728 VISU_Actor* aResActor = NULL;
3729 long aSrcAddr = (long) thePrs;
3730 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3731 if(anActor->IsA("VISU_Actor")){
3732 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3733 long aCurrAddr = (long) anVISUActor->getPrs3d();
3734 if (aSrcAddr == aCurrAddr) {
3743 * Displays only actor of given presentation
3744 * Creates it if it is abcent
3746 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3747 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3748 if (!vf) return NULL;
3750 vtkRenderer *aRen = vf->getRenderer();
3751 vtkActorCollection *anActColl = aRen->GetActors();
3754 VISU_Actor* anVISUActor = NULL;
3755 VISU_Actor* aResActor = NULL;
3756 long aSrcAddr = (long) thePrs;
3757 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3758 if(anActor->IsA("VISU_Actor")){
3759 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3760 long aCurrAddr = (long) anVISUActor->getPrs3d();
3761 if (aSrcAddr == aCurrAddr) {
3762 aResActor = anVISUActor;
3763 aResActor->VisibilityOn();
3764 if ( aResActor->VisuActorType == VisuActorType_Mesh ) {
3765 if ( aResActor->GetProperty()->GetRepresentation() == 2 && !aResActor->IsShrunk )
3766 aResActor->EdgeDevice->VisibilityOn();
3768 aResActor->EdgeDevice->VisibilityOff();
3770 if (aResActor->HasScalarBar())
3771 aResActor->getScalarBar()->VisibilityOn();
3772 } else if (theDispOnly) {
3773 anVISUActor->VisibilityOff();
3774 if ( anVISUActor->VisuActorType == VisuActorType_Mesh) {
3775 anVISUActor->EdgeDevice->VisibilityOff();
3777 if (anVISUActor->HasScalarBar())
3778 anVISUActor->getScalarBar()->VisibilityOff();
3782 if (aResActor) return aResActor;
3787 anVISUActor = thePrs->CreateActor();
3788 MESSAGE("UpdateViewer - thePrs->CreateActor() = "<<anVISUActor);
3789 if ( anVISUActor ) {
3790 vf->AddActor(anVISUActor);
3791 if(anVISUActor->HasScalarBar()){
3792 aRen->AddActor2D(anVISUActor->getScalarBar());
3795 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3796 tr ("Can't visulize current object"),
3797 tr ("VISU_BUT_OK") );
3800 MESSAGE("Cheking time in VisuGUI::UpdateViewer - thePrs->CreateActor + vf->AddActor + aRen->AddActor2D");
3808 * Returns TRUE if Presentation is displayed
3810 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
3811 VISU_Actor* anVISUActor = GetActor(thePrs);
3812 return (anVISUActor)? anVISUActor->GetVisibility() : false;
3816 * Erases Presentation
3818 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
3819 myActiveStudy->unHighlightAll();
3820 VISU_Actor* anVISUActor = GetActor(thePrs);
3822 anVISUActor->VisibilityOff();
3823 if ( anVISUActor->VisuActorType == VisuActorType_Mesh )
3824 anVISUActor->EdgeDevice->VisibilityOff();
3825 if (anVISUActor->HasScalarBar())
3826 anVISUActor->getScalarBar()->VisibilityOff();
3831 * Deletes given presentation from Data structure
3833 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
3834 if (checkLock(myStudy)) return;
3835 if (!thePrs) return;
3837 myActiveStudy->unHighlightAll();
3840 VISU_Actor* aVISUActor = NULL;
3841 long aSrcAddr = (long) thePrs;
3842 int nbFrames = myActiveStudy->getStudyFramesCount();
3843 QAD_StudyFrame* aFrame;
3845 for(int i=0; i<nbFrames; i++) {
3846 aFrame = myActiveStudy->getStudyFrame(i);
3847 if(!aFrame || aFrame->getTypeView() != VIEW_VTK) continue;
3848 vtkRenderer* aRen = ((VTKViewer_ViewFrame*)aFrame->getRightFrame()->getViewFrame())->getRenderer();
3849 vtkActorCollection *anActColl = aRen->GetActors();
3851 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3852 if(anActor->IsA("VISU_Actor")) {
3853 aVISUActor = VISU_Actor::SafeDownCast(anActor);
3854 if (aSrcAddr == ((long) aVISUActor->getPrs3d())) {
3855 if (aVISUActor->HasScalarBar())
3856 aRen->RemoveActor(aVISUActor->getScalarBar());
3857 aRen->RemoveActor(aVISUActor);
3858 aVISUActor->EdgeDevice->Delete();
3859 aVISUActor->Delete();
3865 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(thePrs->GetEntry());
3866 if(aSObj->_is_nil()) return;
3867 myStudyBuilder->RemoveObject(aSObj);
3868 myActiveStudy->updateObjBrowser(); //update Object browser
3872 * Creates new actor of presentation
3874 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
3875 if (!thePrs) return;
3876 QApplication::setOverrideCursor( Qt::waitCursor );
3877 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3883 VISU_Actor* aActor = thePrs->CreateActor();
3885 QApplication::restoreOverrideCursor();
3886 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3887 tr ("The presentation can't be visualized.\n Null actor is created."),
3888 tr ("VISU_BUT_OK") );
3893 MESSAGE("Cheking time in VisuGUI::CreateActor - thePrs->CreateActor");
3896 vtkRenderer *aRenderer = vf->getRenderer();
3897 //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1);
3898 //visuGUI->ShowTrihedron(true);
3903 vf->AddActor(aActor);
3904 if (aActor->HasScalarBar())
3905 aRenderer->AddActor2D(aActor->getScalarBar());
3908 MESSAGE("Cheking time in VisuGUI::CreateActor - vf->AddActor");
3912 QApplication::restoreOverrideCursor();
3917 /* ======================================================================================== */
3918 /* Functions to State of VisuGUI and Dialog Box */
3919 /* ======================================================================================== */
3921 void VisuGUI::SetState(int aState )
3923 this->myState = aState ;
3928 void VisuGUI::ResetState()
3930 this->myState = -1 ;
3934 void VisuGUI::EmitSignalDeactivateDialog()
3936 emit this->SignalDeactivateActiveDialog() ;
3940 void VisuGUI::EmitSignalCloseAllDialogs()
3942 emit this->SignalCloseAllDialogs() ;
3946 QDialog* VisuGUI::GetActiveDialogBox()
3948 return this->myActiveDialogBox ;
3951 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
3953 this->myActiveDialogBox = (QDialog*)aDlg ;
3957 QAD_Study* VisuGUI::GetActiveStudy()
3959 return this->myActiveStudy ;
3962 QAD_Desktop* VisuGUI::GetDesktop()
3964 return this->myDesktop ;