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 <Graphic3d_Structure.hxx>
112 #include <Graphic3d_Group.hxx>
113 #include <V3d_PerspectiveView.hxx>
114 #include <V3d_AmbientLight.hxx>
115 #include <Graphic3d_GraphicDevice.hxx>
116 #include <Graphic3d_Array1OfVertex.hxx>
117 #include <V3d_DirectionalLight.hxx>
118 #include <Xw_Window.hxx>
119 #include <V3d_TypeOfShadingModel.hxx>
120 #include <TCollection_ExtendedString.hxx>
122 #include <BRepAlgoAPI_Fuse.hxx>
124 #include <AIS_ListIteratorOfListOfInteractive.hxx>
127 #define DW_MINIMUM_WIDTH 50
128 #define DWINPUT_MINIMUM_HEIGHT 50
129 #define DWINPUT_MINIMUM_WIDTH 50//255
132 using namespace HEXABLOCK::GUI;
134 int HEXABLOCKGUI::_oldStudyId = -1;
136 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
138 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
139 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
140 bool HEXABLOCKGUI::assocInProgress = false;
141 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
143 HEXABLOCKGUI::HEXABLOCKGUI() :
144 SalomeApp_Module( "HEXABLOCK" ),
152 _patternDataTreeView(0),
153 _patternBuilderTreeView(0),
154 _patternGeomTreeView(0),
157 _treeViewDelegate(0),
159 moduleActivatedOnce(false),
168 _makeCylinderDiag(0),
170 _makeCylindersDiag(0),
178 _makeTransformationDiag(0),
179 _makeSymmetryDiag(0),
180 _performTransformationDiag(0),
181 _performSymmetryDiag(0),
190 _quadRevolutionDiag(0),
191 _makeHemiSphereDiag(0),
192 _modelInfoDiag(NULL),
196 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
198 graphicViewsHandler = new GraphicViewsHandler();
199 loadDocLastPath = new QDir();
200 saveDocLastPath = new QDir();
201 hexa_root = HEXA_NS::Hex::getInstance ();
204 HEXABLOCKGUI::~HEXABLOCKGUI()
209 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
211 SUIT_Application* app = SUIT_Session::session()->activeApplication();
213 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
219 // Gets an reference to the module's engine
220 /****************************************************
221 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
223 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
224 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
225 ASSERT(!CORBA::is_nil(clr));
228 **************************************************** */
230 void HEXABLOCKGUI::initialize( CAM_Application* app )
232 DEBTRACE("HEXABLOCKGUI::initialize");
233 SalomeApp_Module::initialize( app );
235 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
237 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
239 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
240 setResource(aResourceMgr);
242 createAndFillDockWidget();
249 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
251 DEBTRACE("HEXABLOCKGUI::viewManagers");
252 // list.append( QxScene_Viewer::Type() );
253 // list.append( OCCViewer_Viewer::Type() );
254 // list.append( SVTK_Viewer::Type() );
257 void HEXABLOCKGUI::restoreGraphicViews()
260 if (currentOccGView == NULL)
262 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
263 application()->desktop());
264 currentOccGView->getViewWindow()->installEventFilter(this);
266 else if (currentOccGView->getViewWindow() == NULL)
268 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
269 currentOccGView->getViewWindow()->installEventFilter(this);
273 if (currentDocGView == NULL)
275 else if (currentDocGView->getViewWindow() == NULL)
277 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
278 currentDocGView->getViewWindow()->installEventFilter(this);
283 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
285 DEBTRACE("HEXABLOCKGUI::activateModule");
287 /*HexaBlock can be launched in only one application*/
288 if (myApplication == NULL)
289 //remember the first application
290 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
292 //application verification: if it's not the one known by HexaBlock,
293 //leave without activating
294 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
295 if (myApplication != currentApplication) return false;
297 bool bOk = SalomeApp_Module::activateModule( theStudy );
298 if ( !bOk ) return false;
300 showDockWidgets(true);
302 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
303 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
304 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
305 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
307 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
309 SUIT_ViewManager* vm;
310 ViewManagerList OCCViewManagers, VTKViewManagers;
312 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
313 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
314 while ( itOCC.hasNext() && (vm = itOCC.next()) )
315 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
317 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
318 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
319 while ( itVTK.hasNext() && (vm = itVTK.next()) )
320 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
323 SALOME_ListIO selected;
324 sm->selectedObjects( selected );
327 // disable OCC selectors
328 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
329 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
330 while ( itOCCSel.hasNext() )
331 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
332 sr->setEnabled(true);
334 // disable VTK selectors
335 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
336 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
337 while ( itVTKSel.hasNext() )
338 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
339 sr->setEnabled(true);
341 sm->setSelectedObjects( selected, true ); //NPAL 19674
343 //connect close signal to vtk view manager
344 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
347 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
348 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
351 //connect close signal to occ view manager
352 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
355 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
356 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
359 /* ************************************ TODO Hexa6
360 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
361 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
362 if ( _PTR(Study) aStudy = s->studyDS()) {
363 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
364 updateObjBrowser(); // objects can be removed
366 ************************************ */
368 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
369 currentOccGView->getViewWindow()->installEventFilter(this);
371 if (currentDocGView != NULL)
373 switchModel(currentDocGView);
376 if (currentDocGView->getViewWindow() != NULL)
377 currentDocGView->getViewWindow()->installEventFilter(this);
386 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
388 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
389 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
390 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
391 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
393 if ( currentDocGView != NULL && currentDocGView->getViewWindow() != NULL )
394 //default selectionMode in VTKView
395 currentDocGView->getViewWindow()->SetSelectionMode( ActorSelection );
397 if (currentOccGView != NULL)
399 //defaut selectionMode in OccView
400 selectionMgr()->clearSelected();
401 currentOccGView->globalSelection();
402 currentOccGView->localSelection(TopAbs_SHAPE);
405 qDeleteAll(myOCCSelectors);
406 myOCCSelectors.clear();
407 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
409 qDeleteAll(myVTKSelectors);
410 myVTKSelectors.clear();
411 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
413 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
415 //Must be done for all views later
416 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
417 currentOccGView->getViewWindow()->removeEventFilter(this);
419 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
420 currentDocGView->getViewWindow()->removeEventFilter(this);
422 //switch off current document graphic view
423 switchOffGraphicView(currentDocGView);
426 setMenuShown( false );
427 setToolShown( false );
428 showDockWidgets( false );
430 _dwInputPanel->close();
437 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
439 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
440 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
441 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
442 int aStudyID = theStudy->StudyId();
443 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
444 return aDSStudy._retn();
447 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
448 QMap<QString, QString>& docShapesEntry,
449 QMap<QString, QString>& docShapesName)
451 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
452 return; //there's nothing to publish in this case
454 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
455 if(!appStudy) return;
456 _PTR(Study) aStudy = appStudy->studyDS();
457 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
458 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
459 QString entry = currentDocGView->getDocumentModel()->documentEntry();
460 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
461 if (aFatherSO->_is_nil())
464 // * get a presentation
465 bool isNewPrs = false;
466 SOCC_Prs* prs = getOccPrs(currentDocGView);
469 prs = new SOCC_Prs();
473 // * init the presentation with the given shapes
474 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
475 while (i != topo_shapes.constEnd())
477 QString shapeName = i.key();
478 TopoDS_Shape shapeValue = i.value();
479 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
480 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
481 QString objStudyEntry = aSO->GetID(); //the entry of the published object
482 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
483 "HEXABLOCK", shapeName.toStdString().c_str());
484 ais_shape->SetOwner(io);
485 prs->AddObject(ais_shape);
486 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
487 docShapesEntry[shapeName] = objStudyEntry;
488 docShapesName[objStudyEntry] = shapeName;
489 currentOccGView->addShape(objStudyEntry, ais_shape);
490 i++; //handle next shape
494 prs->AddObject(currentOccGView->getPreviewShape());
496 occPrs[currentDocGView] = prs;
497 getApp()->updateObjectBrowser();
502 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
504 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
505 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
506 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
508 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
512 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
516 // Pas de renommage des shapes pour le moment, juste les documents
517 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
518 if (dgview == NULL || dgview->getDocumentModel() == NULL)
521 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
522 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
527 _PTR(Study) aStudy = appStudy->studyDS();
532 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
533 _PTR(GenericAttribute) anAttr;
535 if ( obj->FindAttribute(anAttr, "AttributeName") ){
536 _PTR(AttributeName) aName (anAttr);
537 DocumentModel* docModel = dgview->getDocumentModel();
538 docModel->setName( name );
539 aName->SetValue( name.toLatin1().data() );
540 getApp()->updateObjectBrowser();
541 _dwPattern->setWindowTitle( name );
548 // --- Default windows
549 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
551 DEBTRACE("HEXABLOCKGUI::windows");
553 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
554 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
557 QString HEXABLOCKGUI::engineIOR() const
559 DEBTRACE("HEXABLOCKGUI::engineIOR");
561 /* ************************************ TODO Hexa6
562 CORBA::ORB_var anORB = getApp()->orb();
563 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
564 return QString( anIOR.in() );
565 ************************************ */
569 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
571 if (docs.count(studyObject->entry()) == 0)
573 //Object's document not acquired yet
574 VtkDocumentGraphicView* dgview;
575 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
576 if (directory == NULL)
577 return NULL; //No working director found
579 //------------------ Load the document -----------------
580 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
581 if (document == NULL)
582 return NULL; //No document found
584 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
586 MESSAGE("Doc model creation failed!");
589 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
590 if (dgview == NULL) return NULL;
592 //update the data tree
593 docs[studyObject->entry()] = dgview;
596 return docs[studyObject->entry()];
599 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
601 // ** we want to switch automatically to the right view windows
603 //first, find selected item
605 DataObjectList dol = getApp()->objectBrowser()->getSelected();
606 if (dol.isEmpty()) return;
607 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
608 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
609 item->entry().isEmpty())
612 // find the document corresponding to it
613 VtkDocumentGraphicView* docGView = NULL;
614 if (docs.contains(item->entry()))
615 docGView = docs[item->entry()];
617 docGView = getOrCreateDocument(item);
619 if (docGView == NULL || docGView == currentDocGView)
622 //Init OCC if necessary
623 if (currentOccGView == NULL)
625 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
626 application()->desktop());
627 currentOccGView->getViewWindow()->installEventFilter(this);
629 else if (currentOccGView->getViewWindow() == NULL)
631 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
632 currentOccGView->getViewWindow()->installEventFilter(this);
635 //Init the vtk view if necessary
636 if (docGView->getViewWindow() == NULL)
638 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
640 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
641 docGView->getViewWindow()->installEventFilter(this);
644 docGView->setViewWindow(currentDocGView->getViewWindow());
646 if (docGView->getDocumentActor() == NULL)
650 //update the current document
651 switchModel(docGView);
655 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
657 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
660 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
662 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
664 //Decharger le model correspondant (VTK)
665 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
670 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
671 { //HexaBlock Vtk Window has been closed
673 if (currentDialog != NULL) currentDialog->close();
674 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
675 if (currentDocGView != NULL)
676 currentDocGView->setViewWindow(NULL);
683 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
684 if (dgview == NULL) return; //The window has no document to close
686 //Save the document? (Ask only if the document is not empty
687 int answerCode = SUIT_MessageBox::question(
690 tr("Save the document ?"),
691 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
692 SUIT_MessageBox::Cancel);
693 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
694 else if (answerCode == SUIT_MessageBox::Yes)
695 saveDocument(); //Save the document
697 // switchOffGraphicView(window); //disconnect all connected signals
698 // currentVtkView = NULL;
699 // graphicViewsHandler->closeDocumentGraphicView(window);
701 //create a new one (empty document)
703 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
707 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
709 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
710 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
711 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
712 if (currentDialog != NULL) currentDialog->close();
713 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
715 currentOccGView->getViewWindow()->removeEventFilter(this);
716 currentOccGView->setViewWindow(NULL);
720 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
722 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
724 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
725 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
727 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
729 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
730 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
731 // disable OCC selectors
732 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
733 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
734 while ( itOCCSel.hasNext() )
735 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
736 sr->setEnabled(true);
738 else if ( vm->getType() == SVTK_Viewer::Type() )
740 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
741 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
743 // disable VTK selectors
744 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
745 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
746 while ( itVTKSel.hasNext() )
747 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
748 sr->setEnabled(true);
752 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
754 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
756 SUIT_ViewModel* viewer = vm->getViewModel();
757 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
759 //VTK View Manager removed
760 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
762 //Process only if it's our view manager
763 SUIT_ViewManager* myVm = NULL;
764 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
765 myVm = currentDocGView->getViewWindow()->getViewManager();
769 //close opened dialog
770 if (currentDialog != NULL) currentDialog->close();
771 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
777 //remove its selector
778 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
779 while ( itVTKSel.hasNext() )
780 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
781 if ( sr->viewer() == viewer )
783 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
790 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
792 //OCC View removed: remove its selector
793 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
794 while ( itOCCSel.hasNext() )
795 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
796 if ( sr->viewer() == viewer )
798 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
804 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
806 QModelIndexList l = selected.indexes();
807 if ( l.count() == 0 ) return;
808 if ( !l[0].isValid() ) return;
809 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
810 if ( currentGraphicView == NULL) return;
812 QTreeView* theTree = NULL;
813 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
814 theTree = _patternDataTreeView;
815 } else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
816 theTree = _patternBuilderTreeView;
817 } else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
818 theTree = _patternGeomTreeView;
820 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
821 theTree = _groupsTreeView;
822 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
823 theTree = _meshTreeView;
826 theTree->scrollTo ( l[0] );
830 bool HEXABLOCKGUI::createSComponent() //addComponent
832 DEBTRACE("HEXABLOCKGUI::createSComponent");
833 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
835 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
836 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
837 _PTR(GenericAttribute) anAttr;
838 _PTR(AttributeName) aName;
839 _PTR(AttributeGraphic) aGraphic;
841 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
842 if ( !aComponent ){ //Create hexablock component if there's not one yet
843 aComponent = aBuilder->NewComponent("HEXABLOCK");
844 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
845 aName = _PTR(AttributeName) (anAttr);
846 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
848 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
849 _PTR(AttributePixMap) aPixmap(anAttr);
850 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
852 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
853 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
859 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
861 DEBTRACE("HEXABLOCKGUI::setResource");
862 _myresource = new HEXABLOCKGUI_Resource(r);
863 _myresource->preferencesChanged();
866 void HEXABLOCKGUI::createPreferences()
868 DEBTRACE("HEXABLOCKGUI::createPreferences");
869 _myresource->createPreferences(this);
872 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
874 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
875 _myresource->preferencesChanged(sect, name);
876 // if(name=="userCatalog")
877 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
880 void HEXABLOCKGUI::studyActivated() //CS_TODO
882 int newStudyId = getApp()->activeStudy()->id();
883 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
884 // if (_oldStudyId != -1)
886 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
887 // if (_studyContextMap.count(newStudyId))
889 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
890 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
894 // DEBTRACE("no switch to null context");
897 _oldStudyId = newStudyId;
900 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
902 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
903 QVariant currentAssocVariant;
904 QString currentAssocEntry;
906 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
907 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
908 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
909 QMenu menu( _patternDataTreeView );
911 QAction *clearAct = menu.addAction( "Remove association(s)" );
912 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
913 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
917 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
918 if (currentVtkGraphicView == NULL) return;
919 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
921 //We don't do anything for single items
922 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
923 item->type() == QUADITEM || item->type() == HEXAITEM)
926 //No associations for HEXA
927 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
928 if ( !treeVariant.isValid() ) return;
929 int eltType = treeVariant.toInt();
930 if (eltType == HEXA_DIR_TREE) return;
931 QMenu menu( _patternDataTreeView );
933 //Show association(s)
934 QAction *showAssocAct = menu.addAction( "Show associations" );
935 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
937 //Clear all associations
938 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
939 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
941 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
946 void HEXABLOCKGUI::createAndFillDockWidget()
948 QMainWindow *aParent = application()->desktop();
950 // Create dock widget (3 dock)
952 //1) *********** user input panel ( contain user's edit dialog box )
953 _dwInputPanel = new QDockWidget(aParent);
954 _dwInputPanel->setVisible(false);
955 _dwInputPanel->setWindowTitle("Input Panel");
956 _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
958 _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
960 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
962 _dwPattern = new QDockWidget(aParent);
963 _dwPattern->setVisible(false);
964 _dwPattern->setWindowTitle("Model");
965 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
967 QFrame* patternFrame = new QFrame(_dwPattern);
968 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
969 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
970 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
971 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
972 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
973 _patternBuilderTreeView = new QTreeView(patternFrame);
974 _patternGeomTreeView = new QTreeView(patternFrame);
975 splitter->addWidget(_patternDataTreeView);
976 splitter->addWidget(_patternBuilderTreeView);
977 splitter->addWidget(_patternGeomTreeView);
978 patternLayout->addWidget(splitter);
980 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers/*QAbstractItemView::DoubleClicked*/);
981 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
982 _patternDataTreeView->setItemDelegate(_treeViewDelegate);
985 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
986 _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
988 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
989 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
991 _dwPattern->setWidget(patternFrame);
992 patternFrame->show();
995 _dwGroups = new QDockWidget(aParent);
997 _dwGroups->setVisible(false);
998 _dwGroups->setWindowTitle("Groups");
999 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1000 _groupsTreeView = new QTreeView(_dwGroups);
1001 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1002 _groupsTreeView->setItemDelegate(_treeViewDelegate);
1003 _dwGroups->setWidget(_groupsTreeView);
1004 _groupsTreeView->show();
1007 _dwMesh = new QDockWidget(aParent);
1008 _dwMesh->setVisible(false);
1009 _dwMesh->setWindowTitle("Mesh");
1010 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1011 _meshTreeView = new QTreeView(_dwMesh);
1012 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1013 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1014 _meshTreeView->setItemDelegate(_treeViewDelegate);
1015 _dwMesh->setWidget(_meshTreeView);
1016 _meshTreeView->show();
1018 QDockWidget *_dwObjectBrowser = 0;
1019 QWidget* wid = getApp()->objectBrowser()->treeView();
1020 QWidget *w = wid->parentWidget();
1021 while ( w && !_dwObjectBrowser ) {
1022 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1023 w = w->parentWidget();
1025 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1026 _dwObjectBrowser->setWindowTitle("Study");
1028 // dock widget position
1029 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1030 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1032 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1033 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1034 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1037 #if QT_VERSION >= 0x040500
1038 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1042 // popup menu on data tree view
1043 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1044 connect(_patternDataTreeView,
1045 SIGNAL(customContextMenuRequested(const QPoint &)),
1047 SLOT(treeContextMenu(const QPoint &)),
1048 Qt::UniqueConnection );
1051 void HEXABLOCKGUI::createActions()
1053 QMainWindow *aParent = application()->desktop();
1054 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1057 _newAct = createAction(_menuId++,
1058 tr("Create a new document"),
1059 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1061 tr("Create a new document"),
1062 0, aParent, false, this, SLOT(newDocument()));
1063 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1065 _importAct = createAction(_menuId++,
1066 tr("Load a document"),
1067 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1068 tr("Load Document"),
1069 tr("Load a document"),
1070 0, aParent, false, this, SLOT(loadDocument()));
1071 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1073 _saveAct = createAction(_menuId++,
1074 tr("Save the document"),
1075 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1076 tr("Save Document"),
1077 tr("Save the document"),
1078 0, aParent, false, this, SLOT(saveDocument()));
1080 // Pattern Data creation
1081 _addVertex = createAction(_menuId++,
1082 tr("Create a vertex"),
1083 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1085 tr("Create a new vertex"),
1086 0, aParent, false, this, SLOT(addVertex()));
1088 _addEdge = createAction(_menuId++,
1089 tr("Create an edge"),
1090 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1092 tr("Create a new edge"),
1093 0, aParent, false, this, SLOT(addEdge()));
1095 _addQuad = createAction(_menuId++,
1096 tr("Create a quadrangle"),
1097 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1098 tr("Add Quadrangle"),
1099 tr("Create a new quadrangle"),
1100 0, aParent, false, this, SLOT(addQuad()));
1102 _addHexa = createAction(_menuId++,
1103 tr("Create an hexahedron"),
1104 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1105 tr("Add Hexahedron"),
1106 tr("Create a new hexahedron"),
1107 0, aParent, false, this, SLOT(addHexa()));
1109 // Builder Data creation
1110 _addVector = createAction(_menuId++,
1111 tr("Create a vector"),
1112 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1114 tr("Create a new vector"),
1115 0, aParent, false, this, SLOT(addVector()));
1117 // _addCylinder = createAction(_menuId++,
1118 // tr("Create a cylinder"),
1119 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1120 // tr("Add Cylinder"),
1121 // tr("Create a new cylinder"),
1122 // 0, aParent, false, this, SLOT(addCylinder()));
1124 // _addPipe = createAction(_menuId++,
1125 // tr("Create a pipe"),
1126 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1128 // tr("Create a new pipe"),
1129 // 0, aParent, false, this, SLOT(addPipe()));
1131 _makeGrid = createAction(_menuId++,
1133 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1136 0, aParent, false, this, SLOT(makeGrid()));
1138 _makeCylinder = createAction(_menuId++,
1139 tr("Make a cylinder"),
1140 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1141 tr("Make Cylinder"),
1142 tr("Make a cylinder"),
1143 0, aParent, false, this, SLOT(makeCylinder()));
1145 _makePipe = createAction(_menuId++,
1147 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1150 0, aParent, false, this, SLOT(makePipe()));
1152 _makeCylinders = createAction(_menuId++,
1153 tr("Make cylinders"),
1154 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1155 tr("Make Cylinders"),
1156 tr("Make cylinders"),
1157 0, aParent, false, this, SLOT(makeCylinders()));
1159 _makePipes = createAction(_menuId++,
1161 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1164 0, aParent, false, this, SLOT(makePipes()));
1166 _makeHemiSphere = createAction(_menuId++,
1167 tr("Make an hemisphere"),
1168 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1169 tr("Make Hemisphere"),
1170 tr("Make an hemisphere"),
1171 0, aParent, false, this, SLOT(makeHemiSphere()));
1173 // Pattern Data edition
1174 _removeHexa = createAction(_menuId++,
1175 tr("Remove hexahedra"),
1176 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1177 tr("Remove Hexahedra"),
1178 tr("Remove hexahedra"),
1179 0, aParent, false, this, SLOT(removeHexa()));
1181 _prismQuad = createAction(_menuId++,
1182 tr("Prism quadrangles"),
1183 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1184 tr("Prism Quadrangles"),
1185 tr("Prism quadrangles"),
1186 0, aParent, false, this, SLOT(prismQuad()));
1188 _joinQuad = createAction(_menuId++,
1189 tr("Join quadrangles"),
1190 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1191 tr("Join Quadrangles"),
1192 tr("Join quadrangles with hexahedra"),
1193 0, aParent, false, this, SLOT(joinQuad()));
1195 _merge = createAction(_menuId++,
1197 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1200 0, aParent, false, this, SLOT(merge()));
1202 _disconnect = createAction(_menuId++,
1204 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1206 tr("Disconnect edges, vertexes or quadrangles"),
1207 0, aParent, false, this, SLOT(disconnectElts()));
1209 _cutEdge = createAction(_menuId++,
1211 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1214 0, aParent, false, this, SLOT(cutEdge()));
1216 _makeTransformation = createAction(_menuId++,
1217 tr("Make transformation"),
1218 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1219 tr("Make Transformation"),
1220 tr("Make transformation"),
1221 0, aParent, false, this, SLOT(makeTransformation()));
1223 _makeSymmetry = createAction(_menuId++,
1224 tr("Make symmetry"),
1225 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1226 tr("Make Symmetry"),
1227 tr("Make symmetry"),
1228 0, aParent, false, this, SLOT(makeSymmetry()));
1230 _performTransformation = createAction(_menuId++,
1231 tr("Perform transformation"),
1232 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1233 tr("Perform Transformation"),
1234 tr("Perform transformation"),
1235 0, aParent, false, this, SLOT(performTransformation()));
1237 _performSymmetry = createAction(_menuId++,
1238 tr("Perform symmetry"),
1239 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1240 tr("Perform Symmetry"),
1241 tr("Perform symmetry"),
1242 0, aParent, false, this, SLOT(performSymmetry()));
1244 _replaceHexa = createAction(_menuId++,
1245 tr("Replace hexahedron"),
1246 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1247 tr("Replace Hexahedron"),
1248 tr("Replace hexahedron"),
1249 0, aParent, false, this, SLOT(replaceHexa()));
1251 _quadRevolution = createAction(_menuId++,
1252 tr("Quad revolution"),
1253 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1254 tr("Quad Revolution"),
1255 tr("Quad revolution"),
1256 0, aParent, false, this, SLOT(quadRevolution()));
1259 _assocVertex = createAction(_menuId++,
1260 tr("Make vertex association"),
1261 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1262 tr("Make Vertex association"),
1263 tr("Make vertex association"),
1264 0, aParent, false, this, SLOT(assocVertex()));
1266 _assocEdge = createAction(_menuId++,
1267 tr("Make edge association"),
1268 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1269 tr("Make Edge Association"),
1270 tr("Make edge association"),
1271 0, aParent, false, this, SLOT(assocEdge()));
1273 _assocQuad = createAction(_menuId++,
1274 tr("Make quad association"),
1275 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1276 tr("Make Quad Association"),
1277 tr("Make quad association"),
1278 0, aParent, false, this, SLOT(assocQuad()));
1281 _addGroup = createAction(_menuId++,
1283 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1286 0, aParent, false, this, SLOT(addGroup()));
1288 _removeGroup = createAction(_menuId++,
1289 tr("Remove a group"),
1290 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1292 tr("Remove a group"),
1293 0, aParent, false, this, SLOT(removeGroup()));
1296 _addLaw = createAction(_menuId++,
1298 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1301 0, aParent, false, this, SLOT(addLaw()));
1303 _removeLaw = createAction(_menuId++,
1305 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1308 0, aParent, false, this, SLOT(removeLaw()));
1310 _setPropagation = createAction(_menuId++,
1311 tr("Set propagation"),
1312 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1313 tr("Set Propagation"),
1314 tr("Set propagation"),
1315 0, aParent, false, this, SLOT(setPropagation()));
1317 _computeMesh = createAction(_menuId++,
1319 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1322 0, aParent, false, this, SLOT(computeMesh()));
1324 _showModelInfoAct = createAction(_menuId++,
1325 tr("Show Model Info"),
1326 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1329 0, aParent, false, this, SLOT(showModelInfo()));
1331 _addShapeAct = createAction(_menuId++,
1333 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1336 0, aParent, false, this, SLOT(addShape()));
1338 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1339 // QAction* createAction(const int id,
1340 // const QString& toolTip,
1341 // const QIcon& icon,
1342 // const QString& menu,
1343 // const QString& status,
1344 // const int shortCut,
1345 // QObject* parent =0,
1346 // bool checkable = false,
1347 // QObject* receiver =0,
1348 // const char* member =0);
1350 _sep1 = separator();
1351 _sep2 = separator();
1352 _sep3 = separator();
1353 _sep4 = separator();
1357 void HEXABLOCKGUI::createMenus()
1359 int aMenuId, subMenuId,aMenuIdMain;
1361 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1363 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1364 createMenu( actionId(_newAct), aMenuId );
1365 createMenu( actionId(_importAct), aMenuId );
1366 createMenu( _saveAct, aMenuId );
1369 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1370 createMenu( _newAct, aMenuDocId );//, 10
1371 createMenu( _importAct, aMenuDocId );
1372 createMenu( _saveAct, aMenuDocId );
1374 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1375 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1376 createMenu( _addVertex, subMenuId );
1377 createMenu( _addEdge, subMenuId );
1378 createMenu( _addQuad, subMenuId );
1379 createMenu( _addHexa, subMenuId );
1380 createMenu( _sep1, subMenuId);
1383 createMenu( _addVector, subMenuId );
1384 // createMenu( _addCylinder, subMenuId );
1385 // createMenu( _addPipe, subMenuId );
1387 createMenu( _sep2, subMenuId);
1389 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1390 createMenu( _makeHemiSphere,subMenuId );
1392 createMenu( _sep3, subMenuId);
1394 createMenu( _makeCylinder, subMenuId );
1395 createMenu( _makePipe, subMenuId );
1396 createMenu( _makeCylinders,subMenuId );
1397 createMenu( _makePipes, subMenuId );
1399 // Pattern Data Edition
1400 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1401 createMenu( _removeHexa, subMenuId );
1402 createMenu( _prismQuad, subMenuId );
1403 createMenu( _joinQuad, subMenuId );
1404 createMenu( _merge, subMenuId );
1405 createMenu( _disconnect, subMenuId );
1406 createMenu( _cutEdge, subMenuId );
1407 createMenu( _makeTransformation, subMenuId );
1408 createMenu( _makeSymmetry, subMenuId );
1409 createMenu( _performTransformation, subMenuId );
1410 createMenu( _performSymmetry, subMenuId );
1411 createMenu( _replaceHexa, subMenuId );
1412 createMenu( _quadRevolution, subMenuId );
1413 createMenu( _sep4, aMenuId );
1414 createMenu( _showModelInfoAct, aMenuId );
1417 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1418 createMenu( _addShapeAct, aMenuId );
1419 createMenu( _assocVertex, aMenuId );
1420 createMenu( _assocEdge, aMenuId );
1421 createMenu( _assocQuad, aMenuId );
1424 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1425 createMenu( _addGroup, aMenuId );
1426 createMenu( _removeGroup, aMenuId ); //CS_TODO
1429 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1430 createMenu( _addLaw, aMenuId );
1431 createMenu( _removeLaw, aMenuId );
1432 createMenu( _setPropagation, aMenuId );
1433 createMenu( _computeMesh, aMenuId );
1435 //show model infomation menu
1436 QString aRule = "$component={'HEXABLOCK'}";
1437 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1438 popupMgr()->setRule( _showModelInfoAct, aRule);
1440 //associate shape to a document menu
1441 popupMgr()->insert( _addShapeAct, -1, -1 );
1442 popupMgr()->setRule( _addShapeAct, aRule );
1444 //-------------------------------------------------
1446 //-------------------------------------------------
1447 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1448 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1449 // QString isNotEmpty("numberOfNodes <> 0");
1450 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1451 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1452 //// aType = aType.arg( mesh_part );
1454 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1455 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1456 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1458 // popupMgr()->insert( separator(), -1, -1 );
1459 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1460 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1461 // // MESSAGE("aClient = " << aClient.toStdString());
1462 // // MESSAGE("aType = " << aType.toStdString());
1463 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1464 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1465 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1466 // // MESSAGE("aRule = " << aRule.toStdString());
1467 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1468 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1470 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1471 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1473 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1474 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1476 // popupMgr()->insert( separator(), -1, -1 );
1480 void HEXABLOCKGUI::createTools()
1484 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1485 createTool( _newAct, aToolId );
1486 createTool( _importAct, aToolId );
1487 createTool( _saveAct, aToolId );
1488 createTool( _showModelInfoAct, aToolId );
1489 // createTool( _testAct, aToolId );
1490 //createTool( separator(), aToolId );
1493 aToolId = createTool ( tr( "Construction" ) );
1494 createTool( _addVertex, aToolId );
1495 createTool( _addEdge, aToolId );
1496 createTool( _addQuad, aToolId );
1497 createTool( _addHexa, aToolId );
1499 createTool( _sep1, aToolId );
1502 createTool( _addVector, aToolId );
1503 // createTool( _addCylinder, aToolId );
1504 // createTool( _addPipe, aToolId );
1506 createTool( _sep2, aToolId );
1508 createTool( _makeGrid, aToolId );
1509 createTool( _makeHemiSphere, aToolId );
1511 createTool( _sep3, aToolId );
1513 createTool( _makeCylinder, aToolId );
1514 createTool( _makePipe, aToolId );
1515 createTool( _makeCylinders,aToolId );
1516 createTool( _makePipes, aToolId );
1518 // Pattern Data Edition
1519 aToolId = createTool ( tr( "Operation" ) );
1520 createTool( _removeHexa, aToolId );
1521 createTool( _prismQuad, aToolId );
1522 createTool( _joinQuad, aToolId );
1523 createTool( _merge, aToolId );
1524 createTool( _disconnect, aToolId );
1525 createTool( _cutEdge, aToolId );
1526 createTool( _makeTransformation, aToolId );
1527 createTool( _makeSymmetry, aToolId );
1528 createTool( _performTransformation, aToolId );
1529 createTool( _performSymmetry, aToolId );
1530 createTool( _replaceHexa, aToolId );
1531 createTool( _quadRevolution, aToolId );
1534 aToolId = createTool ( tr( "Association" ) );
1535 createTool( _assocVertex, aToolId );
1536 createTool( _assocEdge, aToolId );
1537 createTool( _assocQuad, aToolId );
1538 createTool( _addShapeAct, aToolId );
1541 aToolId = createTool ( tr( "Group" ) );
1542 createTool( _addGroup, aToolId );
1543 createTool( _removeGroup, aToolId ); //CS_TODO
1546 aToolId = createTool ( tr( "Mesh" ) );
1547 createTool( _addLaw, aToolId );
1548 createTool( _removeLaw, aToolId );
1549 createTool( _setPropagation, aToolId );
1550 createTool( _computeMesh, aToolId );
1554 void HEXABLOCKGUI::initialMenus()
1556 showDocumentMenus( true );
1557 showPatternMenus( false );
1558 showAssociationMenus( false );
1559 showGroupsMenus( false );
1560 showMeshMenus( false );
1563 void HEXABLOCKGUI::showAllMenus()
1565 showDocumentMenus( true );
1566 showPatternMenus( true );
1567 showAssociationMenus( true );
1568 showGroupsMenus( true );
1569 showMeshMenus( true );
1573 void HEXABLOCKGUI::showDocumentMenus(bool show)
1575 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1577 setMenuShown(_newAct, show);
1578 setToolShown(_newAct, show);
1579 setMenuShown(_importAct, show);
1580 setToolShown(_importAct, show);
1581 setMenuShown(_showModelInfoAct, show);
1582 setToolShown(_showModelInfoAct, show);
1583 setMenuShown(_saveAct, show);
1584 setToolShown(_saveAct, show);
1587 void HEXABLOCKGUI::showPatternMenus(bool show)
1589 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1590 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1591 if ( show && !getCurrentModel() ) return;
1593 setMenuShown(_addVertex, show );
1594 setToolShown(_addVertex, show);
1595 setMenuShown(_addEdge, show );
1596 setToolShown(_addEdge, show);
1597 setMenuShown(_addQuad, show );
1598 setToolShown(_addQuad, show);
1599 setMenuShown(_addHexa, show );
1600 setToolShown(_addHexa, show);
1602 setMenuShown(_sep1, show );
1603 setToolShown(_sep1, show);
1605 setMenuShown( _addVector, show );
1606 setToolShown( _addVector, show);
1607 // setMenuShown( _addCylinder, show );
1608 // setToolShown( _addCylinder, show);
1609 // setMenuShown( _addPipe, show );
1610 // setToolShown( _addPipe, show);
1612 setMenuShown(_sep2, show );
1613 setToolShown(_sep2, show);
1615 setMenuShown( _makeGrid, show );
1616 setToolShown( _makeGrid, show);
1617 setMenuShown( _makePipe, show );
1618 setToolShown( _makePipe, show);
1620 setMenuShown(_sep3, show );
1621 setToolShown(_sep3, show);
1623 setMenuShown( _makeCylinder, show );
1624 setToolShown( _makeCylinder, show);
1625 setMenuShown( _makeCylinders, show );
1626 setToolShown( _makeCylinders, show);
1627 setMenuShown( _makePipes, show );
1628 setToolShown( _makePipes, show);
1629 setMenuShown( _makeHemiSphere, show );
1630 setToolShown( _makeHemiSphere, show);
1632 // Pattern Data Edition
1633 setMenuShown( _removeHexa, show );
1634 setToolShown( _removeHexa, show);
1635 setMenuShown( _prismQuad, show );
1636 setToolShown( _prismQuad, show);
1637 setMenuShown( _joinQuad, show );
1638 setToolShown( _joinQuad, show);
1639 setMenuShown( _merge, show );
1640 setToolShown( _merge, show);
1641 setMenuShown( _disconnect, show );
1642 setToolShown( _disconnect, show);
1643 setMenuShown( _cutEdge, show );
1644 setToolShown( _cutEdge, show);
1645 setMenuShown( _makeTransformation, show );
1646 setToolShown( _makeTransformation, show);
1647 setMenuShown( _makeSymmetry, show );
1648 setToolShown( _makeSymmetry, show);
1649 setMenuShown( _performTransformation, show );
1650 setToolShown( _performTransformation, show);
1651 setMenuShown( _performSymmetry, show );
1652 setToolShown( _performSymmetry, show);
1653 setMenuShown( _replaceHexa, show );
1654 setToolShown( _replaceHexa, show);
1655 setMenuShown( _quadRevolution, show );
1656 setToolShown( _quadRevolution, show);
1658 setMenuShown( _sep4, show );
1659 setMenuShown( _showModelInfoAct, show );
1663 void HEXABLOCKGUI::showAssociationMenus(bool show)
1665 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1666 if ( show && !getCurrentModel() ) return;
1668 // Association Edition
1669 setMenuShown( _assocVertex, show );
1670 setToolShown( _assocVertex, show );
1671 setMenuShown( _assocEdge, show );
1672 setToolShown( _assocEdge, show );
1673 setMenuShown( _assocQuad, show );
1674 setToolShown( _assocQuad, show );
1675 setMenuShown( _addShapeAct, show );
1676 setToolShown( _addShapeAct, show );
1680 void HEXABLOCKGUI::showGroupsMenus(bool show)
1682 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1683 if ( show && !getCurrentModel() ) return;
1684 setMenuShown( _addGroup, show );
1685 setToolShown( _addGroup, show);
1686 setMenuShown( _removeGroup , show );
1687 setToolShown( _removeGroup , show);
1690 void HEXABLOCKGUI::showMeshMenus(bool show)
1692 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1693 if ( show && !getCurrentModel() ) return;
1694 setMenuShown( _addLaw, show );
1695 setToolShown( _addLaw, show);
1696 setMenuShown( _removeLaw, show );
1697 setToolShown( _removeLaw, show);;
1698 setMenuShown( _setPropagation, show );
1699 setToolShown( _setPropagation, show);
1700 setMenuShown( _computeMesh, show);
1701 setToolShown( _computeMesh, show);
1704 void HEXABLOCKGUI::showActor()
1706 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1707 if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
1708 currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
1711 currentVtkGView->getViewWindow()->setFocus();
1712 currentVtkGView->getViewWindow()->Display(currentVtkGView->getDocumentActor()->getIO());
1713 currentVtkGView->update();
1714 currentVtkGView->getViewWindow()->onFitAll();
1716 //update the visibility state now
1717 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1718 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1719 if (aStudy == NULL || vman == NULL) return;
1721 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1722 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1723 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1726 //SOCC_Prs* currentPrs = NULL;
1727 void HEXABLOCKGUI::showOnlyActor()
1729 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1730 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1731 currentVtkGView->getDocumentActor() == NULL)
1733 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1734 if (vtkView == NULL)
1737 SALOME_Actor *actor = NULL;
1738 vtkActor *aVTKActor = NULL;
1739 Handle(SALOME_InteractiveObject) anIO;
1741 SUIT_ViewManager* vman = vtkView->getViewManager();
1742 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1743 vtkRenderer *aRenderer = vtkView->getRenderer();
1744 if (aStudy == NULL || vman == NULL || aRenderer == NULL) return;
1746 //update the visibility state for all actors -----------
1747 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1748 vtkActorCollection *aCollection = aCopy.GetActors();
1749 if (aCollection == NULL) return;
1750 aCollection->InitTraversal();
1752 while( (aVTKActor = aCollection->GetNextActor()) != NULL ){
1753 actor = dynamic_cast<SALOME_Actor*>( aVTKActor );
1754 if ( actor && actor->hasIO() ){
1755 anIO = actor->getIO();
1756 if( anIO->hasEntry())
1758 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1759 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1764 //show only the current actor -----------------
1765 vtkView->setFocus();
1766 vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1767 currentVtkGView->update();
1768 anIO = currentVtkGView->getDocumentActor()->getIO();
1769 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1770 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1771 vtkView->onFitAll();
1773 // //showOnly in occ viewer -------------
1775 if (currentOccGView == NULL)
1777 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1778 if (occView == NULL)
1780 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1785 currentOccGView->globalSelection();
1786 SOCC_Prs* prs = getOccPrs(currentDocGView);
1787 currentOccGView->setPrs(prs);
1790 occView->onFitAll();
1793 void HEXABLOCKGUI::hideActor()
1796 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1797 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1798 currentVtkGView->getViewWindow() == NULL ||
1799 currentVtkGView->getDocumentActor() == NULL) return;
1801 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1802 currentVtkGView->getViewWindow()->onResetView();
1804 //update the visibility state now
1805 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1806 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1807 if (aStudy == NULL || vman == NULL) return;
1809 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1810 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1811 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1814 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1815 DocumentModel* docModel = currentVtkGView->getDocumentModel();
1816 if (occView == NULL || docModel == NULL)
1818 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1824 occView->onResetView();
1828 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1830 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1832 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1833 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1835 if (_dwPattern) _dwPattern->setVisible(isVisible);
1836 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1838 if (_dwMesh) _dwMesh->setVisible(isVisible);
1839 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1841 if (_dwGroups) _dwGroups->setVisible(isVisible);
1842 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1846 //clear all used dialogs by the current model
1847 void HEXABLOCKGUI::clearDialogs()
1849 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1850 fin (currentModelDialogs.end());
1851 for(;debut!=fin;++debut) (*debut)->clear();
1853 currentModelDialogs.clear(); //empty the used dialogs list
1856 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1858 if (!gViewDlgBox.contains(dgview)) return NULL;
1859 return gViewDlgBox[dgview];
1862 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1864 if (dgview == NULL) return;
1866 switchOffGraphicView(dgview, false); //to avoid double connect
1869 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1870 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1871 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1872 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1873 connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1874 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1875 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1876 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1877 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1878 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1879 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1880 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1882 if (currentDocGView != NULL)
1884 if (currentDocGView->getViewWindow() != NULL)
1885 dgview->setViewWindow(currentDocGView->getViewWindow());
1888 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1889 dgview->getViewWindow()->installEventFilter(this);
1892 dgview->getViewWindow()->setFocus();
1896 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1898 if (dgview == NULL) return;
1900 //disconnect signals
1901 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1902 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1903 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1904 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1905 disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1906 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1907 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1908 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1909 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1910 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1911 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1912 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1915 gViewDlgBox[dgview] = currentDialog;
1917 //close opened dialog
1918 if (currentDialog != NULL) currentDialog->close();
1919 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1925 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1927 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1931 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1935 //switch off the current document graphic view (disconnect signals...)
1936 if (currentDocGView != NULL)
1938 //Hide current actor
1940 switchOffGraphicView(currentDocGView);
1943 //clear the dialogs used by the current model so they can be used by the new model
1944 if (currentDocGView != dgview) clearDialogs();
1946 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1947 _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1948 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1949 _groupsTreeView->setModel(dgview->getGroupsModel());
1950 _meshTreeView->setModel(dgview->getMeshModel());
1952 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1953 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1955 _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1956 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1958 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1959 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1961 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1962 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1964 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1965 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1967 //switch on this graphic view (connect signals...)
1968 switchOnGraphicView(dgview);
1969 currentDocGView = dgview;
1970 currentDocGView->getViewWindow()->setFocus();
1972 currentDocGView->getDocumentModel()->refresh();
1973 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1977 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1979 if (currentDocGView == NULL) return NULL;
1980 return currentDocGView->getDocumentModel();
1984 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1986 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1987 if (anApp == NULL) return UNKNOWN;
1988 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1989 if (activeVm == NULL) return UNKNOWN;
1991 QString vmType = activeVm->getType();
1992 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1994 else if ( vmType == OCCViewer_Viewer::Type() )
2000 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2002 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2006 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2009 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2011 // Create Document from HEXABLOCK ENGINE
2012 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2013 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2015 // looking doc impl ( c++ )
2016 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2017 // ^Hexa6 ASSERT( dServant );
2018 // ^Hexa6 if ( dServant)
2019 // ^Hexa6 doc = dServant->GetImpl();
2021 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2022 QString docEntry = addDocInStudy (doc);
2024 // looking for docEntry
2025 /* ****************************************************************
2026 if ( !CORBA::is_nil(docIn) ){
2027 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2028 QString docIOR = anIOR.in();
2029 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2030 if ( !docIOR.isEmpty() ) {
2031 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2033 docEntry = SO->GetID().c_str();
2036 **************************************************************** */
2037 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2039 return make_pair (docEntry, doc);
2043 void HEXABLOCKGUI::newDocument()
2045 DEBTRACE("HEXABLOCKGUI::newDocument");
2048 QMainWindow *aParent = application()->desktop();
2049 QWidget *central = aParent->centralWidget();
2051 central->setFocus();
2053 DEBTRACE("No Central Widget");
2056 if (currentOccGView == NULL)
2058 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2059 application()->desktop());
2060 currentOccGView->getViewWindow()->installEventFilter(this);
2062 else if (currentOccGView->getViewWindow() == NULL)
2064 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2065 currentOccGView->getViewWindow()->installEventFilter(this);
2069 // Create Document from HEXABLOCK ENGINE
2070 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2072 VtkDocumentGraphicView* newGraphicView;
2073 //One document at a time
2074 if (currentDocGView != NULL)
2076 if (currentDocGView->getViewWindow() == NULL)
2078 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2079 currentDocGView->getViewWindow()->installEventFilter(this);
2082 // Create a new document with the current window
2083 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2084 new DocumentModel( docEntry_Doc.second,
2085 docEntry_Doc.first, this ),
2086 currentDocGView->getViewWindow(),
2087 application()->desktop() );
2091 // Create the new Document Graphic View with a new window
2092 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2093 new DocumentModel( docEntry_Doc.second,
2094 docEntry_Doc.first, this ),
2095 graphicViewsHandler->createVtkWindow(),
2096 application()->desktop() );
2097 newGraphicView->getViewWindow()->installEventFilter(this);
2100 if (newGraphicView == NULL)
2101 //We couldn't create a new document graphic view
2102 //we'd better show a dialog box info to inform the user
2105 docs[docEntry_Doc.first] = newGraphicView;
2106 switchModel(newGraphicView); //select the corresponding document in the browser instead
2108 getApp()->updateObjectBrowser();
2113 //Loads the model from the xmlFile in the current graphic view
2114 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2116 DEBTRACE("HEXABLOCKGUI::loadDocument");
2119 QMainWindow *aParent = application()->desktop();
2120 QString selectedFile;
2122 if ( inFile.isNull() ){
2123 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2124 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2125 dialog.setHistory( getQuickDirList() );
2127 //use the last path as default
2128 if (!(loadDocLastPath->absolutePath()).isEmpty())
2129 dialog.setDirectory(*loadDocLastPath);
2132 QStringList selectedFiles = dialog.selectedFiles();
2133 if (!selectedFiles.isEmpty())
2134 selectedFile = selectedFiles.first();
2136 //remember the selected path
2137 *loadDocLastPath = dialog.directory();
2140 selectedFile = inFile;
2142 if (selectedFile.isEmpty())
2145 //we create a new document if necessary
2146 if (currentDocGView == NULL)
2147 //Need a new document
2149 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2151 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2152 currentDocGView->getViewWindow()->installEventFilter(this);
2155 if (!currentDocGView->isEmpty())
2156 //we can only have one document for a graphic view
2159 //we load the selected file in the current graphic view
2160 currentDocGView->loadDocument(selectedFile);
2161 DocumentModel* currentModel = getCurrentModel();
2162 renameObject( currentModel->documentEntry(), currentModel->getName() );
2167 void HEXABLOCKGUI::saveDocument()
2169 QMainWindow *aParent = application()->desktop();
2171 QString aDocName = "document", aFilename;
2173 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2174 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2176 //use the last selected directory as default path for file selection
2177 aFilename = saveDocLastPath->absolutePath();
2178 if (!aFilename.isEmpty())
2179 aFilename += QString("/") + aDocName;
2181 //show the dialog for file selection
2182 aFilename = SUIT_FileDlg::getFileName( aParent,
2185 tr( "Save HexaBlock Document" ),
2188 //save the document in the selected file
2189 if ( !aFilename.isEmpty() ) {
2190 getCurrentVtkGraphicView()->saveDocument( aFilename );
2192 //Remember the path for next save
2193 QFileInfo fileInfo(aFilename);
2194 *saveDocLastPath = fileInfo.dir();
2200 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2202 _patternDataTreeView->openPersistentEditor( topLeft );
2205 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2207 if (diag == NULL || _dwInputPanel == NULL ||
2208 getCurrentVtkGraphicView() == NULL) return;
2210 //mark this dialog as used by the current model
2211 currentModelDialogs.insert(diag);
2213 //close the current dialog box info
2214 if (_treeViewDelegate != NULL)
2215 _treeViewDelegate->closeDialog();
2217 if (_dwInputPanel->widget())
2218 _dwInputPanel->widget()->close();
2220 //Temporary for debugging EdgeAssoc Faked InfoDialog
2221 if (diag == _edgeAssocDiag)
2222 diag->debugEdgeAssoc = true;
2224 diag->debugEdgeAssoc = false;
2226 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2227 diag == _quadAssocDiag || diag == _addShapeDiag)
2228 assocInProgress = true;
2230 assocInProgress = false;
2232 //show the dialog box in the dockwidget
2233 diag->resetSizeAndShow(_dwInputPanel);
2235 //clear the current selections
2236 selectionMgr()->clearSelected();
2238 currentDialog = diag;
2242 void HEXABLOCKGUI::addVertex()
2244 if ( !_vertexDiag ){
2245 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2247 _showDialogBox( _vertexDiag );
2250 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2251 if (_vertexDiag != NULL && doc != NULL)
2252 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2255 void HEXABLOCKGUI::addEdge()
2258 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2260 _showDialogBox( _edgeDiag );
2263 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2264 if (_edgeDiag != NULL && doc != NULL)
2265 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2268 void HEXABLOCKGUI::addQuad()
2271 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2274 _showDialogBox( _quadDiag );
2277 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2278 if (_quadDiag != NULL && doc != NULL)
2279 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2282 void HEXABLOCKGUI::addHexa()
2285 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2287 _showDialogBox( _hexaDiag );
2290 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2291 if (_hexaDiag != NULL && doc != NULL)
2292 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2295 void HEXABLOCKGUI::addVector()
2297 if ( !_vectorDiag ){
2298 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2300 _showDialogBox( _vectorDiag );
2303 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2304 if (_vectorDiag != NULL && doc != NULL)
2305 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2308 void HEXABLOCKGUI::addCylinder()
2310 if ( !_cylinderDiag ){
2311 _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2313 _showDialogBox( _cylinderDiag );
2316 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2317 if (_cylinderDiag != NULL && doc != NULL)
2318 _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2322 void HEXABLOCKGUI::addPipe()
2325 _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2327 _showDialogBox( _pipeDiag );
2330 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2331 if (_pipeDiag != NULL && doc != NULL)
2332 _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2336 void HEXABLOCKGUI::makeGrid()
2338 if ( !_makeGridDiag ){
2339 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2341 _showDialogBox( _makeGridDiag );
2345 void HEXABLOCKGUI::makeCylinder()
2347 if ( !_makeCylinderDiag ){
2348 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2350 _showDialogBox( _makeCylinderDiag );
2353 void HEXABLOCKGUI::makePipe()
2355 if ( !_makePipeDiag ){
2356 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2358 _showDialogBox( _makePipeDiag );
2361 void HEXABLOCKGUI::makeCylinders()
2363 if ( !_makeCylindersDiag ){
2364 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2366 _showDialogBox( _makeCylindersDiag );
2369 void HEXABLOCKGUI::makePipes()
2371 if ( !_makePipesDiag ){
2372 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2374 _showDialogBox( _makePipesDiag );
2378 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2380 if ( !_makeHemiSphereDiag ){
2381 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2383 _showDialogBox( _makeHemiSphereDiag );
2387 void HEXABLOCKGUI::removeHexa()
2389 if ( !_removeHexaDiag ){
2390 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2392 _showDialogBox( _removeHexaDiag );
2396 void HEXABLOCKGUI::prismQuad()
2398 if ( !_prismQuadDiag ){
2399 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2401 _showDialogBox( _prismQuadDiag );
2405 void HEXABLOCKGUI::joinQuad()
2407 if ( !_joinQuadDiag ){
2408 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2410 _showDialogBox( _joinQuadDiag );
2413 void HEXABLOCKGUI::merge()
2416 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2418 _showDialogBox( _mergeDiag );
2421 void HEXABLOCKGUI::disconnectElts()
2423 if ( !_disconnectDiag ){
2424 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2426 _showDialogBox( _disconnectDiag );
2429 void HEXABLOCKGUI::cutEdge()
2431 if ( !_cutEdgeDiag ){
2432 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2434 _showDialogBox( _cutEdgeDiag );
2437 void HEXABLOCKGUI::makeTransformation()
2439 if ( !_makeTransformationDiag ){
2440 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2442 _showDialogBox( _makeTransformationDiag );
2446 void HEXABLOCKGUI::makeSymmetry()
2448 if ( !_makeSymmetryDiag ){
2449 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2451 _showDialogBox( _makeSymmetryDiag );
2455 void HEXABLOCKGUI::performTransformation()
2457 if ( !_performTransformationDiag ){
2458 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2460 _showDialogBox( _performTransformationDiag );
2464 void HEXABLOCKGUI::performSymmetry()
2466 if ( !_performSymmetryDiag ){
2467 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2469 _showDialogBox( _performSymmetryDiag );
2473 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2475 if ( !_replaceHexaDiag ){
2476 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2478 _showDialogBox( _replaceHexaDiag );
2482 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2484 if ( !_quadRevolutionDiag ){
2485 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2487 _showDialogBox( _quadRevolutionDiag );
2491 void HEXABLOCKGUI::assocVertex()
2493 if (!_dwInputPanel) return;
2494 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2495 if ( !_vertexAssocDiag )
2496 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2497 _showDialogBox( _vertexAssocDiag );
2501 void HEXABLOCKGUI::assocEdge()
2503 if ( !_edgeAssocDiag )
2504 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2505 _showDialogBox( _edgeAssocDiag );
2508 void HEXABLOCKGUI::assocQuad()
2510 if ( !_quadAssocDiag )
2511 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2512 _showDialogBox( _quadAssocDiag );
2516 void HEXABLOCKGUI::addGroup()
2519 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2521 _showDialogBox( _groupDiag );
2522 if (_groupDiag != NULL && getCurrentModel() != NULL)
2524 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2525 if (doc == NULL) return;
2526 char defaultName[16];
2527 sprintf (defaultName, "g%04d", doc->countGroup());
2528 _groupDiag->name_le->setText(defaultName);
2532 void HEXABLOCKGUI::removeGroup()
2534 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2535 if (currentDGView == NULL) return;
2537 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2538 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2539 int nbGroupsRemoved = 0;
2542 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2543 tr( "No group selected!" ) );
2547 foreach( QModelIndex selected, l ){
2548 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2549 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2550 Q_ASSERT(selected.isValid());
2552 //Confirm the deletion of the group
2553 if (SUIT_MessageBox::question(
2556 tr("Remove group : %1 ?").arg(selected.data().toString()),
2557 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2558 SUIT_MessageBox::Cancel
2559 ) == SUIT_MessageBox::Cancel) return;
2561 bool removed = getCurrentModel()->removeGroup( selected );
2563 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2564 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2570 if (!nbGroupsRemoved)
2571 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2572 tr( "No group selected!" ) );
2575 void HEXABLOCKGUI::addLaw()
2578 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2580 _showDialogBox( _lawDiag );
2581 if (_lawDiag != NULL && getCurrentModel() != NULL)
2583 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2584 if (doc == NULL) return;
2585 char defaultName[16];
2586 sprintf (defaultName, "l%04d", doc->countLaw());
2587 _lawDiag->name_le->setText(defaultName);
2591 void HEXABLOCKGUI::removeLaw()
2593 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2594 if (currentDGView == NULL) return;
2596 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2597 int nbLawsRemoved = 0;
2600 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2601 tr( "No law selected!" ) );
2605 foreach( QModelIndex selected, l ){
2606 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2607 selected = currentDGView->getMeshModel()->mapToSource( selected );
2608 Q_ASSERT(selected.isValid());
2610 //Confirm the deletion of the law
2611 if (SUIT_MessageBox::question(
2614 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2615 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2616 SUIT_MessageBox::Cancel
2617 ) == SUIT_MessageBox::Cancel) return;
2619 bool removed = getCurrentModel()->removeLaw(selected);
2621 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2622 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2629 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2630 tr( "No law selected!" ) );
2635 void HEXABLOCKGUI::setPropagation()
2637 if ( !_propagationDiag ){
2638 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2640 _showDialogBox( _propagationDiag );
2643 // Dialog box to compute a mesh from a document
2644 // --------------------------------------------
2645 void HEXABLOCKGUI::computeMesh()
2647 if ( !_computeMeshDiag ){
2648 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2650 _computeMeshDiag->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
2651 _showDialogBox( _computeMeshDiag );
2654 void HEXABLOCKGUI::clearAssociations()
2656 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2657 if (currentDGView == NULL) return;
2659 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2660 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2661 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2663 getCurrentModel()->clearEltAssociations(iModel);
2665 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2668 void HEXABLOCKGUI::showModelInfo()
2670 //create the info dialog if not yet
2671 if (_modelInfoDiag == NULL)
2672 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2674 //show the model informations dialog
2675 _showDialogBox( _modelInfoDiag );
2678 void HEXABLOCKGUI::addShape()
2680 //create the info dialog if not yet
2681 if (_addShapeDiag == NULL)
2682 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2684 //show the model informations dialog
2685 _showDialogBox( _addShapeDiag );
2688 void HEXABLOCKGUI::clearAllAssociations()
2690 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2691 if (currentDGView == NULL) return;
2693 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2694 if (!currentIndex.isValid()) return;
2695 QVariant currentAssocVariant;
2696 QString currentAssocEntry;
2698 //Confirm the deletion of the associations
2699 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2700 if ( !treeVariant.isValid() ) return;
2701 int eltType = treeVariant.toInt();
2702 QString typeStr = "";
2703 HEXA_NS::EnumElt hexaType;
2704 if (eltType == VERTEX_DIR_TREE)
2706 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2707 hexaType = HEXA_NS::EL_VERTEX;
2709 else if (eltType == EDGE_DIR_TREE)
2711 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2712 hexaType = HEXA_NS::EL_EDGE;
2714 else if (eltType == QUAD_DIR_TREE)
2716 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2717 hexaType = HEXA_NS::EL_QUAD;
2720 if (SUIT_MessageBox::question(
2722 tr("CLEAR_ASSOCIATIONS"),
2723 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2724 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2725 SUIT_MessageBox::Cancel
2726 ) == SUIT_MessageBox::Cancel) return;
2729 DocumentModel* docModel = getCurrentModel();
2730 if (docModel == NULL) return;
2731 docModel->clearAssociation(hexaType);
2734 void HEXABLOCKGUI::showAssociations()
2736 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2737 if (currentDGView == NULL) return;
2739 QModelIndexList elts;
2740 int currentChildIndex = 0;
2741 QVariant currentAssocVariant;
2742 QString currentAssocEntry;
2743 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2744 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2746 while( currentChild.isValid() ) {
2748 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2749 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2750 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2751 elts << currentChild;
2753 currentChild = currentChild.sibling(currentChildIndex++, 0);
2755 currentDocGView->highlight(elts);
2756 currentOccGView->highlight(elts, false);
2760 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2762 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2764 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2769 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2771 if ( event->type() == QEvent::Enter )
2772 { // *** ENTER EVENT
2774 if (currentDialog == NULL || !currentDialog->isVisible())
2775 return QObject::eventFilter(obj, event);
2777 // ** The window acquire the focus when the cursor enter
2779 //OCC - window enter
2780 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2781 if ( occWindow != NULL)
2782 currentDialog->onWindowActivated(occWindow->getViewManager());
2784 //VTK - window enter
2786 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2787 if ( vtkWindow != NULL)
2788 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2792 //standard event processing
2793 return QObject::eventFilter(obj, event);
2796 QStringList HEXABLOCKGUI::getQuickDirList()
2798 QStringList dirList;
2799 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2801 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2807 // --- Export the module
2811 HEXABLOCKGUI_EXPORT CAM_Module* createModule()
2813 return new HEXABLOCKGUI();
2816 HEXABLOCKGUI_EXPORT char* getModuleVersion()
2818 return (char*)HEXABLOCK_VERSION_STR;
2824 // ******************** TESTS ***************************************************
2826 void HEXABLOCKGUI::testDocument()
2830 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2831 // QStandardItem *myItem = new QStandardItem("MyItem");
2832 // parentItem->appendRow(myItem);
2834 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2835 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2836 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2837 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2838 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2839 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2840 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2841 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2844 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2845 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2846 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2847 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2848 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2849 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2851 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2852 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2853 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2854 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2859 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2860 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2861 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2862 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2870 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2871 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2873 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2874 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2878 // newMesh( "toto", 3, "FactoryServer");
2882 void HEXABLOCKGUI::test_make_cart_grid()
2884 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2885 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2886 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2887 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2888 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
2889 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
2891 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
2892 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
2899 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
2900 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
2901 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
2902 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
2903 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
2904 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
2909 void HEXABLOCKGUI::test_make_elmts_transform()
2916 QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
2917 QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
2920 QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
2921 // orig.setScalar(2);
2923 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
2924 // getCurrentModel()->saveVtk(file_name)
2926 QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
2927 QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
2929 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
2930 // getCurrentModel()->saveVtk(file_name)
2932 QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
2935 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
2936 // getCurrentModel()->saveVtk(file_name);
2939 // print "...test make elements by transforming elements OK"
2941 // =============================================================== addDocInSudy
2942 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
2946 if (document == NULL)
2949 QString docName = document->getName ();
2951 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
2952 if (app_study == NULL)
2955 _PTR(Study) study = app_study->studyDS();
2956 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
2957 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
2958 QString entry = app_study->centry("HEXABLOCK");
2959 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
2960 if (aFatherSO->_is_nil())
2963 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
2966 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
2967 docEntry = aSO->GetID(); //the entry of the published object
2972 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
2974 void HEXABLOCKGUI::test()
2976 DEBTRACE("HEXABLOCKGUI::test");
2977 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2978 if (currentDGView == NULL) return;
2979 currentDGView->update();
2983 void HEXABLOCKGUI::test_association()
2985 DEBTRACE("HEXABLOCKGUI::test_association");
2988 QModelIndex v0, v1, v2, v3, e0, e1, q0;
2990 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
2991 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
2992 DocumentModel::GeomObj q0AssocA, q0AssocB;
2994 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
2995 QList<DocumentModel::GeomObj> e1Assocs_test;
2996 DocumentModel::GeomObj q0Assoc_test;
2998 v0 = getCurrentModel()->addVertex(0, 0, 0);
2999 v1 = getCurrentModel()->addVertex(1, 0, 0);
3000 v2 = getCurrentModel()->addVertex(1, 1, 0);
3001 v3 = getCurrentModel()->addVertex(0, 1, 0);
3002 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3003 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3004 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3007 // >>> face3.GetEntry()'0:1:4'
3008 // >>> e1.GetEntry()'0:1:8'
3009 // >>> e2.GetEntry()'0:1:9'
3010 // >>> e3.GetEntry()'0:1:10'
3011 // >>> e4.GetEntry()'0:1:11'
3012 // >>> v1.GetEntry()'0:1:12'
3013 // >>> v2.GetEntry()'0:1:13'
3014 // >>> v3.GetEntry()'0:1:14'
3015 // >>> v4.GetEntry()'0:1:15'
3018 // v0Assoc.name = "geomV0";
3019 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3020 // v0Assoc.brep = "brepV0";
3021 // v1Assoc.name = "geomV1";
3022 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3023 // v1Assoc.brep = "brepV1";
3024 // v2Assoc.name = "geomV2";
3025 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3026 // v2Assoc.brep = "brepV2";
3027 // v3Assoc.name = "geomV3";
3028 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3029 // v3Assoc.brep = "brepV3";
3033 // e0AssocA.name = "geomE0a";
3034 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3035 // e0AssocA.brep = "brepE0a";
3036 // e0AssocA.start = 0.10;
3037 // e0AssocA.end = 0.95;
3041 // e1AssocA.name = "geomE1a";
3042 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3043 // e1AssocA.brep = "brepE1a";
3044 // e1AssocA.start = 0.12;
3045 // e1AssocA.end = 0.89;
3046 // e1AssocB.name = "geomE1b";
3047 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3048 // e1AssocB.brep = "brepE1b";
3049 // e1AssocB.start = 0.20;
3050 // e1AssocB.end = 0.80;
3051 // e1AssocC.name = "geomE1c";
3052 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3053 // e1AssocC.brep = "brepE1c";
3054 // e1AssocC.start = 0.16;
3055 // e1AssocC.end = 0.96;
3057 // q0AssocA.name = "geomQuad";
3058 // q0AssocA.entry = "0:1:1:1:3";
3059 // q0AssocA.brep = "brepq0";
3061 // q0AssocB.name = "geomQuad";
3062 // q0AssocB.entry = "0:1:1:1:4";
3063 // q0AssocB.brep = "brepq0";
3065 // getCurrentModel()->addAssociation( v0, v0Assoc );
3066 // getCurrentModel()->addAssociation( v1, v1Assoc );
3067 // getCurrentModel()->addAssociation( v2, v2Assoc );
3068 // getCurrentModel()->addAssociation( v3, v3Assoc );
3071 // getCurrentModel()->addAssociation( e0, e0AssocA );
3073 // getCurrentModel()->addAssociation( e1, e1AssocA );
3074 // getCurrentModel()->addAssociation( e1, e1AssocB );
3075 // getCurrentModel()->addAssociation( e1, e1AssocC );
3077 // getCurrentModel()->addAssociation( q0, q0AssocA );
3078 // getCurrentModel()->addAssociation( q0, q0AssocB );
3084 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3085 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3086 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3087 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3088 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3089 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3090 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3091 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3092 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3093 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3094 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3095 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3098 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3099 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3100 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3101 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3102 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3103 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3104 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3105 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3106 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3107 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3108 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3109 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3110 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3112 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3113 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3114 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3117 DEBTRACE("HEXABLOCKGUI::test_association fin");