1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include <QInputDialog>
27 #include <QStackedWidget>
29 #include <QtxTreeView.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_ViewManager.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_DataObject.h>
37 #include <SUIT_DataBrowser.h>
38 #include <SUIT_FileDlg.h>
40 #include <SVTK_ViewManager.h>
41 #include <SVTK_ViewModel.h>
42 #include <SVTK_ViewWindow.h>
44 #include <VTKViewer_ViewModel.h>
46 #include <vtkActorCollection.h>
47 #include <VTKViewer_Algorithm.h>
48 #include <vtkRenderer.h>
52 #include <SOCC_ViewModel.h>
53 #include <SOCC_ViewWindow.h>
54 #include <OCCViewer_ViewWindow.h>
55 #include <SALOME_Prs.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_Study.hxx>
61 #include <SALOMEDSClient_StudyBuilder.hxx>
62 #include <SALOMEDSClient_SComponent.hxx>
63 #include <SALOMEDSClient_ClientFactory.hxx>
64 #include <SALOMEDSClient_IParameters.hxx>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Module.h>
70 #include <SalomeApp_Application.h>
71 #include <SalomeApp_DataModel.h>
74 #include <SALOME_ListIO.hxx>
75 #include <SALOME_ListIteratorOfListIO.hxx>
78 #include <SALOME_LifeCycleCORBA.hxx>
80 #include <LightApp_VTKSelector.h>
82 #include <OCCViewer_ViewManager.h>
84 #include <QtxPopupMgr.h>
86 #include "Resource.hxx"
88 #include "HEXABLOCKGUI.hxx"
89 #include "HEXABLOCKGUI_Export.hxx"
90 #include "HEXABLOCKGUI_Trace.hxx"
91 #include "HEXABLOCKGUI_Resource.hxx"
93 #include "HEXABLOCKGUI_DocumentModel.hxx"
94 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
95 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
96 #include "HEXABLOCKGUI_DocumentPanel.hxx"
97 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
98 #include "HEXABLOCKGUI_OccGraphicView.hxx"
99 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
101 #include "HEXABLOCK_version.h"
103 #include "MyBasicGUI_PointDlg.hxx"
105 // #include "HEXABLOCK.hxx" del Hexa6
106 // #include "HexDocument_impl.hxx" del Hexa6
110 #include <Visual3d_ViewManager.hxx>
111 #include <V3d_PerspectiveView.hxx>
112 #include <V3d_AmbientLight.hxx>
113 #include <V3d_DirectionalLight.hxx>
114 #include <Xw_Window.hxx>
115 #include <V3d_TypeOfShadingModel.hxx>
116 #include <TCollection_ExtendedString.hxx>
118 #include <BRepAlgoAPI_Fuse.hxx>
120 #include <AIS_ListIteratorOfListOfInteractive.hxx>
123 #define DW_MINIMUM_WIDTH 50
124 #define DWINPUT_MINIMUM_HEIGHT 50
125 #define DWINPUT_MINIMUM_WIDTH 50//255
128 using namespace HEXABLOCK::GUI;
130 int HEXABLOCKGUI::_oldStudyId = -1;
132 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
134 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
135 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
136 bool HEXABLOCKGUI::assocInProgress = false;
137 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
139 HEXABLOCKGUI::HEXABLOCKGUI() :
140 SalomeApp_Module( "HEXABLOCK" ),
141 // LightApp_Module( "HEXABLOCK" ),
149 _patternDataTreeView(0),
150 // _patternBuilderTreeView(0),
151 _patternGeomTreeView(0),
154 // _treeViewDelegate(0),
156 moduleActivatedOnce(false),
165 _makeCylinderDiag(0),
167 _makeCylindersDiag(0),
175 _makeTransformationDiag(0),
176 _makeSymmetryDiag(0),
177 _performTransformationDiag(0),
178 _performSymmetryDiag(0),
187 _quadRevolutionDiag(0),
188 _makeHemiSphereDiag(0),
189 _modelInfoDiag(NULL),
191 _vertexInfoDialog(NULL),
192 _edgeInfoDialog(NULL),
193 _quadInfoDialog(NULL),
194 _hexaInfoDialog(NULL),
195 _vectorInfoDialog(NULL),
196 _groupInfoDialog(NULL),
197 _lawInfoDialog(NULL),
198 _propagationInfoDialog(NULL),
201 lastVtkDocGView(NULL)
203 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
205 graphicViewsHandler = new GraphicViewsHandler();
206 loadDocLastPath = new QDir();
207 saveDocLastPath = new QDir();
208 hexa_root = HEXA_NS::Hex::getInstance ();
211 HEXABLOCKGUI::~HEXABLOCKGUI()
216 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
218 SUIT_Application* app = SUIT_Session::session()->activeApplication();
220 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
226 // Gets an reference to the module's engine
227 /****************************************************
228 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
230 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
231 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
232 ASSERT(!CORBA::is_nil(clr));
235 **************************************************** */
237 void HEXABLOCKGUI::initialize( CAM_Application* app )
239 DEBTRACE("HEXABLOCKGUI::initialize");
240 SalomeApp_Module::initialize( app );
242 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
244 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
246 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
247 setResource(aResourceMgr);
249 createAndFillDockWidget();
256 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
258 DEBTRACE("HEXABLOCKGUI::viewManagers");
259 // list.append( QxScene_Viewer::Type() );
260 // list.append( OCCViewer_Viewer::Type() );
261 // list.append( SVTK_Viewer::Type() );
265 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
267 DEBTRACE("HEXABLOCKGUI::activateModule");
269 /*HexaBlock can be launched in only one application*/
270 if (myApplication == NULL)
271 //remember the first application
272 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
274 //application verification: if it's not the one known by HexaBlock,
275 //leave without activating
276 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
277 if (myApplication != currentApplication) return false;
279 bool bOk = SalomeApp_Module::activateModule( theStudy );
280 if ( !bOk ) return false;
282 showDockWidgets(true);
284 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
285 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
286 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
287 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
289 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
291 SUIT_ViewManager* vm;
292 ViewManagerList OCCViewManagers, VTKViewManagers;
294 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
295 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
296 while ( itOCC.hasNext() && (vm = itOCC.next()) )
297 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
299 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
300 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
301 while ( itVTK.hasNext() && (vm = itVTK.next()) )
302 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
305 SALOME_ListIO selected;
306 sm->selectedObjects( selected );
309 // disable OCC selectors
310 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
311 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
312 while ( itOCCSel.hasNext() )
313 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
314 sr->setEnabled(true);
316 // disable VTK selectors
317 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
318 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
319 while ( itVTKSel.hasNext() )
320 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
321 sr->setEnabled(true);
323 sm->setSelectedObjects( selected, true ); //NPAL 19674
325 //connect close signal to vtk view manager
326 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
329 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
330 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
333 //connect close signal to occ view manager
334 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
337 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
338 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
341 /* ************************************ TODO Hexa6
342 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
343 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
344 if ( _PTR(Study) aStudy = s->studyDS()) {
345 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
346 updateObjBrowser(); // objects can be removed
348 ************************************ */
350 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
351 currentOccGView->getViewWindow()->installEventFilter(this);
353 if (currentDocGView != NULL)
355 switchModel(currentDocGView);
358 if (currentDocGView->getViewWindow() != NULL)
359 currentDocGView->getViewWindow()->installEventFilter(this);
368 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
370 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
371 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
372 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
373 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
375 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
376 if ( vtkView != NULL)
378 //default selectionMode in VTKView
379 vtkView->SetSelectionMode( ActorSelection );
380 vtkView->removeEventFilter(this);
384 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
387 //defaut selectionMode in OccView
388 selectionMgr()->clearSelected();
389 currentOccGView->globalSelection();
390 occView->removeEventFilter(this);
394 qDeleteAll(myOCCSelectors);
395 myOCCSelectors.clear();
396 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
398 qDeleteAll(myVTKSelectors);
399 myVTKSelectors.clear();
400 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
402 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
404 //switch off current document graphic view
405 switchOffGraphicView(currentDocGView);
408 setMenuShown( false );
409 setToolShown( false );
410 showDockWidgets( false );
412 _dwInputPanel->close();
419 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
421 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
422 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
423 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
424 int aStudyID = theStudy->StudyId();
425 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
426 return aDSStudy._retn();
429 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
430 QMap<QString, QString>& docShapesEntry,
431 QMap<QString, QString>& docShapesName)
433 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
434 return; //there's nothing to publish in this case
436 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
437 if(!appStudy) return;
438 _PTR(Study) aStudy = appStudy->studyDS();
439 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
440 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
441 QString entry = currentDocGView->getDocumentModel()->documentEntry();
442 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
443 if (aFatherSO->_is_nil())
446 // * get a presentation
447 bool isNewPrs = false;
448 SOCC_Prs* prs = getOccPrs(currentDocGView);
451 prs = new SOCC_Prs();
455 // * init the presentation with the given shapes
456 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
457 while (i != topo_shapes.constEnd())
459 QString shapeName = i.key();
460 TopoDS_Shape shapeValue = i.value();
461 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
462 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
463 QString objStudyEntry = aSO->GetID(); //the entry of the published object
464 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
465 "HEXABLOCK", shapeName.toStdString().c_str());
466 ais_shape->SetOwner(io);
467 prs->AddObject(ais_shape);
468 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
469 docShapesEntry[shapeName] = objStudyEntry;
470 docShapesName[objStudyEntry] = shapeName;
471 currentOccGView->addShape(objStudyEntry, ais_shape);
472 i++; //handle next shape
476 prs->AddObject(currentOccGView->getPreviewShape());
478 occPrs[currentDocGView] = prs;
479 getApp()->updateObjectBrowser();
484 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
486 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
487 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
488 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
490 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
494 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
498 // Pas de renommage des shapes pour le moment, juste les documents
499 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
500 if (dgview == NULL || dgview->getDocumentModel() == NULL)
503 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
504 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
509 _PTR(Study) aStudy = appStudy->studyDS();
514 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
515 _PTR(GenericAttribute) anAttr;
517 if ( obj->FindAttribute(anAttr, "AttributeName") ){
518 _PTR(AttributeName) aName (anAttr);
519 DocumentModel* docModel = dgview->getDocumentModel();
520 docModel->setName( name );
521 aName->SetValue( name.toLatin1().data() );
522 getApp()->updateObjectBrowser();
523 _dwPattern->setWindowTitle( name );
530 // --- Default windows
531 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
533 DEBTRACE("HEXABLOCKGUI::windows");
535 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
536 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
539 QString HEXABLOCKGUI::engineIOR() const
541 DEBTRACE("HEXABLOCKGUI::engineIOR");
543 /* ************************************ TODO Hexa6
544 CORBA::ORB_var anORB = getApp()->orb();
545 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
546 return QString( anIOR.in() );
547 ************************************ */
551 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
553 if (docs.count(studyObject->entry()) == 0)
555 //Object's document not acquired yet
556 VtkDocumentGraphicView* dgview;
557 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
558 if (directory == NULL)
559 return NULL; //No working director found
561 //------------------ Load the document -----------------
562 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
563 if (document == NULL)
564 return NULL; //No document found
566 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
568 MESSAGE("Doc model creation failed!");
571 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
572 if (dgview == NULL) return NULL;
574 //update the data tree
575 docs[studyObject->entry()] = dgview;
578 return docs[studyObject->entry()];
581 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
583 // ** we want to switch automatically to the right view windows
585 //first, find selected item
587 DataObjectList dol = getApp()->objectBrowser()->getSelected();
588 if (dol.isEmpty()) return;
589 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
590 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
591 item->entry().isEmpty())
594 // find the document corresponding to it
595 VtkDocumentGraphicView* docGView = NULL;
596 if (docs.contains(item->entry()))
597 docGView = docs[item->entry()];
599 docGView = getOrCreateDocument(item);
601 //Init OCC if necessary
602 if (currentOccGView == NULL)
604 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
605 currentOccGView->getViewWindow()->installEventFilter(this);
607 else if (currentOccGView->getViewWindow() == NULL)
609 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
610 currentOccGView->getViewWindow()->installEventFilter(this);
613 //Init the vtk view if necessary
614 if (docGView->getViewWindow() == NULL)
616 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
618 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
619 docGView->getViewWindow()->installEventFilter(this);
623 docGView->setViewWindow(currentDocGView->getViewWindow());
625 if (docGView->getDocumentActor() == NULL)
629 if (docGView == NULL || docGView == currentDocGView)
635 //update the current document
636 switchModel(docGView);
640 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
642 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
645 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
647 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
649 //Decharger le model correspondant (VTK)
650 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
654 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
655 { //HexaBlock Vtk Window has been closed
657 if (currentDialog != NULL) currentDialog->close();
658 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
659 if (currentDocGView != NULL)
660 currentDocGView->setViewWindow(NULL);
667 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
668 if (dgview == NULL) return; //The window has no document to close
670 //Save the document? (Ask only if the document is not empty
671 int answerCode = SUIT_MessageBox::question(
674 tr("Save the document ?"),
675 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
676 SUIT_MessageBox::Cancel);
677 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
678 else if (answerCode == SUIT_MessageBox::Yes)
679 saveDocument(); //Save the document
681 // switchOffGraphicView(window); //disconnect all connected signals
682 // currentVtkView = NULL;
683 // graphicViewsHandler->closeDocumentGraphicView(window);
685 //create a new one (empty document)
687 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
691 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
693 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
694 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
695 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
696 if (currentDialog != NULL) currentDialog->close();
697 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
699 currentOccGView->getViewWindow()->removeEventFilter(this);
700 currentOccGView->setViewWindow(NULL);
704 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
706 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
708 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
709 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
711 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
713 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
714 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
715 // disable OCC selectors
716 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
717 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
718 while ( itOCCSel.hasNext() )
719 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
720 sr->setEnabled(true);
722 else if ( vm->getType() == SVTK_Viewer::Type() )
724 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
725 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
727 // disable VTK selectors
728 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
729 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
730 while ( itVTKSel.hasNext() )
731 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
732 sr->setEnabled(true);
736 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
738 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
740 SUIT_ViewModel* viewer = vm->getViewModel();
741 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
743 //VTK View Manager removed
744 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
746 //Process only if it's our view manager
747 SUIT_ViewManager* myVm = NULL;
748 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
749 myVm = currentDocGView->getViewWindow()->getViewManager();
753 //close opened dialog
754 if (currentDialog != NULL) currentDialog->close();
755 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
761 //remove its selector
762 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
763 while ( itVTKSel.hasNext() )
764 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
765 if ( sr->viewer() == viewer )
767 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
774 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
776 //OCC View removed: remove its selector
777 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
778 while ( itOCCSel.hasNext() )
779 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
780 if ( sr->viewer() == viewer )
782 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
788 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
790 QModelIndexList l = selected.indexes();
791 if ( l.count() == 0 ) return;
792 if ( !l[0].isValid() ) return;
793 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
794 if ( currentGraphicView == NULL) return;
796 QTreeView* theTree = NULL;
797 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
798 theTree = _patternDataTreeView;
800 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
801 theTree = _patternBuilderTreeView;
803 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
804 theTree = _patternGeomTreeView;
806 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
807 theTree = _groupsTreeView;
808 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
809 theTree = _meshTreeView;
812 theTree->scrollTo ( l[0] );
816 bool HEXABLOCKGUI::createSComponent() //addComponent
818 DEBTRACE("HEXABLOCKGUI::createSComponent");
819 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
821 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
822 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
823 _PTR(GenericAttribute) anAttr;
824 _PTR(AttributeName) aName;
825 _PTR(AttributeGraphic) aGraphic;
827 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
828 if ( !aComponent ){ //Create hexablock component if there's not one yet
829 aComponent = aBuilder->NewComponent("HEXABLOCK");
830 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
831 aName = _PTR(AttributeName) (anAttr);
832 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
834 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
835 _PTR(AttributePixMap) aPixmap(anAttr);
836 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
838 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
839 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
845 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
847 DEBTRACE("HEXABLOCKGUI::setResource");
848 _myresource = new HEXABLOCKGUI_Resource(r);
849 _myresource->preferencesChanged();
852 void HEXABLOCKGUI::createPreferences()
854 DEBTRACE("HEXABLOCKGUI::createPreferences");
855 _myresource->createPreferences(this);
858 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
860 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
861 _myresource->preferencesChanged(sect, name);
862 // if(name=="userCatalog")
863 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
866 void HEXABLOCKGUI::studyActivated() //CS_TODO
868 int newStudyId = getApp()->activeStudy()->id();
869 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
870 // if (_oldStudyId != -1)
872 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
873 // if (_studyContextMap.count(newStudyId))
875 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
876 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
880 // DEBTRACE("no switch to null context");
883 _oldStudyId = newStudyId;
886 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
888 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
889 QVariant currentAssocVariant;
890 QString currentAssocEntry;
892 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
893 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
894 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
895 QMenu menu( _patternDataTreeView );
897 QAction *clearAct = menu.addAction( "Remove association(s)" );
898 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
899 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
903 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
904 if (currentVtkGraphicView == NULL) return;
905 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
907 //We don't do anything for single items
908 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
909 item->type() == QUADITEM || item->type() == HEXAITEM)
912 //No associations for HEXA
913 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
914 if ( !treeVariant.isValid() ) return;
915 int eltType = treeVariant.toInt();
916 if (eltType == HEXA_DIR_TREE) return;
917 QMenu menu( _patternDataTreeView );
919 //Show association(s)
920 QAction *showAssocAct = menu.addAction( "Show associations" );
921 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
923 //Clear all associations
924 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
925 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
927 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
932 void HEXABLOCKGUI::createAndFillDockWidget()
934 QMainWindow *aParent = application()->desktop();
936 // Create dock widget (3 dock)
938 //1) *********** user input panel ( contain user's edit dialog box )
939 _dwInputPanel = new QDockWidget(aParent);
940 _dwInputPanel->setVisible(false);
941 _dwInputPanel->setWindowTitle("Input Panel");
942 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
944 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
946 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
948 _dwPattern = new QDockWidget(aParent);
949 _dwPattern->setVisible(false);
950 _dwPattern->setWindowTitle("Model");
951 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
953 QFrame* patternFrame = new QFrame(_dwPattern);
954 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
955 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
956 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
957 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
958 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
959 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
960 _patternGeomTreeView = new QTreeView(patternFrame);
961 splitter->addWidget(_patternDataTreeView);
962 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
963 splitter->addWidget(_patternGeomTreeView);
964 patternLayout->addWidget(splitter);
966 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
967 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
968 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
971 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
972 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
974 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
975 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
977 _dwPattern->setWidget(patternFrame);
978 patternFrame->show();
981 _dwGroups = new QDockWidget(aParent);
983 _dwGroups->setVisible(false);
984 _dwGroups->setWindowTitle("Groups");
985 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
986 _groupsTreeView = new QTreeView(_dwGroups);
987 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
988 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
989 _dwGroups->setWidget(_groupsTreeView);
990 _groupsTreeView->show();
993 _dwMesh = new QDockWidget(aParent);
994 _dwMesh->setVisible(false);
995 _dwMesh->setWindowTitle("Mesh");
996 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
997 _meshTreeView = new QTreeView(_dwMesh);
998 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
999 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1000 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1001 _dwMesh->setWidget(_meshTreeView);
1002 _meshTreeView->show();
1004 QDockWidget *_dwObjectBrowser = 0;
1005 QWidget* wid = getApp()->objectBrowser()->treeView();
1006 QWidget *w = wid->parentWidget();
1007 while ( w && !_dwObjectBrowser ) {
1008 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1009 w = w->parentWidget();
1011 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1012 _dwObjectBrowser->setWindowTitle("Study");
1014 // dock widget position
1015 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1016 // aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1017 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1019 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1020 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1021 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1024 #if QT_VERSION >= 0x040500
1025 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1029 // popup menu on data tree view
1030 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1031 connect(_patternDataTreeView,
1032 SIGNAL(customContextMenuRequested(const QPoint &)),
1034 SLOT(treeContextMenu(const QPoint &)),
1035 Qt::UniqueConnection );
1038 void HEXABLOCKGUI::createActions()
1040 QMainWindow *aParent = application()->desktop();
1041 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1044 _newAct = createAction(_menuId++,
1045 tr("Create a new document"),
1046 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1048 tr("Create a new document"),
1049 0, aParent, false, this, SLOT(newDocument()));
1050 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1052 _importAct = createAction(_menuId++,
1053 tr("Load a document"),
1054 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1055 tr("Load Document"),
1056 tr("Load a document"),
1057 0, aParent, false, this, SLOT(loadDocument()));
1058 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1060 _saveAct = createAction(_menuId++,
1061 tr("Save the document"),
1062 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1063 tr("Save Document"),
1064 tr("Save the document"),
1065 0, aParent, false, this, SLOT(saveDocument()));
1067 // Pattern Data creation
1068 _addVertex = createAction(_menuId++,
1069 tr("Create a vertex"),
1070 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1072 tr("Create a new vertex"),
1073 0, aParent, false, this, SLOT(addVertex()));
1075 _addEdge = createAction(_menuId++,
1076 tr("Create an edge"),
1077 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1079 tr("Create a new edge"),
1080 0, aParent, false, this, SLOT(addEdge()));
1082 _addQuad = createAction(_menuId++,
1083 tr("Create a quadrangle"),
1084 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1085 tr("Add Quadrangle"),
1086 tr("Create a new quadrangle"),
1087 0, aParent, false, this, SLOT(addQuad()));
1089 _addHexa = createAction(_menuId++,
1090 tr("Create an hexahedron"),
1091 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1092 tr("Add Hexahedron"),
1093 tr("Create a new hexahedron"),
1094 0, aParent, false, this, SLOT(addHexa()));
1096 // Builder Data creation
1097 _addVector = createAction(_menuId++,
1098 tr("Create a vector"),
1099 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1101 tr("Create a new vector"),
1102 0, aParent, false, this, SLOT(addVector()));
1104 // _addCylinder = createAction(_menuId++,
1105 // tr("Create a cylinder"),
1106 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1107 // tr("Add Cylinder"),
1108 // tr("Create a new cylinder"),
1109 // 0, aParent, false, this, SLOT(addCylinder()));
1111 // _addPipe = createAction(_menuId++,
1112 // tr("Create a pipe"),
1113 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1115 // tr("Create a new pipe"),
1116 // 0, aParent, false, this, SLOT(addPipe()));
1118 _makeGrid = createAction(_menuId++,
1120 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1123 0, aParent, false, this, SLOT(makeGrid()));
1125 _makeCylinder = createAction(_menuId++,
1126 tr("Make a cylinder"),
1127 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1128 tr("Make Cylinder"),
1129 tr("Make a cylinder"),
1130 0, aParent, false, this, SLOT(makeCylinder()));
1132 _makePipe = createAction(_menuId++,
1134 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1137 0, aParent, false, this, SLOT(makePipe()));
1139 _makeCylinders = createAction(_menuId++,
1140 tr("Make cylinders"),
1141 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1142 tr("Make Cylinders"),
1143 tr("Make cylinders"),
1144 0, aParent, false, this, SLOT(makeCylinders()));
1146 _makePipes = createAction(_menuId++,
1148 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1151 0, aParent, false, this, SLOT(makePipes()));
1153 _makeHemiSphere = createAction(_menuId++,
1154 tr("Make an hemisphere"),
1155 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1156 tr("Make Hemisphere"),
1157 tr("Make an hemisphere"),
1158 0, aParent, false, this, SLOT(makeHemiSphere()));
1160 // Pattern Data edition
1161 _removeHexa = createAction(_menuId++,
1162 tr("Remove hexahedra"),
1163 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1164 tr("Remove Hexahedra"),
1165 tr("Remove hexahedra"),
1166 0, aParent, false, this, SLOT(removeHexa()));
1168 _prismQuad = createAction(_menuId++,
1169 tr("Prism quadrangles"),
1170 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1171 tr("Prism Quadrangles"),
1172 tr("Prism quadrangles"),
1173 0, aParent, false, this, SLOT(prismQuad()));
1175 _joinQuad = createAction(_menuId++,
1176 tr("Join quadrangles"),
1177 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1178 tr("Join Quadrangles"),
1179 tr("Join quadrangles with hexahedra"),
1180 0, aParent, false, this, SLOT(joinQuad()));
1182 _merge = createAction(_menuId++,
1184 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1187 0, aParent, false, this, SLOT(merge()));
1189 _disconnect = createAction(_menuId++,
1191 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1193 tr("Disconnect edges, vertexes or quadrangles"),
1194 0, aParent, false, this, SLOT(disconnectElts()));
1196 _cutEdge = createAction(_menuId++,
1198 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1201 0, aParent, false, this, SLOT(cutEdge()));
1203 _makeTransformation = createAction(_menuId++,
1204 tr("Make transformation"),
1205 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1206 tr("Make Transformation"),
1207 tr("Make transformation"),
1208 0, aParent, false, this, SLOT(makeTransformation()));
1210 _makeSymmetry = createAction(_menuId++,
1211 tr("Make symmetry"),
1212 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1213 tr("Make Symmetry"),
1214 tr("Make symmetry"),
1215 0, aParent, false, this, SLOT(makeSymmetry()));
1217 _performTransformation = createAction(_menuId++,
1218 tr("Perform transformation"),
1219 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1220 tr("Perform Transformation"),
1221 tr("Perform transformation"),
1222 0, aParent, false, this, SLOT(performTransformation()));
1224 _performSymmetry = createAction(_menuId++,
1225 tr("Perform symmetry"),
1226 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1227 tr("Perform Symmetry"),
1228 tr("Perform symmetry"),
1229 0, aParent, false, this, SLOT(performSymmetry()));
1231 _replaceHexa = createAction(_menuId++,
1232 tr("Replace hexahedron"),
1233 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1234 tr("Replace Hexahedron"),
1235 tr("Replace hexahedron"),
1236 0, aParent, false, this, SLOT(replaceHexa()));
1238 _quadRevolution = createAction(_menuId++,
1239 tr("Quad revolution"),
1240 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1241 tr("Quad Revolution"),
1242 tr("Quad revolution"),
1243 0, aParent, false, this, SLOT(quadRevolution()));
1246 _assocVertex = createAction(_menuId++,
1247 tr("Make vertex association"),
1248 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1249 tr("Make Vertex association"),
1250 tr("Make vertex association"),
1251 0, aParent, false, this, SLOT(assocVertex()));
1253 _assocEdge = createAction(_menuId++,
1254 tr("Make edge association"),
1255 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1256 tr("Make Edge Association"),
1257 tr("Make edge association"),
1258 0, aParent, false, this, SLOT(assocEdge()));
1260 _assocQuad = createAction(_menuId++,
1261 tr("Make quad association"),
1262 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1263 tr("Make Quad Association"),
1264 tr("Make quad association"),
1265 0, aParent, false, this, SLOT(assocQuad()));
1268 _addGroup = createAction(_menuId++,
1270 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1273 0, aParent, false, this, SLOT(addGroup()));
1275 _removeGroup = createAction(_menuId++,
1276 tr("Remove a group"),
1277 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1279 tr("Remove a group"),
1280 0, aParent, false, this, SLOT(removeGroup()));
1283 _addLaw = createAction(_menuId++,
1285 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1288 0, aParent, false, this, SLOT(addLaw()));
1290 _removeLaw = createAction(_menuId++,
1292 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1295 0, aParent, false, this, SLOT(removeLaw()));
1297 _setPropagation = createAction(_menuId++,
1298 tr("Set propagation"),
1299 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1300 tr("Set Propagation"),
1301 tr("Set propagation"),
1302 0, aParent, false, this, SLOT(setPropagation()));
1304 _computeMesh = createAction(_menuId++,
1306 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1309 0, aParent, false, this, SLOT(computeMesh()));
1311 _showModelInfoAct = createAction(_menuId++,
1312 tr("Show Model Info"),
1313 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1316 0, aParent, false, this, SLOT(showModelInfo()));
1318 _addShapeAct = createAction(_menuId++,
1320 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1323 0, aParent, false, this, SLOT(addShape()));
1325 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1326 // QAction* createAction(const int id,
1327 // const QString& toolTip,
1328 // const QIcon& icon,
1329 // const QString& menu,
1330 // const QString& status,
1331 // const int shortCut,
1332 // QObject* parent =0,
1333 // bool checkable = false,
1334 // QObject* receiver =0,
1335 // const char* member =0);
1337 _sep1 = separator();
1338 _sep2 = separator();
1339 _sep3 = separator();
1340 _sep4 = separator();
1344 void HEXABLOCKGUI::createMenus()
1346 int aMenuId, subMenuId,aMenuIdMain;
1348 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1350 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1351 createMenu( actionId(_newAct), aMenuId );
1352 createMenu( actionId(_importAct), aMenuId );
1353 createMenu( _saveAct, aMenuId );
1356 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1357 createMenu( _newAct, aMenuDocId );//, 10
1358 createMenu( _importAct, aMenuDocId );
1359 createMenu( _saveAct, aMenuDocId );
1361 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1362 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1363 createMenu( _addVertex, subMenuId );
1364 createMenu( _addEdge, subMenuId );
1365 createMenu( _addQuad, subMenuId );
1366 createMenu( _addHexa, subMenuId );
1367 createMenu( _sep1, subMenuId);
1370 createMenu( _addVector, subMenuId );
1371 // createMenu( _addCylinder, subMenuId );
1372 // createMenu( _addPipe, subMenuId );
1374 createMenu( _sep2, subMenuId);
1376 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1377 createMenu( _makeHemiSphere,subMenuId );
1379 createMenu( _sep3, subMenuId);
1381 createMenu( _makeCylinder, subMenuId );
1382 createMenu( _makePipe, subMenuId );
1383 createMenu( _makeCylinders,subMenuId );
1384 createMenu( _makePipes, subMenuId );
1386 // Pattern Data Edition
1387 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1388 createMenu( _removeHexa, subMenuId );
1389 createMenu( _prismQuad, subMenuId );
1390 createMenu( _joinQuad, subMenuId );
1391 createMenu( _merge, subMenuId );
1392 createMenu( _disconnect, subMenuId );
1393 createMenu( _cutEdge, subMenuId );
1394 createMenu( _makeTransformation, subMenuId );
1395 createMenu( _makeSymmetry, subMenuId );
1396 createMenu( _performTransformation, subMenuId );
1397 createMenu( _performSymmetry, subMenuId );
1398 createMenu( _replaceHexa, subMenuId );
1399 createMenu( _quadRevolution, subMenuId );
1400 createMenu( _sep4, aMenuId );
1401 createMenu( _showModelInfoAct, aMenuId );
1404 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1405 createMenu( _addShapeAct, aMenuId );
1406 createMenu( _assocVertex, aMenuId );
1407 createMenu( _assocEdge, aMenuId );
1408 createMenu( _assocQuad, aMenuId );
1411 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1412 createMenu( _addGroup, aMenuId );
1413 createMenu( _removeGroup, aMenuId ); //CS_TODO
1416 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1417 createMenu( _addLaw, aMenuId );
1418 createMenu( _removeLaw, aMenuId );
1419 createMenu( _setPropagation, aMenuId );
1420 createMenu( _computeMesh, aMenuId );
1422 //show model infomation menu
1423 QString aRule = "$component={'HEXABLOCK'}";
1424 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1425 popupMgr()->setRule( _showModelInfoAct, aRule);
1427 //associate shape to a document menu
1428 popupMgr()->insert( _addShapeAct, -1, -1 );
1429 popupMgr()->setRule( _addShapeAct, aRule );
1431 //-------------------------------------------------
1433 //-------------------------------------------------
1434 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1435 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1436 // QString isNotEmpty("numberOfNodes <> 0");
1437 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1438 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1439 //// aType = aType.arg( mesh_part );
1441 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1442 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1443 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1445 // popupMgr()->insert( separator(), -1, -1 );
1446 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1447 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1448 // // MESSAGE("aClient = " << aClient.toStdString());
1449 // // MESSAGE("aType = " << aType.toStdString());
1450 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1451 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1452 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1453 // // MESSAGE("aRule = " << aRule.toStdString());
1454 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1455 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1457 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1458 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1460 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1461 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1463 // popupMgr()->insert( separator(), -1, -1 );
1467 void HEXABLOCKGUI::createTools()
1471 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1472 createTool( _newAct, aToolId );
1473 createTool( _importAct, aToolId );
1474 createTool( _saveAct, aToolId );
1475 createTool( _showModelInfoAct, aToolId );
1476 // createTool( _testAct, aToolId );
1477 //createTool( separator(), aToolId );
1480 aToolId = createTool ( tr( "Construction" ) );
1481 createTool( _addVertex, aToolId );
1482 createTool( _addEdge, aToolId );
1483 createTool( _addQuad, aToolId );
1484 createTool( _addHexa, aToolId );
1486 createTool( _sep1, aToolId );
1489 createTool( _addVector, aToolId );
1490 // createTool( _addCylinder, aToolId );
1491 // createTool( _addPipe, aToolId );
1493 createTool( _sep2, aToolId );
1495 createTool( _makeGrid, aToolId );
1496 createTool( _makeHemiSphere, aToolId );
1498 createTool( _sep3, aToolId );
1500 createTool( _makeCylinder, aToolId );
1501 createTool( _makePipe, aToolId );
1502 createTool( _makeCylinders,aToolId );
1503 createTool( _makePipes, aToolId );
1505 // Pattern Data Edition
1506 aToolId = createTool ( tr( "Operation" ) );
1507 createTool( _removeHexa, aToolId );
1508 createTool( _prismQuad, aToolId );
1509 createTool( _joinQuad, aToolId );
1510 createTool( _merge, aToolId );
1511 createTool( _disconnect, aToolId );
1512 createTool( _cutEdge, aToolId );
1513 createTool( _makeTransformation, aToolId );
1514 createTool( _makeSymmetry, aToolId );
1515 createTool( _performTransformation, aToolId );
1516 createTool( _performSymmetry, aToolId );
1517 createTool( _replaceHexa, aToolId );
1518 createTool( _quadRevolution, aToolId );
1521 aToolId = createTool ( tr( "Association" ) );
1522 createTool( _assocVertex, aToolId );
1523 createTool( _assocEdge, aToolId );
1524 createTool( _assocQuad, aToolId );
1525 createTool( _addShapeAct, aToolId );
1528 aToolId = createTool ( tr( "Group" ) );
1529 createTool( _addGroup, aToolId );
1530 createTool( _removeGroup, aToolId ); //CS_TODO
1533 aToolId = createTool ( tr( "Mesh" ) );
1534 createTool( _addLaw, aToolId );
1535 createTool( _removeLaw, aToolId );
1536 createTool( _setPropagation, aToolId );
1537 createTool( _computeMesh, aToolId );
1541 void HEXABLOCKGUI::initialMenus()
1543 showDocumentMenus( true );
1544 showPatternMenus( false );
1545 showAssociationMenus( false );
1546 showGroupsMenus( false );
1547 showMeshMenus( false );
1550 void HEXABLOCKGUI::showAllMenus()
1552 showDocumentMenus( true );
1553 showPatternMenus( true );
1554 showAssociationMenus( true );
1555 showGroupsMenus( true );
1556 showMeshMenus( true );
1560 void HEXABLOCKGUI::showDocumentMenus(bool show)
1562 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1564 setMenuShown(_newAct, show);
1565 setToolShown(_newAct, show);
1566 setMenuShown(_importAct, show);
1567 setToolShown(_importAct, show);
1568 setMenuShown(_showModelInfoAct, show);
1569 setToolShown(_showModelInfoAct, show);
1570 setMenuShown(_saveAct, show);
1571 setToolShown(_saveAct, show);
1574 void HEXABLOCKGUI::showPatternMenus(bool show)
1576 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1577 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1578 if ( show && !getCurrentModel() ) return;
1580 setMenuShown(_addVertex, show );
1581 setToolShown(_addVertex, show);
1582 setMenuShown(_addEdge, show );
1583 setToolShown(_addEdge, show);
1584 setMenuShown(_addQuad, show );
1585 setToolShown(_addQuad, show);
1586 setMenuShown(_addHexa, show );
1587 setToolShown(_addHexa, show);
1589 setMenuShown(_sep1, show );
1590 setToolShown(_sep1, show);
1592 setMenuShown( _addVector, show );
1593 setToolShown( _addVector, show);
1594 // setMenuShown( _addCylinder, show );
1595 // setToolShown( _addCylinder, show);
1596 // setMenuShown( _addPipe, show );
1597 // setToolShown( _addPipe, show);
1599 setMenuShown(_sep2, show );
1600 setToolShown(_sep2, show);
1602 setMenuShown( _makeGrid, show );
1603 setToolShown( _makeGrid, show);
1604 setMenuShown( _makePipe, show );
1605 setToolShown( _makePipe, show);
1607 setMenuShown(_sep3, show );
1608 setToolShown(_sep3, show);
1610 setMenuShown( _makeCylinder, show );
1611 setToolShown( _makeCylinder, show);
1612 setMenuShown( _makeCylinders, show );
1613 setToolShown( _makeCylinders, show);
1614 setMenuShown( _makePipes, show );
1615 setToolShown( _makePipes, show);
1616 setMenuShown( _makeHemiSphere, show );
1617 setToolShown( _makeHemiSphere, show);
1619 // Pattern Data Edition
1620 setMenuShown( _removeHexa, show );
1621 setToolShown( _removeHexa, show);
1622 setMenuShown( _prismQuad, show );
1623 setToolShown( _prismQuad, show);
1624 setMenuShown( _joinQuad, show );
1625 setToolShown( _joinQuad, show);
1626 setMenuShown( _merge, show );
1627 setToolShown( _merge, show);
1628 setMenuShown( _disconnect, show );
1629 setToolShown( _disconnect, show);
1630 setMenuShown( _cutEdge, show );
1631 setToolShown( _cutEdge, show);
1632 setMenuShown( _makeTransformation, show );
1633 setToolShown( _makeTransformation, show);
1634 setMenuShown( _makeSymmetry, show );
1635 setToolShown( _makeSymmetry, show);
1636 setMenuShown( _performTransformation, show );
1637 setToolShown( _performTransformation, show);
1638 setMenuShown( _performSymmetry, show );
1639 setToolShown( _performSymmetry, show);
1640 setMenuShown( _replaceHexa, show );
1641 setToolShown( _replaceHexa, show);
1642 setMenuShown( _quadRevolution, show );
1643 setToolShown( _quadRevolution, show);
1645 setMenuShown( _sep4, show );
1646 setMenuShown( _showModelInfoAct, show );
1650 void HEXABLOCKGUI::showAssociationMenus(bool show)
1652 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1653 if ( show && !getCurrentModel() ) return;
1655 // Association Edition
1656 setMenuShown( _assocVertex, show );
1657 setToolShown( _assocVertex, show );
1658 setMenuShown( _assocEdge, show );
1659 setToolShown( _assocEdge, show );
1660 setMenuShown( _assocQuad, show );
1661 setToolShown( _assocQuad, show );
1662 setMenuShown( _addShapeAct, show );
1663 setToolShown( _addShapeAct, show );
1667 void HEXABLOCKGUI::showGroupsMenus(bool show)
1669 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1670 if ( show && !getCurrentModel() ) return;
1671 setMenuShown( _addGroup, show );
1672 setToolShown( _addGroup, show);
1673 setMenuShown( _removeGroup , show );
1674 setToolShown( _removeGroup , show);
1677 void HEXABLOCKGUI::showMeshMenus(bool show)
1679 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1680 if ( show && !getCurrentModel() ) return;
1681 setMenuShown( _addLaw, show );
1682 setToolShown( _addLaw, show);
1683 setMenuShown( _removeLaw, show );
1684 setToolShown( _removeLaw, show);;
1685 setMenuShown( _setPropagation, show );
1686 setToolShown( _setPropagation, show);
1687 setMenuShown( _computeMesh, show);
1688 setToolShown( _computeMesh, show);
1691 void HEXABLOCKGUI::showVtkActor()
1693 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1694 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1695 currentVtkGView->getDocumentActor() == NULL)
1698 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1699 if (vtkView == NULL)
1702 SUIT_ViewManager* vman = vtkView->getViewManager();
1703 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1705 //show only the current actor -----------------
1706 vtkView->setFocus();
1707 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1708 Document_Actor *lastDocActor;
1709 if (lastVtkDocGView != NULL)
1711 lastDocActor = lastVtkDocGView->getDocumentActor();
1712 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1713 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1715 vtkView->Erase(lastActorIO);
1716 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1717 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1720 currentVtkGView->update();
1721 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1722 if (!anIO.IsNull() && anIO->hasEntry())
1724 vtkView->Display(anIO);
1725 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1726 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1728 vtkView->onFitAll();
1731 void HEXABLOCKGUI::showOccActor()
1733 if (currentOccGView == NULL)
1735 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1736 if (occView == NULL)
1738 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1742 if (lastOccPrs != NULL)
1743 vf->Erase(lastOccPrs);
1744 currentOccGView->globalSelection();
1745 SOCC_Prs* prs = getOccPrs(currentDocGView);
1746 currentOccGView->setPrs(prs);
1749 occView->onFitAll();
1752 void HEXABLOCKGUI::hideVtkActor()
1754 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1755 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1756 currentVtkGView->getViewWindow() == NULL ||
1757 currentVtkGView->getDocumentActor() == NULL) return;
1759 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1760 currentVtkGView->getViewWindow()->onResetView();
1762 //update the visibility state now
1763 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1764 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1765 if (aStudy == NULL || vman == NULL) return;
1767 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1768 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1769 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1772 void HEXABLOCKGUI::hideOccActor()
1774 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1775 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1776 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1777 if (occView == NULL || docModel == NULL)
1779 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1783 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1784 if (currentOccPrs != NULL)
1785 vf->Erase(currentOccPrs);
1787 occView->onResetView();
1790 void HEXABLOCKGUI::showOnlyActor()
1796 void HEXABLOCKGUI::hideActor()
1803 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1805 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1807 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1808 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1810 if (_dwPattern) _dwPattern->setVisible(isVisible);
1811 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1813 if (_dwMesh) _dwMesh->setVisible(isVisible);
1814 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1816 if (_dwGroups) _dwGroups->setVisible(isVisible);
1817 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1821 //clear all used dialogs by the current model
1822 void HEXABLOCKGUI::clearDialogs()
1824 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1825 fin (currentModelDialogs.end());
1826 for(;debut!=fin;++debut) (*debut)->clear();
1828 currentModelDialogs.clear(); //empty the used dialogs list
1831 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1833 if (!gViewDlgBox.contains(dgview)) return NULL;
1834 return gViewDlgBox[dgview];
1837 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1839 if (dgview == NULL) return;
1841 switchOffGraphicView(dgview, false); //to avoid double connect
1844 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1845 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1846 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1847 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1848 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1849 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1850 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1851 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1852 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1853 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1854 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1855 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1860 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1862 if (dgview == NULL) return;
1864 //disconnect signals
1865 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1866 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1867 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1868 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1869 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1870 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1871 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1872 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1873 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1874 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1875 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1876 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1879 gViewDlgBox[dgview] = currentDialog;
1881 //close opened dialog
1882 if (currentDialog != NULL) currentDialog->close();
1883 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1889 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1891 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1895 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1899 //switch off the current document graphic view (disconnect signals...)
1900 if (currentDocGView != NULL)
1902 //Hide current actor
1904 switchOffGraphicView(currentDocGView);
1907 //clear the dialogs used by the current model so they can be used by the new model
1908 if (currentDocGView != dgview) clearDialogs();
1910 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1911 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1912 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1913 _groupsTreeView->setModel(dgview->getGroupsModel());
1914 _meshTreeView->setModel(dgview->getMeshModel());
1916 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1917 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1919 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1920 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1922 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1923 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1925 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1926 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1928 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1929 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1932 // = * init occ view * =
1933 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1935 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1936 currentOccGView->getViewWindow()->installEventFilter(this);
1941 // = * init vtk view * =
1942 if (currentDocGView != NULL)
1944 if (currentDocGView->getViewWindow() != NULL)
1945 dgview->setViewWindow(currentDocGView->getViewWindow());
1948 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1949 dgview->getViewWindow()->installEventFilter(this);
1955 switchOnGraphicView(dgview);
1957 if (currentDocGView != NULL)
1959 lastVtkDocGView = currentDocGView;
1960 lastOccPrs = getOccPrs(currentDocGView);
1964 lastVtkDocGView = dgview;
1965 lastOccPrs = getOccPrs(dgview);
1968 currentDocGView = dgview;
1970 currentDocGView->getDocumentModel()->refresh();
1971 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1975 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1977 if (currentDocGView == NULL) return NULL;
1978 return currentDocGView->getDocumentModel();
1982 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1984 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1985 if (anApp == NULL) return UNKNOWN;
1986 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1987 if (activeVm == NULL) return UNKNOWN;
1989 QString vmType = activeVm->getType();
1990 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1992 else if ( vmType == OCCViewer_Viewer::Type() )
1998 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2000 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2004 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2007 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2009 // Create Document from HEXABLOCK ENGINE
2010 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2011 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2013 // looking doc impl ( c++ )
2014 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2015 // ^Hexa6 ASSERT( dServant );
2016 // ^Hexa6 if ( dServant)
2017 // ^Hexa6 doc = dServant->GetImpl();
2019 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2020 QString docEntry = addDocInStudy (doc);
2022 // looking for docEntry
2023 /* ****************************************************************
2024 if ( !CORBA::is_nil(docIn) ){
2025 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2026 QString docIOR = anIOR.in();
2027 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2028 if ( !docIOR.isEmpty() ) {
2029 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2031 docEntry = SO->GetID().c_str();
2034 **************************************************************** */
2035 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2037 return make_pair (docEntry, doc);
2041 void HEXABLOCKGUI::newDocument()
2043 DEBTRACE("HEXABLOCKGUI::newDocument");
2046 QMainWindow *aParent = application()->desktop();
2047 QWidget *central = aParent->centralWidget();
2049 central->setFocus();
2051 DEBTRACE("No Central Widget");
2054 if (currentOccGView == NULL)
2056 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2057 application()->desktop());
2058 currentOccGView->getViewWindow()->installEventFilter(this);
2060 else if (currentOccGView->getViewWindow() == NULL)
2062 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2063 currentOccGView->getViewWindow()->installEventFilter(this);
2067 // Create Document from HEXABLOCK ENGINE
2068 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2070 VtkDocumentGraphicView* newGraphicView = NULL;
2071 //One document at a time
2072 if (currentDocGView != NULL)
2074 if (currentDocGView->getViewWindow() == NULL)
2076 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2077 currentDocGView->getViewWindow()->installEventFilter(this);
2080 // Create a new document with the current window
2081 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2082 new DocumentModel( docEntry_Doc.second,
2083 docEntry_Doc.first, this ),
2084 currentDocGView->getViewWindow(),
2085 application()->desktop() );
2089 // Create the new Document Graphic View with a new window
2090 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2091 new DocumentModel( docEntry_Doc.second,
2092 docEntry_Doc.first, this ),
2093 graphicViewsHandler->createVtkWindow(),
2094 application()->desktop() );
2095 newGraphicView->getViewWindow()->installEventFilter(this);
2098 if (newGraphicView == NULL)
2099 //We couldn't create a new document graphic view
2100 //we'd better show a dialog box info to inform the user
2103 docs[docEntry_Doc.first] = newGraphicView;
2104 switchModel(newGraphicView); //select the corresponding document in the browser instead
2106 getApp()->updateObjectBrowser();
2111 //Loads the model from the xmlFile in the current graphic view
2112 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2114 DEBTRACE("HEXABLOCKGUI::loadDocument");
2117 QMainWindow *aParent = application()->desktop();
2118 QString selectedFile;
2120 if ( inFile.isNull() ){
2121 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2122 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2123 dialog.setHistory( getQuickDirList() );
2125 //use the last path as default
2126 if (!(loadDocLastPath->absolutePath()).isEmpty())
2127 dialog.setDirectory(*loadDocLastPath);
2130 QStringList selectedFiles = dialog.selectedFiles();
2131 if (!selectedFiles.isEmpty())
2132 selectedFile = selectedFiles.first();
2134 //remember the selected path
2135 *loadDocLastPath = dialog.directory();
2138 selectedFile = inFile;
2140 if (selectedFile.isEmpty())
2143 //we create a new document if necessary
2144 if (currentDocGView == NULL)
2145 //Need a new document
2147 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2149 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2150 currentDocGView->getViewWindow()->installEventFilter(this);
2153 if (!currentDocGView->isEmpty())
2154 //we can only have one document for a graphic view
2157 //we load the selected file in the current graphic view
2158 currentDocGView->loadDocument(selectedFile);
2159 DocumentModel* currentModel = getCurrentModel();
2160 renameObject( currentModel->documentEntry(), currentModel->getName() );
2165 void HEXABLOCKGUI::saveDocument()
2167 QMainWindow *aParent = application()->desktop();
2169 QString aDocName = "document", aFilename;
2171 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2172 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2174 //use the last selected directory as default path for file selection
2175 aFilename = saveDocLastPath->absolutePath();
2176 if (!aFilename.isEmpty())
2177 aFilename += QString("/") + aDocName;
2179 //show the dialog for file selection
2180 aFilename = SUIT_FileDlg::getFileName( aParent,
2183 tr( "Save HexaBlock Document" ),
2186 //save the document in the selected file
2187 if ( !aFilename.isEmpty() ) {
2188 getCurrentVtkGraphicView()->saveDocument( aFilename );
2190 //Remember the path for next save
2191 QFileInfo fileInfo(aFilename);
2192 *saveDocLastPath = fileInfo.dir();
2198 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2200 _patternDataTreeView->openPersistentEditor( topLeft );
2203 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2205 if (diag == NULL || _dwInputPanel == NULL ||
2206 getCurrentVtkGraphicView() == NULL) return;
2208 //mark this dialog as used by the current model
2209 currentModelDialogs.insert(diag);
2211 //close the current dialog box info
2212 // if (_treeViewDelegate != NULL)
2213 // _treeViewDelegate->closeDialog();
2215 // if (_dwInputPanel->widget())
2216 // _dwInputPanel->widget()->close();
2218 //Temporary for debugging EdgeAssoc Faked InfoDialog
2219 if (diag == _edgeAssocDiag)
2220 diag->debugEdgeAssoc = true;
2222 diag->debugEdgeAssoc = false;
2224 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2225 diag == _quadAssocDiag || diag == _addShapeDiag)
2226 assocInProgress = true;
2228 assocInProgress = false;
2230 //show the dialog box in the dockwidget
2231 diag->resetSizeAndShow(_dwInputPanel);
2233 //clear the current selections
2234 selectionMgr()->clearSelected();
2236 currentDialog = diag;
2239 if (currentDocGView != NULL)
2240 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2243 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2245 if (vertex == NULL || _dwInputPanel == NULL)
2248 if (_vertexInfoDialog == NULL)
2249 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2251 _vertexInfoDialog->setValue(vertex);
2252 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2253 currentDialog = _vertexInfoDialog;
2256 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2258 if (edge == NULL || _dwInputPanel == NULL)
2261 if (_edgeInfoDialog == NULL)
2262 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2264 _edgeInfoDialog->setValue(edge);
2265 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2266 currentDialog = _edgeInfoDialog;
2269 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2271 if (quad == NULL || _dwInputPanel == NULL)
2274 if (_quadInfoDialog == NULL)
2275 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2277 _quadInfoDialog->setValue(quad);
2278 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2279 currentDialog = _quadInfoDialog;
2282 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2284 if (hexa == NULL || _dwInputPanel == NULL)
2287 if (_hexaInfoDialog == NULL)
2288 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2290 _hexaInfoDialog->setValue(hexa);
2291 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2292 currentDialog = _hexaInfoDialog;
2295 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2297 if (vector == NULL || _dwInputPanel == NULL)
2300 if (_vectorInfoDialog == NULL)
2301 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2303 _vectorInfoDialog->setValue(vector);
2304 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2305 currentDialog = _vectorInfoDialog;
2308 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2310 if (group == NULL || _dwInputPanel == NULL)
2313 if (_groupInfoDialog == NULL)
2314 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2316 _groupInfoDialog->setValue(group);
2317 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2318 currentDialog = _groupInfoDialog;
2321 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2323 if (law == NULL || _dwInputPanel == NULL)
2326 if (_lawInfoDialog == NULL)
2327 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2329 _lawInfoDialog->setValue(law);
2330 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2331 currentDialog = _lawInfoDialog;
2334 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2336 if (propagation == NULL || _dwInputPanel == NULL)
2339 if (_propagationInfoDialog == NULL)
2340 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2342 _propagationInfoDialog->setValue(propagation);
2343 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2344 currentDialog = _propagationInfoDialog;
2347 void HEXABLOCKGUI::addVertex()
2349 if ( !_vertexDiag ){
2350 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2352 _showDialogBox( _vertexDiag );
2355 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2356 if (_vertexDiag != NULL && doc != NULL)
2357 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2360 void HEXABLOCKGUI::addEdge()
2363 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2365 _showDialogBox( _edgeDiag );
2368 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2369 if (_edgeDiag != NULL && doc != NULL)
2370 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2373 void HEXABLOCKGUI::addQuad()
2376 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2379 _showDialogBox( _quadDiag );
2382 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2383 if (_quadDiag != NULL && doc != NULL)
2384 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2387 void HEXABLOCKGUI::addHexa()
2390 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2392 _showDialogBox( _hexaDiag );
2395 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2396 if (_hexaDiag != NULL && doc != NULL)
2397 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2400 void HEXABLOCKGUI::addVector()
2402 if ( !_vectorDiag ){
2403 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2405 _showDialogBox( _vectorDiag );
2408 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2409 if (_vectorDiag != NULL && doc != NULL)
2410 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2413 //void HEXABLOCKGUI::addCylinder()
2415 // if ( !_cylinderDiag ){
2416 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2418 // _showDialogBox( _cylinderDiag );
2420 // //set default name
2421 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2422 // if (_cylinderDiag != NULL && doc != NULL)
2423 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2427 //void HEXABLOCKGUI::addPipe()
2429 // if ( !_pipeDiag){
2430 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2432 // _showDialogBox( _pipeDiag );
2434 // //set default name
2435 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2436 // if (_pipeDiag != NULL && doc != NULL)
2437 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2441 void HEXABLOCKGUI::makeGrid()
2443 if ( !_makeGridDiag ){
2444 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2446 _showDialogBox( _makeGridDiag );
2450 void HEXABLOCKGUI::makeCylinder()
2452 if ( !_makeCylinderDiag ){
2453 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2455 _showDialogBox( _makeCylinderDiag );
2458 void HEXABLOCKGUI::makePipe()
2460 if ( !_makePipeDiag ){
2461 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2463 _showDialogBox( _makePipeDiag );
2466 void HEXABLOCKGUI::makeCylinders()
2468 if ( !_makeCylindersDiag ){
2469 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2471 _showDialogBox( _makeCylindersDiag );
2474 void HEXABLOCKGUI::makePipes()
2476 if ( !_makePipesDiag ){
2477 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2479 _showDialogBox( _makePipesDiag );
2483 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2485 if ( !_makeHemiSphereDiag ){
2486 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2488 _showDialogBox( _makeHemiSphereDiag );
2492 void HEXABLOCKGUI::removeHexa()
2494 if ( !_removeHexaDiag ){
2495 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2497 _showDialogBox( _removeHexaDiag );
2501 void HEXABLOCKGUI::prismQuad()
2503 if ( !_prismQuadDiag ){
2504 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2506 _showDialogBox( _prismQuadDiag );
2510 void HEXABLOCKGUI::joinQuad()
2512 if ( !_joinQuadDiag ){
2513 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2515 _showDialogBox( _joinQuadDiag );
2518 void HEXABLOCKGUI::merge()
2521 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2523 _showDialogBox( _mergeDiag );
2526 void HEXABLOCKGUI::disconnectElts()
2528 if ( !_disconnectDiag ){
2529 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2531 _showDialogBox( _disconnectDiag );
2534 void HEXABLOCKGUI::cutEdge()
2536 if ( !_cutEdgeDiag ){
2537 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2539 _showDialogBox( _cutEdgeDiag );
2542 void HEXABLOCKGUI::makeTransformation()
2544 if ( !_makeTransformationDiag ){
2545 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2547 _showDialogBox( _makeTransformationDiag );
2551 void HEXABLOCKGUI::makeSymmetry()
2553 if ( !_makeSymmetryDiag ){
2554 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2556 _showDialogBox( _makeSymmetryDiag );
2560 void HEXABLOCKGUI::performTransformation()
2562 if ( !_performTransformationDiag ){
2563 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2565 _showDialogBox( _performTransformationDiag );
2569 void HEXABLOCKGUI::performSymmetry()
2571 if ( !_performSymmetryDiag ){
2572 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2574 _showDialogBox( _performSymmetryDiag );
2578 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2580 if ( !_replaceHexaDiag ){
2581 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2583 _showDialogBox( _replaceHexaDiag );
2587 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2589 if ( !_quadRevolutionDiag ){
2590 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2592 _showDialogBox( _quadRevolutionDiag );
2596 void HEXABLOCKGUI::assocVertex()
2598 if (!_dwInputPanel) return;
2599 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2600 if ( !_vertexAssocDiag )
2601 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2602 _showDialogBox( _vertexAssocDiag );
2606 void HEXABLOCKGUI::assocEdge()
2608 if ( !_edgeAssocDiag )
2609 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2610 _showDialogBox( _edgeAssocDiag );
2613 void HEXABLOCKGUI::assocQuad()
2615 if ( !_quadAssocDiag )
2616 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2617 _showDialogBox( _quadAssocDiag );
2621 void HEXABLOCKGUI::addGroup()
2624 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2626 _showDialogBox( _groupDiag );
2627 if (_groupDiag != NULL && getCurrentModel() != NULL)
2629 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2630 if (doc == NULL) return;
2631 char defaultName[16];
2632 sprintf (defaultName, "g%04d", doc->countGroup());
2633 _groupDiag->name_le->setText(defaultName);
2637 void HEXABLOCKGUI::removeGroup()
2639 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2640 if (currentDGView == NULL) return;
2642 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2643 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2644 int nbGroupsRemoved = 0;
2647 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2648 tr( "No group selected!" ) );
2652 foreach( QModelIndex selected, l ){
2653 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2654 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2655 Q_ASSERT(selected.isValid());
2657 //Confirm the deletion of the group
2658 if (SUIT_MessageBox::question(
2661 tr("Remove group : %1 ?").arg(selected.data().toString()),
2662 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2663 SUIT_MessageBox::Cancel
2664 ) == SUIT_MessageBox::Cancel) return;
2666 bool removed = getCurrentModel()->removeGroup( selected );
2668 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2669 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2675 if (!nbGroupsRemoved)
2676 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2677 tr( "No group selected!" ) );
2680 void HEXABLOCKGUI::addLaw()
2683 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2685 _showDialogBox( _lawDiag );
2686 if (_lawDiag != NULL && getCurrentModel() != NULL)
2688 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2689 if (doc == NULL) return;
2690 char defaultName[16];
2691 sprintf (defaultName, "l%04d", doc->countLaw());
2692 _lawDiag->name_le->setText(defaultName);
2696 void HEXABLOCKGUI::removeLaw()
2698 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2699 if (currentDGView == NULL) return;
2701 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2702 int nbLawsRemoved = 0;
2705 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2706 tr( "No law selected!" ) );
2710 foreach( QModelIndex selected, l ){
2711 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2712 selected = currentDGView->getMeshModel()->mapToSource( selected );
2713 Q_ASSERT(selected.isValid());
2715 //Confirm the deletion of the law
2716 if (SUIT_MessageBox::question(
2719 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2720 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2721 SUIT_MessageBox::Cancel
2722 ) == SUIT_MessageBox::Cancel) return;
2724 bool removed = getCurrentModel()->removeLaw(selected);
2726 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2727 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2734 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2735 tr( "No law selected!" ) );
2740 void HEXABLOCKGUI::setPropagation()
2742 if ( !_propagationDiag )
2743 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2745 _showDialogBox( _propagationDiag );
2748 // Dialog box to compute a mesh from a document
2749 // --------------------------------------------
2750 void HEXABLOCKGUI::computeMesh()
2752 if ( !_computeMeshDiag )
2753 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2755 _showDialogBox( _computeMeshDiag );
2758 void HEXABLOCKGUI::clearAssociations()
2760 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2761 if (currentDGView == NULL) return;
2763 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2764 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2765 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2767 getCurrentModel()->clearEltAssociations(iModel);
2769 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2772 void HEXABLOCKGUI::showModelInfo()
2774 //create the info dialog if not yet
2775 if (_modelInfoDiag == NULL)
2776 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2778 //show the model informations dialog
2779 _showDialogBox( _modelInfoDiag );
2782 void HEXABLOCKGUI::addShape()
2784 //create the info dialog if not yet
2785 if (_addShapeDiag == NULL)
2786 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2788 //show the model informations dialog
2789 _showDialogBox( _addShapeDiag );
2792 void HEXABLOCKGUI::clearAllAssociations()
2794 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2795 if (currentDGView == NULL) return;
2797 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2798 if (!currentIndex.isValid()) return;
2799 QVariant currentAssocVariant;
2800 QString currentAssocEntry;
2802 //Confirm the deletion of the associations
2803 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2804 if ( !treeVariant.isValid() ) return;
2805 int eltType = treeVariant.toInt();
2806 QString typeStr = "";
2807 HEXA_NS::EnumElt hexaType;
2808 if (eltType == VERTEX_DIR_TREE)
2810 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2811 hexaType = HEXA_NS::EL_VERTEX;
2813 else if (eltType == EDGE_DIR_TREE)
2815 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2816 hexaType = HEXA_NS::EL_EDGE;
2818 else if (eltType == QUAD_DIR_TREE)
2820 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2821 hexaType = HEXA_NS::EL_QUAD;
2824 if (SUIT_MessageBox::question(
2826 tr("CLEAR_ASSOCIATIONS"),
2827 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2828 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2829 SUIT_MessageBox::Cancel
2830 ) == SUIT_MessageBox::Cancel) return;
2833 DocumentModel* docModel = getCurrentModel();
2834 if (docModel == NULL) return;
2835 docModel->clearAssociation(hexaType);
2838 void HEXABLOCKGUI::showAssociations()
2840 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2841 if (currentDGView == NULL) return;
2843 QModelIndexList elts;
2844 int currentChildIndex = 0;
2845 QVariant currentAssocVariant;
2846 QString currentAssocEntry;
2847 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2848 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2850 while( currentChild.isValid() ) {
2852 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2853 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2854 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2855 elts << currentChild;
2857 currentChild = currentChild.sibling(currentChildIndex++, 0);
2859 currentDocGView->highlight(elts);
2860 currentOccGView->highlight(elts, false);
2864 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2866 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2868 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2873 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2875 if ( event->type() == QEvent::Enter )
2876 { // *** ENTER EVENT
2878 if (currentDialog == NULL || !currentDialog->isVisible())
2879 return QObject::eventFilter(obj, event);
2881 // ** The window acquire the focus when the cursor enter
2883 //OCC - window enter
2884 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2885 if ( occWindow != NULL)
2886 currentDialog->onWindowActivated(occWindow->getViewManager());
2888 //VTK - window enter
2890 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2891 if ( vtkWindow != NULL)
2892 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2896 //standard event processing
2897 return QObject::eventFilter(obj, event);
2900 QStringList HEXABLOCKGUI::getQuickDirList()
2902 QStringList dirList;
2903 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2905 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2911 // --- Export the module
2915 HEXABLOCK_EXPORT CAM_Module* createModule()
2917 return new HEXABLOCKGUI();
2920 HEXABLOCK_EXPORT char* getModuleVersion()
2922 return (char*)HEXABLOCK_VERSION_STR;
2928 // ******************** TESTS ***************************************************
2930 void HEXABLOCKGUI::testDocument()
2934 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2935 // QStandardItem *myItem = new QStandardItem("MyItem");
2936 // parentItem->appendRow(myItem);
2938 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2939 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2940 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2941 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2942 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2943 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2944 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2945 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2948 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2949 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2950 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2951 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2952 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2953 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2955 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2956 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2957 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2958 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2963 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2964 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2965 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2966 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2974 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2975 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2977 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2978 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2982 // newMesh( "toto", 3, "FactoryServer");
2986 void HEXABLOCKGUI::test_make_cart_grid()
2988 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2989 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2990 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2991 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2992 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
2993 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
2995 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
2996 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3003 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3004 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3005 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3006 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3007 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3008 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3013 void HEXABLOCKGUI::test_make_elmts_transform()
3020 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3021 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3024 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3025 // orig.setScalar(2);
3027 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3028 // getCurrentModel()->saveVtk(file_name)
3030 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3031 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3033 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3034 // getCurrentModel()->saveVtk(file_name)
3036 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3039 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3040 // getCurrentModel()->saveVtk(file_name);
3043 // print "...test make elements by transforming elements OK"
3045 // =============================================================== addDocInSudy
3046 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3050 if (document == NULL)
3053 QString docName = document->getName ();
3055 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3056 if (app_study == NULL)
3059 _PTR(Study) study = app_study->studyDS();
3060 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3061 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3062 QString entry = app_study->centry("HEXABLOCK");
3063 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3064 if (aFatherSO->_is_nil())
3067 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3070 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3071 docEntry = aSO->GetID(); //the entry of the published object
3076 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3078 void HEXABLOCKGUI::test()
3080 DEBTRACE("HEXABLOCKGUI::test");
3081 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3082 if (currentDGView == NULL) return;
3083 currentDGView->update();
3087 void HEXABLOCKGUI::test_association()
3089 DEBTRACE("HEXABLOCKGUI::test_association");
3092 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3094 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3095 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3096 DocumentModel::GeomObj q0AssocA, q0AssocB;
3098 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3099 QList<DocumentModel::GeomObj> e1Assocs_test;
3100 DocumentModel::GeomObj q0Assoc_test;
3102 v0 = getCurrentModel()->addVertex(0, 0, 0);
3103 v1 = getCurrentModel()->addVertex(1, 0, 0);
3104 v2 = getCurrentModel()->addVertex(1, 1, 0);
3105 v3 = getCurrentModel()->addVertex(0, 1, 0);
3106 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3107 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3108 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3111 // >>> face3.GetEntry()'0:1:4'
3112 // >>> e1.GetEntry()'0:1:8'
3113 // >>> e2.GetEntry()'0:1:9'
3114 // >>> e3.GetEntry()'0:1:10'
3115 // >>> e4.GetEntry()'0:1:11'
3116 // >>> v1.GetEntry()'0:1:12'
3117 // >>> v2.GetEntry()'0:1:13'
3118 // >>> v3.GetEntry()'0:1:14'
3119 // >>> v4.GetEntry()'0:1:15'
3122 // v0Assoc.name = "geomV0";
3123 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3124 // v0Assoc.brep = "brepV0";
3125 // v1Assoc.name = "geomV1";
3126 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3127 // v1Assoc.brep = "brepV1";
3128 // v2Assoc.name = "geomV2";
3129 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3130 // v2Assoc.brep = "brepV2";
3131 // v3Assoc.name = "geomV3";
3132 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3133 // v3Assoc.brep = "brepV3";
3137 // e0AssocA.name = "geomE0a";
3138 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3139 // e0AssocA.brep = "brepE0a";
3140 // e0AssocA.start = 0.10;
3141 // e0AssocA.end = 0.95;
3145 // e1AssocA.name = "geomE1a";
3146 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3147 // e1AssocA.brep = "brepE1a";
3148 // e1AssocA.start = 0.12;
3149 // e1AssocA.end = 0.89;
3150 // e1AssocB.name = "geomE1b";
3151 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3152 // e1AssocB.brep = "brepE1b";
3153 // e1AssocB.start = 0.20;
3154 // e1AssocB.end = 0.80;
3155 // e1AssocC.name = "geomE1c";
3156 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3157 // e1AssocC.brep = "brepE1c";
3158 // e1AssocC.start = 0.16;
3159 // e1AssocC.end = 0.96;
3161 // q0AssocA.name = "geomQuad";
3162 // q0AssocA.entry = "0:1:1:1:3";
3163 // q0AssocA.brep = "brepq0";
3165 // q0AssocB.name = "geomQuad";
3166 // q0AssocB.entry = "0:1:1:1:4";
3167 // q0AssocB.brep = "brepq0";
3169 // getCurrentModel()->addAssociation( v0, v0Assoc );
3170 // getCurrentModel()->addAssociation( v1, v1Assoc );
3171 // getCurrentModel()->addAssociation( v2, v2Assoc );
3172 // getCurrentModel()->addAssociation( v3, v3Assoc );
3175 // getCurrentModel()->addAssociation( e0, e0AssocA );
3177 // getCurrentModel()->addAssociation( e1, e1AssocA );
3178 // getCurrentModel()->addAssociation( e1, e1AssocB );
3179 // getCurrentModel()->addAssociation( e1, e1AssocC );
3181 // getCurrentModel()->addAssociation( q0, q0AssocA );
3182 // getCurrentModel()->addAssociation( q0, q0AssocB );
3188 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3189 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3190 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3191 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3192 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3193 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3194 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3195 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3196 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3197 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3198 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3199 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3202 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3203 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3204 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3205 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3206 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3207 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3208 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3209 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3210 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3211 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3212 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3213 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3214 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3216 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3217 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3218 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3221 DEBTRACE("HEXABLOCKGUI::test_association fin");