1 // Copyright (C) 2009-2016 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, or (at your option) any later version.
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>
31 #include <QtxTreeView.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Desktop.h>
36 #include <SUIT_ViewManager.h>
37 #include <SUIT_ViewWindow.h>
38 #include <SUIT_DataObject.h>
39 #include <SUIT_DataBrowser.h>
40 #include <SUIT_FileDlg.h>
42 #include <SVTK_ViewManager.h>
43 #include <SVTK_ViewModel.h>
44 #include <SVTK_ViewWindow.h>
46 #include <VTKViewer_ViewModel.h>
48 #include <vtkActorCollection.h>
49 #include <VTKViewer_Algorithm.h>
50 #include <vtkRenderer.h>
54 #include <SOCC_ViewModel.h>
55 #include <SOCC_ViewWindow.h>
56 #include <OCCViewer_ViewWindow.h>
57 #include <SALOME_Prs.h>
61 // SALOME KERNEL includes
62 #include <SALOMEDS_Study.hxx>
63 #include <SALOMEDSClient_StudyBuilder.hxx>
64 #include <SALOMEDSClient_SComponent.hxx>
65 #include <SALOMEDSClient_ClientFactory.hxx>
66 #include <SALOMEDSClient_IParameters.hxx>
70 #include <SalomeApp_Study.h>
71 #include <SalomeApp_Module.h>
72 #include <SalomeApp_Application.h>
73 #include <SalomeApp_DataModel.h>
76 #include <SALOME_ListIO.hxx>
79 #include <SALOME_LifeCycleCORBA.hxx>
81 #include <LightApp_VTKSelector.h>
83 #include <OCCViewer_ViewManager.h>
85 #include <QtxPopupMgr.h>
87 #include "Resource.hxx"
89 #include "HEXABLOCKGUI.hxx"
90 #include "HEXABLOCKGUI_Export.hxx"
91 #include "HEXABLOCKGUI_Trace.hxx"
92 #include "HEXABLOCKGUI_Resource.hxx"
94 #include "HEXABLOCKGUI_DocumentModel.hxx"
95 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
96 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
97 #include "HEXABLOCKGUI_DocumentPanel.hxx"
98 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
99 #include "HEXABLOCKGUI_OccGraphicView.hxx"
100 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
102 #include "HEXABLOCK_version.h"
104 #include "MyBasicGUI_PointDlg.hxx"
106 // #include "HEXABLOCK.hxx" del Hexa6
107 // #include "HexDocument_impl.hxx" del Hexa6
110 //#include <V3d_PerspectiveView.hxx>
111 #include <V3d_AmbientLight.hxx>
112 #include <V3d_DirectionalLight.hxx>
113 #include <Xw_Window.hxx>
114 #include <V3d_TypeOfShadingModel.hxx>
115 #include <TCollection_ExtendedString.hxx>
117 #include <BRepAlgoAPI_Fuse.hxx>
119 #include <AIS_ListIteratorOfListOfInteractive.hxx>
121 #include <utilities.h>
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 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
132 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
133 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
134 bool HEXABLOCKGUI::assocInProgress = false;
135 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
137 HEXABLOCKGUI::HEXABLOCKGUI() :
138 SalomeApp_Module( "HEXABLOCK" ),
139 // LightApp_Module( "HEXABLOCK" ),
147 _patternDataTreeView(0),
148 // _patternBuilderTreeView(0),
149 _patternGeomTreeView(0),
152 // _treeViewDelegate(0),
154 moduleActivatedOnce(false),
164 _makeCylinderDiag(0),
166 _makeCylindersDiag(0),
174 _makeTransformationDiag(0),
175 _makeSymmetryDiag(0),
176 _performTransformationDiag(0),
177 _performSymmetryDiag(0),
186 _quadRevolutionDiag(0),
187 _makeHemiSphereDiag(0),
188 _modelInfoDiag(NULL),
190 _vertexInfoDialog(NULL),
191 _edgeInfoDialog(NULL),
192 _quadInfoDialog(NULL),
193 _hexaInfoDialog(NULL),
194 _vectorInfoDialog(NULL),
195 _groupInfoDialog(NULL),
196 _lawInfoDialog(NULL),
197 _propagationInfoDialog(NULL),
200 lastVtkDocGView(NULL)
202 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
204 graphicViewsHandler = new GraphicViewsHandler();
205 loadDocLastPath = new QDir();
206 saveDocLastPath = new QDir();
207 hexa_root = HEXA_NS::Hex::getInstance ();
210 HEXABLOCKGUI::~HEXABLOCKGUI()
215 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
217 SUIT_Application* app = SUIT_Session::session()->activeApplication();
219 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
225 // Gets an reference to the module's engine
226 /****************************************************
227 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
229 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
230 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
231 ASSERT(!CORBA::is_nil(clr));
234 **************************************************** */
236 void HEXABLOCKGUI::initialize( CAM_Application* app )
238 MESSAGE("HEXABLOCKGUI::initialize");
239 DEBTRACE("HEXABLOCKGUI::initialize");
240 SalomeApp_Module::initialize( app );
242 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
244 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
246 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
247 setResource(aResourceMgr);
249 createAndFillDockWidget();
255 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
257 DEBTRACE("HEXABLOCKGUI::viewManagers");
258 // list.append( QxScene_Viewer::Type() );
259 // list.append( OCCViewer_Viewer::Type() );
260 // list.append( SVTK_Viewer::Type() );
264 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
266 DEBTRACE("HEXABLOCKGUI::activateModule");
268 /*HexaBlock can be launched in only one application*/
269 if (myApplication == NULL)
270 //remember the first application
271 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
273 //application verification: if it's not the one known by HexaBlock,
274 //leave without activating
275 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
276 if (myApplication != currentApplication) return false;
278 bool bOk = SalomeApp_Module::activateModule( theStudy );
279 if ( !bOk ) return false;
281 showDockWidgets(true);
283 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
284 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
285 if ( getApp()->objectBrowser() ) {
286 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
287 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 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
343 currentOccGView->getViewWindow()->installEventFilter(this);
345 if (currentDocGView != NULL)
347 switchModel(currentDocGView);
350 if (currentDocGView->getViewWindow() != NULL)
351 currentDocGView->getViewWindow()->installEventFilter(this);
363 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
365 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
366 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
367 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
368 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
370 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
371 if ( vtkView != NULL)
373 //default selectionMode in VTKView
374 vtkView->SetSelectionMode( ActorSelection );
375 vtkView->removeEventFilter(this);
379 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
382 //defaut selectionMode in OccView
383 selectionMgr()->clearSelected();
384 currentOccGView->globalSelection();
385 occView->removeEventFilter(this);
389 qDeleteAll(myOCCSelectors);
390 myOCCSelectors.clear();
391 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
393 qDeleteAll(myVTKSelectors);
394 myVTKSelectors.clear();
395 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
397 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
399 //switch off current document graphic view
400 switchOffGraphicView(currentDocGView);
403 setMenuShown( false );
404 setToolShown( false );
405 showDockWidgets( false );
407 _dwInputPanel->close();
414 SALOMEDS::Study_var HEXABLOCKGUI::getStudyServant()
416 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
417 CORBA::Object_var aSMObject = aNamingService->Resolve("/Study");
418 SALOMEDS::Study_var aDSStudy = SALOMEDS::Study::_narrow(aSMObject);
419 return aDSStudy._retn();
422 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
423 QMap<QString, QString>& docShapesEntry,
424 QMap<QString, QString>& docShapesName)
426 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
427 return; //there's nothing to publish in this case
429 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
430 if(!appStudy) return;
431 SALOMEDS::Study_var aDSStudy = getStudyServant();
432 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
433 QString entry = currentDocGView->getDocumentModel()->documentEntry();
434 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
435 if (aFatherSO->_is_nil())
438 // * get a presentation
439 bool isNewPrs = false;
440 SOCC_Prs* prs = getOccPrs(currentDocGView);
443 prs = new SOCC_Prs(0);
447 // * init the presentation with the given shapes
448 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
449 while (i != topo_shapes.constEnd())
451 QString shapeName = i.key();
452 TopoDS_Shape shapeValue = i.value();
453 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
454 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
455 QString objStudyEntry = aSO->GetID(); //the entry of the published object
456 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
457 "HEXABLOCK", shapeName.toStdString().c_str());
458 ais_shape->SetOwner(io);
459 prs->AddObject(ais_shape);
460 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
461 docShapesEntry[shapeName] = objStudyEntry;
462 docShapesName[objStudyEntry] = shapeName;
463 currentOccGView->addShape(objStudyEntry, ais_shape);
464 i++; //handle next shape
468 prs->AddObject(currentOccGView->getPreviewShape());
470 occPrs[currentDocGView] = prs;
471 getApp()->updateObjectBrowser();
476 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
478 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
479 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
480 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
482 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
486 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
490 // Pas de renommage des shapes pour le moment, juste les documents
491 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
492 if (dgview == NULL || dgview->getDocumentModel() == NULL)
495 _PTR(SObject) obj ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(entry)) );
496 _PTR(GenericAttribute) anAttr;
498 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
499 _PTR(AttributeName) aName (anAttr);
500 DocumentModel* docModel = dgview->getDocumentModel();
501 docModel->setName( name );
502 aName->SetValue( name.toLatin1().data() );
503 getApp()->updateObjectBrowser();
504 // _dwPattern->setWindowTitle( name );
511 // --- Default windows
512 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
514 DEBTRACE("HEXABLOCKGUI::windows");
516 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
517 #ifndef DISABLE_PYCONSOLE
518 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
522 QString HEXABLOCKGUI::engineIOR() const
524 DEBTRACE("HEXABLOCKGUI::engineIOR");
526 /* ************************************ TODO Hexa6
527 CORBA::ORB_var anORB = getApp()->orb();
528 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
529 return QString( anIOR.in() );
530 ************************************ */
534 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
536 if (docs.count(studyObject->entry()) == 0)
538 //Object's document not acquired yet
539 VtkDocumentGraphicView* dgview;
540 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
541 if (directory == NULL)
542 return NULL; //No working director found
544 //------------------ Load the document -----------------
545 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
546 if (document == NULL)
547 return NULL; //No document found
549 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
551 MESSAGE("Doc model creation failed!");
554 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
555 if (dgview == NULL) return NULL;
557 //update the data tree
558 docs[studyObject->entry()] = dgview;
561 return docs[studyObject->entry()];
564 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
566 // ** we want to switch automatically to the right view windows
568 //first, find selected item
570 DataObjectList dol = getApp()->objectBrowser()->getSelected();
571 if (dol.isEmpty()) return;
572 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
573 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
574 item->entry().isEmpty())
577 // find the document corresponding to it
578 VtkDocumentGraphicView* docGView = NULL;
579 if (docs.contains(item->entry()))
580 docGView = docs[item->entry()];
582 docGView = getOrCreateDocument(item);
584 //Init OCC if necessary
585 if (currentOccGView == NULL)
587 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
588 currentOccGView->getViewWindow()->installEventFilter(this);
590 else if (currentOccGView->getViewWindow() == NULL)
592 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
593 currentOccGView->getViewWindow()->installEventFilter(this);
596 //Init the vtk view if necessary
597 if (docGView->getViewWindow() == NULL)
599 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
601 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
602 docGView->getViewWindow()->installEventFilter(this);
605 setAllMenusEnabled(true);
608 docGView->setViewWindow(currentDocGView->getViewWindow());
610 if (docGView->getDocumentActor() == NULL)
614 if (docGView == NULL || docGView == currentDocGView)
620 //update the current document
621 switchModel(docGView);
625 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
627 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
630 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
632 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
634 //Decharger le model correspondant (VTK)
635 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
639 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
640 { //HexaBlock Vtk Window has been closed
642 if (currentDialog != NULL) currentDialog->close();
643 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
644 if (currentDocGView != NULL)
645 currentDocGView->setViewWindow(NULL);
648 setAllMenusEnabled(false);
649 enableDocumentMenus(true);
655 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
656 if (dgview == NULL) return; //The window has no document to close
658 //Save the document? (Ask only if the document is not empty
659 int answerCode = SUIT_MessageBox::question(
662 tr("Save the document ?"),
663 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
664 SUIT_MessageBox::Cancel);
665 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
666 else if (answerCode == SUIT_MessageBox::Yes)
667 saveDocument(); //Save the document
669 // switchOffGraphicView(window); //disconnect all connected signals
670 // currentVtkView = NULL;
671 // graphicViewsHandler->closeDocumentGraphicView(window);
673 //create a new one (empty document)
675 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
679 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
681 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
682 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
683 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
684 if (currentDialog != NULL) currentDialog->close();
685 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
687 currentOccGView->getViewWindow()->removeEventFilter(this);
688 currentOccGView->setViewWindow(NULL);
692 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
694 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
696 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
697 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
699 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
701 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
702 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
703 // disable OCC selectors
704 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
705 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
706 while ( itOCCSel.hasNext() )
707 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
708 sr->setEnabled(true);
710 else if ( vm->getType() == SVTK_Viewer::Type() )
712 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
713 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
715 // disable VTK selectors
716 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
717 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
718 while ( itVTKSel.hasNext() )
719 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
720 sr->setEnabled(true);
724 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
726 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
728 SUIT_ViewModel* viewer = vm->getViewModel();
729 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
731 //VTK View Manager removed
732 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
734 //Process only if it's our view manager
735 SUIT_ViewManager* myVm = NULL;
736 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
737 myVm = currentDocGView->getViewWindow()->getViewManager();
741 //close opened dialog
742 if (currentDialog != NULL) currentDialog->close();
743 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
749 //remove its selector
750 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
751 while ( itVTKSel.hasNext() )
752 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
753 if ( sr->viewer() == viewer )
755 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
762 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
764 //OCC View removed: remove its selector
765 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
766 while ( itOCCSel.hasNext() )
767 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
768 if ( sr->viewer() == viewer )
770 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
776 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
778 QModelIndexList l = selected.indexes();
779 if ( l.count() == 0 ) return;
780 if ( !l[0].isValid() ) return;
781 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
782 if ( currentGraphicView == NULL) return;
784 QTreeView* theTree = NULL;
785 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
786 theTree = _patternDataTreeView;
788 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
789 theTree = _patternBuilderTreeView;
791 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
792 theTree = _patternGeomTreeView;
794 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
795 theTree = _groupsTreeView;
796 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
797 theTree = _meshTreeView;
800 theTree->scrollTo ( l[0] );
804 bool HEXABLOCKGUI::createSComponent() //addComponent
806 DEBTRACE("HEXABLOCKGUI::createSComponent");
807 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
809 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
810 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
811 _PTR(GenericAttribute) anAttr;
812 _PTR(AttributeName) aName;
813 _PTR(AttributeGraphic) aGraphic;
815 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
816 if ( !aComponent ){ //Create hexablock component if there's not one yet
817 aComponent = aBuilder->NewComponent("HEXABLOCK");
818 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
819 aName = _PTR(AttributeName) (anAttr);
820 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
822 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
823 _PTR(AttributePixMap) aPixmap(anAttr);
824 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
826 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
827 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
833 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
835 DEBTRACE("HEXABLOCKGUI::setResource");
836 _myresource = new HEXABLOCKGUI_Resource(r);
837 _myresource->preferencesChanged();
840 void HEXABLOCKGUI::createPreferences()
842 DEBTRACE("HEXABLOCKGUI::createPreferences");
843 _myresource->createPreferences(this);
846 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
848 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
849 _myresource->preferencesChanged(sect, name);
850 // if(name=="userCatalog")
851 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
854 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
856 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
857 QVariant currentAssocVariant;
858 QString currentAssocEntry;
860 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
861 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
862 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
863 QMenu menu( _patternDataTreeView );
865 QAction *clearAct = menu.addAction( "Remove association(s)" );
866 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
867 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
871 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
872 if (currentVtkGraphicView == NULL) return;
873 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
875 //We don't do anything for single items
876 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
877 item->type() == QUADITEM || item->type() == HEXAITEM)
880 //No associations for HEXA
881 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
882 if ( !treeVariant.isValid() ) return;
883 int eltType = treeVariant.toInt();
884 if (eltType == HEXA_DIR_TREE) return;
885 QMenu menu( _patternDataTreeView );
887 //Show association(s)
888 QAction *showAssocAct = menu.addAction( "Show associations" );
889 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
891 //Clear all associations
892 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
893 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
895 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
900 void HEXABLOCKGUI::createAndFillDockWidget()
903 QMainWindow *aParent = application()->desktop();
905 // Create dock widget (3 dock)
907 //1) *********** user input panel ( contain user's edit dialog box )
908 _dwInputPanel = new QDockWidget(aParent);
909 _dwInputPanel->setVisible(false);
910 _dwInputPanel->setWindowTitle("Input Panel");
911 _dwInputPanel->setObjectName("hexablockInputPanelDock");
912 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
914 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
916 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
918 _dwPattern = new QDockWidget(aParent);
919 _dwPattern->setVisible(false);
920 _dwPattern->setWindowTitle("Model");
921 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
922 _dwPattern->setObjectName("hexablockModelDock");
924 QFrame* patternFrame = new QFrame(_dwPattern);
925 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
926 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
927 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
928 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
929 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
930 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
931 _patternGeomTreeView = new QTreeView(patternFrame);
932 splitter->addWidget(_patternDataTreeView);
933 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
934 splitter->addWidget(_patternGeomTreeView);
935 patternLayout->addWidget(splitter);
937 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
938 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
939 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
942 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
943 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
945 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
946 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
948 _dwPattern->setWidget(patternFrame);
949 patternFrame->show();
952 _dwGroups = new QDockWidget(aParent);
954 _dwGroups->setVisible(false);
955 _dwGroups->setWindowTitle("Groups");
956 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
957 _dwGroups->setObjectName("hexablockGroupsDock");
958 _groupsTreeView = new QTreeView(_dwGroups);
959 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
960 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
961 _dwGroups->setWidget(_groupsTreeView);
962 _groupsTreeView->show();
965 _dwMesh = new QDockWidget(aParent);
966 _dwMesh->setVisible(false);
967 _dwMesh->setWindowTitle("Mesh");
968 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
969 _dwMesh->setObjectName("hexablockMeshDock");
970 _meshTreeView = new QTreeView(_dwMesh);
971 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
972 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
973 // _meshTreeView->setItemDelegate(_treeViewDelegate);
974 _dwMesh->setWidget(_meshTreeView);
975 _meshTreeView->show();
977 // QDockWidget *_dwObjectBrowser = 0;
979 if ( getApp()->objectBrowser() )
980 wid = getApp()->objectBrowser()->treeView();
981 while ( wid && !_dwObjectBrowser ) {
982 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( wid );
983 wid = wid->parentWidget();
986 if ( _dwObjectBrowser ) {
987 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
988 _dwObjectBrowser->setWindowTitle("Study");
991 // dock widget position
992 if ( _dwObjectBrowser ) {
993 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
995 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
997 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
998 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
999 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1001 if ( _dwObjectBrowser ) {
1002 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1004 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1005 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1007 #if QT_VERSION >= 0x040500
1008 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1011 // popup menu on data tree view
1012 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1013 connect(_patternDataTreeView,
1014 SIGNAL(customContextMenuRequested(const QPoint &)),
1016 SLOT(treeContextMenu(const QPoint &)),
1017 Qt::UniqueConnection );
1020 void HEXABLOCKGUI::createActions()
1022 QMainWindow *aParent = application()->desktop();
1023 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1026 _newAct = createAction(_menuId++,
1027 tr("Create a new document"),
1028 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1030 tr("Create a new document"),
1031 0, aParent, false, this, SLOT(newDocument()));
1032 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1034 _importAct = createAction(_menuId++,
1035 tr("Load a document"),
1036 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1037 tr("Load Document"),
1038 tr("Load a document"),
1039 0, aParent, false, this, SLOT(loadDocument()));
1040 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1042 _saveAct = createAction(_menuId++,
1043 tr("Save the document"),
1044 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1045 tr("Save Document"),
1046 tr("Save the document"),
1047 0, aParent, false, this, SLOT(saveDocument()));
1049 // Pattern Data creation
1050 _addVertex = createAction(_menuId++,
1051 tr("Create a vertex"),
1052 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1054 tr("Create a new vertex"),
1055 0, aParent, false, this, SLOT(addVertex()));
1057 _addEdge = createAction(_menuId++,
1058 tr("Create an edge"),
1059 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1061 tr("Create a new edge"),
1062 0, aParent, false, this, SLOT(addEdge()));
1064 _addQuad = createAction(_menuId++,
1065 tr("Create a quadrangle"),
1066 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1067 tr("Add Quadrangle"),
1068 tr("Create a new quadrangle"),
1069 0, aParent, false, this, SLOT(addQuad()));
1071 _addHexa = createAction(_menuId++,
1072 tr("Create an hexahedron"),
1073 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1074 tr("Add Hexahedron"),
1075 tr("Create a new hexahedron"),
1076 0, aParent, false, this, SLOT(addHexa()));
1078 // Builder Data creation
1079 _addVector = createAction(_menuId++,
1080 tr("Create a vector"),
1081 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1083 tr("Create a new vector"),
1084 0, aParent, false, this, SLOT(addVector()));
1086 // _addCylinder = createAction(_menuId++,
1087 // tr("Create a cylinder"),
1088 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1089 // tr("Add Cylinder"),
1090 // tr("Create a new cylinder"),
1091 // 0, aParent, false, this, SLOT(addCylinder()));
1093 // _addPipe = createAction(_menuId++,
1094 // tr("Create a pipe"),
1095 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1097 // tr("Create a new pipe"),
1098 // 0, aParent, false, this, SLOT(addPipe()));
1100 _makeGrid = createAction(_menuId++,
1102 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1105 0, aParent, false, this, SLOT(makeGrid()));
1107 _makeCylinder = createAction(_menuId++,
1108 tr("Make a cylinder"),
1109 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1110 tr("Make Cylinder"),
1111 tr("Make a cylinder"),
1112 0, aParent, false, this, SLOT(makeCylinder()));
1114 _makePipe = createAction(_menuId++,
1116 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1119 0, aParent, false, this, SLOT(makePipe()));
1121 _makeCylinders = createAction(_menuId++,
1122 tr("Make cylinders"),
1123 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1124 tr("Make Cylinders"),
1125 tr("Make cylinders"),
1126 0, aParent, false, this, SLOT(makeCylinders()));
1128 _makePipes = createAction(_menuId++,
1130 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1133 0, aParent, false, this, SLOT(makePipes()));
1135 _makeHemiSphere = createAction(_menuId++,
1136 tr("Make an hemisphere"),
1137 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1138 tr("Make Hemisphere"),
1139 tr("Make an hemisphere"),
1140 0, aParent, false, this, SLOT(makeHemiSphere()));
1142 // Pattern Data edition
1143 _removeHexa = createAction(_menuId++,
1144 tr("Remove hexahedra"),
1145 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1146 tr("Remove Hexahedra"),
1147 tr("Remove hexahedra"),
1148 0, aParent, false, this, SLOT(removeHexa()));
1150 _prismQuad = createAction(_menuId++,
1151 tr("Prism quadrangles"),
1152 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1153 tr("Prism Quadrangles"),
1154 tr("Prism quadrangles"),
1155 0, aParent, false, this, SLOT(prismQuad()));
1157 _joinQuad = createAction(_menuId++,
1158 tr("Join quadrangles"),
1159 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1160 tr("Join Quadrangles"),
1161 tr("Join quadrangles with hexahedra"),
1162 0, aParent, false, this, SLOT(joinQuad()));
1164 _merge = createAction(_menuId++,
1166 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1169 0, aParent, false, this, SLOT(merge()));
1171 _disconnect = createAction(_menuId++,
1173 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1175 tr("Disconnect edges, vertexes or quadrangles"),
1176 0, aParent, false, this, SLOT(disconnectElts()));
1178 _cutEdge = createAction(_menuId++,
1180 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1183 0, aParent, false, this, SLOT(cutEdge()));
1185 _makeTransformation = createAction(_menuId++,
1186 tr("Make transformation"),
1187 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1188 tr("Make Transformation"),
1189 tr("Make transformation"),
1190 0, aParent, false, this, SLOT(makeTransformation()));
1192 _makeSymmetry = createAction(_menuId++,
1193 tr("Make symmetry"),
1194 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1195 tr("Make Symmetry"),
1196 tr("Make symmetry"),
1197 0, aParent, false, this, SLOT(makeSymmetry()));
1199 _performTransformation = createAction(_menuId++,
1200 tr("Perform transformation"),
1201 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1202 tr("Perform Transformation"),
1203 tr("Perform transformation"),
1204 0, aParent, false, this, SLOT(performTransformation()));
1206 _performSymmetry = createAction(_menuId++,
1207 tr("Perform symmetry"),
1208 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1209 tr("Perform Symmetry"),
1210 tr("Perform symmetry"),
1211 0, aParent, false, this, SLOT(performSymmetry()));
1213 _replaceHexa = createAction(_menuId++,
1214 tr("Replace hexahedron"),
1215 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1216 tr("Replace Hexahedron"),
1217 tr("Replace hexahedron"),
1218 0, aParent, false, this, SLOT(replaceHexa()));
1220 _quadRevolution = createAction(_menuId++,
1221 tr("Quad revolution"),
1222 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1223 tr("Quad Revolution"),
1224 tr("Quad revolution"),
1225 0, aParent, false, this, SLOT(quadRevolution()));
1228 _assocVertex = createAction(_menuId++,
1229 tr("Make vertex association"),
1230 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1231 tr("Make Vertex association"),
1232 tr("Make vertex association"),
1233 0, aParent, false, this, SLOT(assocVertex()));
1235 _assocEdge = createAction(_menuId++,
1236 tr("Make edge association"),
1237 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1238 tr("Make Edge Association"),
1239 tr("Make edge association"),
1240 0, aParent, false, this, SLOT(assocEdge()));
1242 _assocQuad = createAction(_menuId++,
1243 tr("Make quad association"),
1244 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1245 tr("Make Quad Association"),
1246 tr("Make quad association"),
1247 0, aParent, false, this, SLOT(assocQuad()));
1250 _addGroup = createAction(_menuId++,
1252 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1255 0, aParent, false, this, SLOT(addGroup()));
1257 _removeGroup = createAction(_menuId++,
1258 tr("Remove a group"),
1259 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1261 tr("Remove a group"),
1262 0, aParent, false, this, SLOT(removeGroup()));
1265 _addLaw = createAction(_menuId++,
1267 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1270 0, aParent, false, this, SLOT(addLaw()));
1272 _removeLaw = createAction(_menuId++,
1274 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1277 0, aParent, false, this, SLOT(removeLaw()));
1279 _setPropagation = createAction(_menuId++,
1280 tr("Set propagation"),
1281 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1282 tr("Set Propagation"),
1283 tr("Set propagation"),
1284 0, aParent, false, this, SLOT(setPropagation()));
1286 _computeMesh = createAction(_menuId++,
1288 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1291 0, aParent, false, this, SLOT(computeMesh()));
1293 _showModelInfoAct = createAction(_menuId++,
1294 tr("Show Model Info"),
1295 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1298 0, aParent, false, this, SLOT(showModelInfo()));
1300 _addShapeAct = createAction(_menuId++,
1302 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1305 0, aParent, false, this, SLOT(addShape()));
1307 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1308 // QAction* createAction(const int id,
1309 // const QString& toolTip,
1310 // const QIcon& icon,
1311 // const QString& menu,
1312 // const QString& status,
1313 // const int shortCut,
1314 // QObject* parent =0,
1315 // bool checkable = false,
1316 // QObject* receiver =0,
1317 // const char* member =0);
1319 _sep1 = separator();
1320 _sep2 = separator();
1321 _sep3 = separator();
1322 _sep4 = separator();
1326 void HEXABLOCKGUI::createMenus()
1328 int aMenuId, subMenuId,aMenuIdMain;
1330 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1332 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1333 createMenu( actionId(_newAct), aMenuId );
1334 createMenu( actionId(_importAct), aMenuId );
1335 createMenu( _saveAct, aMenuId );
1338 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1339 createMenu( _newAct, aMenuDocId );//, 10
1340 createMenu( _importAct, aMenuDocId );
1341 createMenu( _saveAct, aMenuDocId );
1343 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1344 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1345 createMenu( _addVertex, subMenuId );
1346 createMenu( _addEdge, subMenuId );
1347 createMenu( _addQuad, subMenuId );
1348 createMenu( _addHexa, subMenuId );
1349 createMenu( _sep1, subMenuId);
1352 createMenu( _addVector, subMenuId );
1353 // createMenu( _addCylinder, subMenuId );
1354 // createMenu( _addPipe, subMenuId );
1356 createMenu( _sep2, subMenuId);
1358 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1359 createMenu( _makeHemiSphere,subMenuId );
1361 createMenu( _sep3, subMenuId);
1363 createMenu( _makeCylinder, subMenuId );
1364 createMenu( _makePipe, subMenuId );
1365 createMenu( _makeCylinders,subMenuId );
1366 createMenu( _makePipes, subMenuId );
1368 // Pattern Data Edition
1369 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1370 createMenu( _removeHexa, subMenuId );
1371 createMenu( _prismQuad, subMenuId );
1372 createMenu( _joinQuad, subMenuId );
1373 createMenu( _merge, subMenuId );
1374 createMenu( _disconnect, subMenuId );
1375 createMenu( _cutEdge, subMenuId );
1376 createMenu( _makeTransformation, subMenuId );
1377 createMenu( _makeSymmetry, subMenuId );
1378 createMenu( _performTransformation, subMenuId );
1379 createMenu( _performSymmetry, subMenuId );
1380 createMenu( _replaceHexa, subMenuId );
1381 createMenu( _quadRevolution, subMenuId );
1382 createMenu( _sep4, aMenuId );
1383 createMenu( _showModelInfoAct, aMenuId );
1386 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1387 createMenu( _addShapeAct, aMenuId );
1388 createMenu( _assocVertex, aMenuId );
1389 createMenu( _assocEdge, aMenuId );
1390 createMenu( _assocQuad, aMenuId );
1393 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1394 createMenu( _addGroup, aMenuId );
1395 createMenu( _removeGroup, aMenuId ); //CS_TODO
1398 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1399 createMenu( _addLaw, aMenuId );
1400 createMenu( _removeLaw, aMenuId );
1401 createMenu( _setPropagation, aMenuId );
1402 createMenu( _computeMesh, aMenuId );
1404 //show model infomation menu
1405 QString aRule = "$component={'HEXABLOCK'}";
1406 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1407 popupMgr()->setRule( _showModelInfoAct, aRule);
1409 //associate shape to a document menu
1410 popupMgr()->insert( _addShapeAct, -1, -1 );
1411 popupMgr()->setRule( _addShapeAct, aRule );
1413 //-------------------------------------------------
1415 //-------------------------------------------------
1416 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1417 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1418 // QString isNotEmpty("numberOfNodes <> 0");
1419 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1420 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1421 //// aType = aType.arg( mesh_part );
1423 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1424 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1425 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1427 // popupMgr()->insert( separator(), -1, -1 );
1428 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1429 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1430 // // MESSAGE("aClient = " << aClient.toStdString());
1431 // // MESSAGE("aType = " << aType.toStdString());
1432 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1433 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1434 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1435 // // MESSAGE("aRule = " << aRule.toStdString());
1436 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1437 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1439 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1440 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1442 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1443 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1445 // popupMgr()->insert( separator(), -1, -1 );
1449 void HEXABLOCKGUI::createTools()
1453 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1454 createTool( _newAct, aToolId );
1455 createTool( _importAct, aToolId );
1456 createTool( _saveAct, aToolId );
1457 createTool( _showModelInfoAct, aToolId );
1458 // createTool( _testAct, aToolId );
1459 //createTool( separator(), aToolId );
1462 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1463 createTool( _addVertex, aToolId );
1464 createTool( _addEdge, aToolId );
1465 createTool( _addQuad, aToolId );
1466 createTool( _addHexa, aToolId );
1468 createTool( _sep1, aToolId );
1471 createTool( _addVector, aToolId );
1472 // createTool( _addCylinder, aToolId );
1473 // createTool( _addPipe, aToolId );
1475 createTool( _sep2, aToolId );
1477 createTool( _makeGrid, aToolId );
1478 createTool( _makeHemiSphere, aToolId );
1480 createTool( _sep3, aToolId );
1482 createTool( _makeCylinder, aToolId );
1483 createTool( _makePipe, aToolId );
1484 createTool( _makeCylinders,aToolId );
1485 createTool( _makePipes, aToolId );
1487 // Pattern Data Edition
1488 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1489 createTool( _removeHexa, aToolId );
1490 createTool( _prismQuad, aToolId );
1491 createTool( _joinQuad, aToolId );
1492 createTool( _merge, aToolId );
1493 createTool( _disconnect, aToolId );
1494 createTool( _cutEdge, aToolId );
1495 createTool( _makeTransformation, aToolId );
1496 createTool( _makeSymmetry, aToolId );
1497 createTool( _performTransformation, aToolId );
1498 createTool( _performSymmetry, aToolId );
1499 createTool( _replaceHexa, aToolId );
1500 createTool( _quadRevolution, aToolId );
1503 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1504 createTool( _assocVertex, aToolId );
1505 createTool( _assocEdge, aToolId );
1506 createTool( _assocQuad, aToolId );
1507 createTool( _addShapeAct, aToolId );
1510 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1511 createTool( _addGroup, aToolId );
1512 createTool( _removeGroup, aToolId ); //CS_TODO
1515 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1516 createTool( _addLaw, aToolId );
1517 createTool( _removeLaw, aToolId );
1518 createTool( _setPropagation, aToolId );
1519 createTool( _computeMesh, aToolId );
1523 void HEXABLOCKGUI::initialMenus()
1525 showDocumentMenus( true );
1526 showPatternMenus( false );
1527 showAssociationMenus( false );
1528 showGroupsMenus( false );
1529 showMeshMenus( false );
1532 void HEXABLOCKGUI::showAllMenus()
1534 showDocumentMenus( true );
1535 showPatternMenus( true );
1536 showAssociationMenus( true );
1537 showGroupsMenus( true );
1538 showMeshMenus( true );
1541 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1543 enableDocumentMenus( enable );
1544 enablePatternMenus( enable );
1545 enableAssociationMenus( enable );
1546 enableGroupsMenus( enable );
1547 enableMeshMenus( enable );
1549 menusEnabled = enable;
1552 void HEXABLOCKGUI::showDocumentMenus(bool show)
1554 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1556 setMenuShown(_newAct, show);
1557 setToolShown(_newAct, show);
1558 setMenuShown(_importAct, show);
1559 setToolShown(_importAct, show);
1560 setMenuShown(_showModelInfoAct, show);
1561 setToolShown(_showModelInfoAct, show);
1562 setMenuShown(_saveAct, show);
1563 setToolShown(_saveAct, show);
1566 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1568 _newAct->setEnabled(enable);
1569 // setToolShown(_newAct, enable);
1571 _importAct->setEnabled(enable);
1572 // setToolShown(_importAct, enable);
1574 _showModelInfoAct->setEnabled(enable);
1575 // setToolShown(_showModelInfoAct, enable);
1577 _saveAct->setEnabled(enable);
1578 // setToolShown(_saveAct, enable);
1582 void HEXABLOCKGUI::showPatternMenus(bool show)
1584 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1585 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1586 if ( show && !getCurrentModel() ) return;
1588 setMenuShown(_addVertex, show );
1589 setToolShown(_addVertex, show);
1590 setMenuShown(_addEdge, show );
1591 setToolShown(_addEdge, show);
1592 setMenuShown(_addQuad, show );
1593 setToolShown(_addQuad, show);
1594 setMenuShown(_addHexa, show );
1595 setToolShown(_addHexa, show);
1597 setMenuShown(_sep1, show );
1598 setToolShown(_sep1, show);
1600 setMenuShown( _addVector, show );
1601 setToolShown( _addVector, show);
1602 // setMenuShown( _addCylinder, show );
1603 // setToolShown( _addCylinder, show);
1604 // setMenuShown( _addPipe, show );
1605 // setToolShown( _addPipe, show);
1607 setMenuShown(_sep2, show );
1608 setToolShown(_sep2, show);
1610 setMenuShown( _makeGrid, show );
1611 setToolShown( _makeGrid, show);
1612 setMenuShown( _makePipe, show );
1613 setToolShown( _makePipe, show);
1615 setMenuShown(_sep3, show );
1616 setToolShown(_sep3, show);
1618 setMenuShown( _makeCylinder, show );
1619 setToolShown( _makeCylinder, show);
1620 setMenuShown( _makeCylinders, show );
1621 setToolShown( _makeCylinders, show);
1622 setMenuShown( _makePipes, show );
1623 setToolShown( _makePipes, show);
1624 setMenuShown( _makeHemiSphere, show );
1625 setToolShown( _makeHemiSphere, show);
1627 // Pattern Data Edition
1628 setMenuShown( _removeHexa, show );
1629 setToolShown( _removeHexa, show);
1630 setMenuShown( _prismQuad, show );
1631 setToolShown( _prismQuad, show);
1632 setMenuShown( _joinQuad, show );
1633 setToolShown( _joinQuad, show);
1634 setMenuShown( _merge, show );
1635 setToolShown( _merge, show);
1636 setMenuShown( _disconnect, show );
1637 setToolShown( _disconnect, show);
1638 setMenuShown( _cutEdge, show );
1639 setToolShown( _cutEdge, show);
1640 setMenuShown( _makeTransformation, show );
1641 setToolShown( _makeTransformation, show);
1642 setMenuShown( _makeSymmetry, show );
1643 setToolShown( _makeSymmetry, show);
1644 setMenuShown( _performTransformation, show );
1645 setToolShown( _performTransformation, show);
1646 setMenuShown( _performSymmetry, show );
1647 setToolShown( _performSymmetry, show);
1648 setMenuShown( _replaceHexa, show );
1649 setToolShown( _replaceHexa, show);
1650 setMenuShown( _quadRevolution, show );
1651 setToolShown( _quadRevolution, show);
1653 setMenuShown( _sep4, show );
1654 setMenuShown( _showModelInfoAct, show );
1657 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1659 if ( enable && !getCurrentModel() ) return;
1661 _addVertex->setEnabled(enable);
1662 // setToolShown(_addVertex, enable);
1664 _addEdge->setEnabled(enable);
1665 // setToolShown(_addEdge, enable);
1667 _addQuad->setEnabled(enable);
1668 // setToolShown(_addQuad, enable);
1670 _addHexa->setEnabled(enable);
1671 // setToolShown(_addHexa, enable);
1673 // setMenuShown(_sep1, enable );
1674 // setToolShown(_sep1, enable);
1676 _addVector->setEnabled(enable);
1677 // setToolShown( _addVector, enable);
1679 // setMenuShown(_sep2, enable );
1680 // setToolShown(_sep2, enable);
1682 _makeGrid->setEnabled(enable);
1683 // setToolShown( _makeGrid, enable);
1685 _makePipe->setEnabled(enable);
1686 // setToolShown( _makePipe, enable);
1688 // setMenuShown(_sep3, enable );
1689 // setToolShown(_sep3, enable);
1691 _makeCylinder->setEnabled(enable);
1692 // setToolShown( _makeCylinder, enable);
1694 _makeCylinders->setEnabled(enable);
1695 // setToolShown( _makeCylinders, enable);
1697 _makePipes->setEnabled(enable);
1698 // setToolShown( _makePipes, enable);
1700 _makeHemiSphere->setEnabled(enable);
1701 // setToolShown( _makeHemiSphere, enable);
1703 // Pattern Data Edition
1704 _removeHexa->setEnabled(enable);
1705 // setToolShown( _removeHexa, enable);
1707 _prismQuad->setEnabled(enable);
1708 // setToolShown( _prismQuad, enable);
1710 _joinQuad->setEnabled(enable);
1711 // setToolShown( _joinQuad, enable);
1713 _merge->setEnabled(enable);
1714 // setToolShown( _merge, enable);
1716 _disconnect->setEnabled(enable);
1717 // setToolShown( _disconnect, enable);
1719 _cutEdge->setEnabled(enable);
1720 // setToolShown( _cutEdge, enable);
1722 _makeTransformation->setEnabled(enable);
1723 // setToolShown( _makeTransformation, enable);
1725 _makeSymmetry->setEnabled(enable);
1726 // setToolShown( _makeSymmetry, enable);
1728 _performTransformation->setEnabled(enable);
1729 // setToolShown( _performTransformation, enable);
1731 _performSymmetry->setEnabled(enable);
1732 // setToolShown( _performSymmetry, enable);
1734 _replaceHexa->setEnabled(enable);
1735 // setToolShown( _replaceHexa, enable);
1737 _quadRevolution->setEnabled(enable);
1738 // setToolShown( _quadRevolution, enable);
1740 // setMenuShown( _sep4, enable );
1741 _showModelInfoAct->setEnabled(enable);
1745 void HEXABLOCKGUI::showAssociationMenus(bool show)
1747 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1748 if ( show && !getCurrentModel() ) return;
1750 // Association Edition
1751 setMenuShown( _assocVertex, show );
1752 setToolShown( _assocVertex, show );
1754 setMenuShown( _assocEdge, show );
1755 setToolShown( _assocEdge, show );
1757 setMenuShown( _assocQuad, show );
1758 setToolShown( _assocQuad, show );
1760 setMenuShown( _addShapeAct, show );
1761 setToolShown( _addShapeAct, show );
1764 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1766 if ( enable && !getCurrentModel() )
1769 // Association Edition
1770 _assocVertex->setEnabled(enable);
1771 // setToolShown( _assocVertex, enable );
1773 _assocEdge->setEnabled(enable);
1774 // setToolShown( _assocEdge, enable );
1776 _assocQuad->setEnabled(enable);
1777 // setToolShown( _assocQuad, enable );
1779 _addShapeAct->setEnabled(enable);
1780 // setToolShown( _addShapeAct, enable );
1783 void HEXABLOCKGUI::showGroupsMenus(bool show)
1785 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1786 if ( show && !getCurrentModel() ) return;
1787 setMenuShown( _addGroup, show );
1788 setToolShown( _addGroup, show);
1789 setMenuShown( _removeGroup , show );
1790 setToolShown( _removeGroup , show);
1793 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1795 if ( enable && !getCurrentModel() )
1798 _addGroup->setEnabled(enable);
1799 // setToolShown( _addGroup, enable);
1801 _removeGroup->setEnabled(enable);
1802 // setToolShown( _removeGroup , enable);
1805 void HEXABLOCKGUI::showMeshMenus(bool show)
1807 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1808 if ( show && !getCurrentModel() ) return;
1809 setMenuShown( _addLaw, show );
1810 setToolShown( _addLaw, show);
1811 setMenuShown( _removeLaw, show );
1812 setToolShown( _removeLaw, show);;
1813 setMenuShown( _setPropagation, show );
1814 setToolShown( _setPropagation, show);
1815 setMenuShown( _computeMesh, show);
1816 setToolShown( _computeMesh, show);
1819 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1821 if ( enable && !getCurrentModel() )
1824 _addLaw->setEnabled(enable);
1825 // setToolShown( _addLaw, enable);
1827 _removeLaw->setEnabled(enable);
1828 // setToolShown( _removeLaw, enable);
1830 _setPropagation->setEnabled(enable);
1831 // setToolShown( _setPropagation, enable);
1833 _computeMesh->setEnabled(enable);
1834 // setToolShown( _computeMesh, enable);
1837 void HEXABLOCKGUI::showVtkActor()
1839 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1840 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1841 currentVtkGView->getDocumentActor() == NULL)
1844 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1845 if (vtkView == NULL)
1848 SUIT_ViewManager* vman = vtkView->getViewManager();
1849 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1851 //show only the current actor -----------------
1852 vtkView->setFocus();
1853 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1854 Document_Actor *lastDocActor;
1855 if (lastVtkDocGView != NULL)
1857 lastDocActor = lastVtkDocGView->getDocumentActor();
1858 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1859 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1861 vtkView->Erase(lastActorIO);
1862 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1863 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1866 currentVtkGView->update();
1867 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1868 if (!anIO.IsNull() && anIO->hasEntry())
1870 vtkView->Display(anIO);
1871 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1872 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1874 vtkView->onFitAll();
1877 void HEXABLOCKGUI::showOccActor()
1879 if (currentOccGView == NULL)
1881 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1882 if (occView == NULL)
1884 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1888 if (lastOccPrs != NULL)
1889 vf->Erase(lastOccPrs);
1890 currentOccGView->globalSelection();
1891 SOCC_Prs* prs = getOccPrs(currentDocGView);
1892 currentOccGView->setPrs(prs);
1895 occView->onFitAll();
1898 void HEXABLOCKGUI::hideVtkActor()
1900 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1901 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1902 currentVtkGView->getViewWindow() == NULL ||
1903 currentVtkGView->getDocumentActor() == NULL) return;
1905 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1906 currentVtkGView->getViewWindow()->onResetView();
1908 //update the visibility state now
1909 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1910 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1911 if (aStudy == NULL || vman == NULL) return;
1913 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1914 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1915 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1918 void HEXABLOCKGUI::hideOccActor()
1920 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1921 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1922 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1923 if (occView == NULL || docModel == NULL)
1925 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1929 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1930 if (currentOccPrs != NULL)
1931 vf->Erase(currentOccPrs);
1933 occView->onResetView();
1936 void HEXABLOCKGUI::showOnlyActor()
1942 void HEXABLOCKGUI::hideActor()
1949 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1951 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1953 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1955 if (_dwPattern) _dwPattern->setVisible(isVisible);
1956 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1958 if (_dwMesh) _dwMesh->setVisible(isVisible);
1959 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1961 if (_dwGroups) _dwGroups->setVisible(isVisible);
1962 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1966 //clear all used dialogs by the current model
1967 void HEXABLOCKGUI::clearDialogs()
1969 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1970 fin (currentModelDialogs.end());
1971 for(;debut!=fin;++debut) (*debut)->clear();
1973 currentModelDialogs.clear(); //empty the used dialogs list
1976 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1978 if (!gViewDlgBox.contains(dgview)) return NULL;
1979 return gViewDlgBox[dgview];
1982 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1984 if (dgview == NULL) return;
1986 switchOffGraphicView(dgview, false); //to avoid double connect
1989 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1990 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1991 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1992 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1993 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1994 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1995 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1996 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1997 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1998 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1999 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2000 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2005 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
2007 if (dgview == NULL) return;
2009 //disconnect signals
2010 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2011 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2012 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2013 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2014 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2015 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2016 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2017 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2018 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2019 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2020 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2021 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2024 gViewDlgBox[dgview] = currentDialog;
2026 //close opened dialog
2027 if (currentDialog != NULL) currentDialog->close();
2028 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2034 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2036 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2040 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2044 //switch off the current document graphic view (disconnect signals...)
2045 if (currentDocGView != NULL)
2047 //Hide current actor
2049 switchOffGraphicView(currentDocGView);
2052 //clear the dialogs used by the current model so they can be used by the new model
2053 if (currentDocGView != dgview) clearDialogs();
2055 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2056 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2057 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2058 _groupsTreeView->setModel(dgview->getGroupsModel());
2059 _meshTreeView->setModel(dgview->getMeshModel());
2061 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2062 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2064 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2065 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2067 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2068 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2070 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2071 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2073 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2074 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2077 // = * init occ view * =
2078 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2080 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2081 currentOccGView->getViewWindow()->installEventFilter(this);
2086 // = * init vtk view * =
2087 if (currentDocGView != NULL)
2089 if (currentDocGView->getViewWindow() != NULL)
2090 dgview->setViewWindow(currentDocGView->getViewWindow());
2093 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2094 dgview->getViewWindow()->installEventFilter(this);
2100 switchOnGraphicView(dgview);
2102 if (currentDocGView != NULL)
2104 lastVtkDocGView = currentDocGView;
2105 lastOccPrs = getOccPrs(currentDocGView);
2109 lastVtkDocGView = dgview;
2110 lastOccPrs = getOccPrs(dgview);
2113 currentDocGView = dgview;
2115 currentDocGView->getDocumentModel()->refresh();
2116 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2119 setAllMenusEnabled(true);
2122 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2124 if (currentDocGView == NULL) return NULL;
2125 return currentDocGView->getDocumentModel();
2129 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2131 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2132 if (anApp == NULL) return UNKNOWN;
2133 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2134 if (activeVm == NULL) return UNKNOWN;
2136 QString vmType = activeVm->getType();
2137 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2139 else if ( vmType == OCCViewer_Viewer::Type() )
2145 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2147 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2151 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2154 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2156 // Create Document from HEXABLOCK ENGINE
2157 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2158 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2160 // looking doc impl ( c++ )
2161 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2162 // ^Hexa6 ASSERT( dServant );
2163 // ^Hexa6 if ( dServant)
2164 // ^Hexa6 doc = dServant->GetImpl();
2166 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2167 QString docEntry = addDocInStudy (doc);
2169 // looking for docEntry
2170 /* ****************************************************************
2171 if ( !CORBA::is_nil(docIn) ){
2172 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2173 QString docIOR = anIOR.in();
2174 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2175 if ( !docIOR.isEmpty() ) {
2176 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2178 docEntry = SO->GetID().c_str();
2181 **************************************************************** */
2182 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2184 return make_pair (docEntry, doc);
2188 void HEXABLOCKGUI::newDocument()
2190 DEBTRACE("HEXABLOCKGUI::newDocument");
2193 QMainWindow *aParent = application()->desktop();
2194 QWidget *central = aParent->centralWidget();
2196 central->setFocus();
2198 DEBTRACE("No Central Widget");
2201 if (currentOccGView == NULL)
2203 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2204 application()->desktop());
2205 currentOccGView->getViewWindow()->installEventFilter(this);
2207 else if (currentOccGView->getViewWindow() == NULL)
2209 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2210 currentOccGView->getViewWindow()->installEventFilter(this);
2214 // Create Document from HEXABLOCK ENGINE
2215 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2217 VtkDocumentGraphicView* newGraphicView = NULL;
2218 //One document at a time
2219 if (currentDocGView != NULL)
2221 if (currentDocGView->getViewWindow() == NULL)
2223 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2224 currentDocGView->getViewWindow()->installEventFilter(this);
2227 // Create a new document with the current window
2228 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2229 new DocumentModel( docEntry_Doc.second,
2230 docEntry_Doc.first, this ),
2231 currentDocGView->getViewWindow(),
2232 application()->desktop() );
2236 // Create the new Document Graphic View with a new window
2237 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2238 new DocumentModel( docEntry_Doc.second,
2239 docEntry_Doc.first, this ),
2240 graphicViewsHandler->createVtkWindow(),
2241 application()->desktop() );
2242 newGraphicView->getViewWindow()->installEventFilter(this);
2245 if (newGraphicView == NULL)
2246 //We couldn't create a new document graphic view
2247 //we'd better show a dialog box info to inform the user
2250 docs[docEntry_Doc.first] = newGraphicView;
2251 switchModel(newGraphicView); //select the corresponding document in the browser instead
2253 getApp()->updateObjectBrowser();
2258 //Loads the model from the xmlFile in the current graphic view
2259 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2261 DEBTRACE("HEXABLOCKGUI::loadDocument");
2264 QMainWindow *aParent = application()->desktop();
2265 QString selectedFile;
2267 if ( inFile.isNull() ){
2268 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2269 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2270 dialog.setHistory( getQuickDirList() );
2272 //use the last path as default
2273 if (!(loadDocLastPath->absolutePath()).isEmpty())
2274 dialog.setDirectory(*loadDocLastPath);
2277 QStringList selectedFiles = dialog.selectedFiles();
2278 if (!selectedFiles.isEmpty())
2279 selectedFile = selectedFiles.first();
2281 //remember the selected path
2282 *loadDocLastPath = dialog.directory();
2285 selectedFile = inFile;
2287 if (selectedFile.isEmpty())
2290 //we create a new document if necessary
2291 if (currentDocGView == NULL)
2292 //Need a new document
2294 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2296 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2297 currentDocGView->getViewWindow()->installEventFilter(this);
2300 if (!currentDocGView->isEmpty())
2301 //we can only have one document for a graphic view
2304 //we load the selected file in the current graphic view
2305 currentDocGView->loadDocument(selectedFile);
2306 DocumentModel* currentModel = getCurrentModel();
2307 renameObject( currentModel->documentEntry(), currentModel->getName() );
2312 void HEXABLOCKGUI::saveDocument()
2314 QMainWindow *aParent = application()->desktop();
2316 QString aDocName = "document", aFilename;
2318 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2319 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2321 //use the last selected directory as default path for file selection
2322 aFilename = saveDocLastPath->absolutePath();
2323 if (!aFilename.isEmpty())
2324 aFilename += QString("/") + aDocName;
2326 //show the dialog for file selection
2327 aFilename = SUIT_FileDlg::getFileName( aParent,
2330 tr( "Save HexaBlock Document" ),
2333 //save the document in the selected file
2334 if ( !aFilename.isEmpty() ) {
2335 getCurrentVtkGraphicView()->saveDocument( aFilename );
2337 //Remember the path for next save
2338 QFileInfo fileInfo(aFilename);
2339 *saveDocLastPath = fileInfo.dir();
2345 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2347 _patternDataTreeView->openPersistentEditor( topLeft );
2350 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2352 if (diag == NULL || _dwInputPanel == NULL ||
2353 getCurrentVtkGraphicView() == NULL) return;
2355 //mark this dialog as used by the current model
2356 currentModelDialogs.insert(diag);
2358 //close the current dialog box info
2359 // if (_treeViewDelegate != NULL)
2360 // _treeViewDelegate->closeDialog();
2362 // if (_dwInputPanel->widget())
2363 // _dwInputPanel->widget()->close();
2365 //Temporary for debugging EdgeAssoc Faked InfoDialog
2366 if (diag == _edgeAssocDiag)
2367 diag->debugEdgeAssoc = true;
2369 diag->debugEdgeAssoc = false;
2371 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2372 diag == _quadAssocDiag || diag == _addShapeDiag)
2373 assocInProgress = true;
2375 assocInProgress = false;
2377 //show the dialog box in the dockwidget
2378 diag->resetSizeAndShow(_dwInputPanel);
2380 //clear the current selections
2381 selectionMgr()->clearSelected();
2383 currentDialog = diag;
2386 if (currentDocGView != NULL)
2387 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2390 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2392 if (vertex == NULL || _dwInputPanel == NULL)
2395 if (_vertexInfoDialog == NULL)
2396 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2398 _vertexInfoDialog->setValue(vertex);
2399 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2400 currentDialog = _vertexInfoDialog;
2403 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2405 if (edge == NULL || _dwInputPanel == NULL)
2408 if (_edgeInfoDialog == NULL)
2409 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2411 _edgeInfoDialog->setValue(edge);
2412 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2413 currentDialog = _edgeInfoDialog;
2416 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2418 if (quad == NULL || _dwInputPanel == NULL)
2421 if (_quadInfoDialog == NULL)
2422 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2424 _quadInfoDialog->setValue(quad);
2425 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2426 currentDialog = _quadInfoDialog;
2429 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2431 if (hexa == NULL || _dwInputPanel == NULL)
2434 if (_hexaInfoDialog == NULL)
2435 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2437 _hexaInfoDialog->setValue(hexa);
2438 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2439 currentDialog = _hexaInfoDialog;
2442 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2444 if (vector == NULL || _dwInputPanel == NULL)
2447 if (_vectorInfoDialog == NULL)
2448 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2450 _vectorInfoDialog->setValue(vector);
2451 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2452 currentDialog = _vectorInfoDialog;
2455 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2457 if (group == NULL || _dwInputPanel == NULL)
2460 if (_groupInfoDialog == NULL)
2461 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2463 _groupInfoDialog->setValue(group);
2464 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2465 currentDialog = _groupInfoDialog;
2468 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2470 if (law == NULL || _dwInputPanel == NULL)
2473 if (_lawInfoDialog == NULL)
2474 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2476 _lawInfoDialog->setValue(law);
2477 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2478 currentDialog = _lawInfoDialog;
2481 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2483 if (propagation == NULL || _dwInputPanel == NULL)
2486 if (_propagationInfoDialog == NULL)
2487 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2489 _propagationInfoDialog->setValue(propagation);
2490 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2491 currentDialog = _propagationInfoDialog;
2494 void HEXABLOCKGUI::addVertex()
2496 if ( !_vertexDiag ){
2497 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2499 _showDialogBox( _vertexDiag );
2502 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2503 if (_vertexDiag != NULL && doc != NULL)
2504 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2507 void HEXABLOCKGUI::addEdge()
2510 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2512 _showDialogBox( _edgeDiag );
2515 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2516 if (_edgeDiag != NULL && doc != NULL)
2517 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2520 void HEXABLOCKGUI::addQuad()
2523 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2526 _showDialogBox( _quadDiag );
2529 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2530 if (_quadDiag != NULL && doc != NULL)
2531 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2534 void HEXABLOCKGUI::addHexa()
2537 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2539 _showDialogBox( _hexaDiag );
2542 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2543 if (_hexaDiag != NULL && doc != NULL)
2544 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2547 void HEXABLOCKGUI::addVector()
2549 if ( !_vectorDiag ){
2550 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2552 _showDialogBox( _vectorDiag );
2555 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2556 if (_vectorDiag != NULL && doc != NULL)
2557 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2560 //void HEXABLOCKGUI::addCylinder()
2562 // if ( !_cylinderDiag ){
2563 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2565 // _showDialogBox( _cylinderDiag );
2567 // //set default name
2568 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2569 // if (_cylinderDiag != NULL && doc != NULL)
2570 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2574 //void HEXABLOCKGUI::addPipe()
2576 // if ( !_pipeDiag){
2577 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2579 // _showDialogBox( _pipeDiag );
2581 // //set default name
2582 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2583 // if (_pipeDiag != NULL && doc != NULL)
2584 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2588 void HEXABLOCKGUI::makeGrid()
2590 if ( !_makeGridDiag ){
2591 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2593 _showDialogBox( _makeGridDiag );
2597 void HEXABLOCKGUI::makeCylinder()
2599 if ( !_makeCylinderDiag ){
2600 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2602 _showDialogBox( _makeCylinderDiag );
2605 void HEXABLOCKGUI::makePipe()
2607 if ( !_makePipeDiag ){
2608 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2610 _showDialogBox( _makePipeDiag );
2613 void HEXABLOCKGUI::makeCylinders()
2615 if ( !_makeCylindersDiag ){
2616 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2618 _showDialogBox( _makeCylindersDiag );
2621 void HEXABLOCKGUI::makePipes()
2623 if ( !_makePipesDiag ){
2624 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2626 _showDialogBox( _makePipesDiag );
2630 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2632 if ( !_makeHemiSphereDiag ){
2633 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2635 _showDialogBox( _makeHemiSphereDiag );
2639 void HEXABLOCKGUI::removeHexa()
2641 if ( !_removeHexaDiag ){
2642 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2644 _showDialogBox( _removeHexaDiag );
2648 void HEXABLOCKGUI::prismQuad()
2650 if ( !_prismQuadDiag ){
2651 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2653 _showDialogBox( _prismQuadDiag );
2657 void HEXABLOCKGUI::joinQuad()
2659 if ( !_joinQuadDiag ){
2660 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2662 _showDialogBox( _joinQuadDiag );
2665 void HEXABLOCKGUI::merge()
2668 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2670 _showDialogBox( _mergeDiag );
2673 void HEXABLOCKGUI::disconnectElts()
2675 if ( !_disconnectDiag ){
2676 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2678 _showDialogBox( _disconnectDiag );
2681 void HEXABLOCKGUI::cutEdge()
2683 if ( !_cutEdgeDiag ){
2684 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2686 _showDialogBox( _cutEdgeDiag );
2689 void HEXABLOCKGUI::makeTransformation()
2691 if ( !_makeTransformationDiag ){
2692 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2694 _showDialogBox( _makeTransformationDiag );
2698 void HEXABLOCKGUI::makeSymmetry()
2700 if ( !_makeSymmetryDiag ){
2701 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2703 _showDialogBox( _makeSymmetryDiag );
2707 void HEXABLOCKGUI::performTransformation()
2709 if ( !_performTransformationDiag ){
2710 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2712 _showDialogBox( _performTransformationDiag );
2716 void HEXABLOCKGUI::performSymmetry()
2718 if ( !_performSymmetryDiag ){
2719 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2721 _showDialogBox( _performSymmetryDiag );
2725 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2727 if ( !_replaceHexaDiag ){
2728 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2730 _showDialogBox( _replaceHexaDiag );
2734 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2736 if ( !_quadRevolutionDiag ){
2737 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2739 _showDialogBox( _quadRevolutionDiag );
2743 void HEXABLOCKGUI::assocVertex()
2745 if (!_dwInputPanel) return;
2746 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2747 if ( !_vertexAssocDiag )
2748 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2749 _showDialogBox( _vertexAssocDiag );
2753 void HEXABLOCKGUI::assocEdge()
2755 if ( !_edgeAssocDiag )
2756 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2757 _showDialogBox( _edgeAssocDiag );
2760 void HEXABLOCKGUI::assocQuad()
2762 if ( !_quadAssocDiag )
2763 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2764 _showDialogBox( _quadAssocDiag );
2768 void HEXABLOCKGUI::addGroup()
2771 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2773 _showDialogBox( _groupDiag );
2774 if (_groupDiag != NULL && getCurrentModel() != NULL)
2776 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2777 if (doc == NULL) return;
2778 char defaultName[16];
2779 sprintf (defaultName, "g%04d", doc->countGroup());
2780 _groupDiag->name_le->setText(defaultName);
2784 void HEXABLOCKGUI::removeGroup()
2786 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2787 if (currentDGView == NULL) return;
2789 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2790 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2791 int nbGroupsRemoved = 0;
2794 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2795 tr( "No group selected!" ) );
2799 foreach( QModelIndex selected, l ){
2800 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2801 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2802 Q_ASSERT(selected.isValid());
2804 //Confirm the deletion of the group
2805 if (SUIT_MessageBox::question(
2808 tr("Remove group : %1 ?").arg(selected.data().toString()),
2809 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2810 SUIT_MessageBox::Cancel
2811 ) == SUIT_MessageBox::Cancel) return;
2813 bool removed = getCurrentModel()->removeGroup( selected );
2815 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2816 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2822 if (!nbGroupsRemoved)
2823 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2824 tr( "No group selected!" ) );
2827 void HEXABLOCKGUI::addLaw()
2830 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2832 _showDialogBox( _lawDiag );
2833 if (_lawDiag != NULL && getCurrentModel() != NULL)
2835 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2836 if (doc == NULL) return;
2837 char defaultName[16];
2838 sprintf (defaultName, "l%04d", doc->countLaw());
2839 _lawDiag->name_le->setText(defaultName);
2843 void HEXABLOCKGUI::removeLaw()
2845 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2846 if (currentDGView == NULL) return;
2848 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2849 int nbLawsRemoved = 0;
2852 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2853 tr( "No law selected!" ) );
2857 foreach( QModelIndex selected, l ){
2858 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2859 selected = currentDGView->getMeshModel()->mapToSource( selected );
2860 Q_ASSERT(selected.isValid());
2862 //Confirm the deletion of the law
2863 if (SUIT_MessageBox::question(
2866 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2867 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2868 SUIT_MessageBox::Cancel
2869 ) == SUIT_MessageBox::Cancel) return;
2871 bool removed = getCurrentModel()->removeLaw(selected);
2873 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2874 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2881 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2882 tr( "No law selected!" ) );
2887 void HEXABLOCKGUI::setPropagation()
2889 if ( !_propagationDiag )
2890 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2892 _showDialogBox( _propagationDiag );
2895 // Dialog box to compute a mesh from a document
2896 // --------------------------------------------
2897 void HEXABLOCKGUI::computeMesh()
2899 if ( !_computeMeshDiag )
2900 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2902 _showDialogBox( _computeMeshDiag );
2905 void HEXABLOCKGUI::clearAssociations()
2907 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2908 if (currentDGView == NULL) return;
2910 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2911 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2912 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2914 getCurrentModel()->clearEltAssociations(iModel);
2916 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2919 void HEXABLOCKGUI::showModelInfo()
2921 //create the info dialog if not yet
2922 if (_modelInfoDiag == NULL)
2923 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2925 //show the model informations dialog
2926 _showDialogBox( _modelInfoDiag );
2929 void HEXABLOCKGUI::addShape()
2931 //create the info dialog if not yet
2932 if (_addShapeDiag == NULL)
2933 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2935 //show the model informations dialog
2936 _showDialogBox( _addShapeDiag );
2939 void HEXABLOCKGUI::clearAllAssociations()
2941 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2942 if (currentDGView == NULL) return;
2944 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2945 if (!currentIndex.isValid()) return;
2946 QVariant currentAssocVariant;
2947 QString currentAssocEntry;
2949 //Confirm the deletion of the associations
2950 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2951 if ( !treeVariant.isValid() ) return;
2952 int eltType = treeVariant.toInt();
2953 QString typeStr = "";
2954 HEXA_NS::EnumElt hexaType;
2955 if (eltType == VERTEX_DIR_TREE)
2957 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2958 hexaType = HEXA_NS::EL_VERTEX;
2960 else if (eltType == EDGE_DIR_TREE)
2962 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2963 hexaType = HEXA_NS::EL_EDGE;
2965 else if (eltType == QUAD_DIR_TREE)
2967 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2968 hexaType = HEXA_NS::EL_QUAD;
2971 if (SUIT_MessageBox::question(
2973 tr("CLEAR_ASSOCIATIONS"),
2974 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2975 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2976 SUIT_MessageBox::Cancel
2977 ) == SUIT_MessageBox::Cancel) return;
2980 DocumentModel* docModel = getCurrentModel();
2981 if (docModel == NULL) return;
2982 docModel->clearAssociation(hexaType);
2985 void HEXABLOCKGUI::showAssociations()
2987 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2988 if (currentDGView == NULL) return;
2990 QModelIndexList elts;
2991 int currentChildIndex = 0;
2992 QVariant currentAssocVariant;
2993 QString currentAssocEntry;
2994 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2995 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2997 while( currentChild.isValid() ) {
2999 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
3000 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
3001 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
3002 elts << currentChild;
3004 currentChild = currentChild.sibling(currentChildIndex++, 0);
3006 currentDocGView->highlight(elts);
3007 currentOccGView->highlight(elts, false);
3011 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3013 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3015 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3020 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3022 if ( event->type() == QEvent::Enter )
3023 { // *** ENTER EVENT
3025 if (currentDialog == NULL || !currentDialog->isVisible())
3026 return QObject::eventFilter(obj, event);
3028 // ** The window acquire the focus when the cursor enter
3030 //OCC - window enter
3031 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3032 if ( occWindow != NULL)
3033 currentDialog->onWindowActivated(occWindow->getViewManager());
3035 //VTK - window enter
3037 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3038 if ( vtkWindow != NULL)
3039 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3043 //standard event processing
3044 return QObject::eventFilter(obj, event);
3047 QStringList HEXABLOCKGUI::getQuickDirList()
3049 QStringList dirList;
3050 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3052 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3058 // --- Export the module
3062 HEXABLOCK_EXPORT CAM_Module* createModule()
3064 return new HEXABLOCKGUI();
3067 HEXABLOCK_EXPORT char* getModuleVersion()
3069 return (char*)HEXABLOCK_VERSION_STR;
3075 // ******************** TESTS ***************************************************
3077 void HEXABLOCKGUI::testDocument()
3081 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3082 // QStandardItem *myItem = new QStandardItem("MyItem");
3083 // parentItem->appendRow(myItem);
3085 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3086 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3087 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3088 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3089 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3090 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3091 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3092 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3095 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3096 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3097 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3098 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3099 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3100 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3102 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3103 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3104 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3105 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3110 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3111 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3112 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3113 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3121 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3122 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3124 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3125 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3129 // newMesh( "toto", 3, "FactoryServer");
3133 void HEXABLOCKGUI::test_make_cart_grid()
3135 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3136 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3137 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3138 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3139 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3140 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3142 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3143 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3150 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3151 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3152 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3153 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3154 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3155 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3160 void HEXABLOCKGUI::test_make_elmts_transform()
3167 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3168 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3171 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3172 // orig.setScalar(2);
3174 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3175 // getCurrentModel()->saveVtk(file_name)
3177 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3178 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3180 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3181 // getCurrentModel()->saveVtk(file_name)
3183 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3186 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3187 // getCurrentModel()->saveVtk(file_name);
3190 // print "...test make elements by transforming elements OK"
3192 // =============================================================== addDocInSudy
3193 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3197 if (document == NULL)
3200 QString docName = document->getName ();
3202 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3203 if (app_study == NULL)
3206 SALOMEDS::Study_var ds_study = getStudyServant();
3207 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3208 QString entry = app_study->centry("HEXABLOCK");
3209 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3210 if (aFatherSO->_is_nil())
3213 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3216 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3217 docEntry = aSO->GetID(); //the entry of the published object
3222 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3224 void HEXABLOCKGUI::test()
3226 DEBTRACE("HEXABLOCKGUI::test");
3227 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3228 if (currentDGView == NULL) return;
3229 currentDGView->update();
3233 void HEXABLOCKGUI::test_association()
3235 DEBTRACE("HEXABLOCKGUI::test_association");
3238 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3240 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3241 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3242 DocumentModel::GeomObj q0AssocA, q0AssocB;
3244 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3245 QList<DocumentModel::GeomObj> e1Assocs_test;
3246 DocumentModel::GeomObj q0Assoc_test;
3248 v0 = getCurrentModel()->addVertex(0, 0, 0);
3249 v1 = getCurrentModel()->addVertex(1, 0, 0);
3250 v2 = getCurrentModel()->addVertex(1, 1, 0);
3251 v3 = getCurrentModel()->addVertex(0, 1, 0);
3252 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3253 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3254 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3257 // >>> face3.GetEntry()'0:1:4'
3258 // >>> e1.GetEntry()'0:1:8'
3259 // >>> e2.GetEntry()'0:1:9'
3260 // >>> e3.GetEntry()'0:1:10'
3261 // >>> e4.GetEntry()'0:1:11'
3262 // >>> v1.GetEntry()'0:1:12'
3263 // >>> v2.GetEntry()'0:1:13'
3264 // >>> v3.GetEntry()'0:1:14'
3265 // >>> v4.GetEntry()'0:1:15'
3268 // v0Assoc.name = "geomV0";
3269 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3270 // v0Assoc.brep = "brepV0";
3271 // v1Assoc.name = "geomV1";
3272 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3273 // v1Assoc.brep = "brepV1";
3274 // v2Assoc.name = "geomV2";
3275 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3276 // v2Assoc.brep = "brepV2";
3277 // v3Assoc.name = "geomV3";
3278 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3279 // v3Assoc.brep = "brepV3";
3283 // e0AssocA.name = "geomE0a";
3284 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3285 // e0AssocA.brep = "brepE0a";
3286 // e0AssocA.start = 0.10;
3287 // e0AssocA.end = 0.95;
3291 // e1AssocA.name = "geomE1a";
3292 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3293 // e1AssocA.brep = "brepE1a";
3294 // e1AssocA.start = 0.12;
3295 // e1AssocA.end = 0.89;
3296 // e1AssocB.name = "geomE1b";
3297 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3298 // e1AssocB.brep = "brepE1b";
3299 // e1AssocB.start = 0.20;
3300 // e1AssocB.end = 0.80;
3301 // e1AssocC.name = "geomE1c";
3302 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3303 // e1AssocC.brep = "brepE1c";
3304 // e1AssocC.start = 0.16;
3305 // e1AssocC.end = 0.96;
3307 // q0AssocA.name = "geomQuad";
3308 // q0AssocA.entry = "0:1:1:1:3";
3309 // q0AssocA.brep = "brepq0";
3311 // q0AssocB.name = "geomQuad";
3312 // q0AssocB.entry = "0:1:1:1:4";
3313 // q0AssocB.brep = "brepq0";
3315 // getCurrentModel()->addAssociation( v0, v0Assoc );
3316 // getCurrentModel()->addAssociation( v1, v1Assoc );
3317 // getCurrentModel()->addAssociation( v2, v2Assoc );
3318 // getCurrentModel()->addAssociation( v3, v3Assoc );
3321 // getCurrentModel()->addAssociation( e0, e0AssocA );
3323 // getCurrentModel()->addAssociation( e1, e1AssocA );
3324 // getCurrentModel()->addAssociation( e1, e1AssocB );
3325 // getCurrentModel()->addAssociation( e1, e1AssocC );
3327 // getCurrentModel()->addAssociation( q0, q0AssocA );
3328 // getCurrentModel()->addAssociation( q0, q0AssocB );
3334 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3335 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3336 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3337 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3338 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3339 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3340 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3341 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3342 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3343 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3344 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3345 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3348 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3349 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3350 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3351 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3352 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3353 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3354 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3355 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3356 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3357 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3358 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3359 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3360 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3362 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3363 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3364 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3367 DEBTRACE("HEXABLOCKGUI::test_association fin");