1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include <QInputDialog>
27 #include <QStackedWidget>
29 #include <QtxTreeView.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_ViewManager.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_DataObject.h>
37 #include <SUIT_DataBrowser.h>
38 #include <SUIT_FileDlg.h>
40 #include <SVTK_ViewManager.h>
41 #include <SVTK_ViewModel.h>
42 #include <SVTK_ViewWindow.h>
44 #include <VTKViewer_ViewModel.h>
46 #include <vtkActorCollection.h>
47 #include <VTKViewer_Algorithm.h>
48 #include <vtkRenderer.h>
52 #include <SOCC_ViewModel.h>
53 #include <SOCC_ViewWindow.h>
54 #include <OCCViewer_ViewWindow.h>
55 #include <SALOME_Prs.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_Study.hxx>
61 #include <SALOMEDSClient_StudyBuilder.hxx>
62 #include <SALOMEDSClient_SComponent.hxx>
63 #include <SALOMEDSClient_ClientFactory.hxx>
64 #include <SALOMEDSClient_IParameters.hxx>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Module.h>
70 #include <SalomeApp_Application.h>
71 #include <SalomeApp_DataModel.h>
74 #include <SALOME_ListIO.hxx>
75 #include <SALOME_ListIteratorOfListIO.hxx>
78 #include <SALOME_LifeCycleCORBA.hxx>
80 #include <LightApp_VTKSelector.h>
82 #include <OCCViewer_ViewManager.h>
84 #include <QtxPopupMgr.h>
86 #include "Resource.hxx"
88 #include "HEXABLOCKGUI.hxx"
89 #include "HEXABLOCKGUI_Export.hxx"
90 #include "HEXABLOCKGUI_Trace.hxx"
91 #include "HEXABLOCKGUI_Resource.hxx"
93 #include "HEXABLOCKGUI_DocumentModel.hxx"
94 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
95 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
96 #include "HEXABLOCKGUI_DocumentPanel.hxx"
97 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
98 #include "HEXABLOCKGUI_OccGraphicView.hxx"
99 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
101 #include <HEXABLOCK_version.h>
103 #include "MyBasicGUI_PointDlg.hxx"
105 // #include "HEXABLOCK.hxx" del Hexa6
106 // #include "HexDocument_impl.hxx" del Hexa6
110 #include <Visual3d_ViewManager.hxx>
111 #include <V3d_PerspectiveView.hxx>
112 #include <V3d_AmbientLight.hxx>
113 #include <V3d_DirectionalLight.hxx>
114 #include <Xw_Window.hxx>
115 #include <V3d_TypeOfShadingModel.hxx>
116 #include <TCollection_ExtendedString.hxx>
118 #include <BRepAlgoAPI_Fuse.hxx>
120 #include <AIS_ListIteratorOfListOfInteractive.hxx>
123 #define DW_MINIMUM_WIDTH 50
124 #define DWINPUT_MINIMUM_HEIGHT 50
125 #define DWINPUT_MINIMUM_WIDTH 50//255
128 using namespace HEXABLOCK::GUI;
130 int HEXABLOCKGUI::_oldStudyId = -1;
132 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
134 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
135 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
136 bool HEXABLOCKGUI::assocInProgress = false;
137 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
139 HEXABLOCKGUI::HEXABLOCKGUI() :
140 SalomeApp_Module( "HEXABLOCK" ),
141 // LightApp_Module( "HEXABLOCK" ),
149 _patternDataTreeView(0),
150 // _patternBuilderTreeView(0),
151 _patternGeomTreeView(0),
154 // _treeViewDelegate(0),
156 moduleActivatedOnce(false),
165 _makeCylinderDiag(0),
167 _makeCylindersDiag(0),
175 _makeTransformationDiag(0),
176 _makeSymmetryDiag(0),
177 _performTransformationDiag(0),
178 _performSymmetryDiag(0),
187 _quadRevolutionDiag(0),
188 _makeHemiSphereDiag(0),
189 _modelInfoDiag(NULL),
191 _vertexInfoDialog(NULL),
192 _edgeInfoDialog(NULL),
193 _quadInfoDialog(NULL),
194 _hexaInfoDialog(NULL),
195 _vectorInfoDialog(NULL),
196 _groupInfoDialog(NULL),
197 _lawInfoDialog(NULL),
198 _propagationInfoDialog(NULL),
201 lastVtkDocGView(NULL)
203 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
205 graphicViewsHandler = new GraphicViewsHandler();
206 loadDocLastPath = new QDir();
207 saveDocLastPath = new QDir();
208 hexa_root = HEXA_NS::Hex::getInstance ();
211 HEXABLOCKGUI::~HEXABLOCKGUI()
216 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
218 SUIT_Application* app = SUIT_Session::session()->activeApplication();
220 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
226 // Gets an reference to the module's engine
227 /****************************************************
228 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
230 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
231 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
232 ASSERT(!CORBA::is_nil(clr));
235 **************************************************** */
237 void HEXABLOCKGUI::initialize( CAM_Application* app )
239 DEBTRACE("HEXABLOCKGUI::initialize");
240 SalomeApp_Module::initialize( app );
242 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
244 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
246 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
247 setResource(aResourceMgr);
249 createAndFillDockWidget();
256 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
258 DEBTRACE("HEXABLOCKGUI::viewManagers");
259 // list.append( QxScene_Viewer::Type() );
260 // list.append( OCCViewer_Viewer::Type() );
261 // list.append( SVTK_Viewer::Type() );
265 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
267 DEBTRACE("HEXABLOCKGUI::activateModule");
269 /*HexaBlock can be launched in only one application*/
270 if (myApplication == NULL)
271 //remember the first application
272 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
274 //application verification: if it's not the one known by HexaBlock,
275 //leave without activating
276 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
277 if (myApplication != currentApplication) return false;
279 bool bOk = SalomeApp_Module::activateModule( theStudy );
280 if ( !bOk ) return false;
282 showDockWidgets(true);
284 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
285 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
286 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
287 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
289 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
291 SUIT_ViewManager* vm;
292 ViewManagerList OCCViewManagers, VTKViewManagers;
294 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
295 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
296 while ( itOCC.hasNext() && (vm = itOCC.next()) )
297 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
299 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
300 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
301 while ( itVTK.hasNext() && (vm = itVTK.next()) )
302 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
305 SALOME_ListIO selected;
306 sm->selectedObjects( selected );
309 // disable OCC selectors
310 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
311 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
312 while ( itOCCSel.hasNext() )
313 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
314 sr->setEnabled(true);
316 // disable VTK selectors
317 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
318 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
319 while ( itVTKSel.hasNext() )
320 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
321 sr->setEnabled(true);
323 sm->setSelectedObjects( selected, true ); //NPAL 19674
325 //connect close signal to vtk view manager
326 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
329 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
330 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
333 //connect close signal to occ view manager
334 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
337 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
338 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
341 /* ************************************ TODO Hexa6
342 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
343 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
344 if ( _PTR(Study) aStudy = s->studyDS()) {
345 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
346 updateObjBrowser(); // objects can be removed
348 ************************************ */
350 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
351 currentOccGView->getViewWindow()->installEventFilter(this);
353 if (currentDocGView != NULL)
355 switchModel(currentDocGView);
358 if (currentDocGView->getViewWindow() != NULL)
359 currentDocGView->getViewWindow()->installEventFilter(this);
368 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
370 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
371 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
372 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
373 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
375 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
376 if ( vtkView != NULL)
378 //default selectionMode in VTKView
379 vtkView->SetSelectionMode( ActorSelection );
380 vtkView->removeEventFilter(this);
384 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
387 //defaut selectionMode in OccView
388 selectionMgr()->clearSelected();
389 currentOccGView->globalSelection();
390 occView->removeEventFilter(this);
394 qDeleteAll(myOCCSelectors);
395 myOCCSelectors.clear();
396 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
398 qDeleteAll(myVTKSelectors);
399 myVTKSelectors.clear();
400 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
402 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
404 //switch off current document graphic view
405 switchOffGraphicView(currentDocGView);
408 setMenuShown( false );
409 setToolShown( false );
410 showDockWidgets( false );
412 _dwInputPanel->close();
419 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
421 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
422 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
423 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
424 int aStudyID = theStudy->StudyId();
425 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
426 return aDSStudy._retn();
429 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
430 QMap<QString, QString>& docShapesEntry,
431 QMap<QString, QString>& docShapesName)
433 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
434 return; //there's nothing to publish in this case
436 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
437 if(!appStudy) return;
438 _PTR(Study) aStudy = appStudy->studyDS();
439 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
440 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
441 QString entry = currentDocGView->getDocumentModel()->documentEntry();
442 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
443 if (aFatherSO->_is_nil())
446 // * get a presentation
447 bool isNewPrs = false;
448 SOCC_Prs* prs = getOccPrs(currentDocGView);
451 prs = new SOCC_Prs();
455 // * init the presentation with the given shapes
456 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
457 while (i != topo_shapes.constEnd())
459 QString shapeName = i.key();
460 TopoDS_Shape shapeValue = i.value();
461 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
462 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
463 QString objStudyEntry = aSO->GetID(); //the entry of the published object
464 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
465 "HEXABLOCK", shapeName.toStdString().c_str());
466 ais_shape->SetOwner(io);
467 prs->AddObject(ais_shape);
468 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
469 docShapesEntry[shapeName] = objStudyEntry;
470 docShapesName[objStudyEntry] = shapeName;
471 currentOccGView->addShape(objStudyEntry, ais_shape);
472 i++; //handle next shape
476 prs->AddObject(currentOccGView->getPreviewShape());
478 occPrs[currentDocGView] = prs;
479 getApp()->updateObjectBrowser();
484 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
486 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
487 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
488 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
490 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
494 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
498 // Pas de renommage des shapes pour le moment, juste les documents
499 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
500 if (dgview == NULL || dgview->getDocumentModel() == NULL)
503 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
504 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
509 _PTR(Study) aStudy = appStudy->studyDS();
514 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
515 _PTR(GenericAttribute) anAttr;
517 if ( obj->FindAttribute(anAttr, "AttributeName") ){
518 _PTR(AttributeName) aName (anAttr);
519 DocumentModel* docModel = dgview->getDocumentModel();
520 docModel->setName( name );
521 aName->SetValue( name.toLatin1().data() );
522 getApp()->updateObjectBrowser();
523 _dwPattern->setWindowTitle( name );
530 // --- Default windows
531 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
533 DEBTRACE("HEXABLOCKGUI::windows");
535 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
536 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
539 QString HEXABLOCKGUI::engineIOR() const
541 DEBTRACE("HEXABLOCKGUI::engineIOR");
543 /* ************************************ TODO Hexa6
544 CORBA::ORB_var anORB = getApp()->orb();
545 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
546 return QString( anIOR.in() );
547 ************************************ */
551 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
553 if (docs.count(studyObject->entry()) == 0)
555 //Object's document not acquired yet
556 VtkDocumentGraphicView* dgview;
557 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
558 if (directory == NULL)
559 return NULL; //No working director found
561 //------------------ Load the document -----------------
562 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
563 if (document == NULL)
564 return NULL; //No document found
566 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
568 MESSAGE("Doc model creation failed!");
571 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
572 if (dgview == NULL) return NULL;
574 //update the data tree
575 docs[studyObject->entry()] = dgview;
578 return docs[studyObject->entry()];
581 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
583 // ** we want to switch automatically to the right view windows
585 //first, find selected item
587 DataObjectList dol = getApp()->objectBrowser()->getSelected();
588 if (dol.isEmpty()) return;
589 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
590 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
591 item->entry().isEmpty())
594 // find the document corresponding to it
595 VtkDocumentGraphicView* docGView = NULL;
596 if (docs.contains(item->entry()))
597 docGView = docs[item->entry()];
599 docGView = getOrCreateDocument(item);
601 //Init OCC if necessary
602 if (currentOccGView == NULL)
604 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
605 currentOccGView->getViewWindow()->installEventFilter(this);
607 else if (currentOccGView->getViewWindow() == NULL)
609 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
610 currentOccGView->getViewWindow()->installEventFilter(this);
613 //Init the vtk view if necessary
614 if (docGView->getViewWindow() == NULL)
616 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
618 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
619 docGView->getViewWindow()->installEventFilter(this);
622 docGView->setViewWindow(currentDocGView->getViewWindow());
624 if (docGView->getDocumentActor() == NULL)
628 if (docGView == NULL || docGView == currentDocGView)
634 //update the current document
635 switchModel(docGView);
639 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
641 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
644 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
646 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
648 //Decharger le model correspondant (VTK)
649 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
654 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
655 { //HexaBlock Vtk Window has been closed
657 if (currentDialog != NULL) currentDialog->close();
658 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
659 if (currentDocGView != NULL)
660 currentDocGView->setViewWindow(NULL);
667 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
668 if (dgview == NULL) return; //The window has no document to close
670 //Save the document? (Ask only if the document is not empty
671 int answerCode = SUIT_MessageBox::question(
674 tr("Save the document ?"),
675 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
676 SUIT_MessageBox::Cancel);
677 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
678 else if (answerCode == SUIT_MessageBox::Yes)
679 saveDocument(); //Save the document
681 // switchOffGraphicView(window); //disconnect all connected signals
682 // currentVtkView = NULL;
683 // graphicViewsHandler->closeDocumentGraphicView(window);
685 //create a new one (empty document)
687 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
691 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
693 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
694 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
695 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
696 if (currentDialog != NULL) currentDialog->close();
697 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
699 currentOccGView->getViewWindow()->removeEventFilter(this);
701 currentOccGView->setViewWindow(NULL);
705 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
707 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
709 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
710 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
712 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
714 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
715 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
716 // disable OCC selectors
717 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
718 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
719 while ( itOCCSel.hasNext() )
720 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
721 sr->setEnabled(true);
723 else if ( vm->getType() == SVTK_Viewer::Type() )
725 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
726 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
728 // disable VTK selectors
729 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
730 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
731 while ( itVTKSel.hasNext() )
732 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
733 sr->setEnabled(true);
737 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
739 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
741 SUIT_ViewModel* viewer = vm->getViewModel();
742 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
744 //VTK View Manager removed
745 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
747 //Process only if it's our view manager
748 SUIT_ViewManager* myVm = NULL;
749 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
750 myVm = currentDocGView->getViewWindow()->getViewManager();
754 //close opened dialog
755 if (currentDialog != NULL) currentDialog->close();
756 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
762 //remove its selector
763 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
764 while ( itVTKSel.hasNext() )
765 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
766 if ( sr->viewer() == viewer )
768 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
775 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
777 //OCC View removed: remove its selector
778 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
779 while ( itOCCSel.hasNext() )
780 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
781 if ( sr->viewer() == viewer )
783 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
789 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
791 QModelIndexList l = selected.indexes();
792 if ( l.count() == 0 ) return;
793 if ( !l[0].isValid() ) return;
794 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
795 if ( currentGraphicView == NULL) return;
797 QTreeView* theTree = NULL;
798 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
799 theTree = _patternDataTreeView;
801 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
802 theTree = _patternBuilderTreeView;
804 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
805 theTree = _patternGeomTreeView;
807 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
808 theTree = _groupsTreeView;
809 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
810 theTree = _meshTreeView;
813 theTree->scrollTo ( l[0] );
817 bool HEXABLOCKGUI::createSComponent() //addComponent
819 DEBTRACE("HEXABLOCKGUI::createSComponent");
820 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
822 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
823 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
824 _PTR(GenericAttribute) anAttr;
825 _PTR(AttributeName) aName;
826 _PTR(AttributeGraphic) aGraphic;
828 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
829 if ( !aComponent ){ //Create hexablock component if there's not one yet
830 aComponent = aBuilder->NewComponent("HEXABLOCK");
831 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
832 aName = _PTR(AttributeName) (anAttr);
833 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
835 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
836 _PTR(AttributePixMap) aPixmap(anAttr);
837 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
839 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
840 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
846 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
848 DEBTRACE("HEXABLOCKGUI::setResource");
849 _myresource = new HEXABLOCKGUI_Resource(r);
850 _myresource->preferencesChanged();
853 void HEXABLOCKGUI::createPreferences()
855 DEBTRACE("HEXABLOCKGUI::createPreferences");
856 _myresource->createPreferences(this);
859 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
861 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
862 _myresource->preferencesChanged(sect, name);
863 // if(name=="userCatalog")
864 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
867 void HEXABLOCKGUI::studyActivated() //CS_TODO
869 int newStudyId = getApp()->activeStudy()->id();
870 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
871 // if (_oldStudyId != -1)
873 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
874 // if (_studyContextMap.count(newStudyId))
876 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
877 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
881 // DEBTRACE("no switch to null context");
884 _oldStudyId = newStudyId;
887 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
889 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
890 QVariant currentAssocVariant;
891 QString currentAssocEntry;
893 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
894 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
895 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
896 QMenu menu( _patternDataTreeView );
898 QAction *clearAct = menu.addAction( "Remove association(s)" );
899 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
900 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
904 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
905 if (currentVtkGraphicView == NULL) return;
906 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
908 //We don't do anything for single items
909 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
910 item->type() == QUADITEM || item->type() == HEXAITEM)
913 //No associations for HEXA
914 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
915 if ( !treeVariant.isValid() ) return;
916 int eltType = treeVariant.toInt();
917 if (eltType == HEXA_DIR_TREE) return;
918 QMenu menu( _patternDataTreeView );
920 //Show association(s)
921 QAction *showAssocAct = menu.addAction( "Show associations" );
922 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
924 //Clear all associations
925 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
926 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
928 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
933 void HEXABLOCKGUI::createAndFillDockWidget()
935 QMainWindow *aParent = application()->desktop();
937 // Create dock widget (3 dock)
939 //1) *********** user input panel ( contain user's edit dialog box )
940 _dwInputPanel = new QDockWidget(aParent);
941 _dwInputPanel->setVisible(false);
942 _dwInputPanel->setWindowTitle("Input Panel");
943 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
945 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
947 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
949 _dwPattern = new QDockWidget(aParent);
950 _dwPattern->setVisible(false);
951 _dwPattern->setWindowTitle("Model");
952 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
954 QFrame* patternFrame = new QFrame(_dwPattern);
955 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
956 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
957 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
958 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
959 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
960 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
961 _patternGeomTreeView = new QTreeView(patternFrame);
962 splitter->addWidget(_patternDataTreeView);
963 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
964 splitter->addWidget(_patternGeomTreeView);
965 patternLayout->addWidget(splitter);
967 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
968 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
969 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
972 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
973 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
975 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
976 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
978 _dwPattern->setWidget(patternFrame);
979 patternFrame->show();
982 _dwGroups = new QDockWidget(aParent);
984 _dwGroups->setVisible(false);
985 _dwGroups->setWindowTitle("Groups");
986 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
987 _groupsTreeView = new QTreeView(_dwGroups);
988 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
989 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
990 _dwGroups->setWidget(_groupsTreeView);
991 _groupsTreeView->show();
994 _dwMesh = new QDockWidget(aParent);
995 _dwMesh->setVisible(false);
996 _dwMesh->setWindowTitle("Mesh");
997 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
998 _meshTreeView = new QTreeView(_dwMesh);
999 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1000 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1001 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1002 _dwMesh->setWidget(_meshTreeView);
1003 _meshTreeView->show();
1005 QDockWidget *_dwObjectBrowser = 0;
1006 QWidget* wid = getApp()->objectBrowser()->treeView();
1007 QWidget *w = wid->parentWidget();
1008 while ( w && !_dwObjectBrowser ) {
1009 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1010 w = w->parentWidget();
1012 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1013 _dwObjectBrowser->setWindowTitle("Study");
1015 // dock widget position
1016 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1017 // aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1018 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1020 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1021 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1022 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1025 #if QT_VERSION >= 0x040500
1026 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1030 // popup menu on data tree view
1031 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1032 connect(_patternDataTreeView,
1033 SIGNAL(customContextMenuRequested(const QPoint &)),
1035 SLOT(treeContextMenu(const QPoint &)),
1036 Qt::UniqueConnection );
1039 void HEXABLOCKGUI::createActions()
1041 QMainWindow *aParent = application()->desktop();
1042 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1045 _newAct = createAction(_menuId++,
1046 tr("Create a new document"),
1047 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1049 tr("Create a new document"),
1050 0, aParent, false, this, SLOT(newDocument()));
1051 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1053 _importAct = createAction(_menuId++,
1054 tr("Load a document"),
1055 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1056 tr("Load Document"),
1057 tr("Load a document"),
1058 0, aParent, false, this, SLOT(loadDocument()));
1059 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1061 _saveAct = createAction(_menuId++,
1062 tr("Save the document"),
1063 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1064 tr("Save Document"),
1065 tr("Save the document"),
1066 0, aParent, false, this, SLOT(saveDocument()));
1068 // Pattern Data creation
1069 _addVertex = createAction(_menuId++,
1070 tr("Create a vertex"),
1071 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1073 tr("Create a new vertex"),
1074 0, aParent, false, this, SLOT(addVertex()));
1076 _addEdge = createAction(_menuId++,
1077 tr("Create an edge"),
1078 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1080 tr("Create a new edge"),
1081 0, aParent, false, this, SLOT(addEdge()));
1083 _addQuad = createAction(_menuId++,
1084 tr("Create a quadrangle"),
1085 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1086 tr("Add Quadrangle"),
1087 tr("Create a new quadrangle"),
1088 0, aParent, false, this, SLOT(addQuad()));
1090 _addHexa = createAction(_menuId++,
1091 tr("Create an hexahedron"),
1092 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1093 tr("Add Hexahedron"),
1094 tr("Create a new hexahedron"),
1095 0, aParent, false, this, SLOT(addHexa()));
1097 // Builder Data creation
1098 _addVector = createAction(_menuId++,
1099 tr("Create a vector"),
1100 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1102 tr("Create a new vector"),
1103 0, aParent, false, this, SLOT(addVector()));
1105 // _addCylinder = createAction(_menuId++,
1106 // tr("Create a cylinder"),
1107 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1108 // tr("Add Cylinder"),
1109 // tr("Create a new cylinder"),
1110 // 0, aParent, false, this, SLOT(addCylinder()));
1112 // _addPipe = createAction(_menuId++,
1113 // tr("Create a pipe"),
1114 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1116 // tr("Create a new pipe"),
1117 // 0, aParent, false, this, SLOT(addPipe()));
1119 _makeGrid = createAction(_menuId++,
1121 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1124 0, aParent, false, this, SLOT(makeGrid()));
1126 _makeCylinder = createAction(_menuId++,
1127 tr("Make a cylinder"),
1128 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1129 tr("Make Cylinder"),
1130 tr("Make a cylinder"),
1131 0, aParent, false, this, SLOT(makeCylinder()));
1133 _makePipe = createAction(_menuId++,
1135 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1138 0, aParent, false, this, SLOT(makePipe()));
1140 _makeCylinders = createAction(_menuId++,
1141 tr("Make cylinders"),
1142 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1143 tr("Make Cylinders"),
1144 tr("Make cylinders"),
1145 0, aParent, false, this, SLOT(makeCylinders()));
1147 _makePipes = createAction(_menuId++,
1149 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1152 0, aParent, false, this, SLOT(makePipes()));
1154 _makeHemiSphere = createAction(_menuId++,
1155 tr("Make an hemisphere"),
1156 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1157 tr("Make Hemisphere"),
1158 tr("Make an hemisphere"),
1159 0, aParent, false, this, SLOT(makeHemiSphere()));
1161 // Pattern Data edition
1162 _removeHexa = createAction(_menuId++,
1163 tr("Remove hexahedra"),
1164 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1165 tr("Remove Hexahedra"),
1166 tr("Remove hexahedra"),
1167 0, aParent, false, this, SLOT(removeHexa()));
1169 _prismQuad = createAction(_menuId++,
1170 tr("Prism quadrangles"),
1171 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1172 tr("Prism Quadrangles"),
1173 tr("Prism quadrangles"),
1174 0, aParent, false, this, SLOT(prismQuad()));
1176 _joinQuad = createAction(_menuId++,
1177 tr("Join quadrangles"),
1178 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1179 tr("Join Quadrangles"),
1180 tr("Join quadrangles with hexahedra"),
1181 0, aParent, false, this, SLOT(joinQuad()));
1183 _merge = createAction(_menuId++,
1185 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1188 0, aParent, false, this, SLOT(merge()));
1190 _disconnect = createAction(_menuId++,
1192 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1194 tr("Disconnect edges, vertexes or quadrangles"),
1195 0, aParent, false, this, SLOT(disconnectElts()));
1197 _cutEdge = createAction(_menuId++,
1199 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1202 0, aParent, false, this, SLOT(cutEdge()));
1204 _makeTransformation = createAction(_menuId++,
1205 tr("Make transformation"),
1206 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1207 tr("Make Transformation"),
1208 tr("Make transformation"),
1209 0, aParent, false, this, SLOT(makeTransformation()));
1211 _makeSymmetry = createAction(_menuId++,
1212 tr("Make symmetry"),
1213 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1214 tr("Make Symmetry"),
1215 tr("Make symmetry"),
1216 0, aParent, false, this, SLOT(makeSymmetry()));
1218 _performTransformation = createAction(_menuId++,
1219 tr("Perform transformation"),
1220 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1221 tr("Perform Transformation"),
1222 tr("Perform transformation"),
1223 0, aParent, false, this, SLOT(performTransformation()));
1225 _performSymmetry = createAction(_menuId++,
1226 tr("Perform symmetry"),
1227 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1228 tr("Perform Symmetry"),
1229 tr("Perform symmetry"),
1230 0, aParent, false, this, SLOT(performSymmetry()));
1232 _replaceHexa = createAction(_menuId++,
1233 tr("Replace hexahedron"),
1234 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1235 tr("Replace Hexahedron"),
1236 tr("Replace hexahedron"),
1237 0, aParent, false, this, SLOT(replaceHexa()));
1239 _quadRevolution = createAction(_menuId++,
1240 tr("Quad revolution"),
1241 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1242 tr("Quad Revolution"),
1243 tr("Quad revolution"),
1244 0, aParent, false, this, SLOT(quadRevolution()));
1247 _assocVertex = createAction(_menuId++,
1248 tr("Make vertex association"),
1249 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1250 tr("Make Vertex association"),
1251 tr("Make vertex association"),
1252 0, aParent, false, this, SLOT(assocVertex()));
1254 _assocEdge = createAction(_menuId++,
1255 tr("Make edge association"),
1256 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1257 tr("Make Edge Association"),
1258 tr("Make edge association"),
1259 0, aParent, false, this, SLOT(assocEdge()));
1261 _assocQuad = createAction(_menuId++,
1262 tr("Make quad association"),
1263 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1264 tr("Make Quad Association"),
1265 tr("Make quad association"),
1266 0, aParent, false, this, SLOT(assocQuad()));
1269 _addGroup = createAction(_menuId++,
1271 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1274 0, aParent, false, this, SLOT(addGroup()));
1276 _removeGroup = createAction(_menuId++,
1277 tr("Remove a group"),
1278 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1280 tr("Remove a group"),
1281 0, aParent, false, this, SLOT(removeGroup()));
1284 _addLaw = createAction(_menuId++,
1286 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1289 0, aParent, false, this, SLOT(addLaw()));
1291 _removeLaw = createAction(_menuId++,
1293 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1296 0, aParent, false, this, SLOT(removeLaw()));
1298 _setPropagation = createAction(_menuId++,
1299 tr("Set propagation"),
1300 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1301 tr("Set Propagation"),
1302 tr("Set propagation"),
1303 0, aParent, false, this, SLOT(setPropagation()));
1305 _computeMesh = createAction(_menuId++,
1307 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1310 0, aParent, false, this, SLOT(computeMesh()));
1312 _showModelInfoAct = createAction(_menuId++,
1313 tr("Show Model Info"),
1314 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1317 0, aParent, false, this, SLOT(showModelInfo()));
1319 _addShapeAct = createAction(_menuId++,
1321 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1324 0, aParent, false, this, SLOT(addShape()));
1326 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1327 // QAction* createAction(const int id,
1328 // const QString& toolTip,
1329 // const QIcon& icon,
1330 // const QString& menu,
1331 // const QString& status,
1332 // const int shortCut,
1333 // QObject* parent =0,
1334 // bool checkable = false,
1335 // QObject* receiver =0,
1336 // const char* member =0);
1338 _sep1 = separator();
1339 _sep2 = separator();
1340 _sep3 = separator();
1341 _sep4 = separator();
1345 void HEXABLOCKGUI::createMenus()
1347 int aMenuId, subMenuId,aMenuIdMain;
1349 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1351 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1352 createMenu( actionId(_newAct), aMenuId );
1353 createMenu( actionId(_importAct), aMenuId );
1354 createMenu( _saveAct, aMenuId );
1357 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1358 createMenu( _newAct, aMenuDocId );//, 10
1359 createMenu( _importAct, aMenuDocId );
1360 createMenu( _saveAct, aMenuDocId );
1362 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1363 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1364 createMenu( _addVertex, subMenuId );
1365 createMenu( _addEdge, subMenuId );
1366 createMenu( _addQuad, subMenuId );
1367 createMenu( _addHexa, subMenuId );
1368 createMenu( _sep1, subMenuId);
1371 createMenu( _addVector, subMenuId );
1372 // createMenu( _addCylinder, subMenuId );
1373 // createMenu( _addPipe, subMenuId );
1375 createMenu( _sep2, subMenuId);
1377 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1378 createMenu( _makeHemiSphere,subMenuId );
1380 createMenu( _sep3, subMenuId);
1382 createMenu( _makeCylinder, subMenuId );
1383 createMenu( _makePipe, subMenuId );
1384 createMenu( _makeCylinders,subMenuId );
1385 createMenu( _makePipes, subMenuId );
1387 // Pattern Data Edition
1388 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1389 createMenu( _removeHexa, subMenuId );
1390 createMenu( _prismQuad, subMenuId );
1391 createMenu( _joinQuad, subMenuId );
1392 createMenu( _merge, subMenuId );
1393 createMenu( _disconnect, subMenuId );
1394 createMenu( _cutEdge, subMenuId );
1395 createMenu( _makeTransformation, subMenuId );
1396 createMenu( _makeSymmetry, subMenuId );
1397 createMenu( _performTransformation, subMenuId );
1398 createMenu( _performSymmetry, subMenuId );
1399 createMenu( _replaceHexa, subMenuId );
1400 createMenu( _quadRevolution, subMenuId );
1401 createMenu( _sep4, aMenuId );
1402 createMenu( _showModelInfoAct, aMenuId );
1405 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1406 createMenu( _addShapeAct, aMenuId );
1407 createMenu( _assocVertex, aMenuId );
1408 createMenu( _assocEdge, aMenuId );
1409 createMenu( _assocQuad, aMenuId );
1412 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1413 createMenu( _addGroup, aMenuId );
1414 createMenu( _removeGroup, aMenuId ); //CS_TODO
1417 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1418 createMenu( _addLaw, aMenuId );
1419 createMenu( _removeLaw, aMenuId );
1420 createMenu( _setPropagation, aMenuId );
1421 createMenu( _computeMesh, aMenuId );
1423 //show model infomation menu
1424 QString aRule = "$component={'HEXABLOCK'}";
1425 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1426 popupMgr()->setRule( _showModelInfoAct, aRule);
1428 //associate shape to a document menu
1429 popupMgr()->insert( _addShapeAct, -1, -1 );
1430 popupMgr()->setRule( _addShapeAct, aRule );
1432 //-------------------------------------------------
1434 //-------------------------------------------------
1435 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1436 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1437 // QString isNotEmpty("numberOfNodes <> 0");
1438 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1439 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1440 //// aType = aType.arg( mesh_part );
1442 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1443 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1444 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1446 // popupMgr()->insert( separator(), -1, -1 );
1447 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1448 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1449 // // MESSAGE("aClient = " << aClient.toStdString());
1450 // // MESSAGE("aType = " << aType.toStdString());
1451 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1452 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1453 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1454 // // MESSAGE("aRule = " << aRule.toStdString());
1455 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1456 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1458 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1459 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1461 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1462 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1464 // popupMgr()->insert( separator(), -1, -1 );
1468 void HEXABLOCKGUI::createTools()
1472 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1473 createTool( _newAct, aToolId );
1474 createTool( _importAct, aToolId );
1475 createTool( _saveAct, aToolId );
1476 createTool( _showModelInfoAct, aToolId );
1477 // createTool( _testAct, aToolId );
1478 //createTool( separator(), aToolId );
1481 aToolId = createTool ( tr( "Construction" ) );
1482 createTool( _addVertex, aToolId );
1483 createTool( _addEdge, aToolId );
1484 createTool( _addQuad, aToolId );
1485 createTool( _addHexa, aToolId );
1487 createTool( _sep1, aToolId );
1490 createTool( _addVector, aToolId );
1491 // createTool( _addCylinder, aToolId );
1492 // createTool( _addPipe, aToolId );
1494 createTool( _sep2, aToolId );
1496 createTool( _makeGrid, aToolId );
1497 createTool( _makeHemiSphere, aToolId );
1499 createTool( _sep3, aToolId );
1501 createTool( _makeCylinder, aToolId );
1502 createTool( _makePipe, aToolId );
1503 createTool( _makeCylinders,aToolId );
1504 createTool( _makePipes, aToolId );
1506 // Pattern Data Edition
1507 aToolId = createTool ( tr( "Operation" ) );
1508 createTool( _removeHexa, aToolId );
1509 createTool( _prismQuad, aToolId );
1510 createTool( _joinQuad, aToolId );
1511 createTool( _merge, aToolId );
1512 createTool( _disconnect, aToolId );
1513 createTool( _cutEdge, aToolId );
1514 createTool( _makeTransformation, aToolId );
1515 createTool( _makeSymmetry, aToolId );
1516 createTool( _performTransformation, aToolId );
1517 createTool( _performSymmetry, aToolId );
1518 createTool( _replaceHexa, aToolId );
1519 createTool( _quadRevolution, aToolId );
1522 aToolId = createTool ( tr( "Association" ) );
1523 createTool( _assocVertex, aToolId );
1524 createTool( _assocEdge, aToolId );
1525 createTool( _assocQuad, aToolId );
1526 createTool( _addShapeAct, aToolId );
1529 aToolId = createTool ( tr( "Group" ) );
1530 createTool( _addGroup, aToolId );
1531 createTool( _removeGroup, aToolId ); //CS_TODO
1534 aToolId = createTool ( tr( "Mesh" ) );
1535 createTool( _addLaw, aToolId );
1536 createTool( _removeLaw, aToolId );
1537 createTool( _setPropagation, aToolId );
1538 createTool( _computeMesh, aToolId );
1542 void HEXABLOCKGUI::initialMenus()
1544 showDocumentMenus( true );
1545 showPatternMenus( false );
1546 showAssociationMenus( false );
1547 showGroupsMenus( false );
1548 showMeshMenus( false );
1551 void HEXABLOCKGUI::showAllMenus()
1553 showDocumentMenus( true );
1554 showPatternMenus( true );
1555 showAssociationMenus( true );
1556 showGroupsMenus( true );
1557 showMeshMenus( true );
1561 void HEXABLOCKGUI::showDocumentMenus(bool show)
1563 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1565 setMenuShown(_newAct, show);
1566 setToolShown(_newAct, show);
1567 setMenuShown(_importAct, show);
1568 setToolShown(_importAct, show);
1569 setMenuShown(_showModelInfoAct, show);
1570 setToolShown(_showModelInfoAct, show);
1571 setMenuShown(_saveAct, show);
1572 setToolShown(_saveAct, show);
1575 void HEXABLOCKGUI::showPatternMenus(bool show)
1577 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1578 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1579 if ( show && !getCurrentModel() ) return;
1581 setMenuShown(_addVertex, show );
1582 setToolShown(_addVertex, show);
1583 setMenuShown(_addEdge, show );
1584 setToolShown(_addEdge, show);
1585 setMenuShown(_addQuad, show );
1586 setToolShown(_addQuad, show);
1587 setMenuShown(_addHexa, show );
1588 setToolShown(_addHexa, show);
1590 setMenuShown(_sep1, show );
1591 setToolShown(_sep1, show);
1593 setMenuShown( _addVector, show );
1594 setToolShown( _addVector, show);
1595 // setMenuShown( _addCylinder, show );
1596 // setToolShown( _addCylinder, show);
1597 // setMenuShown( _addPipe, show );
1598 // setToolShown( _addPipe, show);
1600 setMenuShown(_sep2, show );
1601 setToolShown(_sep2, show);
1603 setMenuShown( _makeGrid, show );
1604 setToolShown( _makeGrid, show);
1605 setMenuShown( _makePipe, show );
1606 setToolShown( _makePipe, show);
1608 setMenuShown(_sep3, show );
1609 setToolShown(_sep3, show);
1611 setMenuShown( _makeCylinder, show );
1612 setToolShown( _makeCylinder, show);
1613 setMenuShown( _makeCylinders, show );
1614 setToolShown( _makeCylinders, show);
1615 setMenuShown( _makePipes, show );
1616 setToolShown( _makePipes, show);
1617 setMenuShown( _makeHemiSphere, show );
1618 setToolShown( _makeHemiSphere, show);
1620 // Pattern Data Edition
1621 setMenuShown( _removeHexa, show );
1622 setToolShown( _removeHexa, show);
1623 setMenuShown( _prismQuad, show );
1624 setToolShown( _prismQuad, show);
1625 setMenuShown( _joinQuad, show );
1626 setToolShown( _joinQuad, show);
1627 setMenuShown( _merge, show );
1628 setToolShown( _merge, show);
1629 setMenuShown( _disconnect, show );
1630 setToolShown( _disconnect, show);
1631 setMenuShown( _cutEdge, show );
1632 setToolShown( _cutEdge, show);
1633 setMenuShown( _makeTransformation, show );
1634 setToolShown( _makeTransformation, show);
1635 setMenuShown( _makeSymmetry, show );
1636 setToolShown( _makeSymmetry, show);
1637 setMenuShown( _performTransformation, show );
1638 setToolShown( _performTransformation, show);
1639 setMenuShown( _performSymmetry, show );
1640 setToolShown( _performSymmetry, show);
1641 setMenuShown( _replaceHexa, show );
1642 setToolShown( _replaceHexa, show);
1643 setMenuShown( _quadRevolution, show );
1644 setToolShown( _quadRevolution, show);
1646 setMenuShown( _sep4, show );
1647 setMenuShown( _showModelInfoAct, show );
1651 void HEXABLOCKGUI::showAssociationMenus(bool show)
1653 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1654 if ( show && !getCurrentModel() ) return;
1656 // Association Edition
1657 setMenuShown( _assocVertex, show );
1658 setToolShown( _assocVertex, show );
1659 setMenuShown( _assocEdge, show );
1660 setToolShown( _assocEdge, show );
1661 setMenuShown( _assocQuad, show );
1662 setToolShown( _assocQuad, show );
1663 setMenuShown( _addShapeAct, show );
1664 setToolShown( _addShapeAct, show );
1668 void HEXABLOCKGUI::showGroupsMenus(bool show)
1670 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1671 if ( show && !getCurrentModel() ) return;
1672 setMenuShown( _addGroup, show );
1673 setToolShown( _addGroup, show);
1674 setMenuShown( _removeGroup , show );
1675 setToolShown( _removeGroup , show);
1678 void HEXABLOCKGUI::showMeshMenus(bool show)
1680 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1681 if ( show && !getCurrentModel() ) return;
1682 setMenuShown( _addLaw, show );
1683 setToolShown( _addLaw, show);
1684 setMenuShown( _removeLaw, show );
1685 setToolShown( _removeLaw, show);;
1686 setMenuShown( _setPropagation, show );
1687 setToolShown( _setPropagation, show);
1688 setMenuShown( _computeMesh, show);
1689 setToolShown( _computeMesh, show);
1692 void HEXABLOCKGUI::showActor()
1694 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1695 if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
1696 currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
1699 currentVtkGView->getViewWindow()->setFocus();
1700 currentVtkGView->getViewWindow()->Display(currentVtkGView->getDocumentActor()->getIO());
1701 currentVtkGView->update();
1702 currentVtkGView->getViewWindow()->onFitAll();
1704 //update the visibility state now
1705 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1706 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1707 if (aStudy == NULL || vman == NULL) return;
1709 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1710 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1711 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1714 //SOCC_Prs* currentPrs = NULL;
1715 void HEXABLOCKGUI::showOnlyActor()
1717 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1718 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1719 currentVtkGView->getDocumentActor() == NULL)
1721 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1722 if (vtkView == NULL)
1725 SUIT_ViewManager* vman = vtkView->getViewManager();
1726 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1728 //show only the current actor -----------------
1729 vtkView->setFocus();
1730 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1731 Document_Actor *lastDocActor, *currentDocActor = currentVtkGView->getDocumentActor();
1732 if (lastVtkDocGView != NULL)
1734 lastDocActor = lastVtkDocGView->getDocumentActor();
1735 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1736 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1738 vtkView->Erase(lastActorIO);
1739 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1740 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1743 currentVtkGView->update();
1744 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1745 if (!anIO.IsNull() && anIO->hasEntry())
1747 vtkView->Display(anIO);
1748 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1749 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1751 vtkView->onFitAll();
1753 // //showOnly in occ viewer -------------
1755 if (currentOccGView == NULL)
1757 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1758 if (occView == NULL)
1760 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1765 if (lastOccPrs != NULL)
1766 vf->Erase(lastOccPrs);
1767 currentOccGView->globalSelection();
1768 SOCC_Prs* prs = getOccPrs(currentDocGView);
1769 currentOccGView->setPrs(prs);
1772 occView->onFitAll();
1775 void HEXABLOCKGUI::hideActor()
1778 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1779 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1780 currentVtkGView->getViewWindow() == NULL ||
1781 currentVtkGView->getDocumentActor() == NULL) return;
1783 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1784 currentVtkGView->getViewWindow()->onResetView();
1786 //update the visibility state now
1787 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1788 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1789 if (aStudy == NULL || vman == NULL) return;
1791 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1792 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1793 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1796 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1797 DocumentModel* docModel = currentVtkGView->getDocumentModel();
1798 if (occView == NULL || docModel == NULL)
1800 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1805 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1806 if (currentOccPrs != NULL)
1807 vf->Erase(currentOccPrs);
1809 occView->onResetView();
1813 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1815 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1817 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1818 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1820 if (_dwPattern) _dwPattern->setVisible(isVisible);
1821 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1823 if (_dwMesh) _dwMesh->setVisible(isVisible);
1824 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1826 if (_dwGroups) _dwGroups->setVisible(isVisible);
1827 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1831 //clear all used dialogs by the current model
1832 void HEXABLOCKGUI::clearDialogs()
1834 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1835 fin (currentModelDialogs.end());
1836 for(;debut!=fin;++debut) (*debut)->clear();
1838 currentModelDialogs.clear(); //empty the used dialogs list
1841 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1843 if (!gViewDlgBox.contains(dgview)) return NULL;
1844 return gViewDlgBox[dgview];
1847 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1849 if (dgview == NULL) return;
1851 switchOffGraphicView(dgview, false); //to avoid double connect
1854 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1855 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1856 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1857 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1858 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1859 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1860 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1861 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1862 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1863 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1864 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1865 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1870 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1872 if (dgview == NULL) return;
1874 //disconnect signals
1875 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1876 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1877 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1878 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1879 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1880 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1881 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1882 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1883 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1884 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1885 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1886 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1889 gViewDlgBox[dgview] = currentDialog;
1891 //close opened dialog
1892 if (currentDialog != NULL) currentDialog->close();
1893 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1899 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1901 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1905 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1909 //switch off the current document graphic view (disconnect signals...)
1910 if (currentDocGView != NULL)
1912 //Hide current actor
1914 switchOffGraphicView(currentDocGView);
1917 //clear the dialogs used by the current model so they can be used by the new model
1918 if (currentDocGView != dgview) clearDialogs();
1920 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1921 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1922 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1923 _groupsTreeView->setModel(dgview->getGroupsModel());
1924 _meshTreeView->setModel(dgview->getMeshModel());
1926 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1927 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1929 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1930 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1932 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1933 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1935 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1936 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1938 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1939 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1942 // = * init occ view * =
1943 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1945 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1946 currentOccGView->getViewWindow()->installEventFilter(this);
1951 // = * init vtk view * =
1952 if (currentDocGView != NULL)
1954 if (currentDocGView->getViewWindow() != NULL)
1955 dgview->setViewWindow(currentDocGView->getViewWindow());
1958 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1959 dgview->getViewWindow()->installEventFilter(this);
1965 switchOnGraphicView(dgview);
1967 if (currentDocGView != NULL)
1969 lastVtkDocGView = currentDocGView;
1970 lastOccPrs = getOccPrs(currentDocGView);
1974 lastVtkDocGView = dgview;
1975 lastOccPrs = getOccPrs(dgview);
1978 currentDocGView = dgview;
1980 currentDocGView->getDocumentModel()->refresh();
1981 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1985 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1987 if (currentDocGView == NULL) return NULL;
1988 return currentDocGView->getDocumentModel();
1992 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1994 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1995 if (anApp == NULL) return UNKNOWN;
1996 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1997 if (activeVm == NULL) return UNKNOWN;
1999 QString vmType = activeVm->getType();
2000 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2002 else if ( vmType == OCCViewer_Viewer::Type() )
2008 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2010 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2014 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2017 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2019 // Create Document from HEXABLOCK ENGINE
2020 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2021 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2023 // looking doc impl ( c++ )
2024 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2025 // ^Hexa6 ASSERT( dServant );
2026 // ^Hexa6 if ( dServant)
2027 // ^Hexa6 doc = dServant->GetImpl();
2029 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2030 QString docEntry = addDocInStudy (doc);
2032 // looking for docEntry
2033 /* ****************************************************************
2034 if ( !CORBA::is_nil(docIn) ){
2035 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2036 QString docIOR = anIOR.in();
2037 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2038 if ( !docIOR.isEmpty() ) {
2039 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2041 docEntry = SO->GetID().c_str();
2044 **************************************************************** */
2045 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2047 return make_pair (docEntry, doc);
2051 void HEXABLOCKGUI::newDocument()
2053 DEBTRACE("HEXABLOCKGUI::newDocument");
2056 QMainWindow *aParent = application()->desktop();
2057 QWidget *central = aParent->centralWidget();
2059 central->setFocus();
2061 DEBTRACE("No Central Widget");
2064 if (currentOccGView == NULL)
2066 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2067 application()->desktop());
2068 currentOccGView->getViewWindow()->installEventFilter(this);
2070 else if (currentOccGView->getViewWindow() == NULL)
2072 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2073 currentOccGView->getViewWindow()->installEventFilter(this);
2077 // Create Document from HEXABLOCK ENGINE
2078 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2080 VtkDocumentGraphicView* newGraphicView = NULL;
2081 //One document at a time
2082 if (currentDocGView != NULL)
2084 if (currentDocGView->getViewWindow() == NULL)
2086 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2087 currentDocGView->getViewWindow()->installEventFilter(this);
2090 // Create a new document with the current window
2091 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2092 new DocumentModel( docEntry_Doc.second,
2093 docEntry_Doc.first, this ),
2094 currentDocGView->getViewWindow(),
2095 application()->desktop() );
2099 // Create the new Document Graphic View with a new window
2100 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2101 new DocumentModel( docEntry_Doc.second,
2102 docEntry_Doc.first, this ),
2103 graphicViewsHandler->createVtkWindow(),
2104 application()->desktop() );
2105 newGraphicView->getViewWindow()->installEventFilter(this);
2108 if (newGraphicView == NULL)
2109 //We couldn't create a new document graphic view
2110 //we'd better show a dialog box info to inform the user
2113 docs[docEntry_Doc.first] = newGraphicView;
2114 switchModel(newGraphicView); //select the corresponding document in the browser instead
2116 getApp()->updateObjectBrowser();
2121 //Loads the model from the xmlFile in the current graphic view
2122 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2124 DEBTRACE("HEXABLOCKGUI::loadDocument");
2127 QMainWindow *aParent = application()->desktop();
2128 QString selectedFile;
2130 if ( inFile.isNull() ){
2131 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2132 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2133 dialog.setHistory( getQuickDirList() );
2135 //use the last path as default
2136 if (!(loadDocLastPath->absolutePath()).isEmpty())
2137 dialog.setDirectory(*loadDocLastPath);
2140 QStringList selectedFiles = dialog.selectedFiles();
2141 if (!selectedFiles.isEmpty())
2142 selectedFile = selectedFiles.first();
2144 //remember the selected path
2145 *loadDocLastPath = dialog.directory();
2148 selectedFile = inFile;
2150 if (selectedFile.isEmpty())
2153 //we create a new document if necessary
2154 if (currentDocGView == NULL)
2155 //Need a new document
2157 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2159 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2160 currentDocGView->getViewWindow()->installEventFilter(this);
2163 if (!currentDocGView->isEmpty())
2164 //we can only have one document for a graphic view
2167 //we load the selected file in the current graphic view
2168 currentDocGView->loadDocument(selectedFile);
2169 DocumentModel* currentModel = getCurrentModel();
2170 renameObject( currentModel->documentEntry(), currentModel->getName() );
2175 void HEXABLOCKGUI::saveDocument()
2177 QMainWindow *aParent = application()->desktop();
2179 QString aDocName = "document", aFilename;
2181 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2182 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2184 //use the last selected directory as default path for file selection
2185 aFilename = saveDocLastPath->absolutePath();
2186 if (!aFilename.isEmpty())
2187 aFilename += QString("/") + aDocName;
2189 //show the dialog for file selection
2190 aFilename = SUIT_FileDlg::getFileName( aParent,
2193 tr( "Save HexaBlock Document" ),
2196 //save the document in the selected file
2197 if ( !aFilename.isEmpty() ) {
2198 getCurrentVtkGraphicView()->saveDocument( aFilename );
2200 //Remember the path for next save
2201 QFileInfo fileInfo(aFilename);
2202 *saveDocLastPath = fileInfo.dir();
2208 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2210 _patternDataTreeView->openPersistentEditor( topLeft );
2213 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2215 if (diag == NULL || _dwInputPanel == NULL ||
2216 getCurrentVtkGraphicView() == NULL) return;
2218 //mark this dialog as used by the current model
2219 currentModelDialogs.insert(diag);
2221 //close the current dialog box info
2222 // if (_treeViewDelegate != NULL)
2223 // _treeViewDelegate->closeDialog();
2225 // if (_dwInputPanel->widget())
2226 // _dwInputPanel->widget()->close();
2228 //Temporary for debugging EdgeAssoc Faked InfoDialog
2229 if (diag == _edgeAssocDiag)
2230 diag->debugEdgeAssoc = true;
2232 diag->debugEdgeAssoc = false;
2234 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2235 diag == _quadAssocDiag || diag == _addShapeDiag)
2236 assocInProgress = true;
2238 assocInProgress = false;
2240 //show the dialog box in the dockwidget
2241 diag->resetSizeAndShow(_dwInputPanel);
2243 //clear the current selections
2244 selectionMgr()->clearSelected();
2246 currentDialog = diag;
2249 if (currentDocGView != NULL)
2250 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2253 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2255 if (vertex == NULL || _dwInputPanel == NULL)
2258 if (_vertexInfoDialog == NULL)
2259 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2261 _vertexInfoDialog->setValue(vertex);
2262 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2263 currentDialog = _vertexInfoDialog;
2266 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2268 if (edge == NULL || _dwInputPanel == NULL)
2271 if (_edgeInfoDialog == NULL)
2272 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2274 _edgeInfoDialog->setValue(edge);
2275 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2276 currentDialog = _edgeInfoDialog;
2279 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2281 if (quad == NULL || _dwInputPanel == NULL)
2284 if (_quadInfoDialog == NULL)
2285 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2287 _quadInfoDialog->setValue(quad);
2288 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2289 currentDialog = _quadInfoDialog;
2292 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2294 if (hexa == NULL || _dwInputPanel == NULL)
2297 if (_hexaInfoDialog == NULL)
2298 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2300 _hexaInfoDialog->setValue(hexa);
2301 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2302 currentDialog = _hexaInfoDialog;
2305 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2307 if (vector == NULL || _dwInputPanel == NULL)
2310 if (_vectorInfoDialog == NULL)
2311 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2313 _vectorInfoDialog->setValue(vector);
2314 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2315 currentDialog = _vectorInfoDialog;
2318 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2320 if (group == NULL || _dwInputPanel == NULL)
2323 if (_groupInfoDialog == NULL)
2324 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2326 _groupInfoDialog->setValue(group);
2327 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2328 currentDialog = _groupInfoDialog;
2331 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2333 if (law == NULL || _dwInputPanel == NULL)
2336 if (_lawInfoDialog == NULL)
2337 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2339 _lawInfoDialog->setValue(law);
2340 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2341 currentDialog = _lawInfoDialog;
2344 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2346 if (propagation == NULL || _dwInputPanel == NULL)
2349 if (_propagationInfoDialog == NULL)
2350 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2352 _propagationInfoDialog->setValue(propagation);
2353 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2354 currentDialog = _propagationInfoDialog;
2357 void HEXABLOCKGUI::addVertex()
2359 if ( !_vertexDiag ){
2360 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2362 _showDialogBox( _vertexDiag );
2365 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2366 if (_vertexDiag != NULL && doc != NULL)
2367 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2370 void HEXABLOCKGUI::addEdge()
2373 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2375 _showDialogBox( _edgeDiag );
2378 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2379 if (_edgeDiag != NULL && doc != NULL)
2380 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2383 void HEXABLOCKGUI::addQuad()
2386 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2389 _showDialogBox( _quadDiag );
2392 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2393 if (_quadDiag != NULL && doc != NULL)
2394 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2397 void HEXABLOCKGUI::addHexa()
2400 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2402 _showDialogBox( _hexaDiag );
2405 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2406 if (_hexaDiag != NULL && doc != NULL)
2407 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2410 void HEXABLOCKGUI::addVector()
2412 if ( !_vectorDiag ){
2413 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2415 _showDialogBox( _vectorDiag );
2418 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2419 if (_vectorDiag != NULL && doc != NULL)
2420 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2423 //void HEXABLOCKGUI::addCylinder()
2425 // if ( !_cylinderDiag ){
2426 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2428 // _showDialogBox( _cylinderDiag );
2430 // //set default name
2431 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2432 // if (_cylinderDiag != NULL && doc != NULL)
2433 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2437 //void HEXABLOCKGUI::addPipe()
2439 // if ( !_pipeDiag){
2440 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2442 // _showDialogBox( _pipeDiag );
2444 // //set default name
2445 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2446 // if (_pipeDiag != NULL && doc != NULL)
2447 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2451 void HEXABLOCKGUI::makeGrid()
2453 if ( !_makeGridDiag ){
2454 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2456 _showDialogBox( _makeGridDiag );
2460 void HEXABLOCKGUI::makeCylinder()
2462 if ( !_makeCylinderDiag ){
2463 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2465 _showDialogBox( _makeCylinderDiag );
2468 void HEXABLOCKGUI::makePipe()
2470 if ( !_makePipeDiag ){
2471 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2473 _showDialogBox( _makePipeDiag );
2476 void HEXABLOCKGUI::makeCylinders()
2478 if ( !_makeCylindersDiag ){
2479 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2481 _showDialogBox( _makeCylindersDiag );
2484 void HEXABLOCKGUI::makePipes()
2486 if ( !_makePipesDiag ){
2487 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2489 _showDialogBox( _makePipesDiag );
2493 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2495 if ( !_makeHemiSphereDiag ){
2496 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2498 _showDialogBox( _makeHemiSphereDiag );
2502 void HEXABLOCKGUI::removeHexa()
2504 if ( !_removeHexaDiag ){
2505 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2507 _showDialogBox( _removeHexaDiag );
2511 void HEXABLOCKGUI::prismQuad()
2513 if ( !_prismQuadDiag ){
2514 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2516 _showDialogBox( _prismQuadDiag );
2520 void HEXABLOCKGUI::joinQuad()
2522 if ( !_joinQuadDiag ){
2523 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2525 _showDialogBox( _joinQuadDiag );
2528 void HEXABLOCKGUI::merge()
2531 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2533 _showDialogBox( _mergeDiag );
2536 void HEXABLOCKGUI::disconnectElts()
2538 if ( !_disconnectDiag ){
2539 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2541 _showDialogBox( _disconnectDiag );
2544 void HEXABLOCKGUI::cutEdge()
2546 if ( !_cutEdgeDiag ){
2547 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2549 _showDialogBox( _cutEdgeDiag );
2552 void HEXABLOCKGUI::makeTransformation()
2554 if ( !_makeTransformationDiag ){
2555 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2557 _showDialogBox( _makeTransformationDiag );
2561 void HEXABLOCKGUI::makeSymmetry()
2563 if ( !_makeSymmetryDiag ){
2564 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2566 _showDialogBox( _makeSymmetryDiag );
2570 void HEXABLOCKGUI::performTransformation()
2572 if ( !_performTransformationDiag ){
2573 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2575 _showDialogBox( _performTransformationDiag );
2579 void HEXABLOCKGUI::performSymmetry()
2581 if ( !_performSymmetryDiag ){
2582 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2584 _showDialogBox( _performSymmetryDiag );
2588 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2590 if ( !_replaceHexaDiag ){
2591 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2593 _showDialogBox( _replaceHexaDiag );
2597 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2599 if ( !_quadRevolutionDiag ){
2600 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2602 _showDialogBox( _quadRevolutionDiag );
2606 void HEXABLOCKGUI::assocVertex()
2608 if (!_dwInputPanel) return;
2609 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2610 if ( !_vertexAssocDiag )
2611 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2612 _showDialogBox( _vertexAssocDiag );
2616 void HEXABLOCKGUI::assocEdge()
2618 if ( !_edgeAssocDiag )
2619 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2620 _showDialogBox( _edgeAssocDiag );
2623 void HEXABLOCKGUI::assocQuad()
2625 if ( !_quadAssocDiag )
2626 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2627 _showDialogBox( _quadAssocDiag );
2631 void HEXABLOCKGUI::addGroup()
2634 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2636 _showDialogBox( _groupDiag );
2637 if (_groupDiag != NULL && getCurrentModel() != NULL)
2639 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2640 if (doc == NULL) return;
2641 char defaultName[16];
2642 sprintf (defaultName, "g%04d", doc->countGroup());
2643 _groupDiag->name_le->setText(defaultName);
2647 void HEXABLOCKGUI::removeGroup()
2649 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2650 if (currentDGView == NULL) return;
2652 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2653 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2654 int nbGroupsRemoved = 0;
2657 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2658 tr( "No group selected!" ) );
2662 foreach( QModelIndex selected, l ){
2663 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2664 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2665 Q_ASSERT(selected.isValid());
2667 //Confirm the deletion of the group
2668 if (SUIT_MessageBox::question(
2671 tr("Remove group : %1 ?").arg(selected.data().toString()),
2672 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2673 SUIT_MessageBox::Cancel
2674 ) == SUIT_MessageBox::Cancel) return;
2676 bool removed = getCurrentModel()->removeGroup( selected );
2678 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2679 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2685 if (!nbGroupsRemoved)
2686 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2687 tr( "No group selected!" ) );
2690 void HEXABLOCKGUI::addLaw()
2693 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2695 _showDialogBox( _lawDiag );
2696 if (_lawDiag != NULL && getCurrentModel() != NULL)
2698 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2699 if (doc == NULL) return;
2700 char defaultName[16];
2701 sprintf (defaultName, "l%04d", doc->countLaw());
2702 _lawDiag->name_le->setText(defaultName);
2706 void HEXABLOCKGUI::removeLaw()
2708 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2709 if (currentDGView == NULL) return;
2711 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2712 int nbLawsRemoved = 0;
2715 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2716 tr( "No law selected!" ) );
2720 foreach( QModelIndex selected, l ){
2721 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2722 selected = currentDGView->getMeshModel()->mapToSource( selected );
2723 Q_ASSERT(selected.isValid());
2725 //Confirm the deletion of the law
2726 if (SUIT_MessageBox::question(
2729 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2730 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2731 SUIT_MessageBox::Cancel
2732 ) == SUIT_MessageBox::Cancel) return;
2734 bool removed = getCurrentModel()->removeLaw(selected);
2736 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2737 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2744 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2745 tr( "No law selected!" ) );
2750 void HEXABLOCKGUI::setPropagation()
2752 if ( !_propagationDiag )
2753 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2755 _showDialogBox( _propagationDiag );
2758 // Dialog box to compute a mesh from a document
2759 // --------------------------------------------
2760 void HEXABLOCKGUI::computeMesh()
2762 if ( !_computeMeshDiag )
2763 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2765 _showDialogBox( _computeMeshDiag );
2768 void HEXABLOCKGUI::clearAssociations()
2770 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2771 if (currentDGView == NULL) return;
2773 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2774 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2775 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2777 getCurrentModel()->clearEltAssociations(iModel);
2779 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2782 void HEXABLOCKGUI::showModelInfo()
2784 //create the info dialog if not yet
2785 if (_modelInfoDiag == NULL)
2786 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2788 //show the model informations dialog
2789 _showDialogBox( _modelInfoDiag );
2792 void HEXABLOCKGUI::addShape()
2794 //create the info dialog if not yet
2795 if (_addShapeDiag == NULL)
2796 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2798 //show the model informations dialog
2799 _showDialogBox( _addShapeDiag );
2802 void HEXABLOCKGUI::clearAllAssociations()
2804 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2805 if (currentDGView == NULL) return;
2807 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2808 if (!currentIndex.isValid()) return;
2809 QVariant currentAssocVariant;
2810 QString currentAssocEntry;
2812 //Confirm the deletion of the associations
2813 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2814 if ( !treeVariant.isValid() ) return;
2815 int eltType = treeVariant.toInt();
2816 QString typeStr = "";
2817 HEXA_NS::EnumElt hexaType;
2818 if (eltType == VERTEX_DIR_TREE)
2820 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2821 hexaType = HEXA_NS::EL_VERTEX;
2823 else if (eltType == EDGE_DIR_TREE)
2825 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2826 hexaType = HEXA_NS::EL_EDGE;
2828 else if (eltType == QUAD_DIR_TREE)
2830 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2831 hexaType = HEXA_NS::EL_QUAD;
2834 if (SUIT_MessageBox::question(
2836 tr("CLEAR_ASSOCIATIONS"),
2837 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2838 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2839 SUIT_MessageBox::Cancel
2840 ) == SUIT_MessageBox::Cancel) return;
2843 DocumentModel* docModel = getCurrentModel();
2844 if (docModel == NULL) return;
2845 docModel->clearAssociation(hexaType);
2848 void HEXABLOCKGUI::showAssociations()
2850 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2851 if (currentDGView == NULL) return;
2853 QModelIndexList elts;
2854 int currentChildIndex = 0;
2855 QVariant currentAssocVariant;
2856 QString currentAssocEntry;
2857 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2858 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2860 while( currentChild.isValid() ) {
2862 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2863 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2864 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2865 elts << currentChild;
2867 currentChild = currentChild.sibling(currentChildIndex++, 0);
2869 currentDocGView->highlight(elts);
2870 currentOccGView->highlight(elts, false);
2874 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2876 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2878 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2883 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2885 if ( event->type() == QEvent::Enter )
2886 { // *** ENTER EVENT
2888 if (currentDialog == NULL || !currentDialog->isVisible())
2889 return QObject::eventFilter(obj, event);
2891 // ** The window acquire the focus when the cursor enter
2893 //OCC - window enter
2894 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2895 if ( occWindow != NULL)
2896 currentDialog->onWindowActivated(occWindow->getViewManager());
2898 //VTK - window enter
2900 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2901 if ( vtkWindow != NULL)
2902 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2906 //standard event processing
2907 return QObject::eventFilter(obj, event);
2910 QStringList HEXABLOCKGUI::getQuickDirList()
2912 QStringList dirList;
2913 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2915 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2921 // --- Export the module
2925 HexaExport CAM_Module* createModule()
2927 return new HEXABLOCKGUI();
2930 HexaExport char* getModuleVersion()
2932 return (char*)HEXABLOCK_VERSION_STR;
2938 // ******************** TESTS ***************************************************
2940 void HEXABLOCKGUI::testDocument()
2944 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2945 // QStandardItem *myItem = new QStandardItem("MyItem");
2946 // parentItem->appendRow(myItem);
2948 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2949 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2950 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2951 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2952 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2953 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2954 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2955 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2958 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2959 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2960 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2961 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2962 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2963 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2965 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2966 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2967 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2968 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2973 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2974 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2975 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2976 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2984 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2985 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2987 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2988 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2992 // newMesh( "toto", 3, "FactoryServer");
2996 void HEXABLOCKGUI::test_make_cart_grid()
2998 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2999 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3000 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3001 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3002 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3003 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3005 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3006 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3013 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3014 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3015 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3016 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3017 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3018 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3023 void HEXABLOCKGUI::test_make_elmts_transform()
3030 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3031 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3034 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3035 // orig.setScalar(2);
3037 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3038 // getCurrentModel()->saveVtk(file_name)
3040 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3041 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3043 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3044 // getCurrentModel()->saveVtk(file_name)
3046 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3049 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3050 // getCurrentModel()->saveVtk(file_name);
3053 // print "...test make elements by transforming elements OK"
3055 // =============================================================== addDocInSudy
3056 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3060 if (document == NULL)
3063 QString docName = document->getName ();
3065 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3066 if (app_study == NULL)
3069 _PTR(Study) study = app_study->studyDS();
3070 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3071 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3072 QString entry = app_study->centry("HEXABLOCK");
3073 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3074 if (aFatherSO->_is_nil())
3077 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3080 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3081 docEntry = aSO->GetID(); //the entry of the published object
3086 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3088 void HEXABLOCKGUI::test()
3090 DEBTRACE("HEXABLOCKGUI::test");
3091 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3092 if (currentDGView == NULL) return;
3093 currentDGView->update();
3097 void HEXABLOCKGUI::test_association()
3099 DEBTRACE("HEXABLOCKGUI::test_association");
3102 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3104 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3105 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3106 DocumentModel::GeomObj q0AssocA, q0AssocB;
3108 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3109 QList<DocumentModel::GeomObj> e1Assocs_test;
3110 DocumentModel::GeomObj q0Assoc_test;
3112 v0 = getCurrentModel()->addVertex(0, 0, 0);
3113 v1 = getCurrentModel()->addVertex(1, 0, 0);
3114 v2 = getCurrentModel()->addVertex(1, 1, 0);
3115 v3 = getCurrentModel()->addVertex(0, 1, 0);
3116 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3117 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3118 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3121 // >>> face3.GetEntry()'0:1:4'
3122 // >>> e1.GetEntry()'0:1:8'
3123 // >>> e2.GetEntry()'0:1:9'
3124 // >>> e3.GetEntry()'0:1:10'
3125 // >>> e4.GetEntry()'0:1:11'
3126 // >>> v1.GetEntry()'0:1:12'
3127 // >>> v2.GetEntry()'0:1:13'
3128 // >>> v3.GetEntry()'0:1:14'
3129 // >>> v4.GetEntry()'0:1:15'
3132 // v0Assoc.name = "geomV0";
3133 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3134 // v0Assoc.brep = "brepV0";
3135 // v1Assoc.name = "geomV1";
3136 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3137 // v1Assoc.brep = "brepV1";
3138 // v2Assoc.name = "geomV2";
3139 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3140 // v2Assoc.brep = "brepV2";
3141 // v3Assoc.name = "geomV3";
3142 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3143 // v3Assoc.brep = "brepV3";
3147 // e0AssocA.name = "geomE0a";
3148 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3149 // e0AssocA.brep = "brepE0a";
3150 // e0AssocA.start = 0.10;
3151 // e0AssocA.end = 0.95;
3155 // e1AssocA.name = "geomE1a";
3156 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3157 // e1AssocA.brep = "brepE1a";
3158 // e1AssocA.start = 0.12;
3159 // e1AssocA.end = 0.89;
3160 // e1AssocB.name = "geomE1b";
3161 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3162 // e1AssocB.brep = "brepE1b";
3163 // e1AssocB.start = 0.20;
3164 // e1AssocB.end = 0.80;
3165 // e1AssocC.name = "geomE1c";
3166 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3167 // e1AssocC.brep = "brepE1c";
3168 // e1AssocC.start = 0.16;
3169 // e1AssocC.end = 0.96;
3171 // q0AssocA.name = "geomQuad";
3172 // q0AssocA.entry = "0:1:1:1:3";
3173 // q0AssocA.brep = "brepq0";
3175 // q0AssocB.name = "geomQuad";
3176 // q0AssocB.entry = "0:1:1:1:4";
3177 // q0AssocB.brep = "brepq0";
3179 // getCurrentModel()->addAssociation( v0, v0Assoc );
3180 // getCurrentModel()->addAssociation( v1, v1Assoc );
3181 // getCurrentModel()->addAssociation( v2, v2Assoc );
3182 // getCurrentModel()->addAssociation( v3, v3Assoc );
3185 // getCurrentModel()->addAssociation( e0, e0AssocA );
3187 // getCurrentModel()->addAssociation( e1, e1AssocA );
3188 // getCurrentModel()->addAssociation( e1, e1AssocB );
3189 // getCurrentModel()->addAssociation( e1, e1AssocC );
3191 // getCurrentModel()->addAssociation( q0, q0AssocA );
3192 // getCurrentModel()->addAssociation( q0, q0AssocB );
3198 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3199 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3200 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3201 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3202 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3203 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3204 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3205 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3206 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3207 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3208 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3209 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3212 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3213 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3214 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3215 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3216 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3217 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3218 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3219 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3220 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3221 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3222 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3223 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3224 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3226 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3227 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3228 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3231 DEBTRACE("HEXABLOCKGUI::test_association fin");