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 MESSAGE("HEXABLOCKGUI::initialize");
240 DEBTRACE("HEXABLOCKGUI::initialize");
241 SalomeApp_Module::initialize( app );
243 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
245 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
247 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
248 setResource(aResourceMgr);
250 createAndFillDockWidget();
257 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
259 DEBTRACE("HEXABLOCKGUI::viewManagers");
260 // list.append( QxScene_Viewer::Type() );
261 // list.append( OCCViewer_Viewer::Type() );
262 // list.append( SVTK_Viewer::Type() );
266 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
268 DEBTRACE("HEXABLOCKGUI::activateModule");
270 /*HexaBlock can be launched in only one application*/
271 if (myApplication == NULL)
272 //remember the first application
273 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
275 //application verification: if it's not the one known by HexaBlock,
276 //leave without activating
277 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
278 if (myApplication != currentApplication) return false;
280 bool bOk = SalomeApp_Module::activateModule( theStudy );
281 if ( !bOk ) return false;
283 showDockWidgets(true);
285 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
286 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
287 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
288 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
290 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
292 SUIT_ViewManager* vm;
293 ViewManagerList OCCViewManagers, VTKViewManagers;
295 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
296 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
297 while ( itOCC.hasNext() && (vm = itOCC.next()) )
298 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
300 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
301 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
302 while ( itVTK.hasNext() && (vm = itVTK.next()) )
303 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
306 SALOME_ListIO selected;
307 sm->selectedObjects( selected );
310 // disable OCC selectors
311 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
312 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
313 while ( itOCCSel.hasNext() )
314 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
315 sr->setEnabled(true);
317 // disable VTK selectors
318 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
319 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
320 while ( itVTKSel.hasNext() )
321 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
322 sr->setEnabled(true);
324 sm->setSelectedObjects( selected, true ); //NPAL 19674
326 //connect close signal to vtk view manager
327 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
330 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
331 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
334 //connect close signal to occ view manager
335 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
338 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
339 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
342 /* ************************************ TODO Hexa6
343 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
344 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
345 if ( _PTR(Study) aStudy = s->studyDS()) {
346 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
347 updateObjBrowser(); // objects can be removed
349 ************************************ */
351 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
352 currentOccGView->getViewWindow()->installEventFilter(this);
354 if (currentDocGView != NULL)
356 switchModel(currentDocGView);
359 if (currentDocGView->getViewWindow() != NULL)
360 currentDocGView->getViewWindow()->installEventFilter(this);
369 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
371 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
372 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
373 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
374 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
376 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
377 if ( vtkView != NULL)
379 //default selectionMode in VTKView
380 vtkView->SetSelectionMode( ActorSelection );
381 vtkView->removeEventFilter(this);
385 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
388 //defaut selectionMode in OccView
389 selectionMgr()->clearSelected();
390 currentOccGView->globalSelection();
391 occView->removeEventFilter(this);
395 qDeleteAll(myOCCSelectors);
396 myOCCSelectors.clear();
397 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
399 qDeleteAll(myVTKSelectors);
400 myVTKSelectors.clear();
401 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
403 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
405 //switch off current document graphic view
406 switchOffGraphicView(currentDocGView);
409 setMenuShown( false );
410 setToolShown( false );
411 showDockWidgets( false );
413 _dwInputPanel->close();
420 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
422 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
423 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
424 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
425 int aStudyID = theStudy->StudyId();
426 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
427 return aDSStudy._retn();
430 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
431 QMap<QString, QString>& docShapesEntry,
432 QMap<QString, QString>& docShapesName)
434 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
435 return; //there's nothing to publish in this case
437 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
438 if(!appStudy) return;
439 _PTR(Study) aStudy = appStudy->studyDS();
440 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
441 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
442 QString entry = currentDocGView->getDocumentModel()->documentEntry();
443 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
444 if (aFatherSO->_is_nil())
447 // * get a presentation
448 bool isNewPrs = false;
449 SOCC_Prs* prs = getOccPrs(currentDocGView);
452 prs = new SOCC_Prs();
456 // * init the presentation with the given shapes
457 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
458 while (i != topo_shapes.constEnd())
460 QString shapeName = i.key();
461 TopoDS_Shape shapeValue = i.value();
462 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
463 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
464 QString objStudyEntry = aSO->GetID(); //the entry of the published object
465 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
466 "HEXABLOCK", shapeName.toStdString().c_str());
467 ais_shape->SetOwner(io);
468 prs->AddObject(ais_shape);
469 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
470 docShapesEntry[shapeName] = objStudyEntry;
471 docShapesName[objStudyEntry] = shapeName;
472 currentOccGView->addShape(objStudyEntry, ais_shape);
473 i++; //handle next shape
477 prs->AddObject(currentOccGView->getPreviewShape());
479 occPrs[currentDocGView] = prs;
480 getApp()->updateObjectBrowser();
485 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
487 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
488 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
489 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
491 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
495 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
499 // Pas de renommage des shapes pour le moment, juste les documents
500 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
501 if (dgview == NULL || dgview->getDocumentModel() == NULL)
504 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
505 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
510 _PTR(Study) aStudy = appStudy->studyDS();
515 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
516 _PTR(GenericAttribute) anAttr;
518 if ( obj->FindAttribute(anAttr, "AttributeName") ){
519 _PTR(AttributeName) aName (anAttr);
520 DocumentModel* docModel = dgview->getDocumentModel();
521 docModel->setName( name );
522 aName->SetValue( name.toLatin1().data() );
523 getApp()->updateObjectBrowser();
524 _dwPattern->setWindowTitle( name );
531 // --- Default windows
532 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
534 DEBTRACE("HEXABLOCKGUI::windows");
536 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
537 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
540 QString HEXABLOCKGUI::engineIOR() const
542 DEBTRACE("HEXABLOCKGUI::engineIOR");
544 /* ************************************ TODO Hexa6
545 CORBA::ORB_var anORB = getApp()->orb();
546 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
547 return QString( anIOR.in() );
548 ************************************ */
552 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
554 if (docs.count(studyObject->entry()) == 0)
556 //Object's document not acquired yet
557 VtkDocumentGraphicView* dgview;
558 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
559 if (directory == NULL)
560 return NULL; //No working director found
562 //------------------ Load the document -----------------
563 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
564 if (document == NULL)
565 return NULL; //No document found
567 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
569 MESSAGE("Doc model creation failed!");
572 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
573 if (dgview == NULL) return NULL;
575 //update the data tree
576 docs[studyObject->entry()] = dgview;
579 return docs[studyObject->entry()];
582 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
584 // ** we want to switch automatically to the right view windows
586 //first, find selected item
588 DataObjectList dol = getApp()->objectBrowser()->getSelected();
589 if (dol.isEmpty()) return;
590 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
591 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
592 item->entry().isEmpty())
595 // find the document corresponding to it
596 VtkDocumentGraphicView* docGView = NULL;
597 if (docs.contains(item->entry()))
598 docGView = docs[item->entry()];
600 docGView = getOrCreateDocument(item);
602 //Init OCC if necessary
603 if (currentOccGView == NULL)
605 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
606 currentOccGView->getViewWindow()->installEventFilter(this);
608 else if (currentOccGView->getViewWindow() == NULL)
610 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
611 currentOccGView->getViewWindow()->installEventFilter(this);
614 //Init the vtk view if necessary
615 if (docGView->getViewWindow() == NULL)
617 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
619 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
620 docGView->getViewWindow()->installEventFilter(this);
624 docGView->setViewWindow(currentDocGView->getViewWindow());
626 if (docGView->getDocumentActor() == NULL)
630 if (docGView == NULL || docGView == currentDocGView)
636 //update the current document
637 switchModel(docGView);
641 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
643 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
646 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
648 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
650 //Decharger le model correspondant (VTK)
651 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
655 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
656 { //HexaBlock Vtk Window has been closed
658 if (currentDialog != NULL) currentDialog->close();
659 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
660 if (currentDocGView != NULL)
661 currentDocGView->setViewWindow(NULL);
668 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
669 if (dgview == NULL) return; //The window has no document to close
671 //Save the document? (Ask only if the document is not empty
672 int answerCode = SUIT_MessageBox::question(
675 tr("Save the document ?"),
676 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
677 SUIT_MessageBox::Cancel);
678 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
679 else if (answerCode == SUIT_MessageBox::Yes)
680 saveDocument(); //Save the document
682 // switchOffGraphicView(window); //disconnect all connected signals
683 // currentVtkView = NULL;
684 // graphicViewsHandler->closeDocumentGraphicView(window);
686 //create a new one (empty document)
688 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
692 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
694 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
695 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
696 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
697 if (currentDialog != NULL) currentDialog->close();
698 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
700 currentOccGView->getViewWindow()->removeEventFilter(this);
701 currentOccGView->setViewWindow(NULL);
705 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
707 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
709 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
710 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
712 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
714 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
715 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
716 // disable OCC selectors
717 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
718 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
719 while ( itOCCSel.hasNext() )
720 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
721 sr->setEnabled(true);
723 else if ( vm->getType() == SVTK_Viewer::Type() )
725 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
726 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
728 // disable VTK selectors
729 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
730 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
731 while ( itVTKSel.hasNext() )
732 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
733 sr->setEnabled(true);
737 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
739 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
741 SUIT_ViewModel* viewer = vm->getViewModel();
742 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
744 //VTK View Manager removed
745 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
747 //Process only if it's our view manager
748 SUIT_ViewManager* myVm = NULL;
749 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
750 myVm = currentDocGView->getViewWindow()->getViewManager();
754 //close opened dialog
755 if (currentDialog != NULL) currentDialog->close();
756 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
762 //remove its selector
763 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
764 while ( itVTKSel.hasNext() )
765 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
766 if ( sr->viewer() == viewer )
768 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
775 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
777 //OCC View removed: remove its selector
778 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
779 while ( itOCCSel.hasNext() )
780 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
781 if ( sr->viewer() == viewer )
783 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
789 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
791 QModelIndexList l = selected.indexes();
792 if ( l.count() == 0 ) return;
793 if ( !l[0].isValid() ) return;
794 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
795 if ( currentGraphicView == NULL) return;
797 QTreeView* theTree = NULL;
798 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
799 theTree = _patternDataTreeView;
801 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
802 theTree = _patternBuilderTreeView;
804 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
805 theTree = _patternGeomTreeView;
807 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
808 theTree = _groupsTreeView;
809 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
810 theTree = _meshTreeView;
813 theTree->scrollTo ( l[0] );
817 bool HEXABLOCKGUI::createSComponent() //addComponent
819 DEBTRACE("HEXABLOCKGUI::createSComponent");
820 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
822 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
823 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
824 _PTR(GenericAttribute) anAttr;
825 _PTR(AttributeName) aName;
826 _PTR(AttributeGraphic) aGraphic;
828 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
829 if ( !aComponent ){ //Create hexablock component if there's not one yet
830 aComponent = aBuilder->NewComponent("HEXABLOCK");
831 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
832 aName = _PTR(AttributeName) (anAttr);
833 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
835 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
836 _PTR(AttributePixMap) aPixmap(anAttr);
837 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
839 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
840 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
846 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
848 DEBTRACE("HEXABLOCKGUI::setResource");
849 _myresource = new HEXABLOCKGUI_Resource(r);
850 _myresource->preferencesChanged();
853 void HEXABLOCKGUI::createPreferences()
855 DEBTRACE("HEXABLOCKGUI::createPreferences");
856 _myresource->createPreferences(this);
859 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
861 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
862 _myresource->preferencesChanged(sect, name);
863 // if(name=="userCatalog")
864 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
867 void HEXABLOCKGUI::studyActivated() //CS_TODO
869 int newStudyId = getApp()->activeStudy()->id();
870 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
871 // if (_oldStudyId != -1)
873 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
874 // if (_studyContextMap.count(newStudyId))
876 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
877 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
881 // DEBTRACE("no switch to null context");
884 _oldStudyId = newStudyId;
887 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
889 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
890 QVariant currentAssocVariant;
891 QString currentAssocEntry;
893 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
894 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
895 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
896 QMenu menu( _patternDataTreeView );
898 QAction *clearAct = menu.addAction( "Remove association(s)" );
899 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
900 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
904 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
905 if (currentVtkGraphicView == NULL) return;
906 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
908 //We don't do anything for single items
909 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
910 item->type() == QUADITEM || item->type() == HEXAITEM)
913 //No associations for HEXA
914 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
915 if ( !treeVariant.isValid() ) return;
916 int eltType = treeVariant.toInt();
917 if (eltType == HEXA_DIR_TREE) return;
918 QMenu menu( _patternDataTreeView );
920 //Show association(s)
921 QAction *showAssocAct = menu.addAction( "Show associations" );
922 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
924 //Clear all associations
925 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
926 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
928 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
933 void HEXABLOCKGUI::createAndFillDockWidget()
936 QMainWindow *aParent = application()->desktop();
938 // Create dock widget (3 dock)
940 //1) *********** user input panel ( contain user's edit dialog box )
941 _dwInputPanel = new QDockWidget(aParent);
942 _dwInputPanel->setVisible(false);
943 _dwInputPanel->setWindowTitle("Input Panel");
944 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
946 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
948 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
950 _dwPattern = new QDockWidget(aParent);
951 _dwPattern->setVisible(false);
952 _dwPattern->setWindowTitle("Model");
953 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
955 QFrame* patternFrame = new QFrame(_dwPattern);
956 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
957 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
958 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
959 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
960 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
961 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
962 _patternGeomTreeView = new QTreeView(patternFrame);
963 splitter->addWidget(_patternDataTreeView);
964 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
965 splitter->addWidget(_patternGeomTreeView);
966 patternLayout->addWidget(splitter);
968 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
969 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
970 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
973 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
974 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
976 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
977 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
979 _dwPattern->setWidget(patternFrame);
980 patternFrame->show();
983 _dwGroups = new QDockWidget(aParent);
985 _dwGroups->setVisible(false);
986 _dwGroups->setWindowTitle("Groups");
987 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
988 _groupsTreeView = new QTreeView(_dwGroups);
989 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
990 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
991 _dwGroups->setWidget(_groupsTreeView);
992 _groupsTreeView->show();
995 _dwMesh = new QDockWidget(aParent);
996 _dwMesh->setVisible(false);
997 _dwMesh->setWindowTitle("Mesh");
998 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
999 _meshTreeView = new QTreeView(_dwMesh);
1000 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1001 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1002 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1003 _dwMesh->setWidget(_meshTreeView);
1004 _meshTreeView->show();
1006 // QDockWidget *_dwObjectBrowser = 0;
1007 QWidget* wid = getApp()->objectBrowser()->treeView();
1008 QWidget *w = wid->parentWidget();
1009 while ( w && !_dwObjectBrowser ) {
1010 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1011 w = w->parentWidget();
1013 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1014 _dwObjectBrowser->setWindowTitle("Study");
1016 // dock widget position
1017 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1018 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1020 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1021 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1022 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1024 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1025 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1026 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1028 #if QT_VERSION >= 0x040500
1029 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1032 // popup menu on data tree view
1033 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1034 connect(_patternDataTreeView,
1035 SIGNAL(customContextMenuRequested(const QPoint &)),
1037 SLOT(treeContextMenu(const QPoint &)),
1038 Qt::UniqueConnection );
1041 void HEXABLOCKGUI::createActions()
1043 QMainWindow *aParent = application()->desktop();
1044 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1047 _newAct = createAction(_menuId++,
1048 tr("Create a new document"),
1049 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1051 tr("Create a new document"),
1052 0, aParent, false, this, SLOT(newDocument()));
1053 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1055 _importAct = createAction(_menuId++,
1056 tr("Load a document"),
1057 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1058 tr("Load Document"),
1059 tr("Load a document"),
1060 0, aParent, false, this, SLOT(loadDocument()));
1061 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1063 _saveAct = createAction(_menuId++,
1064 tr("Save the document"),
1065 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1066 tr("Save Document"),
1067 tr("Save the document"),
1068 0, aParent, false, this, SLOT(saveDocument()));
1070 // Pattern Data creation
1071 _addVertex = createAction(_menuId++,
1072 tr("Create a vertex"),
1073 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1075 tr("Create a new vertex"),
1076 0, aParent, false, this, SLOT(addVertex()));
1078 _addEdge = createAction(_menuId++,
1079 tr("Create an edge"),
1080 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1082 tr("Create a new edge"),
1083 0, aParent, false, this, SLOT(addEdge()));
1085 _addQuad = createAction(_menuId++,
1086 tr("Create a quadrangle"),
1087 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1088 tr("Add Quadrangle"),
1089 tr("Create a new quadrangle"),
1090 0, aParent, false, this, SLOT(addQuad()));
1092 _addHexa = createAction(_menuId++,
1093 tr("Create an hexahedron"),
1094 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1095 tr("Add Hexahedron"),
1096 tr("Create a new hexahedron"),
1097 0, aParent, false, this, SLOT(addHexa()));
1099 // Builder Data creation
1100 _addVector = createAction(_menuId++,
1101 tr("Create a vector"),
1102 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1104 tr("Create a new vector"),
1105 0, aParent, false, this, SLOT(addVector()));
1107 // _addCylinder = createAction(_menuId++,
1108 // tr("Create a cylinder"),
1109 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1110 // tr("Add Cylinder"),
1111 // tr("Create a new cylinder"),
1112 // 0, aParent, false, this, SLOT(addCylinder()));
1114 // _addPipe = createAction(_menuId++,
1115 // tr("Create a pipe"),
1116 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1118 // tr("Create a new pipe"),
1119 // 0, aParent, false, this, SLOT(addPipe()));
1121 _makeGrid = createAction(_menuId++,
1123 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1126 0, aParent, false, this, SLOT(makeGrid()));
1128 _makeCylinder = createAction(_menuId++,
1129 tr("Make a cylinder"),
1130 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1131 tr("Make Cylinder"),
1132 tr("Make a cylinder"),
1133 0, aParent, false, this, SLOT(makeCylinder()));
1135 _makePipe = createAction(_menuId++,
1137 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1140 0, aParent, false, this, SLOT(makePipe()));
1142 _makeCylinders = createAction(_menuId++,
1143 tr("Make cylinders"),
1144 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1145 tr("Make Cylinders"),
1146 tr("Make cylinders"),
1147 0, aParent, false, this, SLOT(makeCylinders()));
1149 _makePipes = createAction(_menuId++,
1151 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1154 0, aParent, false, this, SLOT(makePipes()));
1156 _makeHemiSphere = createAction(_menuId++,
1157 tr("Make an hemisphere"),
1158 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1159 tr("Make Hemisphere"),
1160 tr("Make an hemisphere"),
1161 0, aParent, false, this, SLOT(makeHemiSphere()));
1163 // Pattern Data edition
1164 _removeHexa = createAction(_menuId++,
1165 tr("Remove hexahedra"),
1166 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1167 tr("Remove Hexahedra"),
1168 tr("Remove hexahedra"),
1169 0, aParent, false, this, SLOT(removeHexa()));
1171 _prismQuad = createAction(_menuId++,
1172 tr("Prism quadrangles"),
1173 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1174 tr("Prism Quadrangles"),
1175 tr("Prism quadrangles"),
1176 0, aParent, false, this, SLOT(prismQuad()));
1178 _joinQuad = createAction(_menuId++,
1179 tr("Join quadrangles"),
1180 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1181 tr("Join Quadrangles"),
1182 tr("Join quadrangles with hexahedra"),
1183 0, aParent, false, this, SLOT(joinQuad()));
1185 _merge = createAction(_menuId++,
1187 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1190 0, aParent, false, this, SLOT(merge()));
1192 _disconnect = createAction(_menuId++,
1194 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1196 tr("Disconnect edges, vertexes or quadrangles"),
1197 0, aParent, false, this, SLOT(disconnectElts()));
1199 _cutEdge = createAction(_menuId++,
1201 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1204 0, aParent, false, this, SLOT(cutEdge()));
1206 _makeTransformation = createAction(_menuId++,
1207 tr("Make transformation"),
1208 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1209 tr("Make Transformation"),
1210 tr("Make transformation"),
1211 0, aParent, false, this, SLOT(makeTransformation()));
1213 _makeSymmetry = createAction(_menuId++,
1214 tr("Make symmetry"),
1215 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1216 tr("Make Symmetry"),
1217 tr("Make symmetry"),
1218 0, aParent, false, this, SLOT(makeSymmetry()));
1220 _performTransformation = createAction(_menuId++,
1221 tr("Perform transformation"),
1222 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1223 tr("Perform Transformation"),
1224 tr("Perform transformation"),
1225 0, aParent, false, this, SLOT(performTransformation()));
1227 _performSymmetry = createAction(_menuId++,
1228 tr("Perform symmetry"),
1229 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1230 tr("Perform Symmetry"),
1231 tr("Perform symmetry"),
1232 0, aParent, false, this, SLOT(performSymmetry()));
1234 _replaceHexa = createAction(_menuId++,
1235 tr("Replace hexahedron"),
1236 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1237 tr("Replace Hexahedron"),
1238 tr("Replace hexahedron"),
1239 0, aParent, false, this, SLOT(replaceHexa()));
1241 _quadRevolution = createAction(_menuId++,
1242 tr("Quad revolution"),
1243 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1244 tr("Quad Revolution"),
1245 tr("Quad revolution"),
1246 0, aParent, false, this, SLOT(quadRevolution()));
1249 _assocVertex = createAction(_menuId++,
1250 tr("Make vertex association"),
1251 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1252 tr("Make Vertex association"),
1253 tr("Make vertex association"),
1254 0, aParent, false, this, SLOT(assocVertex()));
1256 _assocEdge = createAction(_menuId++,
1257 tr("Make edge association"),
1258 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1259 tr("Make Edge Association"),
1260 tr("Make edge association"),
1261 0, aParent, false, this, SLOT(assocEdge()));
1263 _assocQuad = createAction(_menuId++,
1264 tr("Make quad association"),
1265 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1266 tr("Make Quad Association"),
1267 tr("Make quad association"),
1268 0, aParent, false, this, SLOT(assocQuad()));
1271 _addGroup = createAction(_menuId++,
1273 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1276 0, aParent, false, this, SLOT(addGroup()));
1278 _removeGroup = createAction(_menuId++,
1279 tr("Remove a group"),
1280 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1282 tr("Remove a group"),
1283 0, aParent, false, this, SLOT(removeGroup()));
1286 _addLaw = createAction(_menuId++,
1288 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1291 0, aParent, false, this, SLOT(addLaw()));
1293 _removeLaw = createAction(_menuId++,
1295 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1298 0, aParent, false, this, SLOT(removeLaw()));
1300 _setPropagation = createAction(_menuId++,
1301 tr("Set propagation"),
1302 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1303 tr("Set Propagation"),
1304 tr("Set propagation"),
1305 0, aParent, false, this, SLOT(setPropagation()));
1307 _computeMesh = createAction(_menuId++,
1309 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1312 0, aParent, false, this, SLOT(computeMesh()));
1314 _showModelInfoAct = createAction(_menuId++,
1315 tr("Show Model Info"),
1316 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1319 0, aParent, false, this, SLOT(showModelInfo()));
1321 _addShapeAct = createAction(_menuId++,
1323 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1326 0, aParent, false, this, SLOT(addShape()));
1328 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1329 // QAction* createAction(const int id,
1330 // const QString& toolTip,
1331 // const QIcon& icon,
1332 // const QString& menu,
1333 // const QString& status,
1334 // const int shortCut,
1335 // QObject* parent =0,
1336 // bool checkable = false,
1337 // QObject* receiver =0,
1338 // const char* member =0);
1340 _sep1 = separator();
1341 _sep2 = separator();
1342 _sep3 = separator();
1343 _sep4 = separator();
1347 void HEXABLOCKGUI::createMenus()
1349 int aMenuId, subMenuId,aMenuIdMain;
1351 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1353 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1354 createMenu( actionId(_newAct), aMenuId );
1355 createMenu( actionId(_importAct), aMenuId );
1356 createMenu( _saveAct, aMenuId );
1359 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1360 createMenu( _newAct, aMenuDocId );//, 10
1361 createMenu( _importAct, aMenuDocId );
1362 createMenu( _saveAct, aMenuDocId );
1364 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1365 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1366 createMenu( _addVertex, subMenuId );
1367 createMenu( _addEdge, subMenuId );
1368 createMenu( _addQuad, subMenuId );
1369 createMenu( _addHexa, subMenuId );
1370 createMenu( _sep1, subMenuId);
1373 createMenu( _addVector, subMenuId );
1374 // createMenu( _addCylinder, subMenuId );
1375 // createMenu( _addPipe, subMenuId );
1377 createMenu( _sep2, subMenuId);
1379 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1380 createMenu( _makeHemiSphere,subMenuId );
1382 createMenu( _sep3, subMenuId);
1384 createMenu( _makeCylinder, subMenuId );
1385 createMenu( _makePipe, subMenuId );
1386 createMenu( _makeCylinders,subMenuId );
1387 createMenu( _makePipes, subMenuId );
1389 // Pattern Data Edition
1390 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1391 createMenu( _removeHexa, subMenuId );
1392 createMenu( _prismQuad, subMenuId );
1393 createMenu( _joinQuad, subMenuId );
1394 createMenu( _merge, subMenuId );
1395 createMenu( _disconnect, subMenuId );
1396 createMenu( _cutEdge, subMenuId );
1397 createMenu( _makeTransformation, subMenuId );
1398 createMenu( _makeSymmetry, subMenuId );
1399 createMenu( _performTransformation, subMenuId );
1400 createMenu( _performSymmetry, subMenuId );
1401 createMenu( _replaceHexa, subMenuId );
1402 createMenu( _quadRevolution, subMenuId );
1403 createMenu( _sep4, aMenuId );
1404 createMenu( _showModelInfoAct, aMenuId );
1407 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1408 createMenu( _addShapeAct, aMenuId );
1409 createMenu( _assocVertex, aMenuId );
1410 createMenu( _assocEdge, aMenuId );
1411 createMenu( _assocQuad, aMenuId );
1414 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1415 createMenu( _addGroup, aMenuId );
1416 createMenu( _removeGroup, aMenuId ); //CS_TODO
1419 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1420 createMenu( _addLaw, aMenuId );
1421 createMenu( _removeLaw, aMenuId );
1422 createMenu( _setPropagation, aMenuId );
1423 createMenu( _computeMesh, aMenuId );
1425 //show model infomation menu
1426 QString aRule = "$component={'HEXABLOCK'}";
1427 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1428 popupMgr()->setRule( _showModelInfoAct, aRule);
1430 //associate shape to a document menu
1431 popupMgr()->insert( _addShapeAct, -1, -1 );
1432 popupMgr()->setRule( _addShapeAct, aRule );
1434 //-------------------------------------------------
1436 //-------------------------------------------------
1437 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1438 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1439 // QString isNotEmpty("numberOfNodes <> 0");
1440 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1441 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1442 //// aType = aType.arg( mesh_part );
1444 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1445 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1446 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1448 // popupMgr()->insert( separator(), -1, -1 );
1449 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1450 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1451 // // MESSAGE("aClient = " << aClient.toStdString());
1452 // // MESSAGE("aType = " << aType.toStdString());
1453 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1454 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1455 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1456 // // MESSAGE("aRule = " << aRule.toStdString());
1457 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1458 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1460 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1461 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1463 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1464 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1466 // popupMgr()->insert( separator(), -1, -1 );
1470 void HEXABLOCKGUI::createTools()
1474 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1475 createTool( _newAct, aToolId );
1476 createTool( _importAct, aToolId );
1477 createTool( _saveAct, aToolId );
1478 createTool( _showModelInfoAct, aToolId );
1479 // createTool( _testAct, aToolId );
1480 //createTool( separator(), aToolId );
1483 aToolId = createTool ( tr( "Construction" ) );
1484 createTool( _addVertex, aToolId );
1485 createTool( _addEdge, aToolId );
1486 createTool( _addQuad, aToolId );
1487 createTool( _addHexa, aToolId );
1489 createTool( _sep1, aToolId );
1492 createTool( _addVector, aToolId );
1493 // createTool( _addCylinder, aToolId );
1494 // createTool( _addPipe, aToolId );
1496 createTool( _sep2, aToolId );
1498 createTool( _makeGrid, aToolId );
1499 createTool( _makeHemiSphere, aToolId );
1501 createTool( _sep3, aToolId );
1503 createTool( _makeCylinder, aToolId );
1504 createTool( _makePipe, aToolId );
1505 createTool( _makeCylinders,aToolId );
1506 createTool( _makePipes, aToolId );
1508 // Pattern Data Edition
1509 aToolId = createTool ( tr( "Operation" ) );
1510 createTool( _removeHexa, aToolId );
1511 createTool( _prismQuad, aToolId );
1512 createTool( _joinQuad, aToolId );
1513 createTool( _merge, aToolId );
1514 createTool( _disconnect, aToolId );
1515 createTool( _cutEdge, aToolId );
1516 createTool( _makeTransformation, aToolId );
1517 createTool( _makeSymmetry, aToolId );
1518 createTool( _performTransformation, aToolId );
1519 createTool( _performSymmetry, aToolId );
1520 createTool( _replaceHexa, aToolId );
1521 createTool( _quadRevolution, aToolId );
1524 aToolId = createTool ( tr( "Association" ) );
1525 createTool( _assocVertex, aToolId );
1526 createTool( _assocEdge, aToolId );
1527 createTool( _assocQuad, aToolId );
1528 createTool( _addShapeAct, aToolId );
1531 aToolId = createTool ( tr( "Group" ) );
1532 createTool( _addGroup, aToolId );
1533 createTool( _removeGroup, aToolId ); //CS_TODO
1536 aToolId = createTool ( tr( "Mesh" ) );
1537 createTool( _addLaw, aToolId );
1538 createTool( _removeLaw, aToolId );
1539 createTool( _setPropagation, aToolId );
1540 createTool( _computeMesh, aToolId );
1544 void HEXABLOCKGUI::initialMenus()
1546 showDocumentMenus( true );
1547 showPatternMenus( false );
1548 showAssociationMenus( false );
1549 showGroupsMenus( false );
1550 showMeshMenus( false );
1553 void HEXABLOCKGUI::showAllMenus()
1555 showDocumentMenus( true );
1556 showPatternMenus( true );
1557 showAssociationMenus( true );
1558 showGroupsMenus( true );
1559 showMeshMenus( true );
1563 void HEXABLOCKGUI::showDocumentMenus(bool show)
1565 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1567 setMenuShown(_newAct, show);
1568 setToolShown(_newAct, show);
1569 setMenuShown(_importAct, show);
1570 setToolShown(_importAct, show);
1571 setMenuShown(_showModelInfoAct, show);
1572 setToolShown(_showModelInfoAct, show);
1573 setMenuShown(_saveAct, show);
1574 setToolShown(_saveAct, show);
1577 void HEXABLOCKGUI::showPatternMenus(bool show)
1579 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1580 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1581 if ( show && !getCurrentModel() ) return;
1583 setMenuShown(_addVertex, show );
1584 setToolShown(_addVertex, show);
1585 setMenuShown(_addEdge, show );
1586 setToolShown(_addEdge, show);
1587 setMenuShown(_addQuad, show );
1588 setToolShown(_addQuad, show);
1589 setMenuShown(_addHexa, show );
1590 setToolShown(_addHexa, show);
1592 setMenuShown(_sep1, show );
1593 setToolShown(_sep1, show);
1595 setMenuShown( _addVector, show );
1596 setToolShown( _addVector, show);
1597 // setMenuShown( _addCylinder, show );
1598 // setToolShown( _addCylinder, show);
1599 // setMenuShown( _addPipe, show );
1600 // setToolShown( _addPipe, show);
1602 setMenuShown(_sep2, show );
1603 setToolShown(_sep2, show);
1605 setMenuShown( _makeGrid, show );
1606 setToolShown( _makeGrid, show);
1607 setMenuShown( _makePipe, show );
1608 setToolShown( _makePipe, show);
1610 setMenuShown(_sep3, show );
1611 setToolShown(_sep3, show);
1613 setMenuShown( _makeCylinder, show );
1614 setToolShown( _makeCylinder, show);
1615 setMenuShown( _makeCylinders, show );
1616 setToolShown( _makeCylinders, show);
1617 setMenuShown( _makePipes, show );
1618 setToolShown( _makePipes, show);
1619 setMenuShown( _makeHemiSphere, show );
1620 setToolShown( _makeHemiSphere, show);
1622 // Pattern Data Edition
1623 setMenuShown( _removeHexa, show );
1624 setToolShown( _removeHexa, show);
1625 setMenuShown( _prismQuad, show );
1626 setToolShown( _prismQuad, show);
1627 setMenuShown( _joinQuad, show );
1628 setToolShown( _joinQuad, show);
1629 setMenuShown( _merge, show );
1630 setToolShown( _merge, show);
1631 setMenuShown( _disconnect, show );
1632 setToolShown( _disconnect, show);
1633 setMenuShown( _cutEdge, show );
1634 setToolShown( _cutEdge, show);
1635 setMenuShown( _makeTransformation, show );
1636 setToolShown( _makeTransformation, show);
1637 setMenuShown( _makeSymmetry, show );
1638 setToolShown( _makeSymmetry, show);
1639 setMenuShown( _performTransformation, show );
1640 setToolShown( _performTransformation, show);
1641 setMenuShown( _performSymmetry, show );
1642 setToolShown( _performSymmetry, show);
1643 setMenuShown( _replaceHexa, show );
1644 setToolShown( _replaceHexa, show);
1645 setMenuShown( _quadRevolution, show );
1646 setToolShown( _quadRevolution, show);
1648 setMenuShown( _sep4, show );
1649 setMenuShown( _showModelInfoAct, show );
1653 void HEXABLOCKGUI::showAssociationMenus(bool show)
1655 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1656 if ( show && !getCurrentModel() ) return;
1658 // Association Edition
1659 setMenuShown( _assocVertex, show );
1660 setToolShown( _assocVertex, show );
1661 setMenuShown( _assocEdge, show );
1662 setToolShown( _assocEdge, show );
1663 setMenuShown( _assocQuad, show );
1664 setToolShown( _assocQuad, show );
1665 setMenuShown( _addShapeAct, show );
1666 setToolShown( _addShapeAct, show );
1670 void HEXABLOCKGUI::showGroupsMenus(bool show)
1672 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1673 if ( show && !getCurrentModel() ) return;
1674 setMenuShown( _addGroup, show );
1675 setToolShown( _addGroup, show);
1676 setMenuShown( _removeGroup , show );
1677 setToolShown( _removeGroup , show);
1680 void HEXABLOCKGUI::showMeshMenus(bool show)
1682 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1683 if ( show && !getCurrentModel() ) return;
1684 setMenuShown( _addLaw, show );
1685 setToolShown( _addLaw, show);
1686 setMenuShown( _removeLaw, show );
1687 setToolShown( _removeLaw, show);;
1688 setMenuShown( _setPropagation, show );
1689 setToolShown( _setPropagation, show);
1690 setMenuShown( _computeMesh, show);
1691 setToolShown( _computeMesh, show);
1694 void HEXABLOCKGUI::showVtkActor()
1696 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1697 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1698 currentVtkGView->getDocumentActor() == NULL)
1701 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1702 if (vtkView == NULL)
1705 SUIT_ViewManager* vman = vtkView->getViewManager();
1706 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1708 //show only the current actor -----------------
1709 vtkView->setFocus();
1710 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1711 Document_Actor *lastDocActor;
1712 if (lastVtkDocGView != NULL)
1714 lastDocActor = lastVtkDocGView->getDocumentActor();
1715 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1716 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1718 vtkView->Erase(lastActorIO);
1719 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1720 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1723 currentVtkGView->update();
1724 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1725 if (!anIO.IsNull() && anIO->hasEntry())
1727 vtkView->Display(anIO);
1728 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1729 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1731 vtkView->onFitAll();
1734 void HEXABLOCKGUI::showOccActor()
1736 if (currentOccGView == NULL)
1738 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1739 if (occView == NULL)
1741 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1745 if (lastOccPrs != NULL)
1746 vf->Erase(lastOccPrs);
1747 currentOccGView->globalSelection();
1748 SOCC_Prs* prs = getOccPrs(currentDocGView);
1749 currentOccGView->setPrs(prs);
1752 occView->onFitAll();
1755 void HEXABLOCKGUI::hideVtkActor()
1757 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1758 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1759 currentVtkGView->getViewWindow() == NULL ||
1760 currentVtkGView->getDocumentActor() == NULL) return;
1762 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1763 currentVtkGView->getViewWindow()->onResetView();
1765 //update the visibility state now
1766 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1767 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1768 if (aStudy == NULL || vman == NULL) return;
1770 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1771 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1772 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1775 void HEXABLOCKGUI::hideOccActor()
1777 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1778 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1779 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1780 if (occView == NULL || docModel == NULL)
1782 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1786 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1787 if (currentOccPrs != NULL)
1788 vf->Erase(currentOccPrs);
1790 occView->onResetView();
1793 void HEXABLOCKGUI::showOnlyActor()
1799 void HEXABLOCKGUI::hideActor()
1806 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1808 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1810 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1811 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1813 if (_dwPattern) _dwPattern->setVisible(isVisible);
1814 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1816 if (_dwMesh) _dwMesh->setVisible(isVisible);
1817 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1819 if (_dwGroups) _dwGroups->setVisible(isVisible);
1820 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1824 //clear all used dialogs by the current model
1825 void HEXABLOCKGUI::clearDialogs()
1827 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1828 fin (currentModelDialogs.end());
1829 for(;debut!=fin;++debut) (*debut)->clear();
1831 currentModelDialogs.clear(); //empty the used dialogs list
1834 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1836 if (!gViewDlgBox.contains(dgview)) return NULL;
1837 return gViewDlgBox[dgview];
1840 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1842 if (dgview == NULL) return;
1844 switchOffGraphicView(dgview, false); //to avoid double connect
1847 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1848 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1849 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1850 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1851 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1852 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1853 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1854 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1855 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1856 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1857 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1858 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1863 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1865 if (dgview == NULL) return;
1867 //disconnect signals
1868 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1869 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1870 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1871 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1872 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1873 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1874 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1875 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1876 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1877 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1878 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1879 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1882 gViewDlgBox[dgview] = currentDialog;
1884 //close opened dialog
1885 if (currentDialog != NULL) currentDialog->close();
1886 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1892 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1894 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1898 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1902 //switch off the current document graphic view (disconnect signals...)
1903 if (currentDocGView != NULL)
1905 //Hide current actor
1907 switchOffGraphicView(currentDocGView);
1910 //clear the dialogs used by the current model so they can be used by the new model
1911 if (currentDocGView != dgview) clearDialogs();
1913 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1914 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1915 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1916 _groupsTreeView->setModel(dgview->getGroupsModel());
1917 _meshTreeView->setModel(dgview->getMeshModel());
1919 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1920 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1922 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1923 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1925 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1926 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1928 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1929 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1931 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1932 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1935 // = * init occ view * =
1936 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1938 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1939 currentOccGView->getViewWindow()->installEventFilter(this);
1944 // = * init vtk view * =
1945 if (currentDocGView != NULL)
1947 if (currentDocGView->getViewWindow() != NULL)
1948 dgview->setViewWindow(currentDocGView->getViewWindow());
1951 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1952 dgview->getViewWindow()->installEventFilter(this);
1958 switchOnGraphicView(dgview);
1960 if (currentDocGView != NULL)
1962 lastVtkDocGView = currentDocGView;
1963 lastOccPrs = getOccPrs(currentDocGView);
1967 lastVtkDocGView = dgview;
1968 lastOccPrs = getOccPrs(dgview);
1971 currentDocGView = dgview;
1973 currentDocGView->getDocumentModel()->refresh();
1974 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1978 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1980 if (currentDocGView == NULL) return NULL;
1981 return currentDocGView->getDocumentModel();
1985 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1987 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1988 if (anApp == NULL) return UNKNOWN;
1989 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1990 if (activeVm == NULL) return UNKNOWN;
1992 QString vmType = activeVm->getType();
1993 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1995 else if ( vmType == OCCViewer_Viewer::Type() )
2001 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2003 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2007 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2010 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2012 // Create Document from HEXABLOCK ENGINE
2013 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2014 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2016 // looking doc impl ( c++ )
2017 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2018 // ^Hexa6 ASSERT( dServant );
2019 // ^Hexa6 if ( dServant)
2020 // ^Hexa6 doc = dServant->GetImpl();
2022 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2023 QString docEntry = addDocInStudy (doc);
2025 // looking for docEntry
2026 /* ****************************************************************
2027 if ( !CORBA::is_nil(docIn) ){
2028 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2029 QString docIOR = anIOR.in();
2030 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2031 if ( !docIOR.isEmpty() ) {
2032 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2034 docEntry = SO->GetID().c_str();
2037 **************************************************************** */
2038 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2040 return make_pair (docEntry, doc);
2044 void HEXABLOCKGUI::newDocument()
2046 DEBTRACE("HEXABLOCKGUI::newDocument");
2049 QMainWindow *aParent = application()->desktop();
2050 QWidget *central = aParent->centralWidget();
2052 central->setFocus();
2054 DEBTRACE("No Central Widget");
2057 if (currentOccGView == NULL)
2059 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2060 application()->desktop());
2061 currentOccGView->getViewWindow()->installEventFilter(this);
2063 else if (currentOccGView->getViewWindow() == NULL)
2065 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2066 currentOccGView->getViewWindow()->installEventFilter(this);
2070 // Create Document from HEXABLOCK ENGINE
2071 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2073 VtkDocumentGraphicView* newGraphicView = NULL;
2074 //One document at a time
2075 if (currentDocGView != NULL)
2077 if (currentDocGView->getViewWindow() == NULL)
2079 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2080 currentDocGView->getViewWindow()->installEventFilter(this);
2083 // Create a new document with the current window
2084 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2085 new DocumentModel( docEntry_Doc.second,
2086 docEntry_Doc.first, this ),
2087 currentDocGView->getViewWindow(),
2088 application()->desktop() );
2092 // Create the new Document Graphic View with a new window
2093 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2094 new DocumentModel( docEntry_Doc.second,
2095 docEntry_Doc.first, this ),
2096 graphicViewsHandler->createVtkWindow(),
2097 application()->desktop() );
2098 newGraphicView->getViewWindow()->installEventFilter(this);
2101 if (newGraphicView == NULL)
2102 //We couldn't create a new document graphic view
2103 //we'd better show a dialog box info to inform the user
2106 docs[docEntry_Doc.first] = newGraphicView;
2107 switchModel(newGraphicView); //select the corresponding document in the browser instead
2109 getApp()->updateObjectBrowser();
2114 //Loads the model from the xmlFile in the current graphic view
2115 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2117 DEBTRACE("HEXABLOCKGUI::loadDocument");
2120 QMainWindow *aParent = application()->desktop();
2121 QString selectedFile;
2123 if ( inFile.isNull() ){
2124 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2125 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2126 dialog.setHistory( getQuickDirList() );
2128 //use the last path as default
2129 if (!(loadDocLastPath->absolutePath()).isEmpty())
2130 dialog.setDirectory(*loadDocLastPath);
2133 QStringList selectedFiles = dialog.selectedFiles();
2134 if (!selectedFiles.isEmpty())
2135 selectedFile = selectedFiles.first();
2137 //remember the selected path
2138 *loadDocLastPath = dialog.directory();
2141 selectedFile = inFile;
2143 if (selectedFile.isEmpty())
2146 //we create a new document if necessary
2147 if (currentDocGView == NULL)
2148 //Need a new document
2150 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2152 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2153 currentDocGView->getViewWindow()->installEventFilter(this);
2156 if (!currentDocGView->isEmpty())
2157 //we can only have one document for a graphic view
2160 //we load the selected file in the current graphic view
2161 currentDocGView->loadDocument(selectedFile);
2162 DocumentModel* currentModel = getCurrentModel();
2163 renameObject( currentModel->documentEntry(), currentModel->getName() );
2168 void HEXABLOCKGUI::saveDocument()
2170 QMainWindow *aParent = application()->desktop();
2172 QString aDocName = "document", aFilename;
2174 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2175 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2177 //use the last selected directory as default path for file selection
2178 aFilename = saveDocLastPath->absolutePath();
2179 if (!aFilename.isEmpty())
2180 aFilename += QString("/") + aDocName;
2182 //show the dialog for file selection
2183 aFilename = SUIT_FileDlg::getFileName( aParent,
2186 tr( "Save HexaBlock Document" ),
2189 //save the document in the selected file
2190 if ( !aFilename.isEmpty() ) {
2191 getCurrentVtkGraphicView()->saveDocument( aFilename );
2193 //Remember the path for next save
2194 QFileInfo fileInfo(aFilename);
2195 *saveDocLastPath = fileInfo.dir();
2201 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2203 _patternDataTreeView->openPersistentEditor( topLeft );
2206 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2208 if (diag == NULL || _dwInputPanel == NULL ||
2209 getCurrentVtkGraphicView() == NULL) return;
2211 //mark this dialog as used by the current model
2212 currentModelDialogs.insert(diag);
2214 //close the current dialog box info
2215 // if (_treeViewDelegate != NULL)
2216 // _treeViewDelegate->closeDialog();
2218 // if (_dwInputPanel->widget())
2219 // _dwInputPanel->widget()->close();
2221 //Temporary for debugging EdgeAssoc Faked InfoDialog
2222 if (diag == _edgeAssocDiag)
2223 diag->debugEdgeAssoc = true;
2225 diag->debugEdgeAssoc = false;
2227 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2228 diag == _quadAssocDiag || diag == _addShapeDiag)
2229 assocInProgress = true;
2231 assocInProgress = false;
2233 //show the dialog box in the dockwidget
2234 diag->resetSizeAndShow(_dwInputPanel);
2236 //clear the current selections
2237 selectionMgr()->clearSelected();
2239 currentDialog = diag;
2242 if (currentDocGView != NULL)
2243 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2246 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2248 if (vertex == NULL || _dwInputPanel == NULL)
2251 if (_vertexInfoDialog == NULL)
2252 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2254 _vertexInfoDialog->setValue(vertex);
2255 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2256 currentDialog = _vertexInfoDialog;
2259 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2261 if (edge == NULL || _dwInputPanel == NULL)
2264 if (_edgeInfoDialog == NULL)
2265 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2267 _edgeInfoDialog->setValue(edge);
2268 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2269 currentDialog = _edgeInfoDialog;
2272 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2274 if (quad == NULL || _dwInputPanel == NULL)
2277 if (_quadInfoDialog == NULL)
2278 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2280 _quadInfoDialog->setValue(quad);
2281 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2282 currentDialog = _quadInfoDialog;
2285 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2287 if (hexa == NULL || _dwInputPanel == NULL)
2290 if (_hexaInfoDialog == NULL)
2291 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2293 _hexaInfoDialog->setValue(hexa);
2294 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2295 currentDialog = _hexaInfoDialog;
2298 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2300 if (vector == NULL || _dwInputPanel == NULL)
2303 if (_vectorInfoDialog == NULL)
2304 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2306 _vectorInfoDialog->setValue(vector);
2307 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2308 currentDialog = _vectorInfoDialog;
2311 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2313 if (group == NULL || _dwInputPanel == NULL)
2316 if (_groupInfoDialog == NULL)
2317 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2319 _groupInfoDialog->setValue(group);
2320 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2321 currentDialog = _groupInfoDialog;
2324 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2326 if (law == NULL || _dwInputPanel == NULL)
2329 if (_lawInfoDialog == NULL)
2330 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2332 _lawInfoDialog->setValue(law);
2333 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2334 currentDialog = _lawInfoDialog;
2337 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2339 if (propagation == NULL || _dwInputPanel == NULL)
2342 if (_propagationInfoDialog == NULL)
2343 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2345 _propagationInfoDialog->setValue(propagation);
2346 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2347 currentDialog = _propagationInfoDialog;
2350 void HEXABLOCKGUI::addVertex()
2352 if ( !_vertexDiag ){
2353 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2355 _showDialogBox( _vertexDiag );
2358 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2359 if (_vertexDiag != NULL && doc != NULL)
2360 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2363 void HEXABLOCKGUI::addEdge()
2366 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2368 _showDialogBox( _edgeDiag );
2371 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2372 if (_edgeDiag != NULL && doc != NULL)
2373 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2376 void HEXABLOCKGUI::addQuad()
2379 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2382 _showDialogBox( _quadDiag );
2385 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2386 if (_quadDiag != NULL && doc != NULL)
2387 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2390 void HEXABLOCKGUI::addHexa()
2393 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2395 _showDialogBox( _hexaDiag );
2398 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2399 if (_hexaDiag != NULL && doc != NULL)
2400 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2403 void HEXABLOCKGUI::addVector()
2405 if ( !_vectorDiag ){
2406 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2408 _showDialogBox( _vectorDiag );
2411 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2412 if (_vectorDiag != NULL && doc != NULL)
2413 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2416 //void HEXABLOCKGUI::addCylinder()
2418 // if ( !_cylinderDiag ){
2419 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2421 // _showDialogBox( _cylinderDiag );
2423 // //set default name
2424 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2425 // if (_cylinderDiag != NULL && doc != NULL)
2426 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2430 //void HEXABLOCKGUI::addPipe()
2432 // if ( !_pipeDiag){
2433 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2435 // _showDialogBox( _pipeDiag );
2437 // //set default name
2438 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2439 // if (_pipeDiag != NULL && doc != NULL)
2440 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2444 void HEXABLOCKGUI::makeGrid()
2446 if ( !_makeGridDiag ){
2447 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2449 _showDialogBox( _makeGridDiag );
2453 void HEXABLOCKGUI::makeCylinder()
2455 if ( !_makeCylinderDiag ){
2456 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2458 _showDialogBox( _makeCylinderDiag );
2461 void HEXABLOCKGUI::makePipe()
2463 if ( !_makePipeDiag ){
2464 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2466 _showDialogBox( _makePipeDiag );
2469 void HEXABLOCKGUI::makeCylinders()
2471 if ( !_makeCylindersDiag ){
2472 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2474 _showDialogBox( _makeCylindersDiag );
2477 void HEXABLOCKGUI::makePipes()
2479 if ( !_makePipesDiag ){
2480 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2482 _showDialogBox( _makePipesDiag );
2486 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2488 if ( !_makeHemiSphereDiag ){
2489 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2491 _showDialogBox( _makeHemiSphereDiag );
2495 void HEXABLOCKGUI::removeHexa()
2497 if ( !_removeHexaDiag ){
2498 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2500 _showDialogBox( _removeHexaDiag );
2504 void HEXABLOCKGUI::prismQuad()
2506 if ( !_prismQuadDiag ){
2507 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2509 _showDialogBox( _prismQuadDiag );
2513 void HEXABLOCKGUI::joinQuad()
2515 if ( !_joinQuadDiag ){
2516 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2518 _showDialogBox( _joinQuadDiag );
2521 void HEXABLOCKGUI::merge()
2524 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2526 _showDialogBox( _mergeDiag );
2529 void HEXABLOCKGUI::disconnectElts()
2531 if ( !_disconnectDiag ){
2532 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2534 _showDialogBox( _disconnectDiag );
2537 void HEXABLOCKGUI::cutEdge()
2539 if ( !_cutEdgeDiag ){
2540 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2542 _showDialogBox( _cutEdgeDiag );
2545 void HEXABLOCKGUI::makeTransformation()
2547 if ( !_makeTransformationDiag ){
2548 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2550 _showDialogBox( _makeTransformationDiag );
2554 void HEXABLOCKGUI::makeSymmetry()
2556 if ( !_makeSymmetryDiag ){
2557 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2559 _showDialogBox( _makeSymmetryDiag );
2563 void HEXABLOCKGUI::performTransformation()
2565 if ( !_performTransformationDiag ){
2566 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2568 _showDialogBox( _performTransformationDiag );
2572 void HEXABLOCKGUI::performSymmetry()
2574 if ( !_performSymmetryDiag ){
2575 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2577 _showDialogBox( _performSymmetryDiag );
2581 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2583 if ( !_replaceHexaDiag ){
2584 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2586 _showDialogBox( _replaceHexaDiag );
2590 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2592 if ( !_quadRevolutionDiag ){
2593 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2595 _showDialogBox( _quadRevolutionDiag );
2599 void HEXABLOCKGUI::assocVertex()
2601 if (!_dwInputPanel) return;
2602 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2603 if ( !_vertexAssocDiag )
2604 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2605 _showDialogBox( _vertexAssocDiag );
2609 void HEXABLOCKGUI::assocEdge()
2611 if ( !_edgeAssocDiag )
2612 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2613 _showDialogBox( _edgeAssocDiag );
2616 void HEXABLOCKGUI::assocQuad()
2618 if ( !_quadAssocDiag )
2619 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2620 _showDialogBox( _quadAssocDiag );
2624 void HEXABLOCKGUI::addGroup()
2627 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2629 _showDialogBox( _groupDiag );
2630 if (_groupDiag != NULL && getCurrentModel() != NULL)
2632 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2633 if (doc == NULL) return;
2634 char defaultName[16];
2635 sprintf (defaultName, "g%04d", doc->countGroup());
2636 _groupDiag->name_le->setText(defaultName);
2640 void HEXABLOCKGUI::removeGroup()
2642 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2643 if (currentDGView == NULL) return;
2645 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2646 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2647 int nbGroupsRemoved = 0;
2650 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2651 tr( "No group selected!" ) );
2655 foreach( QModelIndex selected, l ){
2656 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2657 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2658 Q_ASSERT(selected.isValid());
2660 //Confirm the deletion of the group
2661 if (SUIT_MessageBox::question(
2664 tr("Remove group : %1 ?").arg(selected.data().toString()),
2665 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2666 SUIT_MessageBox::Cancel
2667 ) == SUIT_MessageBox::Cancel) return;
2669 bool removed = getCurrentModel()->removeGroup( selected );
2671 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2672 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2678 if (!nbGroupsRemoved)
2679 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2680 tr( "No group selected!" ) );
2683 void HEXABLOCKGUI::addLaw()
2686 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2688 _showDialogBox( _lawDiag );
2689 if (_lawDiag != NULL && getCurrentModel() != NULL)
2691 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2692 if (doc == NULL) return;
2693 char defaultName[16];
2694 sprintf (defaultName, "l%04d", doc->countLaw());
2695 _lawDiag->name_le->setText(defaultName);
2699 void HEXABLOCKGUI::removeLaw()
2701 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2702 if (currentDGView == NULL) return;
2704 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2705 int nbLawsRemoved = 0;
2708 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2709 tr( "No law selected!" ) );
2713 foreach( QModelIndex selected, l ){
2714 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2715 selected = currentDGView->getMeshModel()->mapToSource( selected );
2716 Q_ASSERT(selected.isValid());
2718 //Confirm the deletion of the law
2719 if (SUIT_MessageBox::question(
2722 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2723 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2724 SUIT_MessageBox::Cancel
2725 ) == SUIT_MessageBox::Cancel) return;
2727 bool removed = getCurrentModel()->removeLaw(selected);
2729 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2730 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2737 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2738 tr( "No law selected!" ) );
2743 void HEXABLOCKGUI::setPropagation()
2745 if ( !_propagationDiag )
2746 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2748 _showDialogBox( _propagationDiag );
2751 // Dialog box to compute a mesh from a document
2752 // --------------------------------------------
2753 void HEXABLOCKGUI::computeMesh()
2755 if ( !_computeMeshDiag )
2756 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2758 _showDialogBox( _computeMeshDiag );
2761 void HEXABLOCKGUI::clearAssociations()
2763 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2764 if (currentDGView == NULL) return;
2766 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2767 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2768 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2770 getCurrentModel()->clearEltAssociations(iModel);
2772 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2775 void HEXABLOCKGUI::showModelInfo()
2777 //create the info dialog if not yet
2778 if (_modelInfoDiag == NULL)
2779 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2781 //show the model informations dialog
2782 _showDialogBox( _modelInfoDiag );
2785 void HEXABLOCKGUI::addShape()
2787 //create the info dialog if not yet
2788 if (_addShapeDiag == NULL)
2789 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2791 //show the model informations dialog
2792 _showDialogBox( _addShapeDiag );
2795 void HEXABLOCKGUI::clearAllAssociations()
2797 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2798 if (currentDGView == NULL) return;
2800 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2801 if (!currentIndex.isValid()) return;
2802 QVariant currentAssocVariant;
2803 QString currentAssocEntry;
2805 //Confirm the deletion of the associations
2806 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2807 if ( !treeVariant.isValid() ) return;
2808 int eltType = treeVariant.toInt();
2809 QString typeStr = "";
2810 HEXA_NS::EnumElt hexaType;
2811 if (eltType == VERTEX_DIR_TREE)
2813 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2814 hexaType = HEXA_NS::EL_VERTEX;
2816 else if (eltType == EDGE_DIR_TREE)
2818 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2819 hexaType = HEXA_NS::EL_EDGE;
2821 else if (eltType == QUAD_DIR_TREE)
2823 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2824 hexaType = HEXA_NS::EL_QUAD;
2827 if (SUIT_MessageBox::question(
2829 tr("CLEAR_ASSOCIATIONS"),
2830 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2831 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2832 SUIT_MessageBox::Cancel
2833 ) == SUIT_MessageBox::Cancel) return;
2836 DocumentModel* docModel = getCurrentModel();
2837 if (docModel == NULL) return;
2838 docModel->clearAssociation(hexaType);
2841 void HEXABLOCKGUI::showAssociations()
2843 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2844 if (currentDGView == NULL) return;
2846 QModelIndexList elts;
2847 int currentChildIndex = 0;
2848 QVariant currentAssocVariant;
2849 QString currentAssocEntry;
2850 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2851 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2853 while( currentChild.isValid() ) {
2855 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2856 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2857 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2858 elts << currentChild;
2860 currentChild = currentChild.sibling(currentChildIndex++, 0);
2862 currentDocGView->highlight(elts);
2863 currentOccGView->highlight(elts, false);
2867 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2869 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2871 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2876 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2878 if ( event->type() == QEvent::Enter )
2879 { // *** ENTER EVENT
2881 if (currentDialog == NULL || !currentDialog->isVisible())
2882 return QObject::eventFilter(obj, event);
2884 // ** The window acquire the focus when the cursor enter
2886 //OCC - window enter
2887 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2888 if ( occWindow != NULL)
2889 currentDialog->onWindowActivated(occWindow->getViewManager());
2891 //VTK - window enter
2893 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2894 if ( vtkWindow != NULL)
2895 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2899 //standard event processing
2900 return QObject::eventFilter(obj, event);
2903 QStringList HEXABLOCKGUI::getQuickDirList()
2905 QStringList dirList;
2906 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2908 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2914 // --- Export the module
2918 HEXABLOCK_EXPORT CAM_Module* createModule()
2920 return new HEXABLOCKGUI();
2923 HEXABLOCK_EXPORT char* getModuleVersion()
2925 return (char*)HEXABLOCK_VERSION_STR;
2931 // ******************** TESTS ***************************************************
2933 void HEXABLOCKGUI::testDocument()
2937 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2938 // QStandardItem *myItem = new QStandardItem("MyItem");
2939 // parentItem->appendRow(myItem);
2941 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2942 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2943 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2944 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2945 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2946 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2947 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2948 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2951 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2952 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2953 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2954 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2955 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2956 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2958 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2959 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2960 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2961 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2966 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2967 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2968 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2969 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2977 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2978 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2980 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2981 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2985 // newMesh( "toto", 3, "FactoryServer");
2989 void HEXABLOCKGUI::test_make_cart_grid()
2991 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2992 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2993 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2994 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2995 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
2996 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
2998 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
2999 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3006 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3007 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3008 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3009 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3010 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3011 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3016 void HEXABLOCKGUI::test_make_elmts_transform()
3023 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3024 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3027 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3028 // orig.setScalar(2);
3030 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3031 // getCurrentModel()->saveVtk(file_name)
3033 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3034 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3036 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3037 // getCurrentModel()->saveVtk(file_name)
3039 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3042 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3043 // getCurrentModel()->saveVtk(file_name);
3046 // print "...test make elements by transforming elements OK"
3048 // =============================================================== addDocInSudy
3049 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3053 if (document == NULL)
3056 QString docName = document->getName ();
3058 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3059 if (app_study == NULL)
3062 _PTR(Study) study = app_study->studyDS();
3063 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3064 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3065 QString entry = app_study->centry("HEXABLOCK");
3066 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3067 if (aFatherSO->_is_nil())
3070 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3073 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3074 docEntry = aSO->GetID(); //the entry of the published object
3079 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3081 void HEXABLOCKGUI::test()
3083 DEBTRACE("HEXABLOCKGUI::test");
3084 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3085 if (currentDGView == NULL) return;
3086 currentDGView->update();
3090 void HEXABLOCKGUI::test_association()
3092 DEBTRACE("HEXABLOCKGUI::test_association");
3095 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3097 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3098 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3099 DocumentModel::GeomObj q0AssocA, q0AssocB;
3101 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3102 QList<DocumentModel::GeomObj> e1Assocs_test;
3103 DocumentModel::GeomObj q0Assoc_test;
3105 v0 = getCurrentModel()->addVertex(0, 0, 0);
3106 v1 = getCurrentModel()->addVertex(1, 0, 0);
3107 v2 = getCurrentModel()->addVertex(1, 1, 0);
3108 v3 = getCurrentModel()->addVertex(0, 1, 0);
3109 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3110 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3111 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3114 // >>> face3.GetEntry()'0:1:4'
3115 // >>> e1.GetEntry()'0:1:8'
3116 // >>> e2.GetEntry()'0:1:9'
3117 // >>> e3.GetEntry()'0:1:10'
3118 // >>> e4.GetEntry()'0:1:11'
3119 // >>> v1.GetEntry()'0:1:12'
3120 // >>> v2.GetEntry()'0:1:13'
3121 // >>> v3.GetEntry()'0:1:14'
3122 // >>> v4.GetEntry()'0:1:15'
3125 // v0Assoc.name = "geomV0";
3126 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3127 // v0Assoc.brep = "brepV0";
3128 // v1Assoc.name = "geomV1";
3129 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3130 // v1Assoc.brep = "brepV1";
3131 // v2Assoc.name = "geomV2";
3132 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3133 // v2Assoc.brep = "brepV2";
3134 // v3Assoc.name = "geomV3";
3135 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3136 // v3Assoc.brep = "brepV3";
3140 // e0AssocA.name = "geomE0a";
3141 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3142 // e0AssocA.brep = "brepE0a";
3143 // e0AssocA.start = 0.10;
3144 // e0AssocA.end = 0.95;
3148 // e1AssocA.name = "geomE1a";
3149 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3150 // e1AssocA.brep = "brepE1a";
3151 // e1AssocA.start = 0.12;
3152 // e1AssocA.end = 0.89;
3153 // e1AssocB.name = "geomE1b";
3154 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3155 // e1AssocB.brep = "brepE1b";
3156 // e1AssocB.start = 0.20;
3157 // e1AssocB.end = 0.80;
3158 // e1AssocC.name = "geomE1c";
3159 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3160 // e1AssocC.brep = "brepE1c";
3161 // e1AssocC.start = 0.16;
3162 // e1AssocC.end = 0.96;
3164 // q0AssocA.name = "geomQuad";
3165 // q0AssocA.entry = "0:1:1:1:3";
3166 // q0AssocA.brep = "brepq0";
3168 // q0AssocB.name = "geomQuad";
3169 // q0AssocB.entry = "0:1:1:1:4";
3170 // q0AssocB.brep = "brepq0";
3172 // getCurrentModel()->addAssociation( v0, v0Assoc );
3173 // getCurrentModel()->addAssociation( v1, v1Assoc );
3174 // getCurrentModel()->addAssociation( v2, v2Assoc );
3175 // getCurrentModel()->addAssociation( v3, v3Assoc );
3178 // getCurrentModel()->addAssociation( e0, e0AssocA );
3180 // getCurrentModel()->addAssociation( e1, e1AssocA );
3181 // getCurrentModel()->addAssociation( e1, e1AssocB );
3182 // getCurrentModel()->addAssociation( e1, e1AssocC );
3184 // getCurrentModel()->addAssociation( q0, q0AssocA );
3185 // getCurrentModel()->addAssociation( q0, q0AssocB );
3191 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3192 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3193 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3194 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3195 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3196 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3197 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3198 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3199 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3200 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3201 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3202 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3205 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3206 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3207 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3208 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3209 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3210 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3211 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3212 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3213 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3214 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3215 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3216 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3217 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3219 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3220 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3221 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3224 DEBTRACE("HEXABLOCKGUI::test_association fin");