1 // Copyright (C) 2009-2024 CEA, EDF
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" ),
145 // _dwObjectBrowser(0),
147 _patternDataTreeView(0),
148 // _patternBuilderTreeView(0),
149 _patternGeomTreeView(0),
152 // _treeViewDelegate(0),
154 moduleActivatedOnce(false),
164 _makeCylinderDiag(0),
166 _makeCylindersDiag(0),
174 _makeTransformationDiag(0),
175 _makeSymmetryDiag(0),
176 _performTransformationDiag(0),
177 _performSymmetryDiag(0),
186 _quadRevolutionDiag(0),
187 _makeHemiSphereDiag(0),
188 _modelInfoDiag(NULL),
190 _vertexInfoDialog(NULL),
191 _edgeInfoDialog(NULL),
192 _quadInfoDialog(NULL),
193 _hexaInfoDialog(NULL),
194 _vectorInfoDialog(NULL),
195 _groupInfoDialog(NULL),
196 _lawInfoDialog(NULL),
197 _propagationInfoDialog(NULL),
200 lastVtkDocGView(NULL)
202 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
204 graphicViewsHandler = new GraphicViewsHandler();
205 loadDocLastPath = new QDir();
206 saveDocLastPath = new QDir();
207 hexa_root = HEXA_NS::Hex::getInstance ();
210 HEXABLOCKGUI::~HEXABLOCKGUI()
215 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
217 SUIT_Application* app = SUIT_Session::session()->activeApplication();
219 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
225 // Gets an reference to the module's engine
226 /****************************************************
227 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
229 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
230 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
231 ASSERT(!CORBA::is_nil(clr));
234 **************************************************** */
236 void HEXABLOCKGUI::initialize( CAM_Application* app )
238 MESSAGE("HEXABLOCKGUI::initialize");
239 DEBTRACE("HEXABLOCKGUI::initialize");
240 SalomeApp_Module::initialize( app );
242 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
244 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
246 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
247 setResource(aResourceMgr);
249 createAndFillDockWidget();
255 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
257 DEBTRACE("HEXABLOCKGUI::viewManagers");
258 // list.append( QxScene_Viewer::Type() );
259 // list.append( OCCViewer_Viewer::Type() );
260 // list.append( SVTK_Viewer::Type() );
264 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
266 DEBTRACE("HEXABLOCKGUI::activateModule");
268 /*HexaBlock can be launched in only one application*/
269 if (myApplication == NULL)
270 //remember the first application
271 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
273 //application verification: if it's not the one known by HexaBlock,
274 //leave without activating
275 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
276 if (myApplication != currentApplication) return false;
278 bool bOk = SalomeApp_Module::activateModule( theStudy );
279 if ( !bOk ) return false;
281 showDockWidgets(true);
283 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
284 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
285 if ( getApp()->objectBrowser() ) {
286 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
287 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
290 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
292 SUIT_ViewManager* vm;
293 ViewManagerList OCCViewManagers, VTKViewManagers;
295 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
296 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
297 while ( itOCC.hasNext() && (vm = itOCC.next()) )
298 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
300 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
301 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
302 while ( itVTK.hasNext() && (vm = itVTK.next()) )
303 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
306 SALOME_ListIO selected;
307 sm->selectedObjects( selected );
310 // disable OCC selectors
311 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
312 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
313 while ( itOCCSel.hasNext() )
314 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
315 sr->setEnabled(true);
317 // disable VTK selectors
318 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
319 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
320 while ( itVTKSel.hasNext() )
321 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
322 sr->setEnabled(true);
324 sm->setSelectedObjects( selected, true ); //NPAL 19674
326 //connect close signal to vtk view manager
327 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
330 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
331 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
334 //connect close signal to occ view manager
335 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
338 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
339 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
342 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
343 currentOccGView->getViewWindow()->installEventFilter(this);
345 if (currentDocGView != NULL)
347 switchModel(currentDocGView);
350 if (currentDocGView->getViewWindow() != NULL)
351 currentDocGView->getViewWindow()->installEventFilter(this);
363 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
365 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
366 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
367 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
368 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
370 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
371 if ( vtkView != NULL)
373 //default selectionMode in VTKView
374 vtkView->SetSelectionMode( ActorSelection );
375 vtkView->removeEventFilter(this);
379 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
382 //defaut selectionMode in OccView
383 selectionMgr()->clearSelected();
384 currentOccGView->globalSelection();
385 occView->removeEventFilter(this);
389 qDeleteAll(myOCCSelectors);
390 myOCCSelectors.clear();
391 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
393 qDeleteAll(myVTKSelectors);
394 myVTKSelectors.clear();
395 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
397 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
399 //switch off current document graphic view
400 switchOffGraphicView(currentDocGView);
403 setMenuShown( false );
404 setToolShown( false );
405 showDockWidgets( false );
407 _dwInputPanel->close();
411 if(currentOccGView) {
412 delete currentOccGView;
413 currentOccGView = NULL;
416 if(currentDocGView) {
417 delete currentDocGView;
418 currentDocGView = NULL;
424 SALOMEDS::Study_var HEXABLOCKGUI::getStudyServant()
426 SALOME_NamingService_Abstract *aNamingService = SalomeApp_Application::namingService();
427 CORBA::Object_var aSMObject = aNamingService->Resolve("/Study");
428 SALOMEDS::Study_var aDSStudy = SALOMEDS::Study::_narrow(aSMObject);
429 return aDSStudy._retn();
432 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
433 QMap<QString, QString>& docShapesEntry,
434 QMap<QString, QString>& docShapesName)
436 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
437 return; //there's nothing to publish in this case
439 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
440 if(!appStudy) return;
441 SALOMEDS::Study_var aDSStudy = getStudyServant();
442 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
443 QString entry = currentDocGView->getDocumentModel()->documentEntry();
444 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
445 if (aFatherSO->_is_nil())
448 // * get a presentation
449 bool isNewPrs = false;
450 SOCC_Prs* prs = getOccPrs(currentDocGView);
453 prs = new SOCC_Prs(0);
457 // * init the presentation with the given shapes
458 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
459 while (i != topo_shapes.constEnd())
461 QString shapeName = i.key();
462 TopoDS_Shape shapeValue = i.value();
463 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
464 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
465 QString objStudyEntry = aSO->GetID(); //the entry of the published object
466 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
467 "HEXABLOCK", shapeName.toStdString().c_str());
468 ais_shape->SetOwner(io);
469 prs->AddObject(ais_shape);
470 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
471 docShapesEntry[shapeName] = objStudyEntry;
472 docShapesName[objStudyEntry] = shapeName;
473 currentOccGView->addShape(objStudyEntry, ais_shape);
474 i++; //handle next shape
478 prs->AddObject(currentOccGView->getPreviewShape());
480 occPrs[currentDocGView] = prs;
481 getApp()->updateObjectBrowser();
486 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
488 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
489 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
490 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
492 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
496 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
500 // Pas de renommage des shapes pour le moment, juste les documents
501 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
502 if (dgview == NULL || dgview->getDocumentModel() == NULL)
505 _PTR(SObject) obj ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(entry)) );
506 _PTR(GenericAttribute) anAttr;
508 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
509 _PTR(AttributeName) aName (anAttr);
510 DocumentModel* docModel = dgview->getDocumentModel();
511 docModel->setName( name );
512 aName->SetValue( name.toLatin1().data() );
513 getApp()->updateObjectBrowser();
514 // _dwPattern->setWindowTitle( name );
521 // --- Default windows
522 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
524 DEBTRACE("HEXABLOCKGUI::windows");
526 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
527 #ifndef DISABLE_PYCONSOLE
528 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
532 QString HEXABLOCKGUI::engineIOR() const
534 DEBTRACE("HEXABLOCKGUI::engineIOR");
536 /* ************************************ TODO Hexa6
537 CORBA::ORB_var anORB = getApp()->orb();
538 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
539 return QString( anIOR.in() );
540 ************************************ */
544 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
546 if (docs.count(studyObject->entry()) == 0)
548 //Object's document not acquired yet
549 VtkDocumentGraphicView* dgview;
550 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
551 if (directory == NULL)
552 return NULL; //No working director found
554 //------------------ Load the document -----------------
555 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
556 if (document == NULL)
557 return NULL; //No document found
559 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
561 MESSAGE("Doc model creation failed!");
564 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
565 if (dgview == NULL) return NULL;
567 //update the data tree
568 docs[studyObject->entry()] = dgview;
571 return docs[studyObject->entry()];
574 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
576 // ** we want to switch automatically to the right view windows
578 //first, find selected item
580 DataObjectList dol = getApp()->objectBrowser()->getSelected();
581 if (dol.isEmpty()) return;
582 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
583 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
584 item->entry().isEmpty())
587 // find the document corresponding to it
588 VtkDocumentGraphicView* docGView = NULL;
589 if (docs.contains(item->entry()))
590 docGView = docs[item->entry()];
592 docGView = getOrCreateDocument(item);
594 //Init OCC if necessary
595 if (currentOccGView == NULL)
597 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
598 currentOccGView->getViewWindow()->installEventFilter(this);
600 else if (currentOccGView->getViewWindow() == NULL)
602 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
603 currentOccGView->getViewWindow()->installEventFilter(this);
606 //Init the vtk view if necessary
607 if (docGView->getViewWindow() == NULL)
609 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
611 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
612 docGView->getViewWindow()->installEventFilter(this);
615 setAllMenusEnabled(true);
618 docGView->setViewWindow(currentDocGView->getViewWindow());
620 if (docGView->getDocumentActor() == NULL)
624 if (docGView == NULL || docGView == currentDocGView)
630 //update the current document
631 switchModel(docGView);
635 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
637 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
640 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
642 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
644 //Decharger le model correspondant (VTK)
645 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
649 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
650 { //HexaBlock Vtk Window has been closed
652 if (currentDialog != NULL) currentDialog->close();
653 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
654 if (currentDocGView != NULL)
655 currentDocGView->setViewWindow(NULL);
658 setAllMenusEnabled(false);
659 enableDocumentMenus(true);
665 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
666 if (dgview == NULL) return; //The window has no document to close
668 //Save the document? (Ask only if the document is not empty
669 int answerCode = SUIT_MessageBox::question(
672 tr("Save the document ?"),
673 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
674 SUIT_MessageBox::Cancel);
675 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
676 else if (answerCode == SUIT_MessageBox::Yes)
677 saveDocument(); //Save the document
679 // switchOffGraphicView(window); //disconnect all connected signals
680 // currentVtkView = NULL;
681 // graphicViewsHandler->closeDocumentGraphicView(window);
683 //create a new one (empty document)
685 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
689 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
691 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
692 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
693 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
694 if (currentDialog != NULL) currentDialog->close();
695 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
697 currentOccGView->getViewWindow()->removeEventFilter(this);
698 currentOccGView->setViewWindow(NULL);
702 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
704 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
706 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
707 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
709 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
711 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
712 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
713 // disable OCC selectors
714 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
715 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
716 while ( itOCCSel.hasNext() )
717 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
718 sr->setEnabled(true);
720 else if ( vm->getType() == SVTK_Viewer::Type() )
722 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
723 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
725 // disable VTK selectors
726 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
727 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
728 while ( itVTKSel.hasNext() )
729 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
730 sr->setEnabled(true);
734 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
736 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
738 SUIT_ViewModel* viewer = vm->getViewModel();
739 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
741 //VTK View Manager removed
742 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
744 //Process only if it's our view manager
745 SUIT_ViewManager* myVm = NULL;
746 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
747 myVm = currentDocGView->getViewWindow()->getViewManager();
751 //close opened dialog
752 if (currentDialog != NULL) currentDialog->close();
753 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
759 //remove its selector
760 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
761 while ( itVTKSel.hasNext() )
762 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
763 if ( sr->viewer() == viewer )
765 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
772 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
774 //OCC View removed: remove its selector
775 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
776 while ( itOCCSel.hasNext() )
777 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
778 if ( sr->viewer() == viewer )
780 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
786 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
788 QModelIndexList l = selected.indexes();
789 if ( l.count() == 0 ) return;
790 if ( !l[0].isValid() ) return;
791 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
792 if ( currentGraphicView == NULL) return;
794 QTreeView* theTree = NULL;
795 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
796 theTree = _patternDataTreeView;
798 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
799 theTree = _patternBuilderTreeView;
801 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
802 theTree = _patternGeomTreeView;
804 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
805 theTree = _groupsTreeView;
806 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
807 theTree = _meshTreeView;
810 theTree->scrollTo ( l[0] );
814 bool HEXABLOCKGUI::createSComponent() //addComponent
816 DEBTRACE("HEXABLOCKGUI::createSComponent");
817 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
819 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
820 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
821 _PTR(GenericAttribute) anAttr;
822 _PTR(AttributeName) aName;
823 _PTR(AttributeGraphic) aGraphic;
825 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
826 if ( !aComponent ){ //Create hexablock component if there's not one yet
827 aComponent = aBuilder->NewComponent("HEXABLOCK");
828 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
829 aName = _PTR(AttributeName) (anAttr);
830 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
832 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
833 _PTR(AttributePixMap) aPixmap(anAttr);
834 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
836 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
837 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
843 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
845 DEBTRACE("HEXABLOCKGUI::setResource");
846 _myresource = new HEXABLOCKGUI_Resource(r);
847 _myresource->preferencesChanged();
850 void HEXABLOCKGUI::createPreferences()
852 DEBTRACE("HEXABLOCKGUI::createPreferences");
853 _myresource->createPreferences(this);
856 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
858 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
859 _myresource->preferencesChanged(sect, name);
860 // if(name=="userCatalog")
861 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
864 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
866 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
868 // if nothing is selected, return
869 if (! currentIndex.isValid())
872 QVariant currentAssocVariant;
873 QString currentAssocEntry;
875 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
876 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
877 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
878 QMenu menu( _patternDataTreeView );
880 QAction *clearAct = menu.addAction( "Remove association(s)" );
881 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
882 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
886 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
887 if (currentVtkGraphicView == NULL) return;
888 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
890 //We don't do anything for single items
891 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
892 item->type() == QUADITEM || item->type() == HEXAITEM)
895 //No associations for HEXA
896 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
897 if ( !treeVariant.isValid() ) return;
898 int eltType = treeVariant.toInt();
899 if (eltType == HEXA_DIR_TREE) return;
900 QMenu menu( _patternDataTreeView );
902 //Show association(s)
903 QAction *showAssocAct = menu.addAction( "Show associations" );
904 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
906 //Clear all associations
907 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
908 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
910 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
915 void HEXABLOCKGUI::createAndFillDockWidget()
918 QMainWindow *aParent = application()->desktop();
920 // Create dock widget (3 dock)
922 //1) *********** user input panel ( contain user's edit dialog box )
923 _dwInputPanel = new QDockWidget(aParent);
924 _dwInputPanel->setVisible(false);
925 _dwInputPanel->setWindowTitle("Input Panel");
926 _dwInputPanel->setObjectName("hexablockInputPanelDock");
927 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
929 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
931 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
933 _dwPattern = new QDockWidget(aParent);
934 _dwPattern->setVisible(false);
935 _dwPattern->setWindowTitle("Model");
936 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
937 _dwPattern->setObjectName("hexablockModelDock");
939 QFrame* patternFrame = new QFrame(_dwPattern);
940 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
941 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
942 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
943 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
944 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
945 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
946 _patternGeomTreeView = new QTreeView(patternFrame);
947 splitter->addWidget(_patternDataTreeView);
948 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
949 splitter->addWidget(_patternGeomTreeView);
950 patternLayout->addWidget(splitter);
952 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
953 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
954 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
957 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
958 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
960 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
961 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
963 _dwPattern->setWidget(patternFrame);
964 patternFrame->show();
967 _dwGroups = new QDockWidget(aParent);
969 _dwGroups->setVisible(false);
970 _dwGroups->setWindowTitle("Groups");
971 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
972 _dwGroups->setObjectName("hexablockGroupsDock");
973 _groupsTreeView = new QTreeView(_dwGroups);
974 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
975 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
976 _dwGroups->setWidget(_groupsTreeView);
977 _groupsTreeView->show();
980 _dwMesh = new QDockWidget(aParent);
981 _dwMesh->setVisible(false);
982 _dwMesh->setWindowTitle("Mesh");
983 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
984 _dwMesh->setObjectName("hexablockMeshDock");
985 _meshTreeView = new QTreeView(_dwMesh);
986 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
987 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
988 // _meshTreeView->setItemDelegate(_treeViewDelegate);
989 _dwMesh->setWidget(_meshTreeView);
990 _meshTreeView->show();
992 // QDockWidget *_dwObjectBrowser = 0;
994 if ( getApp()->objectBrowser() )
995 wid = getApp()->objectBrowser()->treeView();
996 while ( wid && !_dwObjectBrowser ) {
997 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( wid );
998 wid = wid->parentWidget();
1001 if ( _dwObjectBrowser ) {
1002 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1003 _dwObjectBrowser->setWindowTitle("Study");
1006 // dock widget position
1007 if ( _dwObjectBrowser ) {
1008 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1010 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1012 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1013 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1014 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1016 if ( _dwObjectBrowser ) {
1017 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1019 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1020 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1021 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1023 // popup menu on data tree view
1024 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1025 connect(_patternDataTreeView,
1026 SIGNAL(customContextMenuRequested(const QPoint &)),
1028 SLOT(treeContextMenu(const QPoint &)),
1029 Qt::UniqueConnection );
1032 void HEXABLOCKGUI::createActions()
1034 QMainWindow *aParent = application()->desktop();
1035 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1038 _newAct = createAction(_menuId++,
1039 tr("Create a new document"),
1040 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1042 tr("Create a new document"),
1043 0, aParent, false, this, SLOT(newDocument()));
1044 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1046 _importAct = createAction(_menuId++,
1047 tr("Load a document"),
1048 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1049 tr("Load Document"),
1050 tr("Load a document"),
1051 0, aParent, false, this, SLOT(loadDocument()));
1052 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1054 _saveAct = createAction(_menuId++,
1055 tr("Save the document"),
1056 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1057 tr("Save Document"),
1058 tr("Save the document"),
1059 0, aParent, false, this, SLOT(saveDocument()));
1061 // Pattern Data creation
1062 _addVertex = createAction(_menuId++,
1063 tr("Create a vertex"),
1064 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1066 tr("Create a new vertex"),
1067 0, aParent, false, this, SLOT(addVertex()));
1069 _addEdge = createAction(_menuId++,
1070 tr("Create an edge"),
1071 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1073 tr("Create a new edge"),
1074 0, aParent, false, this, SLOT(addEdge()));
1076 _addQuad = createAction(_menuId++,
1077 tr("Create a quadrangle"),
1078 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1079 tr("Add Quadrangle"),
1080 tr("Create a new quadrangle"),
1081 0, aParent, false, this, SLOT(addQuad()));
1083 _addHexa = createAction(_menuId++,
1084 tr("Create an hexahedron"),
1085 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1086 tr("Add Hexahedron"),
1087 tr("Create a new hexahedron"),
1088 0, aParent, false, this, SLOT(addHexa()));
1090 // Builder Data creation
1091 _addVector = createAction(_menuId++,
1092 tr("Create a vector"),
1093 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1095 tr("Create a new vector"),
1096 0, aParent, false, this, SLOT(addVector()));
1098 // _addCylinder = createAction(_menuId++,
1099 // tr("Create a cylinder"),
1100 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1101 // tr("Add Cylinder"),
1102 // tr("Create a new cylinder"),
1103 // 0, aParent, false, this, SLOT(addCylinder()));
1105 // _addPipe = createAction(_menuId++,
1106 // tr("Create a pipe"),
1107 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1109 // tr("Create a new pipe"),
1110 // 0, aParent, false, this, SLOT(addPipe()));
1112 _makeGrid = createAction(_menuId++,
1114 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1117 0, aParent, false, this, SLOT(makeGrid()));
1119 _makeCylinder = createAction(_menuId++,
1120 tr("Make a cylinder"),
1121 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1122 tr("Make Cylinder"),
1123 tr("Make a cylinder"),
1124 0, aParent, false, this, SLOT(makeCylinder()));
1126 _makePipe = createAction(_menuId++,
1128 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1131 0, aParent, false, this, SLOT(makePipe()));
1133 _makeCylinders = createAction(_menuId++,
1134 tr("Make cylinders"),
1135 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1136 tr("Make Cylinders"),
1137 tr("Make cylinders"),
1138 0, aParent, false, this, SLOT(makeCylinders()));
1140 _makePipes = createAction(_menuId++,
1142 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1145 0, aParent, false, this, SLOT(makePipes()));
1147 _makeHemiSphere = createAction(_menuId++,
1148 tr("Make an hemisphere"),
1149 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1150 tr("Make Hemisphere"),
1151 tr("Make an hemisphere"),
1152 0, aParent, false, this, SLOT(makeHemiSphere()));
1154 // Pattern Data edition
1155 _removeHexa = createAction(_menuId++,
1156 tr("Remove hexahedra"),
1157 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1158 tr("Remove Hexahedra"),
1159 tr("Remove hexahedra"),
1160 0, aParent, false, this, SLOT(removeHexa()));
1162 _prismQuad = createAction(_menuId++,
1163 tr("Prism quadrangles"),
1164 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1165 tr("Prism Quadrangles"),
1166 tr("Prism quadrangles"),
1167 0, aParent, false, this, SLOT(prismQuad()));
1169 _joinQuad = createAction(_menuId++,
1170 tr("Join quadrangles"),
1171 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1172 tr("Join Quadrangles"),
1173 tr("Join quadrangles with hexahedra"),
1174 0, aParent, false, this, SLOT(joinQuad()));
1176 _merge = createAction(_menuId++,
1178 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1181 0, aParent, false, this, SLOT(merge()));
1183 _disconnect = createAction(_menuId++,
1185 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1187 tr("Disconnect edges, vertexes or quadrangles"),
1188 0, aParent, false, this, SLOT(disconnectElts()));
1190 _cutEdge = createAction(_menuId++,
1192 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1195 0, aParent, false, this, SLOT(cutEdge()));
1197 _makeTransformation = createAction(_menuId++,
1198 tr("Make transformation"),
1199 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1200 tr("Make Transformation"),
1201 tr("Make transformation"),
1202 0, aParent, false, this, SLOT(makeTransformation()));
1204 _makeSymmetry = createAction(_menuId++,
1205 tr("Make symmetry"),
1206 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1207 tr("Make Symmetry"),
1208 tr("Make symmetry"),
1209 0, aParent, false, this, SLOT(makeSymmetry()));
1211 _performTransformation = createAction(_menuId++,
1212 tr("Perform transformation"),
1213 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1214 tr("Perform Transformation"),
1215 tr("Perform transformation"),
1216 0, aParent, false, this, SLOT(performTransformation()));
1218 _performSymmetry = createAction(_menuId++,
1219 tr("Perform symmetry"),
1220 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1221 tr("Perform Symmetry"),
1222 tr("Perform symmetry"),
1223 0, aParent, false, this, SLOT(performSymmetry()));
1225 _replaceHexa = createAction(_menuId++,
1226 tr("Replace hexahedron"),
1227 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1228 tr("Replace Hexahedron"),
1229 tr("Replace hexahedron"),
1230 0, aParent, false, this, SLOT(replaceHexa()));
1232 _quadRevolution = createAction(_menuId++,
1233 tr("Quad revolution"),
1234 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1235 tr("Quad Revolution"),
1236 tr("Quad revolution"),
1237 0, aParent, false, this, SLOT(quadRevolution()));
1240 _assocVertex = createAction(_menuId++,
1241 tr("Make vertex association"),
1242 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1243 tr("Make Vertex association"),
1244 tr("Make vertex association"),
1245 0, aParent, false, this, SLOT(assocVertex()));
1247 _assocEdge = createAction(_menuId++,
1248 tr("Make edge association"),
1249 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1250 tr("Make Edge Association"),
1251 tr("Make edge association"),
1252 0, aParent, false, this, SLOT(assocEdge()));
1254 _assocQuad = createAction(_menuId++,
1255 tr("Make quad association"),
1256 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1257 tr("Make Quad Association"),
1258 tr("Make quad association"),
1259 0, aParent, false, this, SLOT(assocQuad()));
1262 _addGroup = createAction(_menuId++,
1264 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1267 0, aParent, false, this, SLOT(addGroup()));
1269 _removeGroup = createAction(_menuId++,
1270 tr("Remove a group"),
1271 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1273 tr("Remove a group"),
1274 0, aParent, false, this, SLOT(removeGroup()));
1277 _addLaw = createAction(_menuId++,
1279 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1282 0, aParent, false, this, SLOT(addLaw()));
1284 _removeLaw = createAction(_menuId++,
1286 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1289 0, aParent, false, this, SLOT(removeLaw()));
1291 _setPropagation = createAction(_menuId++,
1292 tr("Set propagation"),
1293 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1294 tr("Set Propagation"),
1295 tr("Set propagation"),
1296 0, aParent, false, this, SLOT(setPropagation()));
1298 _computeMesh = createAction(_menuId++,
1300 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1303 0, aParent, false, this, SLOT(computeMesh()));
1305 _showModelInfoAct = createAction(_menuId++,
1306 tr("Show Model Info"),
1307 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1310 0, aParent, false, this, SLOT(showModelInfo()));
1312 _addShapeAct = createAction(_menuId++,
1314 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1317 0, aParent, false, this, SLOT(addShape()));
1319 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1320 // QAction* createAction(const int id,
1321 // const QString& toolTip,
1322 // const QIcon& icon,
1323 // const QString& menu,
1324 // const QString& status,
1325 // const int shortCut,
1326 // QObject* parent =0,
1327 // bool checkable = false,
1328 // QObject* receiver =0,
1329 // const char* member =0);
1331 _sep1 = separator();
1332 _sep2 = separator();
1333 _sep3 = separator();
1334 _sep4 = separator();
1338 void HEXABLOCKGUI::createMenus()
1340 int aMenuId, subMenuId,aMenuIdMain;
1342 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1344 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1345 createMenu( actionId(_newAct), aMenuId );
1346 createMenu( actionId(_importAct), aMenuId );
1347 createMenu( _saveAct, aMenuId );
1350 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1351 createMenu( _newAct, aMenuDocId );//, 10
1352 createMenu( _importAct, aMenuDocId );
1353 createMenu( _saveAct, aMenuDocId );
1355 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1356 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1357 createMenu( _addVertex, subMenuId );
1358 createMenu( _addEdge, subMenuId );
1359 createMenu( _addQuad, subMenuId );
1360 createMenu( _addHexa, subMenuId );
1361 createMenu( _sep1, subMenuId);
1364 createMenu( _addVector, subMenuId );
1365 // createMenu( _addCylinder, subMenuId );
1366 // createMenu( _addPipe, subMenuId );
1368 createMenu( _sep2, subMenuId);
1370 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1371 createMenu( _makeHemiSphere,subMenuId );
1373 createMenu( _sep3, subMenuId);
1375 createMenu( _makeCylinder, subMenuId );
1376 createMenu( _makePipe, subMenuId );
1377 createMenu( _makeCylinders,subMenuId );
1378 createMenu( _makePipes, subMenuId );
1380 // Pattern Data Edition
1381 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1382 createMenu( _removeHexa, subMenuId );
1383 createMenu( _prismQuad, subMenuId );
1384 createMenu( _joinQuad, subMenuId );
1385 createMenu( _merge, subMenuId );
1386 createMenu( _disconnect, subMenuId );
1387 createMenu( _cutEdge, subMenuId );
1388 createMenu( _makeTransformation, subMenuId );
1389 createMenu( _makeSymmetry, subMenuId );
1390 createMenu( _performTransformation, subMenuId );
1391 createMenu( _performSymmetry, subMenuId );
1392 createMenu( _replaceHexa, subMenuId );
1393 createMenu( _quadRevolution, subMenuId );
1394 createMenu( _sep4, aMenuId );
1395 createMenu( _showModelInfoAct, aMenuId );
1398 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1399 createMenu( _addShapeAct, aMenuId );
1400 createMenu( _assocVertex, aMenuId );
1401 createMenu( _assocEdge, aMenuId );
1402 createMenu( _assocQuad, aMenuId );
1405 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1406 createMenu( _addGroup, aMenuId );
1407 createMenu( _removeGroup, aMenuId ); //CS_TODO
1410 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1411 createMenu( _addLaw, aMenuId );
1412 createMenu( _removeLaw, aMenuId );
1413 createMenu( _setPropagation, aMenuId );
1414 createMenu( _computeMesh, aMenuId );
1416 //show model infomation menu
1417 QString aRule = "$component={'HEXABLOCK'}";
1418 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1419 popupMgr()->setRule( _showModelInfoAct, aRule);
1421 //associate shape to a document menu
1422 popupMgr()->insert( _addShapeAct, -1, -1 );
1423 popupMgr()->setRule( _addShapeAct, aRule );
1425 //-------------------------------------------------
1427 //-------------------------------------------------
1428 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1429 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1430 // QString isNotEmpty("numberOfNodes <> 0");
1431 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1432 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1433 //// aType = aType.arg( mesh_part );
1435 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1436 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1437 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1439 // popupMgr()->insert( separator(), -1, -1 );
1440 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1441 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1442 // // MESSAGE("aClient = " << aClient.toStdString());
1443 // // MESSAGE("aType = " << aType.toStdString());
1444 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1445 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1446 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1447 // // MESSAGE("aRule = " << aRule.toStdString());
1448 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1449 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1451 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1452 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1454 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1455 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1457 // popupMgr()->insert( separator(), -1, -1 );
1461 void HEXABLOCKGUI::createTools()
1465 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1466 createTool( _newAct, aToolId );
1467 createTool( _importAct, aToolId );
1468 createTool( _saveAct, aToolId );
1469 createTool( _showModelInfoAct, aToolId );
1470 // createTool( _testAct, aToolId );
1471 //createTool( separator(), aToolId );
1474 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1475 createTool( _addVertex, aToolId );
1476 createTool( _addEdge, aToolId );
1477 createTool( _addQuad, aToolId );
1478 createTool( _addHexa, aToolId );
1480 createTool( _sep1, aToolId );
1483 createTool( _addVector, aToolId );
1484 // createTool( _addCylinder, aToolId );
1485 // createTool( _addPipe, aToolId );
1487 createTool( _sep2, aToolId );
1489 createTool( _makeGrid, aToolId );
1490 createTool( _makeHemiSphere, aToolId );
1492 createTool( _sep3, aToolId );
1494 createTool( _makeCylinder, aToolId );
1495 createTool( _makePipe, aToolId );
1496 createTool( _makeCylinders,aToolId );
1497 createTool( _makePipes, aToolId );
1499 // Pattern Data Edition
1500 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1501 createTool( _removeHexa, aToolId );
1502 createTool( _prismQuad, aToolId );
1503 createTool( _joinQuad, aToolId );
1504 createTool( _merge, aToolId );
1505 createTool( _disconnect, aToolId );
1506 createTool( _cutEdge, aToolId );
1507 createTool( _makeTransformation, aToolId );
1508 createTool( _makeSymmetry, aToolId );
1509 createTool( _performTransformation, aToolId );
1510 createTool( _performSymmetry, aToolId );
1511 createTool( _replaceHexa, aToolId );
1512 createTool( _quadRevolution, aToolId );
1515 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1516 createTool( _assocVertex, aToolId );
1517 createTool( _assocEdge, aToolId );
1518 createTool( _assocQuad, aToolId );
1519 createTool( _addShapeAct, aToolId );
1522 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1523 createTool( _addGroup, aToolId );
1524 createTool( _removeGroup, aToolId ); //CS_TODO
1527 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1528 createTool( _addLaw, aToolId );
1529 createTool( _removeLaw, aToolId );
1530 createTool( _setPropagation, aToolId );
1531 createTool( _computeMesh, aToolId );
1535 void HEXABLOCKGUI::initialMenus()
1537 showDocumentMenus( true );
1538 showPatternMenus( false );
1539 showAssociationMenus( false );
1540 showGroupsMenus( false );
1541 showMeshMenus( false );
1544 void HEXABLOCKGUI::showAllMenus()
1546 showDocumentMenus( true );
1547 showPatternMenus( true );
1548 showAssociationMenus( true );
1549 showGroupsMenus( true );
1550 showMeshMenus( true );
1553 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1555 enableDocumentMenus( enable );
1556 enablePatternMenus( enable );
1557 enableAssociationMenus( enable );
1558 enableGroupsMenus( enable );
1559 enableMeshMenus( enable );
1561 menusEnabled = enable;
1564 void HEXABLOCKGUI::showDocumentMenus(bool show)
1566 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1568 setMenuShown(_newAct, show);
1569 setToolShown(_newAct, show);
1570 setMenuShown(_importAct, show);
1571 setToolShown(_importAct, show);
1572 setMenuShown(_showModelInfoAct, show);
1573 setToolShown(_showModelInfoAct, show);
1574 setMenuShown(_saveAct, show);
1575 setToolShown(_saveAct, show);
1578 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1580 _newAct->setEnabled(enable);
1581 // setToolShown(_newAct, enable);
1583 _importAct->setEnabled(enable);
1584 // setToolShown(_importAct, enable);
1586 _showModelInfoAct->setEnabled(enable);
1587 // setToolShown(_showModelInfoAct, enable);
1589 _saveAct->setEnabled(enable);
1590 // setToolShown(_saveAct, enable);
1594 void HEXABLOCKGUI::showPatternMenus(bool show)
1596 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1597 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1598 if ( show && !getCurrentModel() ) return;
1600 setMenuShown(_addVertex, show );
1601 setToolShown(_addVertex, show);
1602 setMenuShown(_addEdge, show );
1603 setToolShown(_addEdge, show);
1604 setMenuShown(_addQuad, show );
1605 setToolShown(_addQuad, show);
1606 setMenuShown(_addHexa, show );
1607 setToolShown(_addHexa, show);
1609 setMenuShown(_sep1, show );
1610 setToolShown(_sep1, show);
1612 setMenuShown( _addVector, show );
1613 setToolShown( _addVector, show);
1614 // setMenuShown( _addCylinder, show );
1615 // setToolShown( _addCylinder, show);
1616 // setMenuShown( _addPipe, show );
1617 // setToolShown( _addPipe, show);
1619 setMenuShown(_sep2, show );
1620 setToolShown(_sep2, show);
1622 setMenuShown( _makeGrid, show );
1623 setToolShown( _makeGrid, show);
1624 setMenuShown( _makePipe, show );
1625 setToolShown( _makePipe, show);
1627 setMenuShown(_sep3, show );
1628 setToolShown(_sep3, show);
1630 setMenuShown( _makeCylinder, show );
1631 setToolShown( _makeCylinder, show);
1632 setMenuShown( _makeCylinders, show );
1633 setToolShown( _makeCylinders, show);
1634 setMenuShown( _makePipes, show );
1635 setToolShown( _makePipes, show);
1636 setMenuShown( _makeHemiSphere, show );
1637 setToolShown( _makeHemiSphere, show);
1639 // Pattern Data Edition
1640 setMenuShown( _removeHexa, show );
1641 setToolShown( _removeHexa, show);
1642 setMenuShown( _prismQuad, show );
1643 setToolShown( _prismQuad, show);
1644 setMenuShown( _joinQuad, show );
1645 setToolShown( _joinQuad, show);
1646 setMenuShown( _merge, show );
1647 setToolShown( _merge, show);
1648 setMenuShown( _disconnect, show );
1649 setToolShown( _disconnect, show);
1650 setMenuShown( _cutEdge, show );
1651 setToolShown( _cutEdge, show);
1652 setMenuShown( _makeTransformation, show );
1653 setToolShown( _makeTransformation, show);
1654 setMenuShown( _makeSymmetry, show );
1655 setToolShown( _makeSymmetry, show);
1656 setMenuShown( _performTransformation, show );
1657 setToolShown( _performTransformation, show);
1658 setMenuShown( _performSymmetry, show );
1659 setToolShown( _performSymmetry, show);
1660 setMenuShown( _replaceHexa, show );
1661 setToolShown( _replaceHexa, show);
1662 setMenuShown( _quadRevolution, show );
1663 setToolShown( _quadRevolution, show);
1665 setMenuShown( _sep4, show );
1666 setMenuShown( _showModelInfoAct, show );
1669 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1671 if ( enable && !getCurrentModel() ) return;
1673 _addVertex->setEnabled(enable);
1674 // setToolShown(_addVertex, enable);
1676 _addEdge->setEnabled(enable);
1677 // setToolShown(_addEdge, enable);
1679 _addQuad->setEnabled(enable);
1680 // setToolShown(_addQuad, enable);
1682 _addHexa->setEnabled(enable);
1683 // setToolShown(_addHexa, enable);
1685 // setMenuShown(_sep1, enable );
1686 // setToolShown(_sep1, enable);
1688 _addVector->setEnabled(enable);
1689 // setToolShown( _addVector, enable);
1691 // setMenuShown(_sep2, enable );
1692 // setToolShown(_sep2, enable);
1694 _makeGrid->setEnabled(enable);
1695 // setToolShown( _makeGrid, enable);
1697 _makePipe->setEnabled(enable);
1698 // setToolShown( _makePipe, enable);
1700 // setMenuShown(_sep3, enable );
1701 // setToolShown(_sep3, enable);
1703 _makeCylinder->setEnabled(enable);
1704 // setToolShown( _makeCylinder, enable);
1706 _makeCylinders->setEnabled(enable);
1707 // setToolShown( _makeCylinders, enable);
1709 _makePipes->setEnabled(enable);
1710 // setToolShown( _makePipes, enable);
1712 _makeHemiSphere->setEnabled(enable);
1713 // setToolShown( _makeHemiSphere, enable);
1715 // Pattern Data Edition
1716 _removeHexa->setEnabled(enable);
1717 // setToolShown( _removeHexa, enable);
1719 _prismQuad->setEnabled(enable);
1720 // setToolShown( _prismQuad, enable);
1722 _joinQuad->setEnabled(enable);
1723 // setToolShown( _joinQuad, enable);
1725 _merge->setEnabled(enable);
1726 // setToolShown( _merge, enable);
1728 _disconnect->setEnabled(enable);
1729 // setToolShown( _disconnect, enable);
1731 _cutEdge->setEnabled(enable);
1732 // setToolShown( _cutEdge, enable);
1734 _makeTransformation->setEnabled(enable);
1735 // setToolShown( _makeTransformation, enable);
1737 _makeSymmetry->setEnabled(enable);
1738 // setToolShown( _makeSymmetry, enable);
1740 _performTransformation->setEnabled(enable);
1741 // setToolShown( _performTransformation, enable);
1743 _performSymmetry->setEnabled(enable);
1744 // setToolShown( _performSymmetry, enable);
1746 _replaceHexa->setEnabled(enable);
1747 // setToolShown( _replaceHexa, enable);
1749 _quadRevolution->setEnabled(enable);
1750 // setToolShown( _quadRevolution, enable);
1752 // setMenuShown( _sep4, enable );
1753 _showModelInfoAct->setEnabled(enable);
1757 void HEXABLOCKGUI::showAssociationMenus(bool show)
1759 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1760 if ( show && !getCurrentModel() ) return;
1762 // Association Edition
1763 setMenuShown( _assocVertex, show );
1764 setToolShown( _assocVertex, show );
1766 setMenuShown( _assocEdge, show );
1767 setToolShown( _assocEdge, show );
1769 setMenuShown( _assocQuad, show );
1770 setToolShown( _assocQuad, show );
1772 setMenuShown( _addShapeAct, show );
1773 setToolShown( _addShapeAct, show );
1776 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1778 if ( enable && !getCurrentModel() )
1781 // Association Edition
1782 _assocVertex->setEnabled(enable);
1783 // setToolShown( _assocVertex, enable );
1785 _assocEdge->setEnabled(enable);
1786 // setToolShown( _assocEdge, enable );
1788 _assocQuad->setEnabled(enable);
1789 // setToolShown( _assocQuad, enable );
1791 _addShapeAct->setEnabled(enable);
1792 // setToolShown( _addShapeAct, enable );
1795 void HEXABLOCKGUI::showGroupsMenus(bool show)
1797 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1798 if ( show && !getCurrentModel() ) return;
1799 setMenuShown( _addGroup, show );
1800 setToolShown( _addGroup, show);
1801 setMenuShown( _removeGroup , show );
1802 setToolShown( _removeGroup , show);
1805 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1807 if ( enable && !getCurrentModel() )
1810 _addGroup->setEnabled(enable);
1811 // setToolShown( _addGroup, enable);
1813 _removeGroup->setEnabled(enable);
1814 // setToolShown( _removeGroup , enable);
1817 void HEXABLOCKGUI::showMeshMenus(bool show)
1819 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1820 if ( show && !getCurrentModel() ) return;
1821 setMenuShown( _addLaw, show );
1822 setToolShown( _addLaw, show);
1823 setMenuShown( _removeLaw, show );
1824 setToolShown( _removeLaw, show);;
1825 setMenuShown( _setPropagation, show );
1826 setToolShown( _setPropagation, show);
1827 setMenuShown( _computeMesh, show);
1828 setToolShown( _computeMesh, show);
1831 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1833 if ( enable && !getCurrentModel() )
1836 _addLaw->setEnabled(enable);
1837 // setToolShown( _addLaw, enable);
1839 _removeLaw->setEnabled(enable);
1840 // setToolShown( _removeLaw, enable);
1842 _setPropagation->setEnabled(enable);
1843 // setToolShown( _setPropagation, enable);
1845 _computeMesh->setEnabled(enable);
1846 // setToolShown( _computeMesh, enable);
1849 void HEXABLOCKGUI::showVtkActor()
1851 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1852 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1853 currentVtkGView->getDocumentActor() == NULL)
1856 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1857 if (vtkView == NULL)
1860 SUIT_ViewManager* vman = vtkView->getViewManager();
1861 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1863 //show only the current actor -----------------
1864 vtkView->setFocus();
1865 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1866 Document_Actor *lastDocActor;
1867 if (lastVtkDocGView != NULL)
1869 lastDocActor = lastVtkDocGView->getDocumentActor();
1870 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1871 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1873 vtkView->Erase(lastActorIO);
1874 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1875 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1878 currentVtkGView->update();
1879 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1880 if (!anIO.IsNull() && anIO->hasEntry())
1882 vtkView->Display(anIO);
1883 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1884 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1886 vtkView->onFitAll();
1889 void HEXABLOCKGUI::showOccActor()
1891 if (currentOccGView == NULL)
1893 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1894 if (occView == NULL)
1896 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1900 if (lastOccPrs != NULL)
1901 vf->Erase(lastOccPrs);
1902 currentOccGView->globalSelection();
1903 SOCC_Prs* prs = getOccPrs(currentDocGView);
1904 currentOccGView->setPrs(prs);
1907 occView->onFitAll();
1910 void HEXABLOCKGUI::hideVtkActor()
1912 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1913 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1914 currentVtkGView->getViewWindow() == NULL ||
1915 currentVtkGView->getDocumentActor() == NULL) return;
1917 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1918 currentVtkGView->getViewWindow()->onResetView();
1920 //update the visibility state now
1921 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1922 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1923 if (aStudy == NULL || vman == NULL) return;
1925 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1926 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1927 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1930 void HEXABLOCKGUI::hideOccActor()
1932 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1933 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1934 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1935 if (occView == NULL || docModel == NULL)
1937 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1941 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1942 if (currentOccPrs != NULL)
1943 vf->Erase(currentOccPrs);
1945 occView->onResetView();
1948 void HEXABLOCKGUI::showOnlyActor()
1954 void HEXABLOCKGUI::hideActor()
1961 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1963 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1965 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1967 if (_dwPattern) _dwPattern->setVisible(isVisible);
1968 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1970 if (_dwMesh) _dwMesh->setVisible(isVisible);
1971 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1973 if (_dwGroups) _dwGroups->setVisible(isVisible);
1974 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1978 //clear all used dialogs by the current model
1979 void HEXABLOCKGUI::clearDialogs()
1981 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1982 fin (currentModelDialogs.end());
1983 for(;debut!=fin;++debut) (*debut)->clear();
1985 currentModelDialogs.clear(); //empty the used dialogs list
1988 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1990 if (!gViewDlgBox.contains(dgview)) return NULL;
1991 return gViewDlgBox[dgview];
1994 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1996 if (dgview == NULL) return;
1998 switchOffGraphicView(dgview, false); //to avoid double connect
2001 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2002 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
2003 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2004 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2005 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2006 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2007 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2008 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2009 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2010 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2011 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2012 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2017 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
2019 if (dgview == NULL) return;
2021 //disconnect signals
2022 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2023 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2024 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2025 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2026 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2027 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2028 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2029 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2030 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2031 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2032 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2033 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2036 gViewDlgBox[dgview] = currentDialog;
2038 //close opened dialog
2039 if (currentDialog != NULL) currentDialog->close();
2040 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2046 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2048 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2052 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2056 //switch off the current document graphic view (disconnect signals...)
2057 if (currentDocGView != NULL)
2059 //Hide current actor
2061 switchOffGraphicView(currentDocGView);
2064 //clear the dialogs used by the current model so they can be used by the new model
2065 if (currentDocGView != dgview) clearDialogs();
2067 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2068 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2069 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2070 _groupsTreeView->setModel(dgview->getGroupsModel());
2071 _meshTreeView->setModel(dgview->getMeshModel());
2073 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2074 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2076 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2077 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2079 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2080 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2082 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2083 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2085 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2086 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2089 // = * init occ view * =
2090 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2092 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2093 currentOccGView->getViewWindow()->installEventFilter(this);
2098 // = * init vtk view * =
2099 if (currentDocGView != NULL)
2101 if (currentDocGView->getViewWindow() != NULL)
2102 dgview->setViewWindow(currentDocGView->getViewWindow());
2105 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2106 dgview->getViewWindow()->installEventFilter(this);
2112 switchOnGraphicView(dgview);
2114 if (currentDocGView != NULL)
2116 lastVtkDocGView = currentDocGView;
2117 lastOccPrs = getOccPrs(currentDocGView);
2121 lastVtkDocGView = dgview;
2122 lastOccPrs = getOccPrs(dgview);
2125 currentDocGView = dgview;
2127 currentDocGView->getDocumentModel()->refresh();
2128 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2131 setAllMenusEnabled(true);
2134 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2136 if (currentDocGView == NULL) return NULL;
2137 return currentDocGView->getDocumentModel();
2141 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2143 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2144 if (anApp == NULL) return UNKNOWN;
2145 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2146 if (activeVm == NULL) return UNKNOWN;
2148 QString vmType = activeVm->getType();
2149 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2151 else if ( vmType == OCCViewer_Viewer::Type() )
2157 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2159 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2163 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2166 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2168 // Create Document from HEXABLOCK ENGINE
2169 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2170 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2172 // looking doc impl ( c++ )
2173 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2174 // ^Hexa6 ASSERT( dServant );
2175 // ^Hexa6 if ( dServant)
2176 // ^Hexa6 doc = dServant->GetImpl();
2178 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2179 QString docEntry = addDocInStudy (doc);
2181 // looking for docEntry
2182 /* ****************************************************************
2183 if ( !CORBA::is_nil(docIn) ){
2184 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2185 QString docIOR = anIOR.in();
2186 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2187 if ( !docIOR.isEmpty() ) {
2188 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2190 docEntry = SO->GetID().c_str();
2193 **************************************************************** */
2194 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2196 return make_pair (docEntry, doc);
2200 void HEXABLOCKGUI::newDocument()
2202 DEBTRACE("HEXABLOCKGUI::newDocument");
2205 QMainWindow *aParent = application()->desktop();
2206 QWidget *central = aParent->centralWidget();
2208 central->setFocus();
2210 DEBTRACE("No Central Widget");
2213 if (currentOccGView == NULL)
2215 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2216 application()->desktop());
2217 currentOccGView->getViewWindow()->installEventFilter(this);
2219 else if (currentOccGView->getViewWindow() == NULL)
2221 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2222 currentOccGView->getViewWindow()->installEventFilter(this);
2226 // Create Document from HEXABLOCK ENGINE
2227 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2229 VtkDocumentGraphicView* newGraphicView = NULL;
2230 //One document at a time
2231 if (currentDocGView != NULL)
2233 if (currentDocGView->getViewWindow() == NULL)
2235 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2236 currentDocGView->getViewWindow()->installEventFilter(this);
2239 // Create a new document with the current window
2240 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2241 new DocumentModel( docEntry_Doc.second,
2242 docEntry_Doc.first, this ),
2243 currentDocGView->getViewWindow(),
2244 application()->desktop() );
2248 // Create the new Document Graphic View with a new window
2249 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2250 new DocumentModel( docEntry_Doc.second,
2251 docEntry_Doc.first, this ),
2252 graphicViewsHandler->createVtkWindow(),
2253 application()->desktop() );
2254 newGraphicView->getViewWindow()->installEventFilter(this);
2257 if (newGraphicView == NULL)
2258 //We couldn't create a new document graphic view
2259 //we'd better show a dialog box info to inform the user
2262 docs[docEntry_Doc.first] = newGraphicView;
2263 switchModel(newGraphicView); //select the corresponding document in the browser instead
2265 getApp()->updateObjectBrowser();
2270 //Loads the model from the xmlFile in the current graphic view
2271 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2273 DEBTRACE("HEXABLOCKGUI::loadDocument");
2276 QMainWindow *aParent = application()->desktop();
2277 QString selectedFile;
2279 if ( inFile.isNull() ){
2280 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2281 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2282 dialog.setHistory( getQuickDirList() );
2284 //use the last path as default
2285 if (!(loadDocLastPath->absolutePath()).isEmpty())
2286 dialog.setDirectory(*loadDocLastPath);
2289 QStringList selectedFiles = dialog.selectedFiles();
2290 if (!selectedFiles.isEmpty())
2291 selectedFile = selectedFiles.first();
2293 //remember the selected path
2294 *loadDocLastPath = dialog.directory();
2297 selectedFile = inFile;
2299 if (selectedFile.isEmpty())
2302 //we create a new document if necessary
2303 if (currentDocGView == NULL)
2304 //Need a new document
2306 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2308 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2309 currentDocGView->getViewWindow()->installEventFilter(this);
2312 if (!currentDocGView->isEmpty())
2313 //we can only have one document for a graphic view
2316 //we load the selected file in the current graphic view
2317 currentDocGView->loadDocument(selectedFile);
2318 DocumentModel* currentModel = getCurrentModel();
2319 renameObject( currentModel->documentEntry(), currentModel->getName() );
2324 void HEXABLOCKGUI::saveDocument()
2326 QMainWindow *aParent = application()->desktop();
2328 QString aDocName = "document", aFilename;
2330 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2331 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2333 //use the last selected directory as default path for file selection
2334 aFilename = saveDocLastPath->absolutePath();
2335 if (!aFilename.isEmpty())
2336 aFilename += QString("/") + aDocName;
2338 //show the dialog for file selection
2339 aFilename = SUIT_FileDlg::getFileName( aParent,
2342 tr( "Save HexaBlock Document" ),
2345 //save the document in the selected file
2346 if ( !aFilename.isEmpty() ) {
2347 getCurrentVtkGraphicView()->saveDocument( aFilename );
2349 //Remember the path for next save
2350 QFileInfo fileInfo(aFilename);
2351 *saveDocLastPath = fileInfo.dir();
2357 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2359 _patternDataTreeView->openPersistentEditor( topLeft );
2362 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2364 if (diag == NULL || _dwInputPanel == NULL ||
2365 getCurrentVtkGraphicView() == NULL) return;
2367 //mark this dialog as used by the current model
2368 currentModelDialogs.insert(diag);
2370 //close the current dialog box info
2371 // if (_treeViewDelegate != NULL)
2372 // _treeViewDelegate->closeDialog();
2374 // if (_dwInputPanel->widget())
2375 // _dwInputPanel->widget()->close();
2377 //Temporary for debugging EdgeAssoc Faked InfoDialog
2378 if (diag == _edgeAssocDiag)
2379 diag->debugEdgeAssoc = true;
2381 diag->debugEdgeAssoc = false;
2383 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2384 diag == _quadAssocDiag || diag == _addShapeDiag)
2385 assocInProgress = true;
2387 assocInProgress = false;
2389 //show the dialog box in the dockwidget
2390 diag->resetSizeAndShow(_dwInputPanel);
2392 //clear the current selections
2393 selectionMgr()->clearSelected();
2395 currentDialog = diag;
2398 if (currentDocGView != NULL)
2399 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2402 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2404 if (vertex == NULL || _dwInputPanel == NULL)
2407 if (_vertexInfoDialog == NULL)
2408 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2410 _vertexInfoDialog->setValue(vertex);
2411 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2412 currentDialog = _vertexInfoDialog;
2415 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2417 if (edge == NULL || _dwInputPanel == NULL)
2420 if (_edgeInfoDialog == NULL)
2421 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2423 _edgeInfoDialog->setValue(edge);
2424 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2425 currentDialog = _edgeInfoDialog;
2428 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2430 if (quad == NULL || _dwInputPanel == NULL)
2433 if (_quadInfoDialog == NULL)
2434 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2436 _quadInfoDialog->setValue(quad);
2437 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2438 currentDialog = _quadInfoDialog;
2441 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2443 if (hexa == NULL || _dwInputPanel == NULL)
2446 if (_hexaInfoDialog == NULL)
2447 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2449 _hexaInfoDialog->setValue(hexa);
2450 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2451 currentDialog = _hexaInfoDialog;
2454 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2456 if (vector == NULL || _dwInputPanel == NULL)
2459 if (_vectorInfoDialog == NULL)
2460 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2462 _vectorInfoDialog->setValue(vector);
2463 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2464 currentDialog = _vectorInfoDialog;
2467 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2469 if (group == NULL || _dwInputPanel == NULL)
2472 if (_groupInfoDialog == NULL)
2473 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2475 _groupInfoDialog->setValue(group);
2476 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2477 currentDialog = _groupInfoDialog;
2480 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2482 if (law == NULL || _dwInputPanel == NULL)
2485 if (_lawInfoDialog == NULL)
2486 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2488 _lawInfoDialog->setValue(law);
2489 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2490 currentDialog = _lawInfoDialog;
2493 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2495 if (propagation == NULL || _dwInputPanel == NULL)
2498 if (_propagationInfoDialog == NULL)
2499 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2501 _propagationInfoDialog->setValue(propagation);
2502 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2503 currentDialog = _propagationInfoDialog;
2506 void HEXABLOCKGUI::addVertex()
2508 if ( !_vertexDiag ){
2509 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2511 _showDialogBox( _vertexDiag );
2514 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2515 if (_vertexDiag != NULL && doc != NULL)
2516 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2519 void HEXABLOCKGUI::addEdge()
2522 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2524 _showDialogBox( _edgeDiag );
2527 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2528 if (_edgeDiag != NULL && doc != NULL)
2529 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2532 void HEXABLOCKGUI::addQuad()
2535 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2538 _showDialogBox( _quadDiag );
2541 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2542 if (_quadDiag != NULL && doc != NULL)
2543 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2546 void HEXABLOCKGUI::addHexa()
2549 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2551 _showDialogBox( _hexaDiag );
2554 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2555 if (_hexaDiag != NULL && doc != NULL)
2556 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2559 void HEXABLOCKGUI::addVector()
2561 if ( !_vectorDiag ){
2562 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2564 _showDialogBox( _vectorDiag );
2567 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2568 if (_vectorDiag != NULL && doc != NULL)
2569 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2572 //void HEXABLOCKGUI::addCylinder()
2574 // if ( !_cylinderDiag ){
2575 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2577 // _showDialogBox( _cylinderDiag );
2579 // //set default name
2580 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2581 // if (_cylinderDiag != NULL && doc != NULL)
2582 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2586 //void HEXABLOCKGUI::addPipe()
2588 // if ( !_pipeDiag){
2589 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2591 // _showDialogBox( _pipeDiag );
2593 // //set default name
2594 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2595 // if (_pipeDiag != NULL && doc != NULL)
2596 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2600 void HEXABLOCKGUI::makeGrid()
2602 if ( !_makeGridDiag ){
2603 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2605 _showDialogBox( _makeGridDiag );
2609 void HEXABLOCKGUI::makeCylinder()
2611 if ( !_makeCylinderDiag ){
2612 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2614 _showDialogBox( _makeCylinderDiag );
2617 void HEXABLOCKGUI::makePipe()
2619 if ( !_makePipeDiag ){
2620 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2622 _showDialogBox( _makePipeDiag );
2625 void HEXABLOCKGUI::makeCylinders()
2627 if ( !_makeCylindersDiag ){
2628 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2630 _showDialogBox( _makeCylindersDiag );
2633 void HEXABLOCKGUI::makePipes()
2635 if ( !_makePipesDiag ){
2636 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2638 _showDialogBox( _makePipesDiag );
2642 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2644 if ( !_makeHemiSphereDiag ){
2645 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2647 _showDialogBox( _makeHemiSphereDiag );
2651 void HEXABLOCKGUI::removeHexa()
2653 if ( !_removeHexaDiag ){
2654 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2656 _showDialogBox( _removeHexaDiag );
2660 void HEXABLOCKGUI::prismQuad()
2662 if ( !_prismQuadDiag ){
2663 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2665 _showDialogBox( _prismQuadDiag );
2669 void HEXABLOCKGUI::joinQuad()
2671 if ( !_joinQuadDiag ){
2672 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2674 _showDialogBox( _joinQuadDiag );
2677 void HEXABLOCKGUI::merge()
2680 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2682 _showDialogBox( _mergeDiag );
2685 void HEXABLOCKGUI::disconnectElts()
2687 if ( !_disconnectDiag ){
2688 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2690 _showDialogBox( _disconnectDiag );
2693 void HEXABLOCKGUI::cutEdge()
2695 if ( !_cutEdgeDiag ){
2696 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2698 _showDialogBox( _cutEdgeDiag );
2701 void HEXABLOCKGUI::makeTransformation()
2703 if ( !_makeTransformationDiag ){
2704 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2706 _showDialogBox( _makeTransformationDiag );
2710 void HEXABLOCKGUI::makeSymmetry()
2712 if ( !_makeSymmetryDiag ){
2713 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2715 _showDialogBox( _makeSymmetryDiag );
2719 void HEXABLOCKGUI::performTransformation()
2721 if ( !_performTransformationDiag ){
2722 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2724 _showDialogBox( _performTransformationDiag );
2728 void HEXABLOCKGUI::performSymmetry()
2730 if ( !_performSymmetryDiag ){
2731 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2733 _showDialogBox( _performSymmetryDiag );
2737 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2739 if ( !_replaceHexaDiag ){
2740 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2742 _showDialogBox( _replaceHexaDiag );
2746 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2748 if ( !_quadRevolutionDiag ){
2749 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2751 _showDialogBox( _quadRevolutionDiag );
2755 void HEXABLOCKGUI::assocVertex()
2757 if (!_dwInputPanel) return;
2758 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2759 if ( !_vertexAssocDiag )
2760 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2761 _showDialogBox( _vertexAssocDiag );
2765 void HEXABLOCKGUI::assocEdge()
2767 if ( !_edgeAssocDiag )
2768 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2769 _showDialogBox( _edgeAssocDiag );
2772 void HEXABLOCKGUI::assocQuad()
2774 if ( !_quadAssocDiag )
2775 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2776 _showDialogBox( _quadAssocDiag );
2780 void HEXABLOCKGUI::addGroup()
2783 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2785 _showDialogBox( _groupDiag );
2786 if (_groupDiag != NULL && getCurrentModel() != NULL)
2788 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2789 if (doc == NULL) return;
2790 char defaultName[16];
2791 sprintf (defaultName, "g%04d", doc->countGroup());
2792 _groupDiag->name_le->setText(defaultName);
2796 void HEXABLOCKGUI::removeGroup()
2798 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2799 if (currentDGView == NULL) return;
2801 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2802 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2803 int nbGroupsRemoved = 0;
2806 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2807 tr( "No group selected!" ) );
2811 foreach( QModelIndex selected, l ){
2812 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2813 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2814 Q_ASSERT(selected.isValid());
2816 //Confirm the deletion of the group
2817 if (SUIT_MessageBox::question(
2820 tr("Remove group : %1 ?").arg(selected.data().toString()),
2821 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2822 SUIT_MessageBox::Cancel
2823 ) == SUIT_MessageBox::Cancel) return;
2825 bool removed = getCurrentModel()->removeGroup( selected );
2827 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2828 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2834 if (!nbGroupsRemoved)
2835 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2836 tr( "No group selected!" ) );
2839 void HEXABLOCKGUI::addLaw()
2842 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2844 _showDialogBox( _lawDiag );
2845 if (_lawDiag != NULL && getCurrentModel() != NULL)
2847 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2848 if (doc == NULL) return;
2849 char defaultName[16];
2850 sprintf (defaultName, "l%04d", doc->countLaw());
2851 _lawDiag->name_le->setText(defaultName);
2855 void HEXABLOCKGUI::removeLaw()
2857 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2858 if (currentDGView == NULL) return;
2860 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2861 int nbLawsRemoved = 0;
2864 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2865 tr( "No law selected!" ) );
2869 foreach( QModelIndex selected, l ){
2870 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2871 selected = currentDGView->getMeshModel()->mapToSource( selected );
2872 Q_ASSERT(selected.isValid());
2874 //Confirm the deletion of the law
2875 if (SUIT_MessageBox::question(
2878 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2879 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2880 SUIT_MessageBox::Cancel
2881 ) == SUIT_MessageBox::Cancel) return;
2883 bool removed = getCurrentModel()->removeLaw(selected);
2885 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2886 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2893 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2894 tr( "No law selected!" ) );
2899 void HEXABLOCKGUI::setPropagation()
2901 if ( !_propagationDiag )
2902 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2904 _showDialogBox( _propagationDiag );
2907 // Dialog box to compute a mesh from a document
2908 // --------------------------------------------
2909 void HEXABLOCKGUI::computeMesh()
2911 if ( !_computeMeshDiag )
2912 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2914 _showDialogBox( _computeMeshDiag );
2917 void HEXABLOCKGUI::clearAssociations()
2919 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2920 if (currentDGView == NULL) return;
2922 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2923 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2924 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2926 getCurrentModel()->clearEltAssociations(iModel);
2928 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2931 void HEXABLOCKGUI::showModelInfo()
2933 //create the info dialog if not yet
2934 if (_modelInfoDiag == NULL)
2935 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2937 //show the model informations dialog
2938 _showDialogBox( _modelInfoDiag );
2941 void HEXABLOCKGUI::addShape()
2943 //create the info dialog if not yet
2944 if (_addShapeDiag == NULL)
2945 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2947 //show the model informations dialog
2948 _showDialogBox( _addShapeDiag );
2951 void HEXABLOCKGUI::clearAllAssociations()
2953 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2954 if (currentDGView == NULL) return;
2956 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2957 if (!currentIndex.isValid()) return;
2958 QVariant currentAssocVariant;
2959 QString currentAssocEntry;
2961 //Confirm the deletion of the associations
2962 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2963 if ( !treeVariant.isValid() ) return;
2964 int eltType = treeVariant.toInt();
2965 QString typeStr = "";
2966 HEXA_NS::EnumElt hexaType;
2967 if (eltType == VERTEX_DIR_TREE)
2969 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2970 hexaType = HEXA_NS::EL_VERTEX;
2972 else if (eltType == EDGE_DIR_TREE)
2974 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2975 hexaType = HEXA_NS::EL_EDGE;
2977 else if (eltType == QUAD_DIR_TREE)
2979 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2980 hexaType = HEXA_NS::EL_QUAD;
2983 if (SUIT_MessageBox::question(
2985 tr("CLEAR_ASSOCIATIONS"),
2986 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2987 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2988 SUIT_MessageBox::Cancel
2989 ) == SUIT_MessageBox::Cancel) return;
2992 DocumentModel* docModel = getCurrentModel();
2993 if (docModel == NULL) return;
2994 docModel->clearAssociation(hexaType);
2997 void HEXABLOCKGUI::showAssociations()
2999 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3000 if (currentDGView == NULL) return;
3002 QModelIndexList elts;
3003 int currentChildIndex = 0;
3004 QVariant currentAssocVariant;
3005 QString currentAssocEntry;
3006 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
3007 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
3009 while( currentChild.isValid() ) {
3011 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
3012 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
3013 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
3014 elts << currentChild;
3016 currentChild = currentChild.sibling(currentChildIndex++, 0);
3018 currentDocGView->highlight(elts);
3019 currentOccGView->highlight(elts, false);
3023 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3025 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3027 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3032 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3034 if ( event->type() == QEvent::Enter )
3035 { // *** ENTER EVENT
3037 if (currentDialog == NULL || !currentDialog->isVisible())
3038 return QObject::eventFilter(obj, event);
3040 // ** The window acquire the focus when the cursor enter
3042 //OCC - window enter
3043 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3044 if ( occWindow != NULL)
3045 currentDialog->onWindowActivated(occWindow->getViewManager());
3047 //VTK - window enter
3049 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3050 if ( vtkWindow != NULL)
3051 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3055 //standard event processing
3056 return QObject::eventFilter(obj, event);
3059 QStringList HEXABLOCKGUI::getQuickDirList()
3061 QStringList dirList;
3062 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3064 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3070 // --- Export the module
3074 HEXABLOCK_EXPORT CAM_Module* createModule()
3076 return new HEXABLOCKGUI();
3079 HEXABLOCK_EXPORT char* getModuleVersion()
3081 return (char*)HEXABLOCK_VERSION_STR;
3087 // ******************** TESTS ***************************************************
3089 void HEXABLOCKGUI::testDocument()
3093 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3094 // QStandardItem *myItem = new QStandardItem("MyItem");
3095 // parentItem->appendRow(myItem);
3097 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3098 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3099 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3100 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3101 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3102 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3103 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3104 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3107 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3108 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3109 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3110 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3111 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3112 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3114 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3115 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3116 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3117 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3122 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3123 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3124 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3125 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3133 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3134 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3136 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3137 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3141 // newMesh( "toto", 3, "FactoryServer");
3145 void HEXABLOCKGUI::test_make_cart_grid()
3147 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3148 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3149 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3150 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3151 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3152 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3154 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3155 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3162 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3163 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3164 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3165 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3166 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3167 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3172 void HEXABLOCKGUI::test_make_elmts_transform()
3179 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3180 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3183 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3184 // orig.setScalar(2);
3186 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3187 // getCurrentModel()->saveVtk(file_name)
3189 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3190 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3192 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3193 // getCurrentModel()->saveVtk(file_name)
3195 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3198 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3199 // getCurrentModel()->saveVtk(file_name);
3202 // print "...test make elements by transforming elements OK"
3204 // =============================================================== addDocInSudy
3205 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3209 if (document == NULL)
3212 QString docName = document->getName ();
3214 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3215 if (app_study == NULL)
3218 SALOMEDS::Study_var ds_study = getStudyServant();
3219 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3220 QString entry = app_study->centry("HEXABLOCK");
3221 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3222 if (aFatherSO->_is_nil())
3225 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3228 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3229 docEntry = aSO->GetID(); //the entry of the published object
3234 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3236 void HEXABLOCKGUI::test()
3238 DEBTRACE("HEXABLOCKGUI::test");
3239 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3240 if (currentDGView == NULL) return;
3241 currentDGView->update();
3245 void HEXABLOCKGUI::test_association()
3247 DEBTRACE("HEXABLOCKGUI::test_association");
3250 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3252 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3253 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3254 DocumentModel::GeomObj q0AssocA, q0AssocB;
3256 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3257 QList<DocumentModel::GeomObj> e1Assocs_test;
3258 DocumentModel::GeomObj q0Assoc_test;
3260 v0 = getCurrentModel()->addVertex(0, 0, 0);
3261 v1 = getCurrentModel()->addVertex(1, 0, 0);
3262 v2 = getCurrentModel()->addVertex(1, 1, 0);
3263 v3 = getCurrentModel()->addVertex(0, 1, 0);
3264 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3265 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3266 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3269 // >>> face3.GetEntry()'0:1:4'
3270 // >>> e1.GetEntry()'0:1:8'
3271 // >>> e2.GetEntry()'0:1:9'
3272 // >>> e3.GetEntry()'0:1:10'
3273 // >>> e4.GetEntry()'0:1:11'
3274 // >>> v1.GetEntry()'0:1:12'
3275 // >>> v2.GetEntry()'0:1:13'
3276 // >>> v3.GetEntry()'0:1:14'
3277 // >>> v4.GetEntry()'0:1:15'
3280 // v0Assoc.name = "geomV0";
3281 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3282 // v0Assoc.brep = "brepV0";
3283 // v1Assoc.name = "geomV1";
3284 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3285 // v1Assoc.brep = "brepV1";
3286 // v2Assoc.name = "geomV2";
3287 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3288 // v2Assoc.brep = "brepV2";
3289 // v3Assoc.name = "geomV3";
3290 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3291 // v3Assoc.brep = "brepV3";
3295 // e0AssocA.name = "geomE0a";
3296 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3297 // e0AssocA.brep = "brepE0a";
3298 // e0AssocA.start = 0.10;
3299 // e0AssocA.end = 0.95;
3303 // e1AssocA.name = "geomE1a";
3304 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3305 // e1AssocA.brep = "brepE1a";
3306 // e1AssocA.start = 0.12;
3307 // e1AssocA.end = 0.89;
3308 // e1AssocB.name = "geomE1b";
3309 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3310 // e1AssocB.brep = "brepE1b";
3311 // e1AssocB.start = 0.20;
3312 // e1AssocB.end = 0.80;
3313 // e1AssocC.name = "geomE1c";
3314 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3315 // e1AssocC.brep = "brepE1c";
3316 // e1AssocC.start = 0.16;
3317 // e1AssocC.end = 0.96;
3319 // q0AssocA.name = "geomQuad";
3320 // q0AssocA.entry = "0:1:1:1:3";
3321 // q0AssocA.brep = "brepq0";
3323 // q0AssocB.name = "geomQuad";
3324 // q0AssocB.entry = "0:1:1:1:4";
3325 // q0AssocB.brep = "brepq0";
3327 // getCurrentModel()->addAssociation( v0, v0Assoc );
3328 // getCurrentModel()->addAssociation( v1, v1Assoc );
3329 // getCurrentModel()->addAssociation( v2, v2Assoc );
3330 // getCurrentModel()->addAssociation( v3, v3Assoc );
3333 // getCurrentModel()->addAssociation( e0, e0AssocA );
3335 // getCurrentModel()->addAssociation( e1, e1AssocA );
3336 // getCurrentModel()->addAssociation( e1, e1AssocB );
3337 // getCurrentModel()->addAssociation( e1, e1AssocC );
3339 // getCurrentModel()->addAssociation( q0, q0AssocA );
3340 // getCurrentModel()->addAssociation( q0, q0AssocB );
3346 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3347 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3348 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3349 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3350 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3351 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3352 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3353 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3354 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3355 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3356 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3357 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3360 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3361 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3362 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3363 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3364 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3365 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3366 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3367 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3368 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3369 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3370 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3371 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3372 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3374 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3375 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3376 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3379 DEBTRACE("HEXABLOCKGUI::test_association fin");