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 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
286 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
288 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
290 SUIT_ViewManager* vm;
291 ViewManagerList OCCViewManagers, VTKViewManagers;
293 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
294 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
295 while ( itOCC.hasNext() && (vm = itOCC.next()) )
296 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
298 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
299 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
300 while ( itVTK.hasNext() && (vm = itVTK.next()) )
301 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
304 SALOME_ListIO selected;
305 sm->selectedObjects( selected );
308 // disable OCC selectors
309 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
310 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
311 while ( itOCCSel.hasNext() )
312 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
313 sr->setEnabled(true);
315 // disable VTK selectors
316 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
317 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
318 while ( itVTKSel.hasNext() )
319 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
320 sr->setEnabled(true);
322 sm->setSelectedObjects( selected, true ); //NPAL 19674
324 //connect close signal to vtk view manager
325 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
328 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
329 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
332 //connect close signal to occ view manager
333 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
336 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
337 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
340 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
341 currentOccGView->getViewWindow()->installEventFilter(this);
343 if (currentDocGView != NULL)
345 switchModel(currentDocGView);
348 if (currentDocGView->getViewWindow() != NULL)
349 currentDocGView->getViewWindow()->installEventFilter(this);
361 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
363 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
364 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
365 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
366 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
368 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
369 if ( vtkView != NULL)
371 //default selectionMode in VTKView
372 vtkView->SetSelectionMode( ActorSelection );
373 vtkView->removeEventFilter(this);
377 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
380 //defaut selectionMode in OccView
381 selectionMgr()->clearSelected();
382 currentOccGView->globalSelection();
383 occView->removeEventFilter(this);
387 qDeleteAll(myOCCSelectors);
388 myOCCSelectors.clear();
389 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
391 qDeleteAll(myVTKSelectors);
392 myVTKSelectors.clear();
393 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
395 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
397 //switch off current document graphic view
398 switchOffGraphicView(currentDocGView);
401 setMenuShown( false );
402 setToolShown( false );
403 showDockWidgets( false );
405 _dwInputPanel->close();
412 SALOMEDS::Study_var HEXABLOCKGUI::getStudyServant()
414 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
415 CORBA::Object_var aSMObject = aNamingService->Resolve("/Study");
416 SALOMEDS::Study_var aDSStudy = SALOMEDS::Study::_narrow(aSMObject);
417 return aDSStudy._retn();
420 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
421 QMap<QString, QString>& docShapesEntry,
422 QMap<QString, QString>& docShapesName)
424 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
425 return; //there's nothing to publish in this case
427 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
428 if(!appStudy) return;
429 SALOMEDS::Study_var aDSStudy = getStudyServant();
430 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
431 QString entry = currentDocGView->getDocumentModel()->documentEntry();
432 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
433 if (aFatherSO->_is_nil())
436 // * get a presentation
437 bool isNewPrs = false;
438 SOCC_Prs* prs = getOccPrs(currentDocGView);
441 prs = new SOCC_Prs(0);
445 // * init the presentation with the given shapes
446 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
447 while (i != topo_shapes.constEnd())
449 QString shapeName = i.key();
450 TopoDS_Shape shapeValue = i.value();
451 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
452 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
453 QString objStudyEntry = aSO->GetID(); //the entry of the published object
454 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
455 "HEXABLOCK", shapeName.toStdString().c_str());
456 ais_shape->SetOwner(io);
457 prs->AddObject(ais_shape);
458 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
459 docShapesEntry[shapeName] = objStudyEntry;
460 docShapesName[objStudyEntry] = shapeName;
461 currentOccGView->addShape(objStudyEntry, ais_shape);
462 i++; //handle next shape
466 prs->AddObject(currentOccGView->getPreviewShape());
468 occPrs[currentDocGView] = prs;
469 getApp()->updateObjectBrowser();
474 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
476 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
477 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
478 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
480 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
484 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
488 // Pas de renommage des shapes pour le moment, juste les documents
489 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
490 if (dgview == NULL || dgview->getDocumentModel() == NULL)
493 _PTR(SObject) obj ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(entry)) );
494 _PTR(GenericAttribute) anAttr;
496 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
497 _PTR(AttributeName) aName (anAttr);
498 DocumentModel* docModel = dgview->getDocumentModel();
499 docModel->setName( name );
500 aName->SetValue( name.toLatin1().data() );
501 getApp()->updateObjectBrowser();
502 // _dwPattern->setWindowTitle( name );
509 // --- Default windows
510 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
512 DEBTRACE("HEXABLOCKGUI::windows");
514 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
515 #ifndef DISABLE_PYCONSOLE
516 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
520 QString HEXABLOCKGUI::engineIOR() const
522 DEBTRACE("HEXABLOCKGUI::engineIOR");
524 /* ************************************ TODO Hexa6
525 CORBA::ORB_var anORB = getApp()->orb();
526 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
527 return QString( anIOR.in() );
528 ************************************ */
532 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
534 if (docs.count(studyObject->entry()) == 0)
536 //Object's document not acquired yet
537 VtkDocumentGraphicView* dgview;
538 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
539 if (directory == NULL)
540 return NULL; //No working director found
542 //------------------ Load the document -----------------
543 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
544 if (document == NULL)
545 return NULL; //No document found
547 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
549 MESSAGE("Doc model creation failed!");
552 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
553 if (dgview == NULL) return NULL;
555 //update the data tree
556 docs[studyObject->entry()] = dgview;
559 return docs[studyObject->entry()];
562 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
564 // ** we want to switch automatically to the right view windows
566 //first, find selected item
568 DataObjectList dol = getApp()->objectBrowser()->getSelected();
569 if (dol.isEmpty()) return;
570 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
571 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
572 item->entry().isEmpty())
575 // find the document corresponding to it
576 VtkDocumentGraphicView* docGView = NULL;
577 if (docs.contains(item->entry()))
578 docGView = docs[item->entry()];
580 docGView = getOrCreateDocument(item);
582 //Init OCC if necessary
583 if (currentOccGView == NULL)
585 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
586 currentOccGView->getViewWindow()->installEventFilter(this);
588 else if (currentOccGView->getViewWindow() == NULL)
590 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
591 currentOccGView->getViewWindow()->installEventFilter(this);
594 //Init the vtk view if necessary
595 if (docGView->getViewWindow() == NULL)
597 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
599 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
600 docGView->getViewWindow()->installEventFilter(this);
603 setAllMenusEnabled(true);
606 docGView->setViewWindow(currentDocGView->getViewWindow());
608 if (docGView->getDocumentActor() == NULL)
612 if (docGView == NULL || docGView == currentDocGView)
618 //update the current document
619 switchModel(docGView);
623 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
625 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
628 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
630 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
632 //Decharger le model correspondant (VTK)
633 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
637 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
638 { //HexaBlock Vtk Window has been closed
640 if (currentDialog != NULL) currentDialog->close();
641 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
642 if (currentDocGView != NULL)
643 currentDocGView->setViewWindow(NULL);
646 setAllMenusEnabled(false);
647 enableDocumentMenus(true);
653 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
654 if (dgview == NULL) return; //The window has no document to close
656 //Save the document? (Ask only if the document is not empty
657 int answerCode = SUIT_MessageBox::question(
660 tr("Save the document ?"),
661 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
662 SUIT_MessageBox::Cancel);
663 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
664 else if (answerCode == SUIT_MessageBox::Yes)
665 saveDocument(); //Save the document
667 // switchOffGraphicView(window); //disconnect all connected signals
668 // currentVtkView = NULL;
669 // graphicViewsHandler->closeDocumentGraphicView(window);
671 //create a new one (empty document)
673 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
677 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
679 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
680 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
681 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
682 if (currentDialog != NULL) currentDialog->close();
683 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
685 currentOccGView->getViewWindow()->removeEventFilter(this);
686 currentOccGView->setViewWindow(NULL);
690 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
692 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
694 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
695 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
697 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
699 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
700 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
701 // disable OCC selectors
702 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
703 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
704 while ( itOCCSel.hasNext() )
705 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
706 sr->setEnabled(true);
708 else if ( vm->getType() == SVTK_Viewer::Type() )
710 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
711 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
713 // disable VTK selectors
714 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
715 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
716 while ( itVTKSel.hasNext() )
717 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
718 sr->setEnabled(true);
722 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
724 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
726 SUIT_ViewModel* viewer = vm->getViewModel();
727 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
729 //VTK View Manager removed
730 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
732 //Process only if it's our view manager
733 SUIT_ViewManager* myVm = NULL;
734 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
735 myVm = currentDocGView->getViewWindow()->getViewManager();
739 //close opened dialog
740 if (currentDialog != NULL) currentDialog->close();
741 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
747 //remove its selector
748 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
749 while ( itVTKSel.hasNext() )
750 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
751 if ( sr->viewer() == viewer )
753 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
760 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
762 //OCC View removed: remove its selector
763 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
764 while ( itOCCSel.hasNext() )
765 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
766 if ( sr->viewer() == viewer )
768 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
774 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
776 QModelIndexList l = selected.indexes();
777 if ( l.count() == 0 ) return;
778 if ( !l[0].isValid() ) return;
779 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
780 if ( currentGraphicView == NULL) return;
782 QTreeView* theTree = NULL;
783 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
784 theTree = _patternDataTreeView;
786 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
787 theTree = _patternBuilderTreeView;
789 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
790 theTree = _patternGeomTreeView;
792 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
793 theTree = _groupsTreeView;
794 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
795 theTree = _meshTreeView;
798 theTree->scrollTo ( l[0] );
802 bool HEXABLOCKGUI::createSComponent() //addComponent
804 DEBTRACE("HEXABLOCKGUI::createSComponent");
805 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
807 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
808 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
809 _PTR(GenericAttribute) anAttr;
810 _PTR(AttributeName) aName;
811 _PTR(AttributeGraphic) aGraphic;
813 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
814 if ( !aComponent ){ //Create hexablock component if there's not one yet
815 aComponent = aBuilder->NewComponent("HEXABLOCK");
816 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
817 aName = _PTR(AttributeName) (anAttr);
818 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
820 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
821 _PTR(AttributePixMap) aPixmap(anAttr);
822 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
824 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
825 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
831 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
833 DEBTRACE("HEXABLOCKGUI::setResource");
834 _myresource = new HEXABLOCKGUI_Resource(r);
835 _myresource->preferencesChanged();
838 void HEXABLOCKGUI::createPreferences()
840 DEBTRACE("HEXABLOCKGUI::createPreferences");
841 _myresource->createPreferences(this);
844 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
846 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
847 _myresource->preferencesChanged(sect, name);
848 // if(name=="userCatalog")
849 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
852 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
854 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
855 QVariant currentAssocVariant;
856 QString currentAssocEntry;
858 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
859 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
860 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
861 QMenu menu( _patternDataTreeView );
863 QAction *clearAct = menu.addAction( "Remove association(s)" );
864 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
865 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
869 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
870 if (currentVtkGraphicView == NULL) return;
871 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
873 //We don't do anything for single items
874 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
875 item->type() == QUADITEM || item->type() == HEXAITEM)
878 //No associations for HEXA
879 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
880 if ( !treeVariant.isValid() ) return;
881 int eltType = treeVariant.toInt();
882 if (eltType == HEXA_DIR_TREE) return;
883 QMenu menu( _patternDataTreeView );
885 //Show association(s)
886 QAction *showAssocAct = menu.addAction( "Show associations" );
887 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
889 //Clear all associations
890 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
891 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
893 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
898 void HEXABLOCKGUI::createAndFillDockWidget()
901 QMainWindow *aParent = application()->desktop();
903 // Create dock widget (3 dock)
905 //1) *********** user input panel ( contain user's edit dialog box )
906 _dwInputPanel = new QDockWidget(aParent);
907 _dwInputPanel->setVisible(false);
908 _dwInputPanel->setWindowTitle("Input Panel");
909 _dwInputPanel->setObjectName("hexablockInputPanelDock");
910 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
912 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
914 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
916 _dwPattern = new QDockWidget(aParent);
917 _dwPattern->setVisible(false);
918 _dwPattern->setWindowTitle("Model");
919 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
920 _dwPattern->setObjectName("hexablockModelDock");
922 QFrame* patternFrame = new QFrame(_dwPattern);
923 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
924 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
925 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
926 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
927 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
928 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
929 _patternGeomTreeView = new QTreeView(patternFrame);
930 splitter->addWidget(_patternDataTreeView);
931 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
932 splitter->addWidget(_patternGeomTreeView);
933 patternLayout->addWidget(splitter);
935 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
936 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
937 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
940 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
941 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
943 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
944 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
946 _dwPattern->setWidget(patternFrame);
947 patternFrame->show();
950 _dwGroups = new QDockWidget(aParent);
952 _dwGroups->setVisible(false);
953 _dwGroups->setWindowTitle("Groups");
954 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
955 _dwGroups->setObjectName("hexablockGroupsDock");
956 _groupsTreeView = new QTreeView(_dwGroups);
957 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
958 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
959 _dwGroups->setWidget(_groupsTreeView);
960 _groupsTreeView->show();
963 _dwMesh = new QDockWidget(aParent);
964 _dwMesh->setVisible(false);
965 _dwMesh->setWindowTitle("Mesh");
966 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
967 _dwMesh->setObjectName("hexablockMeshDock");
968 _meshTreeView = new QTreeView(_dwMesh);
969 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
970 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
971 // _meshTreeView->setItemDelegate(_treeViewDelegate);
972 _dwMesh->setWidget(_meshTreeView);
973 _meshTreeView->show();
975 // QDockWidget *_dwObjectBrowser = 0;
976 QWidget* wid = getApp()->objectBrowser()->treeView();
977 QWidget *w = wid->parentWidget();
978 while ( w && !_dwObjectBrowser ) {
979 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
980 w = w->parentWidget();
982 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
983 _dwObjectBrowser->setWindowTitle("Study");
985 // dock widget position
986 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
987 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
989 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
990 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
991 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
993 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
994 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
995 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
997 #if QT_VERSION >= 0x040500
998 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1001 // popup menu on data tree view
1002 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1003 connect(_patternDataTreeView,
1004 SIGNAL(customContextMenuRequested(const QPoint &)),
1006 SLOT(treeContextMenu(const QPoint &)),
1007 Qt::UniqueConnection );
1010 void HEXABLOCKGUI::createActions()
1012 QMainWindow *aParent = application()->desktop();
1013 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1016 _newAct = createAction(_menuId++,
1017 tr("Create a new document"),
1018 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1020 tr("Create a new document"),
1021 0, aParent, false, this, SLOT(newDocument()));
1022 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1024 _importAct = createAction(_menuId++,
1025 tr("Load a document"),
1026 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1027 tr("Load Document"),
1028 tr("Load a document"),
1029 0, aParent, false, this, SLOT(loadDocument()));
1030 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1032 _saveAct = createAction(_menuId++,
1033 tr("Save the document"),
1034 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1035 tr("Save Document"),
1036 tr("Save the document"),
1037 0, aParent, false, this, SLOT(saveDocument()));
1039 // Pattern Data creation
1040 _addVertex = createAction(_menuId++,
1041 tr("Create a vertex"),
1042 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1044 tr("Create a new vertex"),
1045 0, aParent, false, this, SLOT(addVertex()));
1047 _addEdge = createAction(_menuId++,
1048 tr("Create an edge"),
1049 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1051 tr("Create a new edge"),
1052 0, aParent, false, this, SLOT(addEdge()));
1054 _addQuad = createAction(_menuId++,
1055 tr("Create a quadrangle"),
1056 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1057 tr("Add Quadrangle"),
1058 tr("Create a new quadrangle"),
1059 0, aParent, false, this, SLOT(addQuad()));
1061 _addHexa = createAction(_menuId++,
1062 tr("Create an hexahedron"),
1063 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1064 tr("Add Hexahedron"),
1065 tr("Create a new hexahedron"),
1066 0, aParent, false, this, SLOT(addHexa()));
1068 // Builder Data creation
1069 _addVector = createAction(_menuId++,
1070 tr("Create a vector"),
1071 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1073 tr("Create a new vector"),
1074 0, aParent, false, this, SLOT(addVector()));
1076 // _addCylinder = createAction(_menuId++,
1077 // tr("Create a cylinder"),
1078 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1079 // tr("Add Cylinder"),
1080 // tr("Create a new cylinder"),
1081 // 0, aParent, false, this, SLOT(addCylinder()));
1083 // _addPipe = createAction(_menuId++,
1084 // tr("Create a pipe"),
1085 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1087 // tr("Create a new pipe"),
1088 // 0, aParent, false, this, SLOT(addPipe()));
1090 _makeGrid = createAction(_menuId++,
1092 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1095 0, aParent, false, this, SLOT(makeGrid()));
1097 _makeCylinder = createAction(_menuId++,
1098 tr("Make a cylinder"),
1099 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1100 tr("Make Cylinder"),
1101 tr("Make a cylinder"),
1102 0, aParent, false, this, SLOT(makeCylinder()));
1104 _makePipe = createAction(_menuId++,
1106 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1109 0, aParent, false, this, SLOT(makePipe()));
1111 _makeCylinders = createAction(_menuId++,
1112 tr("Make cylinders"),
1113 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1114 tr("Make Cylinders"),
1115 tr("Make cylinders"),
1116 0, aParent, false, this, SLOT(makeCylinders()));
1118 _makePipes = createAction(_menuId++,
1120 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1123 0, aParent, false, this, SLOT(makePipes()));
1125 _makeHemiSphere = createAction(_menuId++,
1126 tr("Make an hemisphere"),
1127 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1128 tr("Make Hemisphere"),
1129 tr("Make an hemisphere"),
1130 0, aParent, false, this, SLOT(makeHemiSphere()));
1132 // Pattern Data edition
1133 _removeHexa = createAction(_menuId++,
1134 tr("Remove hexahedra"),
1135 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1136 tr("Remove Hexahedra"),
1137 tr("Remove hexahedra"),
1138 0, aParent, false, this, SLOT(removeHexa()));
1140 _prismQuad = createAction(_menuId++,
1141 tr("Prism quadrangles"),
1142 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1143 tr("Prism Quadrangles"),
1144 tr("Prism quadrangles"),
1145 0, aParent, false, this, SLOT(prismQuad()));
1147 _joinQuad = createAction(_menuId++,
1148 tr("Join quadrangles"),
1149 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1150 tr("Join Quadrangles"),
1151 tr("Join quadrangles with hexahedra"),
1152 0, aParent, false, this, SLOT(joinQuad()));
1154 _merge = createAction(_menuId++,
1156 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1159 0, aParent, false, this, SLOT(merge()));
1161 _disconnect = createAction(_menuId++,
1163 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1165 tr("Disconnect edges, vertexes or quadrangles"),
1166 0, aParent, false, this, SLOT(disconnectElts()));
1168 _cutEdge = createAction(_menuId++,
1170 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1173 0, aParent, false, this, SLOT(cutEdge()));
1175 _makeTransformation = createAction(_menuId++,
1176 tr("Make transformation"),
1177 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1178 tr("Make Transformation"),
1179 tr("Make transformation"),
1180 0, aParent, false, this, SLOT(makeTransformation()));
1182 _makeSymmetry = createAction(_menuId++,
1183 tr("Make symmetry"),
1184 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1185 tr("Make Symmetry"),
1186 tr("Make symmetry"),
1187 0, aParent, false, this, SLOT(makeSymmetry()));
1189 _performTransformation = createAction(_menuId++,
1190 tr("Perform transformation"),
1191 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1192 tr("Perform Transformation"),
1193 tr("Perform transformation"),
1194 0, aParent, false, this, SLOT(performTransformation()));
1196 _performSymmetry = createAction(_menuId++,
1197 tr("Perform symmetry"),
1198 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1199 tr("Perform Symmetry"),
1200 tr("Perform symmetry"),
1201 0, aParent, false, this, SLOT(performSymmetry()));
1203 _replaceHexa = createAction(_menuId++,
1204 tr("Replace hexahedron"),
1205 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1206 tr("Replace Hexahedron"),
1207 tr("Replace hexahedron"),
1208 0, aParent, false, this, SLOT(replaceHexa()));
1210 _quadRevolution = createAction(_menuId++,
1211 tr("Quad revolution"),
1212 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1213 tr("Quad Revolution"),
1214 tr("Quad revolution"),
1215 0, aParent, false, this, SLOT(quadRevolution()));
1218 _assocVertex = createAction(_menuId++,
1219 tr("Make vertex association"),
1220 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1221 tr("Make Vertex association"),
1222 tr("Make vertex association"),
1223 0, aParent, false, this, SLOT(assocVertex()));
1225 _assocEdge = createAction(_menuId++,
1226 tr("Make edge association"),
1227 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1228 tr("Make Edge Association"),
1229 tr("Make edge association"),
1230 0, aParent, false, this, SLOT(assocEdge()));
1232 _assocQuad = createAction(_menuId++,
1233 tr("Make quad association"),
1234 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1235 tr("Make Quad Association"),
1236 tr("Make quad association"),
1237 0, aParent, false, this, SLOT(assocQuad()));
1240 _addGroup = createAction(_menuId++,
1242 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1245 0, aParent, false, this, SLOT(addGroup()));
1247 _removeGroup = createAction(_menuId++,
1248 tr("Remove a group"),
1249 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1251 tr("Remove a group"),
1252 0, aParent, false, this, SLOT(removeGroup()));
1255 _addLaw = createAction(_menuId++,
1257 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1260 0, aParent, false, this, SLOT(addLaw()));
1262 _removeLaw = createAction(_menuId++,
1264 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1267 0, aParent, false, this, SLOT(removeLaw()));
1269 _setPropagation = createAction(_menuId++,
1270 tr("Set propagation"),
1271 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1272 tr("Set Propagation"),
1273 tr("Set propagation"),
1274 0, aParent, false, this, SLOT(setPropagation()));
1276 _computeMesh = createAction(_menuId++,
1278 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1281 0, aParent, false, this, SLOT(computeMesh()));
1283 _showModelInfoAct = createAction(_menuId++,
1284 tr("Show Model Info"),
1285 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1288 0, aParent, false, this, SLOT(showModelInfo()));
1290 _addShapeAct = createAction(_menuId++,
1292 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1295 0, aParent, false, this, SLOT(addShape()));
1297 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1298 // QAction* createAction(const int id,
1299 // const QString& toolTip,
1300 // const QIcon& icon,
1301 // const QString& menu,
1302 // const QString& status,
1303 // const int shortCut,
1304 // QObject* parent =0,
1305 // bool checkable = false,
1306 // QObject* receiver =0,
1307 // const char* member =0);
1309 _sep1 = separator();
1310 _sep2 = separator();
1311 _sep3 = separator();
1312 _sep4 = separator();
1316 void HEXABLOCKGUI::createMenus()
1318 int aMenuId, subMenuId,aMenuIdMain;
1320 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1322 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1323 createMenu( actionId(_newAct), aMenuId );
1324 createMenu( actionId(_importAct), aMenuId );
1325 createMenu( _saveAct, aMenuId );
1328 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1329 createMenu( _newAct, aMenuDocId );//, 10
1330 createMenu( _importAct, aMenuDocId );
1331 createMenu( _saveAct, aMenuDocId );
1333 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1334 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1335 createMenu( _addVertex, subMenuId );
1336 createMenu( _addEdge, subMenuId );
1337 createMenu( _addQuad, subMenuId );
1338 createMenu( _addHexa, subMenuId );
1339 createMenu( _sep1, subMenuId);
1342 createMenu( _addVector, subMenuId );
1343 // createMenu( _addCylinder, subMenuId );
1344 // createMenu( _addPipe, subMenuId );
1346 createMenu( _sep2, subMenuId);
1348 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1349 createMenu( _makeHemiSphere,subMenuId );
1351 createMenu( _sep3, subMenuId);
1353 createMenu( _makeCylinder, subMenuId );
1354 createMenu( _makePipe, subMenuId );
1355 createMenu( _makeCylinders,subMenuId );
1356 createMenu( _makePipes, subMenuId );
1358 // Pattern Data Edition
1359 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1360 createMenu( _removeHexa, subMenuId );
1361 createMenu( _prismQuad, subMenuId );
1362 createMenu( _joinQuad, subMenuId );
1363 createMenu( _merge, subMenuId );
1364 createMenu( _disconnect, subMenuId );
1365 createMenu( _cutEdge, subMenuId );
1366 createMenu( _makeTransformation, subMenuId );
1367 createMenu( _makeSymmetry, subMenuId );
1368 createMenu( _performTransformation, subMenuId );
1369 createMenu( _performSymmetry, subMenuId );
1370 createMenu( _replaceHexa, subMenuId );
1371 createMenu( _quadRevolution, subMenuId );
1372 createMenu( _sep4, aMenuId );
1373 createMenu( _showModelInfoAct, aMenuId );
1376 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1377 createMenu( _addShapeAct, aMenuId );
1378 createMenu( _assocVertex, aMenuId );
1379 createMenu( _assocEdge, aMenuId );
1380 createMenu( _assocQuad, aMenuId );
1383 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1384 createMenu( _addGroup, aMenuId );
1385 createMenu( _removeGroup, aMenuId ); //CS_TODO
1388 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1389 createMenu( _addLaw, aMenuId );
1390 createMenu( _removeLaw, aMenuId );
1391 createMenu( _setPropagation, aMenuId );
1392 createMenu( _computeMesh, aMenuId );
1394 //show model infomation menu
1395 QString aRule = "$component={'HEXABLOCK'}";
1396 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1397 popupMgr()->setRule( _showModelInfoAct, aRule);
1399 //associate shape to a document menu
1400 popupMgr()->insert( _addShapeAct, -1, -1 );
1401 popupMgr()->setRule( _addShapeAct, aRule );
1403 //-------------------------------------------------
1405 //-------------------------------------------------
1406 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1407 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1408 // QString isNotEmpty("numberOfNodes <> 0");
1409 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1410 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1411 //// aType = aType.arg( mesh_part );
1413 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1414 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1415 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1417 // popupMgr()->insert( separator(), -1, -1 );
1418 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1419 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1420 // // MESSAGE("aClient = " << aClient.toStdString());
1421 // // MESSAGE("aType = " << aType.toStdString());
1422 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1423 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1424 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1425 // // MESSAGE("aRule = " << aRule.toStdString());
1426 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1427 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1429 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1430 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1432 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1433 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1435 // popupMgr()->insert( separator(), -1, -1 );
1439 void HEXABLOCKGUI::createTools()
1443 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1444 createTool( _newAct, aToolId );
1445 createTool( _importAct, aToolId );
1446 createTool( _saveAct, aToolId );
1447 createTool( _showModelInfoAct, aToolId );
1448 // createTool( _testAct, aToolId );
1449 //createTool( separator(), aToolId );
1452 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1453 createTool( _addVertex, aToolId );
1454 createTool( _addEdge, aToolId );
1455 createTool( _addQuad, aToolId );
1456 createTool( _addHexa, aToolId );
1458 createTool( _sep1, aToolId );
1461 createTool( _addVector, aToolId );
1462 // createTool( _addCylinder, aToolId );
1463 // createTool( _addPipe, aToolId );
1465 createTool( _sep2, aToolId );
1467 createTool( _makeGrid, aToolId );
1468 createTool( _makeHemiSphere, aToolId );
1470 createTool( _sep3, aToolId );
1472 createTool( _makeCylinder, aToolId );
1473 createTool( _makePipe, aToolId );
1474 createTool( _makeCylinders,aToolId );
1475 createTool( _makePipes, aToolId );
1477 // Pattern Data Edition
1478 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1479 createTool( _removeHexa, aToolId );
1480 createTool( _prismQuad, aToolId );
1481 createTool( _joinQuad, aToolId );
1482 createTool( _merge, aToolId );
1483 createTool( _disconnect, aToolId );
1484 createTool( _cutEdge, aToolId );
1485 createTool( _makeTransformation, aToolId );
1486 createTool( _makeSymmetry, aToolId );
1487 createTool( _performTransformation, aToolId );
1488 createTool( _performSymmetry, aToolId );
1489 createTool( _replaceHexa, aToolId );
1490 createTool( _quadRevolution, aToolId );
1493 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1494 createTool( _assocVertex, aToolId );
1495 createTool( _assocEdge, aToolId );
1496 createTool( _assocQuad, aToolId );
1497 createTool( _addShapeAct, aToolId );
1500 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1501 createTool( _addGroup, aToolId );
1502 createTool( _removeGroup, aToolId ); //CS_TODO
1505 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1506 createTool( _addLaw, aToolId );
1507 createTool( _removeLaw, aToolId );
1508 createTool( _setPropagation, aToolId );
1509 createTool( _computeMesh, aToolId );
1513 void HEXABLOCKGUI::initialMenus()
1515 showDocumentMenus( true );
1516 showPatternMenus( false );
1517 showAssociationMenus( false );
1518 showGroupsMenus( false );
1519 showMeshMenus( false );
1522 void HEXABLOCKGUI::showAllMenus()
1524 showDocumentMenus( true );
1525 showPatternMenus( true );
1526 showAssociationMenus( true );
1527 showGroupsMenus( true );
1528 showMeshMenus( true );
1531 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1533 enableDocumentMenus( enable );
1534 enablePatternMenus( enable );
1535 enableAssociationMenus( enable );
1536 enableGroupsMenus( enable );
1537 enableMeshMenus( enable );
1539 menusEnabled = enable;
1542 void HEXABLOCKGUI::showDocumentMenus(bool show)
1544 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1546 setMenuShown(_newAct, show);
1547 setToolShown(_newAct, show);
1548 setMenuShown(_importAct, show);
1549 setToolShown(_importAct, show);
1550 setMenuShown(_showModelInfoAct, show);
1551 setToolShown(_showModelInfoAct, show);
1552 setMenuShown(_saveAct, show);
1553 setToolShown(_saveAct, show);
1556 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1558 _newAct->setEnabled(enable);
1559 // setToolShown(_newAct, enable);
1561 _importAct->setEnabled(enable);
1562 // setToolShown(_importAct, enable);
1564 _showModelInfoAct->setEnabled(enable);
1565 // setToolShown(_showModelInfoAct, enable);
1567 _saveAct->setEnabled(enable);
1568 // setToolShown(_saveAct, enable);
1572 void HEXABLOCKGUI::showPatternMenus(bool show)
1574 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1575 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1576 if ( show && !getCurrentModel() ) return;
1578 setMenuShown(_addVertex, show );
1579 setToolShown(_addVertex, show);
1580 setMenuShown(_addEdge, show );
1581 setToolShown(_addEdge, show);
1582 setMenuShown(_addQuad, show );
1583 setToolShown(_addQuad, show);
1584 setMenuShown(_addHexa, show );
1585 setToolShown(_addHexa, show);
1587 setMenuShown(_sep1, show );
1588 setToolShown(_sep1, show);
1590 setMenuShown( _addVector, show );
1591 setToolShown( _addVector, show);
1592 // setMenuShown( _addCylinder, show );
1593 // setToolShown( _addCylinder, show);
1594 // setMenuShown( _addPipe, show );
1595 // setToolShown( _addPipe, show);
1597 setMenuShown(_sep2, show );
1598 setToolShown(_sep2, show);
1600 setMenuShown( _makeGrid, show );
1601 setToolShown( _makeGrid, show);
1602 setMenuShown( _makePipe, show );
1603 setToolShown( _makePipe, show);
1605 setMenuShown(_sep3, show );
1606 setToolShown(_sep3, show);
1608 setMenuShown( _makeCylinder, show );
1609 setToolShown( _makeCylinder, show);
1610 setMenuShown( _makeCylinders, show );
1611 setToolShown( _makeCylinders, show);
1612 setMenuShown( _makePipes, show );
1613 setToolShown( _makePipes, show);
1614 setMenuShown( _makeHemiSphere, show );
1615 setToolShown( _makeHemiSphere, show);
1617 // Pattern Data Edition
1618 setMenuShown( _removeHexa, show );
1619 setToolShown( _removeHexa, show);
1620 setMenuShown( _prismQuad, show );
1621 setToolShown( _prismQuad, show);
1622 setMenuShown( _joinQuad, show );
1623 setToolShown( _joinQuad, show);
1624 setMenuShown( _merge, show );
1625 setToolShown( _merge, show);
1626 setMenuShown( _disconnect, show );
1627 setToolShown( _disconnect, show);
1628 setMenuShown( _cutEdge, show );
1629 setToolShown( _cutEdge, show);
1630 setMenuShown( _makeTransformation, show );
1631 setToolShown( _makeTransformation, show);
1632 setMenuShown( _makeSymmetry, show );
1633 setToolShown( _makeSymmetry, show);
1634 setMenuShown( _performTransformation, show );
1635 setToolShown( _performTransformation, show);
1636 setMenuShown( _performSymmetry, show );
1637 setToolShown( _performSymmetry, show);
1638 setMenuShown( _replaceHexa, show );
1639 setToolShown( _replaceHexa, show);
1640 setMenuShown( _quadRevolution, show );
1641 setToolShown( _quadRevolution, show);
1643 setMenuShown( _sep4, show );
1644 setMenuShown( _showModelInfoAct, show );
1647 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1649 if ( enable && !getCurrentModel() ) return;
1651 _addVertex->setEnabled(enable);
1652 // setToolShown(_addVertex, enable);
1654 _addEdge->setEnabled(enable);
1655 // setToolShown(_addEdge, enable);
1657 _addQuad->setEnabled(enable);
1658 // setToolShown(_addQuad, enable);
1660 _addHexa->setEnabled(enable);
1661 // setToolShown(_addHexa, enable);
1663 // setMenuShown(_sep1, enable );
1664 // setToolShown(_sep1, enable);
1666 _addVector->setEnabled(enable);
1667 // setToolShown( _addVector, enable);
1669 // setMenuShown(_sep2, enable );
1670 // setToolShown(_sep2, enable);
1672 _makeGrid->setEnabled(enable);
1673 // setToolShown( _makeGrid, enable);
1675 _makePipe->setEnabled(enable);
1676 // setToolShown( _makePipe, enable);
1678 // setMenuShown(_sep3, enable );
1679 // setToolShown(_sep3, enable);
1681 _makeCylinder->setEnabled(enable);
1682 // setToolShown( _makeCylinder, enable);
1684 _makeCylinders->setEnabled(enable);
1685 // setToolShown( _makeCylinders, enable);
1687 _makePipes->setEnabled(enable);
1688 // setToolShown( _makePipes, enable);
1690 _makeHemiSphere->setEnabled(enable);
1691 // setToolShown( _makeHemiSphere, enable);
1693 // Pattern Data Edition
1694 _removeHexa->setEnabled(enable);
1695 // setToolShown( _removeHexa, enable);
1697 _prismQuad->setEnabled(enable);
1698 // setToolShown( _prismQuad, enable);
1700 _joinQuad->setEnabled(enable);
1701 // setToolShown( _joinQuad, enable);
1703 _merge->setEnabled(enable);
1704 // setToolShown( _merge, enable);
1706 _disconnect->setEnabled(enable);
1707 // setToolShown( _disconnect, enable);
1709 _cutEdge->setEnabled(enable);
1710 // setToolShown( _cutEdge, enable);
1712 _makeTransformation->setEnabled(enable);
1713 // setToolShown( _makeTransformation, enable);
1715 _makeSymmetry->setEnabled(enable);
1716 // setToolShown( _makeSymmetry, enable);
1718 _performTransformation->setEnabled(enable);
1719 // setToolShown( _performTransformation, enable);
1721 _performSymmetry->setEnabled(enable);
1722 // setToolShown( _performSymmetry, enable);
1724 _replaceHexa->setEnabled(enable);
1725 // setToolShown( _replaceHexa, enable);
1727 _quadRevolution->setEnabled(enable);
1728 // setToolShown( _quadRevolution, enable);
1730 // setMenuShown( _sep4, enable );
1731 _showModelInfoAct->setEnabled(enable);
1735 void HEXABLOCKGUI::showAssociationMenus(bool show)
1737 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1738 if ( show && !getCurrentModel() ) return;
1740 // Association Edition
1741 setMenuShown( _assocVertex, show );
1742 setToolShown( _assocVertex, show );
1744 setMenuShown( _assocEdge, show );
1745 setToolShown( _assocEdge, show );
1747 setMenuShown( _assocQuad, show );
1748 setToolShown( _assocQuad, show );
1750 setMenuShown( _addShapeAct, show );
1751 setToolShown( _addShapeAct, show );
1754 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1756 if ( enable && !getCurrentModel() )
1759 // Association Edition
1760 _assocVertex->setEnabled(enable);
1761 // setToolShown( _assocVertex, enable );
1763 _assocEdge->setEnabled(enable);
1764 // setToolShown( _assocEdge, enable );
1766 _assocQuad->setEnabled(enable);
1767 // setToolShown( _assocQuad, enable );
1769 _addShapeAct->setEnabled(enable);
1770 // setToolShown( _addShapeAct, enable );
1773 void HEXABLOCKGUI::showGroupsMenus(bool show)
1775 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1776 if ( show && !getCurrentModel() ) return;
1777 setMenuShown( _addGroup, show );
1778 setToolShown( _addGroup, show);
1779 setMenuShown( _removeGroup , show );
1780 setToolShown( _removeGroup , show);
1783 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1785 if ( enable && !getCurrentModel() )
1788 _addGroup->setEnabled(enable);
1789 // setToolShown( _addGroup, enable);
1791 _removeGroup->setEnabled(enable);
1792 // setToolShown( _removeGroup , enable);
1795 void HEXABLOCKGUI::showMeshMenus(bool show)
1797 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1798 if ( show && !getCurrentModel() ) return;
1799 setMenuShown( _addLaw, show );
1800 setToolShown( _addLaw, show);
1801 setMenuShown( _removeLaw, show );
1802 setToolShown( _removeLaw, show);;
1803 setMenuShown( _setPropagation, show );
1804 setToolShown( _setPropagation, show);
1805 setMenuShown( _computeMesh, show);
1806 setToolShown( _computeMesh, show);
1809 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1811 if ( enable && !getCurrentModel() )
1814 _addLaw->setEnabled(enable);
1815 // setToolShown( _addLaw, enable);
1817 _removeLaw->setEnabled(enable);
1818 // setToolShown( _removeLaw, enable);
1820 _setPropagation->setEnabled(enable);
1821 // setToolShown( _setPropagation, enable);
1823 _computeMesh->setEnabled(enable);
1824 // setToolShown( _computeMesh, enable);
1827 void HEXABLOCKGUI::showVtkActor()
1829 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1830 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1831 currentVtkGView->getDocumentActor() == NULL)
1834 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1835 if (vtkView == NULL)
1838 SUIT_ViewManager* vman = vtkView->getViewManager();
1839 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1841 //show only the current actor -----------------
1842 vtkView->setFocus();
1843 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1844 Document_Actor *lastDocActor;
1845 if (lastVtkDocGView != NULL)
1847 lastDocActor = lastVtkDocGView->getDocumentActor();
1848 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1849 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1851 vtkView->Erase(lastActorIO);
1852 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1853 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1856 currentVtkGView->update();
1857 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1858 if (!anIO.IsNull() && anIO->hasEntry())
1860 vtkView->Display(anIO);
1861 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1862 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1864 vtkView->onFitAll();
1867 void HEXABLOCKGUI::showOccActor()
1869 if (currentOccGView == NULL)
1871 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1872 if (occView == NULL)
1874 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1878 if (lastOccPrs != NULL)
1879 vf->Erase(lastOccPrs);
1880 currentOccGView->globalSelection();
1881 SOCC_Prs* prs = getOccPrs(currentDocGView);
1882 currentOccGView->setPrs(prs);
1885 occView->onFitAll();
1888 void HEXABLOCKGUI::hideVtkActor()
1890 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1891 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1892 currentVtkGView->getViewWindow() == NULL ||
1893 currentVtkGView->getDocumentActor() == NULL) return;
1895 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1896 currentVtkGView->getViewWindow()->onResetView();
1898 //update the visibility state now
1899 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1900 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1901 if (aStudy == NULL || vman == NULL) return;
1903 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1904 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1905 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1908 void HEXABLOCKGUI::hideOccActor()
1910 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1911 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1912 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1913 if (occView == NULL || docModel == NULL)
1915 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1919 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1920 if (currentOccPrs != NULL)
1921 vf->Erase(currentOccPrs);
1923 occView->onResetView();
1926 void HEXABLOCKGUI::showOnlyActor()
1932 void HEXABLOCKGUI::hideActor()
1939 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1941 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1943 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1945 if (_dwPattern) _dwPattern->setVisible(isVisible);
1946 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1948 if (_dwMesh) _dwMesh->setVisible(isVisible);
1949 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1951 if (_dwGroups) _dwGroups->setVisible(isVisible);
1952 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1956 //clear all used dialogs by the current model
1957 void HEXABLOCKGUI::clearDialogs()
1959 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1960 fin (currentModelDialogs.end());
1961 for(;debut!=fin;++debut) (*debut)->clear();
1963 currentModelDialogs.clear(); //empty the used dialogs list
1966 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1968 if (!gViewDlgBox.contains(dgview)) return NULL;
1969 return gViewDlgBox[dgview];
1972 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1974 if (dgview == NULL) return;
1976 switchOffGraphicView(dgview, false); //to avoid double connect
1979 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1980 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1981 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1982 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1983 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1984 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1985 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1986 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1987 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1988 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1989 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1990 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1995 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1997 if (dgview == NULL) return;
1999 //disconnect signals
2000 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2001 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2002 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2003 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2004 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2005 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2006 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2007 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2008 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2009 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2010 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2011 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2014 gViewDlgBox[dgview] = currentDialog;
2016 //close opened dialog
2017 if (currentDialog != NULL) currentDialog->close();
2018 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2024 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2026 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2030 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2034 //switch off the current document graphic view (disconnect signals...)
2035 if (currentDocGView != NULL)
2037 //Hide current actor
2039 switchOffGraphicView(currentDocGView);
2042 //clear the dialogs used by the current model so they can be used by the new model
2043 if (currentDocGView != dgview) clearDialogs();
2045 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2046 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2047 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2048 _groupsTreeView->setModel(dgview->getGroupsModel());
2049 _meshTreeView->setModel(dgview->getMeshModel());
2051 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2052 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2054 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2055 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2057 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2058 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2060 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2061 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2063 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2064 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2067 // = * init occ view * =
2068 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2070 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2071 currentOccGView->getViewWindow()->installEventFilter(this);
2076 // = * init vtk view * =
2077 if (currentDocGView != NULL)
2079 if (currentDocGView->getViewWindow() != NULL)
2080 dgview->setViewWindow(currentDocGView->getViewWindow());
2083 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2084 dgview->getViewWindow()->installEventFilter(this);
2090 switchOnGraphicView(dgview);
2092 if (currentDocGView != NULL)
2094 lastVtkDocGView = currentDocGView;
2095 lastOccPrs = getOccPrs(currentDocGView);
2099 lastVtkDocGView = dgview;
2100 lastOccPrs = getOccPrs(dgview);
2103 currentDocGView = dgview;
2105 currentDocGView->getDocumentModel()->refresh();
2106 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2109 setAllMenusEnabled(true);
2112 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2114 if (currentDocGView == NULL) return NULL;
2115 return currentDocGView->getDocumentModel();
2119 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2121 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2122 if (anApp == NULL) return UNKNOWN;
2123 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2124 if (activeVm == NULL) return UNKNOWN;
2126 QString vmType = activeVm->getType();
2127 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2129 else if ( vmType == OCCViewer_Viewer::Type() )
2135 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2137 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2141 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2144 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2146 // Create Document from HEXABLOCK ENGINE
2147 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2148 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2150 // looking doc impl ( c++ )
2151 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2152 // ^Hexa6 ASSERT( dServant );
2153 // ^Hexa6 if ( dServant)
2154 // ^Hexa6 doc = dServant->GetImpl();
2156 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2157 QString docEntry = addDocInStudy (doc);
2159 // looking for docEntry
2160 /* ****************************************************************
2161 if ( !CORBA::is_nil(docIn) ){
2162 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2163 QString docIOR = anIOR.in();
2164 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2165 if ( !docIOR.isEmpty() ) {
2166 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2168 docEntry = SO->GetID().c_str();
2171 **************************************************************** */
2172 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2174 return make_pair (docEntry, doc);
2178 void HEXABLOCKGUI::newDocument()
2180 DEBTRACE("HEXABLOCKGUI::newDocument");
2183 QMainWindow *aParent = application()->desktop();
2184 QWidget *central = aParent->centralWidget();
2186 central->setFocus();
2188 DEBTRACE("No Central Widget");
2191 if (currentOccGView == NULL)
2193 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2194 application()->desktop());
2195 currentOccGView->getViewWindow()->installEventFilter(this);
2197 else if (currentOccGView->getViewWindow() == NULL)
2199 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2200 currentOccGView->getViewWindow()->installEventFilter(this);
2204 // Create Document from HEXABLOCK ENGINE
2205 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2207 VtkDocumentGraphicView* newGraphicView = NULL;
2208 //One document at a time
2209 if (currentDocGView != NULL)
2211 if (currentDocGView->getViewWindow() == NULL)
2213 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2214 currentDocGView->getViewWindow()->installEventFilter(this);
2217 // Create a new document with the current window
2218 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2219 new DocumentModel( docEntry_Doc.second,
2220 docEntry_Doc.first, this ),
2221 currentDocGView->getViewWindow(),
2222 application()->desktop() );
2226 // Create the new Document Graphic View with a new window
2227 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2228 new DocumentModel( docEntry_Doc.second,
2229 docEntry_Doc.first, this ),
2230 graphicViewsHandler->createVtkWindow(),
2231 application()->desktop() );
2232 newGraphicView->getViewWindow()->installEventFilter(this);
2235 if (newGraphicView == NULL)
2236 //We couldn't create a new document graphic view
2237 //we'd better show a dialog box info to inform the user
2240 docs[docEntry_Doc.first] = newGraphicView;
2241 switchModel(newGraphicView); //select the corresponding document in the browser instead
2243 getApp()->updateObjectBrowser();
2248 //Loads the model from the xmlFile in the current graphic view
2249 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2251 DEBTRACE("HEXABLOCKGUI::loadDocument");
2254 QMainWindow *aParent = application()->desktop();
2255 QString selectedFile;
2257 if ( inFile.isNull() ){
2258 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2259 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2260 dialog.setHistory( getQuickDirList() );
2262 //use the last path as default
2263 if (!(loadDocLastPath->absolutePath()).isEmpty())
2264 dialog.setDirectory(*loadDocLastPath);
2267 QStringList selectedFiles = dialog.selectedFiles();
2268 if (!selectedFiles.isEmpty())
2269 selectedFile = selectedFiles.first();
2271 //remember the selected path
2272 *loadDocLastPath = dialog.directory();
2275 selectedFile = inFile;
2277 if (selectedFile.isEmpty())
2280 //we create a new document if necessary
2281 if (currentDocGView == NULL)
2282 //Need a new document
2284 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2286 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2287 currentDocGView->getViewWindow()->installEventFilter(this);
2290 if (!currentDocGView->isEmpty())
2291 //we can only have one document for a graphic view
2294 //we load the selected file in the current graphic view
2295 currentDocGView->loadDocument(selectedFile);
2296 DocumentModel* currentModel = getCurrentModel();
2297 renameObject( currentModel->documentEntry(), currentModel->getName() );
2302 void HEXABLOCKGUI::saveDocument()
2304 QMainWindow *aParent = application()->desktop();
2306 QString aDocName = "document", aFilename;
2308 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2309 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2311 //use the last selected directory as default path for file selection
2312 aFilename = saveDocLastPath->absolutePath();
2313 if (!aFilename.isEmpty())
2314 aFilename += QString("/") + aDocName;
2316 //show the dialog for file selection
2317 aFilename = SUIT_FileDlg::getFileName( aParent,
2320 tr( "Save HexaBlock Document" ),
2323 //save the document in the selected file
2324 if ( !aFilename.isEmpty() ) {
2325 getCurrentVtkGraphicView()->saveDocument( aFilename );
2327 //Remember the path for next save
2328 QFileInfo fileInfo(aFilename);
2329 *saveDocLastPath = fileInfo.dir();
2335 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2337 _patternDataTreeView->openPersistentEditor( topLeft );
2340 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2342 if (diag == NULL || _dwInputPanel == NULL ||
2343 getCurrentVtkGraphicView() == NULL) return;
2345 //mark this dialog as used by the current model
2346 currentModelDialogs.insert(diag);
2348 //close the current dialog box info
2349 // if (_treeViewDelegate != NULL)
2350 // _treeViewDelegate->closeDialog();
2352 // if (_dwInputPanel->widget())
2353 // _dwInputPanel->widget()->close();
2355 //Temporary for debugging EdgeAssoc Faked InfoDialog
2356 if (diag == _edgeAssocDiag)
2357 diag->debugEdgeAssoc = true;
2359 diag->debugEdgeAssoc = false;
2361 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2362 diag == _quadAssocDiag || diag == _addShapeDiag)
2363 assocInProgress = true;
2365 assocInProgress = false;
2367 //show the dialog box in the dockwidget
2368 diag->resetSizeAndShow(_dwInputPanel);
2370 //clear the current selections
2371 selectionMgr()->clearSelected();
2373 currentDialog = diag;
2376 if (currentDocGView != NULL)
2377 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2380 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2382 if (vertex == NULL || _dwInputPanel == NULL)
2385 if (_vertexInfoDialog == NULL)
2386 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2388 _vertexInfoDialog->setValue(vertex);
2389 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2390 currentDialog = _vertexInfoDialog;
2393 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2395 if (edge == NULL || _dwInputPanel == NULL)
2398 if (_edgeInfoDialog == NULL)
2399 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2401 _edgeInfoDialog->setValue(edge);
2402 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2403 currentDialog = _edgeInfoDialog;
2406 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2408 if (quad == NULL || _dwInputPanel == NULL)
2411 if (_quadInfoDialog == NULL)
2412 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2414 _quadInfoDialog->setValue(quad);
2415 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2416 currentDialog = _quadInfoDialog;
2419 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2421 if (hexa == NULL || _dwInputPanel == NULL)
2424 if (_hexaInfoDialog == NULL)
2425 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2427 _hexaInfoDialog->setValue(hexa);
2428 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2429 currentDialog = _hexaInfoDialog;
2432 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2434 if (vector == NULL || _dwInputPanel == NULL)
2437 if (_vectorInfoDialog == NULL)
2438 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2440 _vectorInfoDialog->setValue(vector);
2441 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2442 currentDialog = _vectorInfoDialog;
2445 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2447 if (group == NULL || _dwInputPanel == NULL)
2450 if (_groupInfoDialog == NULL)
2451 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2453 _groupInfoDialog->setValue(group);
2454 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2455 currentDialog = _groupInfoDialog;
2458 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2460 if (law == NULL || _dwInputPanel == NULL)
2463 if (_lawInfoDialog == NULL)
2464 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2466 _lawInfoDialog->setValue(law);
2467 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2468 currentDialog = _lawInfoDialog;
2471 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2473 if (propagation == NULL || _dwInputPanel == NULL)
2476 if (_propagationInfoDialog == NULL)
2477 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2479 _propagationInfoDialog->setValue(propagation);
2480 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2481 currentDialog = _propagationInfoDialog;
2484 void HEXABLOCKGUI::addVertex()
2486 if ( !_vertexDiag ){
2487 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2489 _showDialogBox( _vertexDiag );
2492 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2493 if (_vertexDiag != NULL && doc != NULL)
2494 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2497 void HEXABLOCKGUI::addEdge()
2500 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2502 _showDialogBox( _edgeDiag );
2505 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2506 if (_edgeDiag != NULL && doc != NULL)
2507 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2510 void HEXABLOCKGUI::addQuad()
2513 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2516 _showDialogBox( _quadDiag );
2519 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2520 if (_quadDiag != NULL && doc != NULL)
2521 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2524 void HEXABLOCKGUI::addHexa()
2527 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2529 _showDialogBox( _hexaDiag );
2532 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2533 if (_hexaDiag != NULL && doc != NULL)
2534 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2537 void HEXABLOCKGUI::addVector()
2539 if ( !_vectorDiag ){
2540 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2542 _showDialogBox( _vectorDiag );
2545 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2546 if (_vectorDiag != NULL && doc != NULL)
2547 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2550 //void HEXABLOCKGUI::addCylinder()
2552 // if ( !_cylinderDiag ){
2553 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2555 // _showDialogBox( _cylinderDiag );
2557 // //set default name
2558 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2559 // if (_cylinderDiag != NULL && doc != NULL)
2560 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2564 //void HEXABLOCKGUI::addPipe()
2566 // if ( !_pipeDiag){
2567 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2569 // _showDialogBox( _pipeDiag );
2571 // //set default name
2572 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2573 // if (_pipeDiag != NULL && doc != NULL)
2574 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2578 void HEXABLOCKGUI::makeGrid()
2580 if ( !_makeGridDiag ){
2581 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2583 _showDialogBox( _makeGridDiag );
2587 void HEXABLOCKGUI::makeCylinder()
2589 if ( !_makeCylinderDiag ){
2590 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2592 _showDialogBox( _makeCylinderDiag );
2595 void HEXABLOCKGUI::makePipe()
2597 if ( !_makePipeDiag ){
2598 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2600 _showDialogBox( _makePipeDiag );
2603 void HEXABLOCKGUI::makeCylinders()
2605 if ( !_makeCylindersDiag ){
2606 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2608 _showDialogBox( _makeCylindersDiag );
2611 void HEXABLOCKGUI::makePipes()
2613 if ( !_makePipesDiag ){
2614 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2616 _showDialogBox( _makePipesDiag );
2620 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2622 if ( !_makeHemiSphereDiag ){
2623 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2625 _showDialogBox( _makeHemiSphereDiag );
2629 void HEXABLOCKGUI::removeHexa()
2631 if ( !_removeHexaDiag ){
2632 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2634 _showDialogBox( _removeHexaDiag );
2638 void HEXABLOCKGUI::prismQuad()
2640 if ( !_prismQuadDiag ){
2641 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2643 _showDialogBox( _prismQuadDiag );
2647 void HEXABLOCKGUI::joinQuad()
2649 if ( !_joinQuadDiag ){
2650 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2652 _showDialogBox( _joinQuadDiag );
2655 void HEXABLOCKGUI::merge()
2658 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2660 _showDialogBox( _mergeDiag );
2663 void HEXABLOCKGUI::disconnectElts()
2665 if ( !_disconnectDiag ){
2666 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2668 _showDialogBox( _disconnectDiag );
2671 void HEXABLOCKGUI::cutEdge()
2673 if ( !_cutEdgeDiag ){
2674 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2676 _showDialogBox( _cutEdgeDiag );
2679 void HEXABLOCKGUI::makeTransformation()
2681 if ( !_makeTransformationDiag ){
2682 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2684 _showDialogBox( _makeTransformationDiag );
2688 void HEXABLOCKGUI::makeSymmetry()
2690 if ( !_makeSymmetryDiag ){
2691 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2693 _showDialogBox( _makeSymmetryDiag );
2697 void HEXABLOCKGUI::performTransformation()
2699 if ( !_performTransformationDiag ){
2700 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2702 _showDialogBox( _performTransformationDiag );
2706 void HEXABLOCKGUI::performSymmetry()
2708 if ( !_performSymmetryDiag ){
2709 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2711 _showDialogBox( _performSymmetryDiag );
2715 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2717 if ( !_replaceHexaDiag ){
2718 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2720 _showDialogBox( _replaceHexaDiag );
2724 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2726 if ( !_quadRevolutionDiag ){
2727 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2729 _showDialogBox( _quadRevolutionDiag );
2733 void HEXABLOCKGUI::assocVertex()
2735 if (!_dwInputPanel) return;
2736 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2737 if ( !_vertexAssocDiag )
2738 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2739 _showDialogBox( _vertexAssocDiag );
2743 void HEXABLOCKGUI::assocEdge()
2745 if ( !_edgeAssocDiag )
2746 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2747 _showDialogBox( _edgeAssocDiag );
2750 void HEXABLOCKGUI::assocQuad()
2752 if ( !_quadAssocDiag )
2753 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2754 _showDialogBox( _quadAssocDiag );
2758 void HEXABLOCKGUI::addGroup()
2761 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2763 _showDialogBox( _groupDiag );
2764 if (_groupDiag != NULL && getCurrentModel() != NULL)
2766 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2767 if (doc == NULL) return;
2768 char defaultName[16];
2769 sprintf (defaultName, "g%04d", doc->countGroup());
2770 _groupDiag->name_le->setText(defaultName);
2774 void HEXABLOCKGUI::removeGroup()
2776 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2777 if (currentDGView == NULL) return;
2779 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2780 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2781 int nbGroupsRemoved = 0;
2784 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2785 tr( "No group selected!" ) );
2789 foreach( QModelIndex selected, l ){
2790 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2791 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2792 Q_ASSERT(selected.isValid());
2794 //Confirm the deletion of the group
2795 if (SUIT_MessageBox::question(
2798 tr("Remove group : %1 ?").arg(selected.data().toString()),
2799 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2800 SUIT_MessageBox::Cancel
2801 ) == SUIT_MessageBox::Cancel) return;
2803 bool removed = getCurrentModel()->removeGroup( selected );
2805 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2806 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2812 if (!nbGroupsRemoved)
2813 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2814 tr( "No group selected!" ) );
2817 void HEXABLOCKGUI::addLaw()
2820 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2822 _showDialogBox( _lawDiag );
2823 if (_lawDiag != NULL && getCurrentModel() != NULL)
2825 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2826 if (doc == NULL) return;
2827 char defaultName[16];
2828 sprintf (defaultName, "l%04d", doc->countLaw());
2829 _lawDiag->name_le->setText(defaultName);
2833 void HEXABLOCKGUI::removeLaw()
2835 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2836 if (currentDGView == NULL) return;
2838 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2839 int nbLawsRemoved = 0;
2842 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2843 tr( "No law selected!" ) );
2847 foreach( QModelIndex selected, l ){
2848 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2849 selected = currentDGView->getMeshModel()->mapToSource( selected );
2850 Q_ASSERT(selected.isValid());
2852 //Confirm the deletion of the law
2853 if (SUIT_MessageBox::question(
2856 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2857 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2858 SUIT_MessageBox::Cancel
2859 ) == SUIT_MessageBox::Cancel) return;
2861 bool removed = getCurrentModel()->removeLaw(selected);
2863 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2864 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2871 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2872 tr( "No law selected!" ) );
2877 void HEXABLOCKGUI::setPropagation()
2879 if ( !_propagationDiag )
2880 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2882 _showDialogBox( _propagationDiag );
2885 // Dialog box to compute a mesh from a document
2886 // --------------------------------------------
2887 void HEXABLOCKGUI::computeMesh()
2889 if ( !_computeMeshDiag )
2890 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2892 _showDialogBox( _computeMeshDiag );
2895 void HEXABLOCKGUI::clearAssociations()
2897 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2898 if (currentDGView == NULL) return;
2900 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2901 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2902 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2904 getCurrentModel()->clearEltAssociations(iModel);
2906 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2909 void HEXABLOCKGUI::showModelInfo()
2911 //create the info dialog if not yet
2912 if (_modelInfoDiag == NULL)
2913 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2915 //show the model informations dialog
2916 _showDialogBox( _modelInfoDiag );
2919 void HEXABLOCKGUI::addShape()
2921 //create the info dialog if not yet
2922 if (_addShapeDiag == NULL)
2923 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2925 //show the model informations dialog
2926 _showDialogBox( _addShapeDiag );
2929 void HEXABLOCKGUI::clearAllAssociations()
2931 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2932 if (currentDGView == NULL) return;
2934 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2935 if (!currentIndex.isValid()) return;
2936 QVariant currentAssocVariant;
2937 QString currentAssocEntry;
2939 //Confirm the deletion of the associations
2940 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2941 if ( !treeVariant.isValid() ) return;
2942 int eltType = treeVariant.toInt();
2943 QString typeStr = "";
2944 HEXA_NS::EnumElt hexaType;
2945 if (eltType == VERTEX_DIR_TREE)
2947 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2948 hexaType = HEXA_NS::EL_VERTEX;
2950 else if (eltType == EDGE_DIR_TREE)
2952 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2953 hexaType = HEXA_NS::EL_EDGE;
2955 else if (eltType == QUAD_DIR_TREE)
2957 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2958 hexaType = HEXA_NS::EL_QUAD;
2961 if (SUIT_MessageBox::question(
2963 tr("CLEAR_ASSOCIATIONS"),
2964 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2965 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2966 SUIT_MessageBox::Cancel
2967 ) == SUIT_MessageBox::Cancel) return;
2970 DocumentModel* docModel = getCurrentModel();
2971 if (docModel == NULL) return;
2972 docModel->clearAssociation(hexaType);
2975 void HEXABLOCKGUI::showAssociations()
2977 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2978 if (currentDGView == NULL) return;
2980 QModelIndexList elts;
2981 int currentChildIndex = 0;
2982 QVariant currentAssocVariant;
2983 QString currentAssocEntry;
2984 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2985 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2987 while( currentChild.isValid() ) {
2989 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2990 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2991 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2992 elts << currentChild;
2994 currentChild = currentChild.sibling(currentChildIndex++, 0);
2996 currentDocGView->highlight(elts);
2997 currentOccGView->highlight(elts, false);
3001 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3003 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3005 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3010 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3012 if ( event->type() == QEvent::Enter )
3013 { // *** ENTER EVENT
3015 if (currentDialog == NULL || !currentDialog->isVisible())
3016 return QObject::eventFilter(obj, event);
3018 // ** The window acquire the focus when the cursor enter
3020 //OCC - window enter
3021 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3022 if ( occWindow != NULL)
3023 currentDialog->onWindowActivated(occWindow->getViewManager());
3025 //VTK - window enter
3027 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3028 if ( vtkWindow != NULL)
3029 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3033 //standard event processing
3034 return QObject::eventFilter(obj, event);
3037 QStringList HEXABLOCKGUI::getQuickDirList()
3039 QStringList dirList;
3040 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3042 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3048 // --- Export the module
3052 HEXABLOCK_EXPORT CAM_Module* createModule()
3054 return new HEXABLOCKGUI();
3057 HEXABLOCK_EXPORT char* getModuleVersion()
3059 return (char*)HEXABLOCK_VERSION_STR;
3065 // ******************** TESTS ***************************************************
3067 void HEXABLOCKGUI::testDocument()
3071 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3072 // QStandardItem *myItem = new QStandardItem("MyItem");
3073 // parentItem->appendRow(myItem);
3075 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3076 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3077 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3078 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3079 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3080 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3081 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3082 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3085 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3086 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3087 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3088 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3089 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3090 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3092 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3093 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3094 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3095 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3100 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3101 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3102 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3103 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3111 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3112 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3114 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3115 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3119 // newMesh( "toto", 3, "FactoryServer");
3123 void HEXABLOCKGUI::test_make_cart_grid()
3125 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3126 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3127 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3128 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3129 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3130 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3132 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3133 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3140 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3141 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3142 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3143 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3144 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3145 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3150 void HEXABLOCKGUI::test_make_elmts_transform()
3157 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3158 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3161 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3162 // orig.setScalar(2);
3164 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3165 // getCurrentModel()->saveVtk(file_name)
3167 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3168 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3170 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3171 // getCurrentModel()->saveVtk(file_name)
3173 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3176 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3177 // getCurrentModel()->saveVtk(file_name);
3180 // print "...test make elements by transforming elements OK"
3182 // =============================================================== addDocInSudy
3183 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3187 if (document == NULL)
3190 QString docName = document->getName ();
3192 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3193 if (app_study == NULL)
3196 SALOMEDS::Study_var ds_study = getStudyServant();
3197 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3198 QString entry = app_study->centry("HEXABLOCK");
3199 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3200 if (aFatherSO->_is_nil())
3203 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3206 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3207 docEntry = aSO->GetID(); //the entry of the published object
3212 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3214 void HEXABLOCKGUI::test()
3216 DEBTRACE("HEXABLOCKGUI::test");
3217 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3218 if (currentDGView == NULL) return;
3219 currentDGView->update();
3223 void HEXABLOCKGUI::test_association()
3225 DEBTRACE("HEXABLOCKGUI::test_association");
3228 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3230 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3231 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3232 DocumentModel::GeomObj q0AssocA, q0AssocB;
3234 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3235 QList<DocumentModel::GeomObj> e1Assocs_test;
3236 DocumentModel::GeomObj q0Assoc_test;
3238 v0 = getCurrentModel()->addVertex(0, 0, 0);
3239 v1 = getCurrentModel()->addVertex(1, 0, 0);
3240 v2 = getCurrentModel()->addVertex(1, 1, 0);
3241 v3 = getCurrentModel()->addVertex(0, 1, 0);
3242 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3243 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3244 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3247 // >>> face3.GetEntry()'0:1:4'
3248 // >>> e1.GetEntry()'0:1:8'
3249 // >>> e2.GetEntry()'0:1:9'
3250 // >>> e3.GetEntry()'0:1:10'
3251 // >>> e4.GetEntry()'0:1:11'
3252 // >>> v1.GetEntry()'0:1:12'
3253 // >>> v2.GetEntry()'0:1:13'
3254 // >>> v3.GetEntry()'0:1:14'
3255 // >>> v4.GetEntry()'0:1:15'
3258 // v0Assoc.name = "geomV0";
3259 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3260 // v0Assoc.brep = "brepV0";
3261 // v1Assoc.name = "geomV1";
3262 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3263 // v1Assoc.brep = "brepV1";
3264 // v2Assoc.name = "geomV2";
3265 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3266 // v2Assoc.brep = "brepV2";
3267 // v3Assoc.name = "geomV3";
3268 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3269 // v3Assoc.brep = "brepV3";
3273 // e0AssocA.name = "geomE0a";
3274 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3275 // e0AssocA.brep = "brepE0a";
3276 // e0AssocA.start = 0.10;
3277 // e0AssocA.end = 0.95;
3281 // e1AssocA.name = "geomE1a";
3282 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3283 // e1AssocA.brep = "brepE1a";
3284 // e1AssocA.start = 0.12;
3285 // e1AssocA.end = 0.89;
3286 // e1AssocB.name = "geomE1b";
3287 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3288 // e1AssocB.brep = "brepE1b";
3289 // e1AssocB.start = 0.20;
3290 // e1AssocB.end = 0.80;
3291 // e1AssocC.name = "geomE1c";
3292 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3293 // e1AssocC.brep = "brepE1c";
3294 // e1AssocC.start = 0.16;
3295 // e1AssocC.end = 0.96;
3297 // q0AssocA.name = "geomQuad";
3298 // q0AssocA.entry = "0:1:1:1:3";
3299 // q0AssocA.brep = "brepq0";
3301 // q0AssocB.name = "geomQuad";
3302 // q0AssocB.entry = "0:1:1:1:4";
3303 // q0AssocB.brep = "brepq0";
3305 // getCurrentModel()->addAssociation( v0, v0Assoc );
3306 // getCurrentModel()->addAssociation( v1, v1Assoc );
3307 // getCurrentModel()->addAssociation( v2, v2Assoc );
3308 // getCurrentModel()->addAssociation( v3, v3Assoc );
3311 // getCurrentModel()->addAssociation( e0, e0AssocA );
3313 // getCurrentModel()->addAssociation( e1, e1AssocA );
3314 // getCurrentModel()->addAssociation( e1, e1AssocB );
3315 // getCurrentModel()->addAssociation( e1, e1AssocC );
3317 // getCurrentModel()->addAssociation( q0, q0AssocA );
3318 // getCurrentModel()->addAssociation( q0, q0AssocB );
3324 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3325 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3326 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3327 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3328 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3329 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3330 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3331 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3332 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3333 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3334 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3335 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3338 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3339 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3340 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3341 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3342 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3343 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3344 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3345 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3346 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3347 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3348 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3349 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3350 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3352 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3353 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3354 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3357 DEBTRACE("HEXABLOCKGUI::test_association fin");