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() );
258 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
260 DEBTRACE("HEXABLOCKGUI::activateModule");
262 /*HexaBlock can be launched in only one application*/
263 if (myApplication == NULL)
264 //remember the first application
265 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
267 //application verification: if it's not the one known by HexaBlock,
268 //leave without activating
269 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
270 if (myApplication != currentApplication) return false;
272 bool bOk = SalomeApp_Module::activateModule( theStudy );
273 if ( !bOk ) return false;
275 showDockWidgets(true);
277 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
278 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
279 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
280 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
282 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
284 SUIT_ViewManager* vm;
285 ViewManagerList OCCViewManagers, VTKViewManagers;
287 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
288 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
289 while ( itOCC.hasNext() && (vm = itOCC.next()) )
290 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
292 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
293 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
294 while ( itVTK.hasNext() && (vm = itVTK.next()) )
295 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
298 SALOME_ListIO selected;
299 sm->selectedObjects( selected );
302 // disable OCC selectors
303 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
304 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
305 while ( itOCCSel.hasNext() )
306 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
307 sr->setEnabled(true);
309 // disable VTK selectors
310 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
311 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
312 while ( itVTKSel.hasNext() )
313 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
314 sr->setEnabled(true);
316 sm->setSelectedObjects( selected, true ); //NPAL 19674
318 //connect close signal to vtk view manager
319 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
322 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
323 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
326 //connect close signal to occ view manager
327 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
330 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
331 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
334 /* ************************************ TODO Hexa6
335 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
336 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
337 if ( _PTR(Study) aStudy = s->studyDS()) {
338 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
339 updateObjBrowser(); // objects can be removed
341 ************************************ */
343 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
344 currentOccGView->getViewWindow()->installEventFilter(this);
346 if (currentDocGView != NULL)
348 switchModel(currentDocGView);
351 if (currentDocGView->getViewWindow() != NULL)
352 currentDocGView->getViewWindow()->installEventFilter(this);
361 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
363 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
364 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
365 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
366 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
368 // if ( currentDocGView != NULL && currentDocGView->getViewWindow() != NULL )
370 // //default selectionMode in VTKView
371 //// currentDocGView->getViewWindow()->SetSelectionMode( ActorSelection );
372 // currentDocGView->getViewWindow()->close();
375 // if (currentOccGView != NULL)
377 // //defaut selectionMode in OccView
378 //// selectionMgr()->clearSelected();
379 //// currentOccGView->globalSelection();
380 //// currentOccGView->localSelection(TopAbs_SHAPE);
381 // if (currentOccGView->getViewWindow() != NULL)
382 // currentOccGView->getViewWindow()->close();
385 qDeleteAll(myOCCSelectors);
386 myOCCSelectors.clear();
387 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
389 qDeleteAll(myVTKSelectors);
390 myVTKSelectors.clear();
391 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
393 //Must be done for all views later
394 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
395 // currentOccGView->getViewWindow()->removeEventFilter(this);
396 currentOccGView->getViewWindow()->close();
398 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
399 // currentDocGView->getViewWindow()->removeEventFilter(this);
400 currentDocGView->getViewWindow()->close();
402 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
404 //switch off current document graphic view
405 switchOffGraphicView(currentDocGView);
408 setMenuShown( false );
409 setToolShown( false );
410 showDockWidgets( false );
412 _dwInputPanel->close();
419 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
421 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
422 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
423 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
424 int aStudyID = theStudy->StudyId();
425 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
426 return aDSStudy._retn();
429 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
430 QMap<QString, QString>& docShapesEntry,
431 QMap<QString, QString>& docShapesName)
433 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
434 return; //there's nothing to publish in this case
436 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
437 if(!appStudy) return;
438 _PTR(Study) aStudy = appStudy->studyDS();
439 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
440 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
441 QString entry = currentDocGView->getDocumentModel()->documentEntry();
442 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
443 if (aFatherSO->_is_nil())
446 // * get a presentation
447 bool isNewPrs = false;
448 SOCC_Prs* prs = getOccPrs(currentDocGView);
451 prs = new SOCC_Prs();
455 // * init the presentation with the given shapes
456 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
457 while (i != topo_shapes.constEnd())
459 QString shapeName = i.key();
460 TopoDS_Shape shapeValue = i.value();
461 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
462 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
463 QString objStudyEntry = aSO->GetID(); //the entry of the published object
464 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
465 "HEXABLOCK", shapeName.toStdString().c_str());
466 ais_shape->SetOwner(io);
467 prs->AddObject(ais_shape);
468 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
469 docShapesEntry[shapeName] = objStudyEntry;
470 docShapesName[objStudyEntry] = shapeName;
471 currentOccGView->addShape(objStudyEntry, ais_shape);
472 i++; //handle next shape
476 prs->AddObject(currentOccGView->getPreviewShape());
478 occPrs[currentDocGView] = prs;
479 getApp()->updateObjectBrowser();
484 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
486 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
487 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
488 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
490 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
494 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
498 // Pas de renommage des shapes pour le moment, juste les documents
499 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
500 if (dgview == NULL || dgview->getDocumentModel() == NULL)
503 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
504 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
509 _PTR(Study) aStudy = appStudy->studyDS();
514 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
515 _PTR(GenericAttribute) anAttr;
517 if ( obj->FindAttribute(anAttr, "AttributeName") ){
518 _PTR(AttributeName) aName (anAttr);
519 DocumentModel* docModel = dgview->getDocumentModel();
520 docModel->setName( name );
521 aName->SetValue( name.toLatin1().data() );
522 getApp()->updateObjectBrowser();
523 _dwPattern->setWindowTitle( name );
530 // --- Default windows
531 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
533 DEBTRACE("HEXABLOCKGUI::windows");
535 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
536 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
539 QString HEXABLOCKGUI::engineIOR() const
541 DEBTRACE("HEXABLOCKGUI::engineIOR");
543 /* ************************************ TODO Hexa6
544 CORBA::ORB_var anORB = getApp()->orb();
545 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
546 return QString( anIOR.in() );
547 ************************************ */
551 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
553 if (docs.count(studyObject->entry()) == 0)
555 //Object's document not acquired yet
556 VtkDocumentGraphicView* dgview;
557 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
558 if (directory == NULL)
559 return NULL; //No working director found
561 //------------------ Load the document -----------------
562 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
563 if (document == NULL)
564 return NULL; //No document found
566 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
568 MESSAGE("Doc model creation failed!");
571 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
572 if (dgview == NULL) return NULL;
574 //update the data tree
575 docs[studyObject->entry()] = dgview;
578 return docs[studyObject->entry()];
581 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
583 // ** we want to switch automatically to the right view windows
585 MESSAGE("===============> ON OBJECT BROWSER CLICKED!!!!!!! ");
586 //first, find selected item
588 DataObjectList dol = getApp()->objectBrowser()->getSelected();
589 if (dol.isEmpty()) return;
590 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
591 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
592 item->entry().isEmpty())
595 // find the document corresponding to it
596 VtkDocumentGraphicView* docGView = NULL;
597 if (docs.contains(item->entry()))
598 docGView = docs[item->entry()];
600 docGView = getOrCreateDocument(item);
602 if (docGView == NULL || docGView == currentDocGView)
605 //Init OCC if necessary
606 if (currentOccGView == NULL)
608 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
609 currentOccGView->getViewWindow()->installEventFilter(this);
611 else if (currentOccGView->getViewWindow() == NULL)
613 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
614 currentOccGView->getViewWindow()->installEventFilter(this);
617 //Init the vtk view if necessary
618 if (docGView->getViewWindow() == NULL)
620 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
622 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
623 docGView->getViewWindow()->installEventFilter(this);
626 docGView->setViewWindow(currentDocGView->getViewWindow());
628 if (docGView->getDocumentActor() == NULL)
632 //update the current document
633 switchModel(docGView);
637 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
639 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
642 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
644 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
646 //Decharger le model correspondant (VTK)
647 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
652 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
653 { //HexaBlock Vtk Window has been closed
655 if (currentDialog != NULL) currentDialog->close();
656 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
657 if (currentDocGView != NULL)
658 currentDocGView->setViewWindow(NULL);
665 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
666 if (dgview == NULL) return; //The window has no document to close
668 //Save the document? (Ask only if the document is not empty
669 int answerCode = SUIT_MessageBox::question(
672 tr("Save the document ?"),
673 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
674 SUIT_MessageBox::Cancel);
675 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
676 else if (answerCode == SUIT_MessageBox::Yes)
677 saveDocument(); //Save the document
679 // switchOffGraphicView(window); //disconnect all connected signals
680 // currentVtkView = NULL;
681 // graphicViewsHandler->closeDocumentGraphicView(window);
683 //create a new one (empty document)
685 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
689 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
691 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
692 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
693 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
694 if (currentDialog != NULL) currentDialog->close();
695 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
697 currentOccGView->getViewWindow()->removeEventFilter(this);
698 currentOccGView->setViewWindow(NULL);
702 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
704 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
706 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
707 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
709 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
711 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
712 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
713 // disable OCC selectors
714 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
715 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
716 while ( itOCCSel.hasNext() )
717 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
718 sr->setEnabled(true);
720 else if ( vm->getType() == SVTK_Viewer::Type() )
722 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
723 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
725 // disable VTK selectors
726 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
727 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
728 while ( itVTKSel.hasNext() )
729 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
730 sr->setEnabled(true);
734 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
736 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
738 SUIT_ViewModel* viewer = vm->getViewModel();
739 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
741 //VTK View Manager removed
742 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
744 //Process only if it's our view manager
745 SUIT_ViewManager* myVm = NULL;
746 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
747 myVm = currentDocGView->getViewWindow()->getViewManager();
751 //close opened dialog
752 if (currentDialog != NULL) currentDialog->close();
753 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
759 //remove its selector
760 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
761 while ( itVTKSel.hasNext() )
762 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
763 if ( sr->viewer() == viewer )
765 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
772 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
774 //OCC View removed: remove its selector
775 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
776 while ( itOCCSel.hasNext() )
777 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
778 if ( sr->viewer() == viewer )
780 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
786 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
788 QModelIndexList l = selected.indexes();
789 if ( l.count() == 0 ) return;
790 if ( !l[0].isValid() ) return;
791 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
792 if ( currentGraphicView == NULL) return;
794 QTreeView* theTree = NULL;
795 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
796 theTree = _patternDataTreeView;
797 } else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
798 theTree = _patternBuilderTreeView;
799 } else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
800 theTree = _patternGeomTreeView;
802 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
803 theTree = _groupsTreeView;
804 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
805 theTree = _meshTreeView;
808 theTree->scrollTo ( l[0] );
812 bool HEXABLOCKGUI::createSComponent() //addComponent
814 DEBTRACE("HEXABLOCKGUI::createSComponent");
815 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
817 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
818 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
819 _PTR(GenericAttribute) anAttr;
820 _PTR(AttributeName) aName;
821 _PTR(AttributeGraphic) aGraphic;
823 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
824 if ( !aComponent ){ //Create hexablock component if there's not one yet
825 aComponent = aBuilder->NewComponent("HEXABLOCK");
826 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
827 aName = _PTR(AttributeName) (anAttr);
828 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
830 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
831 _PTR(AttributePixMap) aPixmap(anAttr);
832 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
834 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
835 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
841 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
843 DEBTRACE("HEXABLOCKGUI::setResource");
844 _myresource = new HEXABLOCKGUI_Resource(r);
845 _myresource->preferencesChanged();
848 void HEXABLOCKGUI::createPreferences()
850 DEBTRACE("HEXABLOCKGUI::createPreferences");
851 _myresource->createPreferences(this);
854 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
856 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
857 _myresource->preferencesChanged(sect, name);
858 // if(name=="userCatalog")
859 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
862 void HEXABLOCKGUI::studyActivated() //CS_TODO
864 int newStudyId = getApp()->activeStudy()->id();
865 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
866 // if (_oldStudyId != -1)
868 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
869 // if (_studyContextMap.count(newStudyId))
871 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
872 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
876 // DEBTRACE("no switch to null context");
879 _oldStudyId = newStudyId;
882 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
884 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
885 QVariant currentAssocVariant;
886 QString currentAssocEntry;
888 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
889 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
890 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
891 QMenu menu( _patternDataTreeView );
893 QAction *clearAct = menu.addAction( "Remove association(s)" );
894 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
895 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
899 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
900 if (currentVtkGraphicView == NULL) return;
901 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
903 //We don't do anything for single items
904 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
905 item->type() == QUADITEM || item->type() == HEXAITEM)
908 //No associations for HEXA
909 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
910 if ( !treeVariant.isValid() ) return;
911 int eltType = treeVariant.toInt();
912 if (eltType == HEXA_DIR_TREE) return;
913 QMenu menu( _patternDataTreeView );
915 //Show association(s)
916 QAction *showAssocAct = menu.addAction( "Show associations" );
917 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
919 //Clear all associations
920 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
921 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
923 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
928 void HEXABLOCKGUI::createAndFillDockWidget()
930 QMainWindow *aParent = application()->desktop();
932 // Create dock widget (3 dock)
934 //1) *********** user input panel ( contain user's edit dialog box )
935 _dwInputPanel = new QDockWidget(aParent);
936 _dwInputPanel->setVisible(false);
937 _dwInputPanel->setWindowTitle("Input Panel");
938 _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
940 _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
942 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
944 _dwPattern = new QDockWidget(aParent);
945 _dwPattern->setVisible(false);
946 _dwPattern->setWindowTitle("Model");
947 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
949 QFrame* patternFrame = new QFrame(_dwPattern);
950 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
951 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
952 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
953 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
954 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
955 _patternBuilderTreeView = new QTreeView(patternFrame);
956 _patternGeomTreeView = new QTreeView(patternFrame);
957 splitter->addWidget(_patternDataTreeView);
958 splitter->addWidget(_patternBuilderTreeView);
959 splitter->addWidget(_patternGeomTreeView);
960 patternLayout->addWidget(splitter);
962 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers/*QAbstractItemView::DoubleClicked*/);
963 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
964 _patternDataTreeView->setItemDelegate(_treeViewDelegate);
967 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
968 _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
970 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
971 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
973 _dwPattern->setWidget(patternFrame);
974 patternFrame->show();
977 _dwGroups = new QDockWidget(aParent);
979 _dwGroups->setVisible(false);
980 _dwGroups->setWindowTitle("Groups");
981 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
982 _groupsTreeView = new QTreeView(_dwGroups);
983 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
984 _groupsTreeView->setItemDelegate(_treeViewDelegate);
985 _dwGroups->setWidget(_groupsTreeView);
986 _groupsTreeView->show();
989 _dwMesh = new QDockWidget(aParent);
990 _dwMesh->setVisible(false);
991 _dwMesh->setWindowTitle("Mesh");
992 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
993 _meshTreeView = new QTreeView(_dwMesh);
994 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
995 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
996 _meshTreeView->setItemDelegate(_treeViewDelegate);
997 _dwMesh->setWidget(_meshTreeView);
998 _meshTreeView->show();
1000 QDockWidget *_dwObjectBrowser = 0;
1001 QWidget* wid = getApp()->objectBrowser()->treeView();
1002 QWidget *w = wid->parentWidget();
1003 while ( w && !_dwObjectBrowser ) {
1004 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1005 w = w->parentWidget();
1007 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1008 _dwObjectBrowser->setWindowTitle("Study");
1010 // dock widget position
1011 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1012 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1014 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1015 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1016 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1019 #if QT_VERSION >= 0x040500
1020 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1024 // popup menu on data tree view
1025 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1026 connect(_patternDataTreeView,
1027 SIGNAL(customContextMenuRequested(const QPoint &)),
1029 SLOT(treeContextMenu(const QPoint &)),
1030 Qt::UniqueConnection );
1033 void HEXABLOCKGUI::createActions()
1035 QMainWindow *aParent = application()->desktop();
1036 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1039 _newAct = createAction(_menuId++,
1040 tr("Create a new document"),
1041 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1043 tr("Create a new document"),
1044 0, aParent, false, this, SLOT(newDocument()));
1045 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1047 _importAct = createAction(_menuId++,
1048 tr("Load a document"),
1049 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1050 tr("Load Document"),
1051 tr("Load a document"),
1052 0, aParent, false, this, SLOT(loadDocument()));
1053 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1055 _saveAct = createAction(_menuId++,
1056 tr("Save the document"),
1057 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1058 tr("Save Document"),
1059 tr("Save the document"),
1060 0, aParent, false, this, SLOT(saveDocument()));
1062 // Pattern Data creation
1063 _addVertex = createAction(_menuId++,
1064 tr("Create a vertex"),
1065 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1067 tr("Create a new vertex"),
1068 0, aParent, false, this, SLOT(addVertex()));
1070 _addEdge = createAction(_menuId++,
1071 tr("Create an edge"),
1072 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1074 tr("Create a new edge"),
1075 0, aParent, false, this, SLOT(addEdge()));
1077 _addQuad = createAction(_menuId++,
1078 tr("Create a quadrangle"),
1079 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1080 tr("Add Quadrangle"),
1081 tr("Create a new quadrangle"),
1082 0, aParent, false, this, SLOT(addQuad()));
1084 _addHexa = createAction(_menuId++,
1085 tr("Create an hexahedron"),
1086 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1087 tr("Add Hexahedron"),
1088 tr("Create a new hexahedron"),
1089 0, aParent, false, this, SLOT(addHexa()));
1091 // Builder Data creation
1092 _addVector = createAction(_menuId++,
1093 tr("Create a vector"),
1094 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1096 tr("Create a new vector"),
1097 0, aParent, false, this, SLOT(addVector()));
1099 // _addCylinder = createAction(_menuId++,
1100 // tr("Create a cylinder"),
1101 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1102 // tr("Add Cylinder"),
1103 // tr("Create a new cylinder"),
1104 // 0, aParent, false, this, SLOT(addCylinder()));
1106 // _addPipe = createAction(_menuId++,
1107 // tr("Create a pipe"),
1108 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1110 // tr("Create a new pipe"),
1111 // 0, aParent, false, this, SLOT(addPipe()));
1113 _makeGrid = createAction(_menuId++,
1115 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1118 0, aParent, false, this, SLOT(makeGrid()));
1120 _makeCylinder = createAction(_menuId++,
1121 tr("Make a cylinder"),
1122 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1123 tr("Make Cylinder"),
1124 tr("Make a cylinder"),
1125 0, aParent, false, this, SLOT(makeCylinder()));
1127 _makePipe = createAction(_menuId++,
1129 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1132 0, aParent, false, this, SLOT(makePipe()));
1134 _makeCylinders = createAction(_menuId++,
1135 tr("Make cylinders"),
1136 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1137 tr("Make Cylinders"),
1138 tr("Make cylinders"),
1139 0, aParent, false, this, SLOT(makeCylinders()));
1141 _makePipes = createAction(_menuId++,
1143 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1146 0, aParent, false, this, SLOT(makePipes()));
1148 _makeHemiSphere = createAction(_menuId++,
1149 tr("Make an hemisphere"),
1150 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1151 tr("Make Hemisphere"),
1152 tr("Make an hemisphere"),
1153 0, aParent, false, this, SLOT(makeHemiSphere()));
1155 // Pattern Data edition
1156 _removeHexa = createAction(_menuId++,
1157 tr("Remove hexahedra"),
1158 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1159 tr("Remove Hexahedra"),
1160 tr("Remove hexahedra"),
1161 0, aParent, false, this, SLOT(removeHexa()));
1163 _prismQuad = createAction(_menuId++,
1164 tr("Prism quadrangles"),
1165 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1166 tr("Prism Quadrangles"),
1167 tr("Prism quadrangles"),
1168 0, aParent, false, this, SLOT(prismQuad()));
1170 _joinQuad = createAction(_menuId++,
1171 tr("Join quadrangles"),
1172 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1173 tr("Join Quadrangles"),
1174 tr("Join quadrangles with hexahedra"),
1175 0, aParent, false, this, SLOT(joinQuad()));
1177 _merge = createAction(_menuId++,
1179 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1182 0, aParent, false, this, SLOT(merge()));
1184 _disconnect = createAction(_menuId++,
1186 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1188 tr("Disconnect edges, vertexes or quadrangles"),
1189 0, aParent, false, this, SLOT(disconnectElts()));
1191 _cutEdge = createAction(_menuId++,
1193 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1196 0, aParent, false, this, SLOT(cutEdge()));
1198 _makeTransformation = createAction(_menuId++,
1199 tr("Make transformation"),
1200 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1201 tr("Make Transformation"),
1202 tr("Make transformation"),
1203 0, aParent, false, this, SLOT(makeTransformation()));
1205 _makeSymmetry = createAction(_menuId++,
1206 tr("Make symmetry"),
1207 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1208 tr("Make Symmetry"),
1209 tr("Make symmetry"),
1210 0, aParent, false, this, SLOT(makeSymmetry()));
1212 _performTransformation = createAction(_menuId++,
1213 tr("Perform transformation"),
1214 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1215 tr("Perform Transformation"),
1216 tr("Perform transformation"),
1217 0, aParent, false, this, SLOT(performTransformation()));
1219 _performSymmetry = createAction(_menuId++,
1220 tr("Perform symmetry"),
1221 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1222 tr("Perform Symmetry"),
1223 tr("Perform symmetry"),
1224 0, aParent, false, this, SLOT(performSymmetry()));
1226 _replaceHexa = createAction(_menuId++,
1227 tr("Replace hexahedron"),
1228 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1229 tr("Replace Hexahedron"),
1230 tr("Replace hexahedron"),
1231 0, aParent, false, this, SLOT(replaceHexa()));
1233 _quadRevolution = createAction(_menuId++,
1234 tr("Quad revolution"),
1235 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1236 tr("Quad Revolution"),
1237 tr("Quad revolution"),
1238 0, aParent, false, this, SLOT(quadRevolution()));
1241 _assocVertex = createAction(_menuId++,
1242 tr("Make vertex association"),
1243 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1244 tr("Make Vertex association"),
1245 tr("Make vertex association"),
1246 0, aParent, false, this, SLOT(assocVertex()));
1248 _assocEdge = createAction(_menuId++,
1249 tr("Make edge association"),
1250 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1251 tr("Make Edge Association"),
1252 tr("Make edge association"),
1253 0, aParent, false, this, SLOT(assocEdge()));
1255 _assocQuad = createAction(_menuId++,
1256 tr("Make quad association"),
1257 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1258 tr("Make Quad Association"),
1259 tr("Make quad association"),
1260 0, aParent, false, this, SLOT(assocQuad()));
1263 _addGroup = createAction(_menuId++,
1265 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1268 0, aParent, false, this, SLOT(addGroup()));
1270 _removeGroup = createAction(_menuId++,
1271 tr("Remove a group"),
1272 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1274 tr("Remove a group"),
1275 0, aParent, false, this, SLOT(removeGroup()));
1278 _addLaw = createAction(_menuId++,
1280 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1283 0, aParent, false, this, SLOT(addLaw()));
1285 _removeLaw = createAction(_menuId++,
1287 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1290 0, aParent, false, this, SLOT(removeLaw()));
1292 _setPropagation = createAction(_menuId++,
1293 tr("Set propagation"),
1294 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1295 tr("Set Propagation"),
1296 tr("Set propagation"),
1297 0, aParent, false, this, SLOT(setPropagation()));
1299 _computeMesh = createAction(_menuId++,
1301 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1304 0, aParent, false, this, SLOT(computeMesh()));
1306 _showModelInfoAct = createAction(_menuId++,
1307 tr("Show Model Info"),
1308 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1311 0, aParent, false, this, SLOT(showModelInfo()));
1313 _addShapeAct = createAction(_menuId++,
1315 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1318 0, aParent, false, this, SLOT(addShape()));
1320 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1321 // QAction* createAction(const int id,
1322 // const QString& toolTip,
1323 // const QIcon& icon,
1324 // const QString& menu,
1325 // const QString& status,
1326 // const int shortCut,
1327 // QObject* parent =0,
1328 // bool checkable = false,
1329 // QObject* receiver =0,
1330 // const char* member =0);
1332 _sep1 = separator();
1333 _sep2 = separator();
1334 _sep3 = separator();
1335 _sep4 = separator();
1339 void HEXABLOCKGUI::createMenus()
1341 int aMenuId, subMenuId,aMenuIdMain;
1343 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1345 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1346 createMenu( actionId(_newAct), aMenuId );
1347 createMenu( actionId(_importAct), aMenuId );
1348 createMenu( _saveAct, aMenuId );
1351 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1352 createMenu( _newAct, aMenuDocId );//, 10
1353 createMenu( _importAct, aMenuDocId );
1354 createMenu( _saveAct, aMenuDocId );
1356 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1357 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1358 createMenu( _addVertex, subMenuId );
1359 createMenu( _addEdge, subMenuId );
1360 createMenu( _addQuad, subMenuId );
1361 createMenu( _addHexa, subMenuId );
1362 createMenu( _sep1, subMenuId);
1365 createMenu( _addVector, subMenuId );
1366 // createMenu( _addCylinder, subMenuId );
1367 // createMenu( _addPipe, subMenuId );
1369 createMenu( _sep2, subMenuId);
1371 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1372 createMenu( _makeHemiSphere,subMenuId );
1374 createMenu( _sep3, subMenuId);
1376 createMenu( _makeCylinder, subMenuId );
1377 createMenu( _makePipe, subMenuId );
1378 createMenu( _makeCylinders,subMenuId );
1379 createMenu( _makePipes, subMenuId );
1381 // Pattern Data Edition
1382 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1383 createMenu( _removeHexa, subMenuId );
1384 createMenu( _prismQuad, subMenuId );
1385 createMenu( _joinQuad, subMenuId );
1386 createMenu( _merge, subMenuId );
1387 createMenu( _disconnect, subMenuId );
1388 createMenu( _cutEdge, subMenuId );
1389 createMenu( _makeTransformation, subMenuId );
1390 createMenu( _makeSymmetry, subMenuId );
1391 createMenu( _performTransformation, subMenuId );
1392 createMenu( _performSymmetry, subMenuId );
1393 createMenu( _replaceHexa, subMenuId );
1394 createMenu( _quadRevolution, subMenuId );
1395 createMenu( _sep4, aMenuId );
1396 createMenu( _showModelInfoAct, aMenuId );
1399 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1400 createMenu( _addShapeAct, aMenuId );
1401 createMenu( _assocVertex, aMenuId );
1402 createMenu( _assocEdge, aMenuId );
1403 createMenu( _assocQuad, aMenuId );
1406 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1407 createMenu( _addGroup, aMenuId );
1408 createMenu( _removeGroup, aMenuId ); //CS_TODO
1411 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1412 createMenu( _addLaw, aMenuId );
1413 createMenu( _removeLaw, aMenuId );
1414 createMenu( _setPropagation, aMenuId );
1415 createMenu( _computeMesh, aMenuId );
1417 //show model infomation menu
1418 QString aRule = "$component={'HEXABLOCK'}";
1419 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1420 popupMgr()->setRule( _showModelInfoAct, aRule);
1422 //associate shape to a document menu
1423 popupMgr()->insert( _addShapeAct, -1, -1 );
1424 popupMgr()->setRule( _addShapeAct, aRule );
1426 //-------------------------------------------------
1428 //-------------------------------------------------
1429 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1430 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1431 // QString isNotEmpty("numberOfNodes <> 0");
1432 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1433 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1434 //// aType = aType.arg( mesh_part );
1436 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1437 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1438 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1440 // popupMgr()->insert( separator(), -1, -1 );
1441 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1442 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1443 // // MESSAGE("aClient = " << aClient.toStdString());
1444 // // MESSAGE("aType = " << aType.toStdString());
1445 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1446 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1447 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1448 // // MESSAGE("aRule = " << aRule.toStdString());
1449 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1450 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1452 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1453 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1455 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1456 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1458 // popupMgr()->insert( separator(), -1, -1 );
1462 void HEXABLOCKGUI::createTools()
1466 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1467 createTool( _newAct, aToolId );
1468 createTool( _importAct, aToolId );
1469 createTool( _saveAct, aToolId );
1470 createTool( _showModelInfoAct, aToolId );
1471 // createTool( _testAct, aToolId );
1472 //createTool( separator(), aToolId );
1475 aToolId = createTool ( tr( "Construction" ) );
1476 createTool( _addVertex, aToolId );
1477 createTool( _addEdge, aToolId );
1478 createTool( _addQuad, aToolId );
1479 createTool( _addHexa, aToolId );
1481 createTool( _sep1, aToolId );
1484 createTool( _addVector, aToolId );
1485 // createTool( _addCylinder, aToolId );
1486 // createTool( _addPipe, aToolId );
1488 createTool( _sep2, aToolId );
1490 createTool( _makeGrid, aToolId );
1491 createTool( _makeHemiSphere, aToolId );
1493 createTool( _sep3, aToolId );
1495 createTool( _makeCylinder, aToolId );
1496 createTool( _makePipe, aToolId );
1497 createTool( _makeCylinders,aToolId );
1498 createTool( _makePipes, aToolId );
1500 // Pattern Data Edition
1501 aToolId = createTool ( tr( "Operation" ) );
1502 createTool( _removeHexa, aToolId );
1503 createTool( _prismQuad, aToolId );
1504 createTool( _joinQuad, aToolId );
1505 createTool( _merge, aToolId );
1506 createTool( _disconnect, aToolId );
1507 createTool( _cutEdge, aToolId );
1508 createTool( _makeTransformation, aToolId );
1509 createTool( _makeSymmetry, aToolId );
1510 createTool( _performTransformation, aToolId );
1511 createTool( _performSymmetry, aToolId );
1512 createTool( _replaceHexa, aToolId );
1513 createTool( _quadRevolution, aToolId );
1516 aToolId = createTool ( tr( "Association" ) );
1517 createTool( _assocVertex, aToolId );
1518 createTool( _assocEdge, aToolId );
1519 createTool( _assocQuad, aToolId );
1520 createTool( _addShapeAct, aToolId );
1523 aToolId = createTool ( tr( "Group" ) );
1524 createTool( _addGroup, aToolId );
1525 createTool( _removeGroup, aToolId ); //CS_TODO
1528 aToolId = createTool ( tr( "Mesh" ) );
1529 createTool( _addLaw, aToolId );
1530 createTool( _removeLaw, aToolId );
1531 createTool( _setPropagation, aToolId );
1532 createTool( _computeMesh, aToolId );
1536 void HEXABLOCKGUI::initialMenus()
1538 showDocumentMenus( true );
1539 showPatternMenus( false );
1540 showAssociationMenus( false );
1541 showGroupsMenus( false );
1542 showMeshMenus( false );
1545 void HEXABLOCKGUI::showAllMenus()
1547 showDocumentMenus( true );
1548 showPatternMenus( true );
1549 showAssociationMenus( true );
1550 showGroupsMenus( true );
1551 showMeshMenus( true );
1555 void HEXABLOCKGUI::showDocumentMenus(bool show)
1557 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1559 setMenuShown(_newAct, show);
1560 setToolShown(_newAct, show);
1561 setMenuShown(_importAct, show);
1562 setToolShown(_importAct, show);
1563 setMenuShown(_showModelInfoAct, show);
1564 setToolShown(_showModelInfoAct, show);
1565 setMenuShown(_saveAct, show);
1566 setToolShown(_saveAct, show);
1569 void HEXABLOCKGUI::showPatternMenus(bool show)
1571 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1572 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1573 if ( show && !getCurrentModel() ) return;
1575 setMenuShown(_addVertex, show );
1576 setToolShown(_addVertex, show);
1577 setMenuShown(_addEdge, show );
1578 setToolShown(_addEdge, show);
1579 setMenuShown(_addQuad, show );
1580 setToolShown(_addQuad, show);
1581 setMenuShown(_addHexa, show );
1582 setToolShown(_addHexa, show);
1584 setMenuShown(_sep1, show );
1585 setToolShown(_sep1, show);
1587 setMenuShown( _addVector, show );
1588 setToolShown( _addVector, show);
1589 // setMenuShown( _addCylinder, show );
1590 // setToolShown( _addCylinder, show);
1591 // setMenuShown( _addPipe, show );
1592 // setToolShown( _addPipe, show);
1594 setMenuShown(_sep2, show );
1595 setToolShown(_sep2, show);
1597 setMenuShown( _makeGrid, show );
1598 setToolShown( _makeGrid, show);
1599 setMenuShown( _makePipe, show );
1600 setToolShown( _makePipe, show);
1602 setMenuShown(_sep3, show );
1603 setToolShown(_sep3, show);
1605 setMenuShown( _makeCylinder, show );
1606 setToolShown( _makeCylinder, show);
1607 setMenuShown( _makeCylinders, show );
1608 setToolShown( _makeCylinders, show);
1609 setMenuShown( _makePipes, show );
1610 setToolShown( _makePipes, show);
1611 setMenuShown( _makeHemiSphere, show );
1612 setToolShown( _makeHemiSphere, show);
1614 // Pattern Data Edition
1615 setMenuShown( _removeHexa, show );
1616 setToolShown( _removeHexa, show);
1617 setMenuShown( _prismQuad, show );
1618 setToolShown( _prismQuad, show);
1619 setMenuShown( _joinQuad, show );
1620 setToolShown( _joinQuad, show);
1621 setMenuShown( _merge, show );
1622 setToolShown( _merge, show);
1623 setMenuShown( _disconnect, show );
1624 setToolShown( _disconnect, show);
1625 setMenuShown( _cutEdge, show );
1626 setToolShown( _cutEdge, show);
1627 setMenuShown( _makeTransformation, show );
1628 setToolShown( _makeTransformation, show);
1629 setMenuShown( _makeSymmetry, show );
1630 setToolShown( _makeSymmetry, show);
1631 setMenuShown( _performTransformation, show );
1632 setToolShown( _performTransformation, show);
1633 setMenuShown( _performSymmetry, show );
1634 setToolShown( _performSymmetry, show);
1635 setMenuShown( _replaceHexa, show );
1636 setToolShown( _replaceHexa, show);
1637 setMenuShown( _quadRevolution, show );
1638 setToolShown( _quadRevolution, show);
1640 setMenuShown( _sep4, show );
1641 setMenuShown( _showModelInfoAct, show );
1645 void HEXABLOCKGUI::showAssociationMenus(bool show)
1647 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1648 if ( show && !getCurrentModel() ) return;
1650 // Association Edition
1651 setMenuShown( _assocVertex, show );
1652 setToolShown( _assocVertex, show );
1653 setMenuShown( _assocEdge, show );
1654 setToolShown( _assocEdge, show );
1655 setMenuShown( _assocQuad, show );
1656 setToolShown( _assocQuad, show );
1657 setMenuShown( _addShapeAct, show );
1658 setToolShown( _addShapeAct, show );
1662 void HEXABLOCKGUI::showGroupsMenus(bool show)
1664 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1665 if ( show && !getCurrentModel() ) return;
1666 setMenuShown( _addGroup, show );
1667 setToolShown( _addGroup, show);
1668 setMenuShown( _removeGroup , show );
1669 setToolShown( _removeGroup , show);
1672 void HEXABLOCKGUI::showMeshMenus(bool show)
1674 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1675 if ( show && !getCurrentModel() ) return;
1676 setMenuShown( _addLaw, show );
1677 setToolShown( _addLaw, show);
1678 setMenuShown( _removeLaw, show );
1679 setToolShown( _removeLaw, show);;
1680 setMenuShown( _setPropagation, show );
1681 setToolShown( _setPropagation, show);
1682 setMenuShown( _computeMesh, show);
1683 setToolShown( _computeMesh, show);
1686 void HEXABLOCKGUI::showActor()
1688 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1689 if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
1690 currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
1693 currentVtkGView->getViewWindow()->setFocus();
1694 currentVtkGView->getViewWindow()->Display(currentVtkGView->getDocumentActor()->getIO());
1695 currentVtkGView->update();
1696 currentVtkGView->getViewWindow()->onFitAll();
1698 //update the visibility state now
1699 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1700 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1701 if (aStudy == NULL || vman == NULL) return;
1703 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1704 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1705 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1708 //SOCC_Prs* currentPrs = NULL;
1709 void HEXABLOCKGUI::showOnlyActor()
1711 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1712 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1713 currentVtkGView->getDocumentActor() == NULL)
1715 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1716 if (vtkView == NULL)
1719 SALOME_Actor *actor = NULL;
1720 vtkActor *aVTKActor = NULL;
1721 Handle(SALOME_InteractiveObject) anIO;
1723 SUIT_ViewManager* vman = vtkView->getViewManager();
1724 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1725 vtkRenderer *aRenderer = vtkView->getRenderer();
1726 if (aStudy == NULL || vman == NULL || aRenderer == NULL) return;
1728 //update the visibility state for all actors -----------
1729 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1730 vtkActorCollection *aCollection = aCopy.GetActors();
1731 if (aCollection == NULL) return;
1732 aCollection->InitTraversal();
1734 while( (aVTKActor = aCollection->GetNextActor()) != NULL ){
1735 actor = dynamic_cast<SALOME_Actor*>( aVTKActor );
1736 if ( actor && actor->hasIO() ){
1737 anIO = actor->getIO();
1738 if( anIO->hasEntry())
1740 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1741 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1746 //show only the current actor -----------------
1747 vtkView->setFocus();
1748 vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1749 currentVtkGView->update();
1750 anIO = currentVtkGView->getDocumentActor()->getIO();
1751 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1752 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1753 vtkView->onFitAll();
1755 // //showOnly in occ viewer -------------
1757 if (currentOccGView == NULL)
1759 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1760 if (occView == NULL)
1762 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1767 currentOccGView->globalSelection();
1768 SOCC_Prs* prs = getOccPrs(currentDocGView);
1769 currentOccGView->setPrs(prs);
1772 occView->onFitAll();
1775 void HEXABLOCKGUI::hideActor()
1778 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1779 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1780 currentVtkGView->getViewWindow() == NULL ||
1781 currentVtkGView->getDocumentActor() == NULL) return;
1783 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1784 currentVtkGView->getViewWindow()->onResetView();
1786 //update the visibility state now
1787 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1788 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1789 if (aStudy == NULL || vman == NULL) return;
1791 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1792 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1793 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1796 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1797 DocumentModel* docModel = currentVtkGView->getDocumentModel();
1798 if (occView == NULL || docModel == NULL)
1800 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1806 occView->onResetView();
1810 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1812 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1814 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1815 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1817 if (_dwPattern) _dwPattern->setVisible(isVisible);
1818 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1820 if (_dwMesh) _dwMesh->setVisible(isVisible);
1821 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1823 if (_dwGroups) _dwGroups->setVisible(isVisible);
1824 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1828 //clear all used dialogs by the current model
1829 void HEXABLOCKGUI::clearDialogs()
1831 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1832 fin (currentModelDialogs.end());
1833 for(;debut!=fin;++debut) (*debut)->clear();
1835 currentModelDialogs.clear(); //empty the used dialogs list
1838 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1840 if (!gViewDlgBox.contains(dgview)) return NULL;
1841 return gViewDlgBox[dgview];
1844 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1846 if (dgview == NULL) return;
1848 switchOffGraphicView(dgview, false); //to avoid double connect
1851 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1852 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1853 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1854 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1855 connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1856 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1857 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1858 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1859 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1860 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1861 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1862 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1867 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1869 if (dgview == NULL) return;
1871 //disconnect signals
1872 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1873 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1874 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1875 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1876 disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1877 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1878 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1879 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1880 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1881 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1882 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1883 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1886 gViewDlgBox[dgview] = currentDialog;
1888 //close opened dialog
1889 if (currentDialog != NULL) currentDialog->close();
1890 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1896 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1898 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1899 MESSAGE("=========> SWITCH MODEL");
1903 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1907 //switch off the current document graphic view (disconnect signals...)
1908 if (currentDocGView != NULL)
1910 //Hide current actor
1912 switchOffGraphicView(currentDocGView);
1915 //clear the dialogs used by the current model so they can be used by the new model
1916 if (currentDocGView != dgview) clearDialogs();
1918 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1919 _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1920 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1921 _groupsTreeView->setModel(dgview->getGroupsModel());
1922 _meshTreeView->setModel(dgview->getMeshModel());
1924 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1925 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1927 _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1928 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1930 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1931 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1933 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1934 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1936 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1937 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1940 // = * init occ view * =
1941 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1943 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1944 currentOccGView->getViewWindow()->installEventFilter(this);
1949 // = * init vtk view * =
1950 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
1951 dgview->setViewWindow(currentDocGView->getViewWindow());
1953 if (dgview->getViewWindow() == NULL)
1955 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1956 dgview->getViewWindow()->installEventFilter(this);
1960 switchOnGraphicView(dgview);
1961 currentDocGView = dgview;
1962 currentDocGView->getViewWindow()->setFocus();
1964 currentDocGView->getDocumentModel()->refresh();
1965 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1969 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1971 if (currentDocGView == NULL) return NULL;
1972 return currentDocGView->getDocumentModel();
1976 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1978 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1979 if (anApp == NULL) return UNKNOWN;
1980 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1981 if (activeVm == NULL) return UNKNOWN;
1983 QString vmType = activeVm->getType();
1984 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1986 else if ( vmType == OCCViewer_Viewer::Type() )
1992 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
1994 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1998 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2001 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2003 // Create Document from HEXABLOCK ENGINE
2004 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2005 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2007 // looking doc impl ( c++ )
2008 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2009 // ^Hexa6 ASSERT( dServant );
2010 // ^Hexa6 if ( dServant)
2011 // ^Hexa6 doc = dServant->GetImpl();
2013 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2014 QString docEntry = addDocInStudy (doc);
2016 // looking for docEntry
2017 /* ****************************************************************
2018 if ( !CORBA::is_nil(docIn) ){
2019 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2020 QString docIOR = anIOR.in();
2021 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2022 if ( !docIOR.isEmpty() ) {
2023 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2025 docEntry = SO->GetID().c_str();
2028 **************************************************************** */
2029 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2031 return make_pair (docEntry, doc);
2035 void HEXABLOCKGUI::newDocument()
2037 DEBTRACE("HEXABLOCKGUI::newDocument");
2040 QMainWindow *aParent = application()->desktop();
2041 QWidget *central = aParent->centralWidget();
2043 central->setFocus();
2045 DEBTRACE("No Central Widget");
2048 if (currentOccGView == NULL)
2050 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2051 application()->desktop());
2052 currentOccGView->getViewWindow()->installEventFilter(this);
2054 else if (currentOccGView->getViewWindow() == NULL)
2056 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2057 currentOccGView->getViewWindow()->installEventFilter(this);
2061 // Create Document from HEXABLOCK ENGINE
2062 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2064 VtkDocumentGraphicView* newGraphicView = NULL;
2065 //One document at a time
2066 if (currentDocGView != NULL)
2068 if (currentDocGView->getViewWindow() == NULL)
2070 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2071 currentDocGView->getViewWindow()->installEventFilter(this);
2074 // Create a new document with the current window
2075 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2076 new DocumentModel( docEntry_Doc.second,
2077 docEntry_Doc.first, this ),
2078 currentDocGView->getViewWindow(),
2079 application()->desktop() );
2083 // Create the new Document Graphic View with a new window
2084 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2085 new DocumentModel( docEntry_Doc.second,
2086 docEntry_Doc.first, this ),
2087 graphicViewsHandler->createVtkWindow(),
2088 application()->desktop() );
2089 newGraphicView->getViewWindow()->installEventFilter(this);
2092 if (newGraphicView == NULL)
2093 //We couldn't create a new document graphic view
2094 //we'd better show a dialog box info to inform the user
2097 docs[docEntry_Doc.first] = newGraphicView;
2098 switchModel(newGraphicView); //select the corresponding document in the browser instead
2100 getApp()->updateObjectBrowser();
2105 //Loads the model from the xmlFile in the current graphic view
2106 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2108 DEBTRACE("HEXABLOCKGUI::loadDocument");
2111 QMainWindow *aParent = application()->desktop();
2112 QString selectedFile;
2114 if ( inFile.isNull() ){
2115 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2116 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2117 dialog.setHistory( getQuickDirList() );
2119 //use the last path as default
2120 if (!(loadDocLastPath->absolutePath()).isEmpty())
2121 dialog.setDirectory(*loadDocLastPath);
2124 QStringList selectedFiles = dialog.selectedFiles();
2125 if (!selectedFiles.isEmpty())
2126 selectedFile = selectedFiles.first();
2128 //remember the selected path
2129 *loadDocLastPath = dialog.directory();
2132 selectedFile = inFile;
2134 if (selectedFile.isEmpty())
2137 //we create a new document if necessary
2138 if (currentDocGView == NULL)
2139 //Need a new document
2141 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2143 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2144 currentDocGView->getViewWindow()->installEventFilter(this);
2147 if (!currentDocGView->isEmpty())
2148 //we can only have one document for a graphic view
2151 //we load the selected file in the current graphic view
2152 currentDocGView->loadDocument(selectedFile);
2153 DocumentModel* currentModel = getCurrentModel();
2154 renameObject( currentModel->documentEntry(), currentModel->getName() );
2159 void HEXABLOCKGUI::saveDocument()
2161 QMainWindow *aParent = application()->desktop();
2163 QString aDocName = "document", aFilename;
2165 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2166 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2168 //use the last selected directory as default path for file selection
2169 aFilename = saveDocLastPath->absolutePath();
2170 if (!aFilename.isEmpty())
2171 aFilename += QString("/") + aDocName;
2173 //show the dialog for file selection
2174 aFilename = SUIT_FileDlg::getFileName( aParent,
2177 tr( "Save HexaBlock Document" ),
2180 //save the document in the selected file
2181 if ( !aFilename.isEmpty() ) {
2182 getCurrentVtkGraphicView()->saveDocument( aFilename );
2184 //Remember the path for next save
2185 QFileInfo fileInfo(aFilename);
2186 *saveDocLastPath = fileInfo.dir();
2192 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2194 _patternDataTreeView->openPersistentEditor( topLeft );
2197 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2199 if (diag == NULL || _dwInputPanel == NULL ||
2200 getCurrentVtkGraphicView() == NULL) return;
2202 //mark this dialog as used by the current model
2203 currentModelDialogs.insert(diag);
2205 //close the current dialog box info
2206 if (_treeViewDelegate != NULL)
2207 _treeViewDelegate->closeDialog();
2209 if (_dwInputPanel->widget())
2210 _dwInputPanel->widget()->close();
2212 //Temporary for debugging EdgeAssoc Faked InfoDialog
2213 if (diag == _edgeAssocDiag)
2214 diag->debugEdgeAssoc = true;
2216 diag->debugEdgeAssoc = false;
2218 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2219 diag == _quadAssocDiag || diag == _addShapeDiag)
2220 assocInProgress = true;
2222 assocInProgress = false;
2224 //show the dialog box in the dockwidget
2225 diag->resetSizeAndShow(_dwInputPanel);
2227 //clear the current selections
2228 selectionMgr()->clearSelected();
2230 currentDialog = diag;
2234 void HEXABLOCKGUI::addVertex()
2236 if ( !_vertexDiag ){
2237 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2239 _showDialogBox( _vertexDiag );
2242 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2243 if (_vertexDiag != NULL && doc != NULL)
2244 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2247 void HEXABLOCKGUI::addEdge()
2250 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2252 _showDialogBox( _edgeDiag );
2255 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2256 if (_edgeDiag != NULL && doc != NULL)
2257 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2260 void HEXABLOCKGUI::addQuad()
2263 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2266 _showDialogBox( _quadDiag );
2269 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2270 if (_quadDiag != NULL && doc != NULL)
2271 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2274 void HEXABLOCKGUI::addHexa()
2277 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2279 _showDialogBox( _hexaDiag );
2282 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2283 if (_hexaDiag != NULL && doc != NULL)
2284 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2287 void HEXABLOCKGUI::addVector()
2289 if ( !_vectorDiag ){
2290 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2292 _showDialogBox( _vectorDiag );
2295 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2296 if (_vectorDiag != NULL && doc != NULL)
2297 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2300 void HEXABLOCKGUI::addCylinder()
2302 if ( !_cylinderDiag ){
2303 _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2305 _showDialogBox( _cylinderDiag );
2308 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2309 if (_cylinderDiag != NULL && doc != NULL)
2310 _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2314 void HEXABLOCKGUI::addPipe()
2317 _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2319 _showDialogBox( _pipeDiag );
2322 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2323 if (_pipeDiag != NULL && doc != NULL)
2324 _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2328 void HEXABLOCKGUI::makeGrid()
2330 if ( !_makeGridDiag ){
2331 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2333 _showDialogBox( _makeGridDiag );
2337 void HEXABLOCKGUI::makeCylinder()
2339 if ( !_makeCylinderDiag ){
2340 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2342 _showDialogBox( _makeCylinderDiag );
2345 void HEXABLOCKGUI::makePipe()
2347 if ( !_makePipeDiag ){
2348 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2350 _showDialogBox( _makePipeDiag );
2353 void HEXABLOCKGUI::makeCylinders()
2355 if ( !_makeCylindersDiag ){
2356 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2358 _showDialogBox( _makeCylindersDiag );
2361 void HEXABLOCKGUI::makePipes()
2363 if ( !_makePipesDiag ){
2364 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2366 _showDialogBox( _makePipesDiag );
2370 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2372 if ( !_makeHemiSphereDiag ){
2373 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2375 _showDialogBox( _makeHemiSphereDiag );
2379 void HEXABLOCKGUI::removeHexa()
2381 if ( !_removeHexaDiag ){
2382 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2384 _showDialogBox( _removeHexaDiag );
2388 void HEXABLOCKGUI::prismQuad()
2390 if ( !_prismQuadDiag ){
2391 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2393 _showDialogBox( _prismQuadDiag );
2397 void HEXABLOCKGUI::joinQuad()
2399 if ( !_joinQuadDiag ){
2400 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2402 _showDialogBox( _joinQuadDiag );
2405 void HEXABLOCKGUI::merge()
2408 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2410 _showDialogBox( _mergeDiag );
2413 void HEXABLOCKGUI::disconnectElts()
2415 if ( !_disconnectDiag ){
2416 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2418 _showDialogBox( _disconnectDiag );
2421 void HEXABLOCKGUI::cutEdge()
2423 if ( !_cutEdgeDiag ){
2424 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2426 _showDialogBox( _cutEdgeDiag );
2429 void HEXABLOCKGUI::makeTransformation()
2431 if ( !_makeTransformationDiag ){
2432 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2434 _showDialogBox( _makeTransformationDiag );
2438 void HEXABLOCKGUI::makeSymmetry()
2440 if ( !_makeSymmetryDiag ){
2441 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2443 _showDialogBox( _makeSymmetryDiag );
2447 void HEXABLOCKGUI::performTransformation()
2449 if ( !_performTransformationDiag ){
2450 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2452 _showDialogBox( _performTransformationDiag );
2456 void HEXABLOCKGUI::performSymmetry()
2458 if ( !_performSymmetryDiag ){
2459 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2461 _showDialogBox( _performSymmetryDiag );
2465 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2467 if ( !_replaceHexaDiag ){
2468 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2470 _showDialogBox( _replaceHexaDiag );
2474 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2476 if ( !_quadRevolutionDiag ){
2477 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2479 _showDialogBox( _quadRevolutionDiag );
2483 void HEXABLOCKGUI::assocVertex()
2485 if (!_dwInputPanel) return;
2486 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2487 if ( !_vertexAssocDiag )
2488 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2489 _showDialogBox( _vertexAssocDiag );
2493 void HEXABLOCKGUI::assocEdge()
2495 if ( !_edgeAssocDiag )
2496 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2497 _showDialogBox( _edgeAssocDiag );
2500 void HEXABLOCKGUI::assocQuad()
2502 if ( !_quadAssocDiag )
2503 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2504 _showDialogBox( _quadAssocDiag );
2508 void HEXABLOCKGUI::addGroup()
2511 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2513 _showDialogBox( _groupDiag );
2514 if (_groupDiag != NULL && getCurrentModel() != NULL)
2516 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2517 if (doc == NULL) return;
2518 char defaultName[16];
2519 sprintf (defaultName, "g%04d", doc->countGroup());
2520 _groupDiag->name_le->setText(defaultName);
2524 void HEXABLOCKGUI::removeGroup()
2526 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2527 if (currentDGView == NULL) return;
2529 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2530 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2531 int nbGroupsRemoved = 0;
2534 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2535 tr( "No group selected!" ) );
2539 foreach( QModelIndex selected, l ){
2540 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2541 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2542 Q_ASSERT(selected.isValid());
2544 //Confirm the deletion of the group
2545 if (SUIT_MessageBox::question(
2548 tr("Remove group : %1 ?").arg(selected.data().toString()),
2549 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2550 SUIT_MessageBox::Cancel
2551 ) == SUIT_MessageBox::Cancel) return;
2553 bool removed = getCurrentModel()->removeGroup( selected );
2555 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2556 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2562 if (!nbGroupsRemoved)
2563 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2564 tr( "No group selected!" ) );
2567 void HEXABLOCKGUI::addLaw()
2570 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2572 _showDialogBox( _lawDiag );
2573 if (_lawDiag != NULL && getCurrentModel() != NULL)
2575 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2576 if (doc == NULL) return;
2577 char defaultName[16];
2578 sprintf (defaultName, "l%04d", doc->countLaw());
2579 _lawDiag->name_le->setText(defaultName);
2583 void HEXABLOCKGUI::removeLaw()
2585 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2586 if (currentDGView == NULL) return;
2588 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2589 int nbLawsRemoved = 0;
2592 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2593 tr( "No law selected!" ) );
2597 foreach( QModelIndex selected, l ){
2598 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2599 selected = currentDGView->getMeshModel()->mapToSource( selected );
2600 Q_ASSERT(selected.isValid());
2602 //Confirm the deletion of the law
2603 if (SUIT_MessageBox::question(
2606 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2607 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2608 SUIT_MessageBox::Cancel
2609 ) == SUIT_MessageBox::Cancel) return;
2611 bool removed = getCurrentModel()->removeLaw(selected);
2613 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2614 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2621 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2622 tr( "No law selected!" ) );
2627 void HEXABLOCKGUI::setPropagation()
2629 if ( !_propagationDiag ){
2630 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2632 _showDialogBox( _propagationDiag );
2635 // Dialog box to compute a mesh from a document
2636 // --------------------------------------------
2637 void HEXABLOCKGUI::computeMesh()
2639 if ( !_computeMeshDiag ){
2640 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2642 _computeMeshDiag->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
2643 _showDialogBox( _computeMeshDiag );
2646 void HEXABLOCKGUI::clearAssociations()
2648 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2649 if (currentDGView == NULL) return;
2651 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2652 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2653 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2655 getCurrentModel()->clearEltAssociations(iModel);
2657 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2660 void HEXABLOCKGUI::showModelInfo()
2662 //create the info dialog if not yet
2663 if (_modelInfoDiag == NULL)
2664 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2666 //show the model informations dialog
2667 _showDialogBox( _modelInfoDiag );
2670 void HEXABLOCKGUI::addShape()
2672 //create the info dialog if not yet
2673 if (_addShapeDiag == NULL)
2674 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2676 //show the model informations dialog
2677 _showDialogBox( _addShapeDiag );
2680 void HEXABLOCKGUI::clearAllAssociations()
2682 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2683 if (currentDGView == NULL) return;
2685 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2686 if (!currentIndex.isValid()) return;
2687 QVariant currentAssocVariant;
2688 QString currentAssocEntry;
2690 //Confirm the deletion of the associations
2691 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2692 if ( !treeVariant.isValid() ) return;
2693 int eltType = treeVariant.toInt();
2694 QString typeStr = "";
2695 HEXA_NS::EnumElt hexaType;
2696 if (eltType == VERTEX_DIR_TREE)
2698 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2699 hexaType = HEXA_NS::EL_VERTEX;
2701 else if (eltType == EDGE_DIR_TREE)
2703 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2704 hexaType = HEXA_NS::EL_EDGE;
2706 else if (eltType == QUAD_DIR_TREE)
2708 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2709 hexaType = HEXA_NS::EL_QUAD;
2712 if (SUIT_MessageBox::question(
2714 tr("CLEAR_ASSOCIATIONS"),
2715 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2716 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2717 SUIT_MessageBox::Cancel
2718 ) == SUIT_MessageBox::Cancel) return;
2721 DocumentModel* docModel = getCurrentModel();
2722 if (docModel == NULL) return;
2723 docModel->clearAssociation(hexaType);
2726 void HEXABLOCKGUI::showAssociations()
2728 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2729 if (currentDGView == NULL) return;
2731 QModelIndexList elts;
2732 int currentChildIndex = 0;
2733 QVariant currentAssocVariant;
2734 QString currentAssocEntry;
2735 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2736 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2738 while( currentChild.isValid() ) {
2740 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2741 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2742 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2743 elts << currentChild;
2745 currentChild = currentChild.sibling(currentChildIndex++, 0);
2747 currentDocGView->highlight(elts);
2748 currentOccGView->highlight(elts, false);
2752 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2754 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2756 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2761 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2763 if ( event->type() == QEvent::Enter )
2764 { // *** ENTER EVENT
2766 if (currentDialog == NULL || !currentDialog->isVisible())
2767 return QObject::eventFilter(obj, event);
2769 // ** The window acquire the focus when the cursor enter
2771 //OCC - window enter
2772 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2773 if ( occWindow != NULL)
2774 currentDialog->onWindowActivated(occWindow->getViewManager());
2776 //VTK - window enter
2778 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2779 if ( vtkWindow != NULL)
2780 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2784 //standard event processing
2785 return QObject::eventFilter(obj, event);
2788 QStringList HEXABLOCKGUI::getQuickDirList()
2790 QStringList dirList;
2791 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2793 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2799 // --- Export the module
2803 HEXABLOCKGUI_EXPORT CAM_Module* createModule()
2805 return new HEXABLOCKGUI();
2808 HEXABLOCKGUI_EXPORT char* getModuleVersion()
2810 return (char*)HEXABLOCK_VERSION_STR;
2816 // ******************** TESTS ***************************************************
2818 void HEXABLOCKGUI::testDocument()
2822 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2823 // QStandardItem *myItem = new QStandardItem("MyItem");
2824 // parentItem->appendRow(myItem);
2826 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2827 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2828 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2829 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2830 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2831 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2832 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2833 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2836 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2837 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2838 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2839 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2840 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2841 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2843 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2844 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2845 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2846 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2851 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2852 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2853 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2854 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2862 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2863 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2865 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2866 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2870 // newMesh( "toto", 3, "FactoryServer");
2874 void HEXABLOCKGUI::test_make_cart_grid()
2876 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2877 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2878 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2879 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2880 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
2881 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
2883 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
2884 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
2891 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
2892 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
2893 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
2894 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
2895 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
2896 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
2901 void HEXABLOCKGUI::test_make_elmts_transform()
2908 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
2909 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
2912 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
2913 // orig.setScalar(2);
2915 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
2916 // getCurrentModel()->saveVtk(file_name)
2918 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
2919 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
2921 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
2922 // getCurrentModel()->saveVtk(file_name)
2924 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
2927 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
2928 // getCurrentModel()->saveVtk(file_name);
2931 // print "...test make elements by transforming elements OK"
2933 // =============================================================== addDocInSudy
2934 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
2938 if (document == NULL)
2941 QString docName = document->getName ();
2943 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
2944 if (app_study == NULL)
2947 _PTR(Study) study = app_study->studyDS();
2948 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
2949 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
2950 QString entry = app_study->centry("HEXABLOCK");
2951 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
2952 if (aFatherSO->_is_nil())
2955 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
2958 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
2959 docEntry = aSO->GetID(); //the entry of the published object
2964 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
2966 void HEXABLOCKGUI::test()
2968 DEBTRACE("HEXABLOCKGUI::test");
2969 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2970 if (currentDGView == NULL) return;
2971 currentDGView->update();
2975 void HEXABLOCKGUI::test_association()
2977 DEBTRACE("HEXABLOCKGUI::test_association");
2980 QModelIndex v0, v1, v2, v3, e0, e1, q0;
2982 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
2983 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
2984 DocumentModel::GeomObj q0AssocA, q0AssocB;
2986 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
2987 QList<DocumentModel::GeomObj> e1Assocs_test;
2988 DocumentModel::GeomObj q0Assoc_test;
2990 v0 = getCurrentModel()->addVertex(0, 0, 0);
2991 v1 = getCurrentModel()->addVertex(1, 0, 0);
2992 v2 = getCurrentModel()->addVertex(1, 1, 0);
2993 v3 = getCurrentModel()->addVertex(0, 1, 0);
2994 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
2995 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
2996 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2999 // >>> face3.GetEntry()'0:1:4'
3000 // >>> e1.GetEntry()'0:1:8'
3001 // >>> e2.GetEntry()'0:1:9'
3002 // >>> e3.GetEntry()'0:1:10'
3003 // >>> e4.GetEntry()'0:1:11'
3004 // >>> v1.GetEntry()'0:1:12'
3005 // >>> v2.GetEntry()'0:1:13'
3006 // >>> v3.GetEntry()'0:1:14'
3007 // >>> v4.GetEntry()'0:1:15'
3010 // v0Assoc.name = "geomV0";
3011 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3012 // v0Assoc.brep = "brepV0";
3013 // v1Assoc.name = "geomV1";
3014 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3015 // v1Assoc.brep = "brepV1";
3016 // v2Assoc.name = "geomV2";
3017 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3018 // v2Assoc.brep = "brepV2";
3019 // v3Assoc.name = "geomV3";
3020 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3021 // v3Assoc.brep = "brepV3";
3025 // e0AssocA.name = "geomE0a";
3026 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3027 // e0AssocA.brep = "brepE0a";
3028 // e0AssocA.start = 0.10;
3029 // e0AssocA.end = 0.95;
3033 // e1AssocA.name = "geomE1a";
3034 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3035 // e1AssocA.brep = "brepE1a";
3036 // e1AssocA.start = 0.12;
3037 // e1AssocA.end = 0.89;
3038 // e1AssocB.name = "geomE1b";
3039 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3040 // e1AssocB.brep = "brepE1b";
3041 // e1AssocB.start = 0.20;
3042 // e1AssocB.end = 0.80;
3043 // e1AssocC.name = "geomE1c";
3044 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3045 // e1AssocC.brep = "brepE1c";
3046 // e1AssocC.start = 0.16;
3047 // e1AssocC.end = 0.96;
3049 // q0AssocA.name = "geomQuad";
3050 // q0AssocA.entry = "0:1:1:1:3";
3051 // q0AssocA.brep = "brepq0";
3053 // q0AssocB.name = "geomQuad";
3054 // q0AssocB.entry = "0:1:1:1:4";
3055 // q0AssocB.brep = "brepq0";
3057 // getCurrentModel()->addAssociation( v0, v0Assoc );
3058 // getCurrentModel()->addAssociation( v1, v1Assoc );
3059 // getCurrentModel()->addAssociation( v2, v2Assoc );
3060 // getCurrentModel()->addAssociation( v3, v3Assoc );
3063 // getCurrentModel()->addAssociation( e0, e0AssocA );
3065 // getCurrentModel()->addAssociation( e1, e1AssocA );
3066 // getCurrentModel()->addAssociation( e1, e1AssocB );
3067 // getCurrentModel()->addAssociation( e1, e1AssocC );
3069 // getCurrentModel()->addAssociation( q0, q0AssocA );
3070 // getCurrentModel()->addAssociation( q0, q0AssocB );
3076 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3077 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3078 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3079 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3080 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3081 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3082 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3083 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3084 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3085 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3086 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3087 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3090 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3091 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3092 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3093 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3094 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3095 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3096 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3097 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3098 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3099 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3100 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3101 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3102 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3104 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3105 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3106 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3109 DEBTRACE("HEXABLOCKGUI::test_association fin");