1 // Copyright (C) 2009-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include <QInputDialog>
27 #include <QStackedWidget>
31 #include <QtxTreeView.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Desktop.h>
36 #include <SUIT_ViewManager.h>
37 #include <SUIT_ViewWindow.h>
38 #include <SUIT_DataObject.h>
39 #include <SUIT_DataBrowser.h>
40 #include <SUIT_FileDlg.h>
42 #include <SVTK_ViewManager.h>
43 #include <SVTK_ViewModel.h>
44 #include <SVTK_ViewWindow.h>
46 #include <VTKViewer_ViewModel.h>
48 #include <vtkActorCollection.h>
49 #include <VTKViewer_Algorithm.h>
50 #include <vtkRenderer.h>
54 #include <SOCC_ViewModel.h>
55 #include <SOCC_ViewWindow.h>
56 #include <OCCViewer_ViewWindow.h>
57 #include <SALOME_Prs.h>
61 // SALOME KERNEL includes
62 #include <SALOMEDS_Study.hxx>
63 #include <SALOMEDSClient_StudyBuilder.hxx>
64 #include <SALOMEDSClient_SComponent.hxx>
65 #include <SALOMEDSClient_ClientFactory.hxx>
66 #include <SALOMEDSClient_IParameters.hxx>
70 #include <SalomeApp_Study.h>
71 #include <SalomeApp_Module.h>
72 #include <SalomeApp_Application.h>
73 #include <SalomeApp_DataModel.h>
76 #include <SALOME_ListIO.hxx>
79 #include <SALOME_LifeCycleCORBA.hxx>
81 #include <LightApp_VTKSelector.h>
83 #include <OCCViewer_ViewManager.h>
85 #include <QtxPopupMgr.h>
87 #include "Resource.hxx"
89 #include "HEXABLOCKGUI.hxx"
90 #include "HEXABLOCKGUI_Export.hxx"
91 #include "HEXABLOCKGUI_Trace.hxx"
92 #include "HEXABLOCKGUI_Resource.hxx"
94 #include "HEXABLOCKGUI_DocumentModel.hxx"
95 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
96 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
97 #include "HEXABLOCKGUI_DocumentPanel.hxx"
98 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
99 #include "HEXABLOCKGUI_OccGraphicView.hxx"
100 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
102 #include "HEXABLOCK_version.h"
104 #include "MyBasicGUI_PointDlg.hxx"
106 // #include "HEXABLOCK.hxx" del Hexa6
107 // #include "HexDocument_impl.hxx" del Hexa6
110 //#include <V3d_PerspectiveView.hxx>
111 #include <V3d_AmbientLight.hxx>
112 #include <V3d_DirectionalLight.hxx>
113 #include <Xw_Window.hxx>
114 #include <V3d_TypeOfShadingModel.hxx>
115 #include <TCollection_ExtendedString.hxx>
117 #include <BRepAlgoAPI_Fuse.hxx>
119 #include <AIS_ListIteratorOfListOfInteractive.hxx>
121 #include <utilities.h>
123 #define DW_MINIMUM_WIDTH 50
124 #define DWINPUT_MINIMUM_HEIGHT 50
125 #define DWINPUT_MINIMUM_WIDTH 50//255
128 using namespace HEXABLOCK::GUI;
130 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
132 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
133 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
134 bool HEXABLOCKGUI::assocInProgress = false;
135 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
137 HEXABLOCKGUI::HEXABLOCKGUI() :
138 SalomeApp_Module( "HEXABLOCK" ),
139 // LightApp_Module( "HEXABLOCK" ),
147 _patternDataTreeView(0),
148 // _patternBuilderTreeView(0),
149 _patternGeomTreeView(0),
152 // _treeViewDelegate(0),
154 moduleActivatedOnce(false),
164 _makeCylinderDiag(0),
166 _makeCylindersDiag(0),
174 _makeTransformationDiag(0),
175 _makeSymmetryDiag(0),
176 _performTransformationDiag(0),
177 _performSymmetryDiag(0),
186 _quadRevolutionDiag(0),
187 _makeHemiSphereDiag(0),
188 _modelInfoDiag(NULL),
190 _vertexInfoDialog(NULL),
191 _edgeInfoDialog(NULL),
192 _quadInfoDialog(NULL),
193 _hexaInfoDialog(NULL),
194 _vectorInfoDialog(NULL),
195 _groupInfoDialog(NULL),
196 _lawInfoDialog(NULL),
197 _propagationInfoDialog(NULL),
200 lastVtkDocGView(NULL)
202 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
204 graphicViewsHandler = new GraphicViewsHandler();
205 loadDocLastPath = new QDir();
206 saveDocLastPath = new QDir();
207 hexa_root = HEXA_NS::Hex::getInstance ();
210 HEXABLOCKGUI::~HEXABLOCKGUI()
215 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
217 SUIT_Application* app = SUIT_Session::session()->activeApplication();
219 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
225 // Gets an reference to the module's engine
226 /****************************************************
227 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
229 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
230 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
231 ASSERT(!CORBA::is_nil(clr));
234 **************************************************** */
236 void HEXABLOCKGUI::initialize( CAM_Application* app )
238 MESSAGE("HEXABLOCKGUI::initialize");
239 DEBTRACE("HEXABLOCKGUI::initialize");
240 SalomeApp_Module::initialize( app );
242 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
244 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
246 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
247 setResource(aResourceMgr);
249 createAndFillDockWidget();
255 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
257 DEBTRACE("HEXABLOCKGUI::viewManagers");
258 // list.append( QxScene_Viewer::Type() );
259 // list.append( OCCViewer_Viewer::Type() );
260 // list.append( SVTK_Viewer::Type() );
264 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
266 DEBTRACE("HEXABLOCKGUI::activateModule");
268 /*HexaBlock can be launched in only one application*/
269 if (myApplication == NULL)
270 //remember the first application
271 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
273 //application verification: if it's not the one known by HexaBlock,
274 //leave without activating
275 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
276 if (myApplication != currentApplication) return false;
278 bool bOk = SalomeApp_Module::activateModule( theStudy );
279 if ( !bOk ) return false;
281 showDockWidgets(true);
283 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
284 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
285 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
286 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
288 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
290 SUIT_ViewManager* vm;
291 ViewManagerList OCCViewManagers, VTKViewManagers;
293 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
294 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
295 while ( itOCC.hasNext() && (vm = itOCC.next()) )
296 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
298 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
299 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
300 while ( itVTK.hasNext() && (vm = itVTK.next()) )
301 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
304 SALOME_ListIO selected;
305 sm->selectedObjects( selected );
308 // disable OCC selectors
309 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
310 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
311 while ( itOCCSel.hasNext() )
312 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
313 sr->setEnabled(true);
315 // disable VTK selectors
316 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
317 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
318 while ( itVTKSel.hasNext() )
319 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
320 sr->setEnabled(true);
322 sm->setSelectedObjects( selected, true ); //NPAL 19674
324 //connect close signal to vtk view manager
325 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
328 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
329 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
332 //connect close signal to occ view manager
333 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
336 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
337 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
340 /* ************************************ TODO Hexa6
341 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
342 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
343 if ( _PTR(Study) aStudy = s->studyDS()) {
344 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
345 updateObjBrowser(); // objects can be removed
347 ************************************ */
349 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
350 currentOccGView->getViewWindow()->installEventFilter(this);
352 if (currentDocGView != NULL)
354 switchModel(currentDocGView);
357 if (currentDocGView->getViewWindow() != NULL)
358 currentDocGView->getViewWindow()->installEventFilter(this);
370 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
372 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
373 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
374 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
375 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
377 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
378 if ( vtkView != NULL)
380 //default selectionMode in VTKView
381 vtkView->SetSelectionMode( ActorSelection );
382 vtkView->removeEventFilter(this);
386 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
389 //defaut selectionMode in OccView
390 selectionMgr()->clearSelected();
391 currentOccGView->globalSelection();
392 occView->removeEventFilter(this);
396 qDeleteAll(myOCCSelectors);
397 myOCCSelectors.clear();
398 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
400 qDeleteAll(myVTKSelectors);
401 myVTKSelectors.clear();
402 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
404 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
406 //switch off current document graphic view
407 switchOffGraphicView(currentDocGView);
410 setMenuShown( false );
411 setToolShown( false );
412 showDockWidgets( false );
414 _dwInputPanel->close();
421 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudy()
423 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
424 CORBA::Object_var aSMObject = aNamingService->Resolve("/Study");
425 SALOMEDS::Study_var aDSStudy = SALOMEDS::Study::_narrow(aSMObject);
426 return aDSStudy._retn();
429 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
430 QMap<QString, QString>& docShapesEntry,
431 QMap<QString, QString>& docShapesName)
433 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
434 return; //there's nothing to publish in this case
436 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
437 if(!appStudy) return;
438 SALOMEDS::Study_var aDSStudy = ClientStudy();
439 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
440 QString entry = currentDocGView->getDocumentModel()->documentEntry();
441 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
442 if (aFatherSO->_is_nil())
445 // * get a presentation
446 bool isNewPrs = false;
447 SOCC_Prs* prs = getOccPrs(currentDocGView);
450 prs = new SOCC_Prs(0);
454 // * init the presentation with the given shapes
455 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
456 while (i != topo_shapes.constEnd())
458 QString shapeName = i.key();
459 TopoDS_Shape shapeValue = i.value();
460 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
461 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
462 QString objStudyEntry = aSO->GetID(); //the entry of the published object
463 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
464 "HEXABLOCK", shapeName.toStdString().c_str());
465 ais_shape->SetOwner(io);
466 prs->AddObject(ais_shape);
467 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
468 docShapesEntry[shapeName] = objStudyEntry;
469 docShapesName[objStudyEntry] = shapeName;
470 currentOccGView->addShape(objStudyEntry, ais_shape);
471 i++; //handle next shape
475 prs->AddObject(currentOccGView->getPreviewShape());
477 occPrs[currentDocGView] = prs;
478 getApp()->updateObjectBrowser();
483 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
485 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
486 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
487 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
489 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
493 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
497 // Pas de renommage des shapes pour le moment, juste les documents
498 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
499 if (dgview == NULL || dgview->getDocumentModel() == NULL)
502 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
503 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
508 _PTR(Study) aStudy = appStudy->studyDS();
513 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
514 _PTR(GenericAttribute) anAttr;
516 if ( obj->FindAttribute(anAttr, "AttributeName") ){
517 _PTR(AttributeName) aName (anAttr);
518 DocumentModel* docModel = dgview->getDocumentModel();
519 docModel->setName( name );
520 aName->SetValue( name.toLatin1().data() );
521 getApp()->updateObjectBrowser();
522 // _dwPattern->setWindowTitle( name );
529 // --- Default windows
530 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
532 DEBTRACE("HEXABLOCKGUI::windows");
534 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
535 #ifndef DISABLE_PYCONSOLE
536 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
540 QString HEXABLOCKGUI::engineIOR() const
542 DEBTRACE("HEXABLOCKGUI::engineIOR");
544 /* ************************************ TODO Hexa6
545 CORBA::ORB_var anORB = getApp()->orb();
546 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
547 return QString( anIOR.in() );
548 ************************************ */
552 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
554 if (docs.count(studyObject->entry()) == 0)
556 //Object's document not acquired yet
557 VtkDocumentGraphicView* dgview;
558 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
559 if (directory == NULL)
560 return NULL; //No working director found
562 //------------------ Load the document -----------------
563 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
564 if (document == NULL)
565 return NULL; //No document found
567 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
569 MESSAGE("Doc model creation failed!");
572 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
573 if (dgview == NULL) return NULL;
575 //update the data tree
576 docs[studyObject->entry()] = dgview;
579 return docs[studyObject->entry()];
582 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
584 // ** we want to switch automatically to the right view windows
586 //first, find selected item
588 DataObjectList dol = getApp()->objectBrowser()->getSelected();
589 if (dol.isEmpty()) return;
590 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
591 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
592 item->entry().isEmpty())
595 // find the document corresponding to it
596 VtkDocumentGraphicView* docGView = NULL;
597 if (docs.contains(item->entry()))
598 docGView = docs[item->entry()];
600 docGView = getOrCreateDocument(item);
602 //Init OCC if necessary
603 if (currentOccGView == NULL)
605 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
606 currentOccGView->getViewWindow()->installEventFilter(this);
608 else if (currentOccGView->getViewWindow() == NULL)
610 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
611 currentOccGView->getViewWindow()->installEventFilter(this);
614 //Init the vtk view if necessary
615 if (docGView->getViewWindow() == NULL)
617 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
619 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
620 docGView->getViewWindow()->installEventFilter(this);
623 setAllMenusEnabled(true);
626 docGView->setViewWindow(currentDocGView->getViewWindow());
628 if (docGView->getDocumentActor() == NULL)
632 if (docGView == NULL || docGView == currentDocGView)
638 //update the current document
639 switchModel(docGView);
643 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
645 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
648 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
650 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
652 //Decharger le model correspondant (VTK)
653 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
657 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
658 { //HexaBlock Vtk Window has been closed
660 if (currentDialog != NULL) currentDialog->close();
661 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
662 if (currentDocGView != NULL)
663 currentDocGView->setViewWindow(NULL);
666 setAllMenusEnabled(false);
667 enableDocumentMenus(true);
673 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
674 if (dgview == NULL) return; //The window has no document to close
676 //Save the document? (Ask only if the document is not empty
677 int answerCode = SUIT_MessageBox::question(
680 tr("Save the document ?"),
681 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
682 SUIT_MessageBox::Cancel);
683 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
684 else if (answerCode == SUIT_MessageBox::Yes)
685 saveDocument(); //Save the document
687 // switchOffGraphicView(window); //disconnect all connected signals
688 // currentVtkView = NULL;
689 // graphicViewsHandler->closeDocumentGraphicView(window);
691 //create a new one (empty document)
693 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
697 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
699 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
700 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
701 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
702 if (currentDialog != NULL) currentDialog->close();
703 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
705 currentOccGView->getViewWindow()->removeEventFilter(this);
706 currentOccGView->setViewWindow(NULL);
710 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
712 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
714 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
715 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
717 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
719 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
720 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
721 // disable OCC selectors
722 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
723 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
724 while ( itOCCSel.hasNext() )
725 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
726 sr->setEnabled(true);
728 else if ( vm->getType() == SVTK_Viewer::Type() )
730 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
731 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
733 // disable VTK selectors
734 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
735 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
736 while ( itVTKSel.hasNext() )
737 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
738 sr->setEnabled(true);
742 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
744 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
746 SUIT_ViewModel* viewer = vm->getViewModel();
747 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
749 //VTK View Manager removed
750 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
752 //Process only if it's our view manager
753 SUIT_ViewManager* myVm = NULL;
754 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
755 myVm = currentDocGView->getViewWindow()->getViewManager();
759 //close opened dialog
760 if (currentDialog != NULL) currentDialog->close();
761 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
767 //remove its selector
768 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
769 while ( itVTKSel.hasNext() )
770 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
771 if ( sr->viewer() == viewer )
773 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
780 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
782 //OCC View removed: remove its selector
783 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
784 while ( itOCCSel.hasNext() )
785 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
786 if ( sr->viewer() == viewer )
788 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
794 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
796 QModelIndexList l = selected.indexes();
797 if ( l.count() == 0 ) return;
798 if ( !l[0].isValid() ) return;
799 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
800 if ( currentGraphicView == NULL) return;
802 QTreeView* theTree = NULL;
803 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
804 theTree = _patternDataTreeView;
806 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
807 theTree = _patternBuilderTreeView;
809 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
810 theTree = _patternGeomTreeView;
812 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
813 theTree = _groupsTreeView;
814 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
815 theTree = _meshTreeView;
818 theTree->scrollTo ( l[0] );
822 bool HEXABLOCKGUI::createSComponent() //addComponent
824 DEBTRACE("HEXABLOCKGUI::createSComponent");
825 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
827 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
828 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
829 _PTR(GenericAttribute) anAttr;
830 _PTR(AttributeName) aName;
831 _PTR(AttributeGraphic) aGraphic;
833 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
834 if ( !aComponent ){ //Create hexablock component if there's not one yet
835 aComponent = aBuilder->NewComponent("HEXABLOCK");
836 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
837 aName = _PTR(AttributeName) (anAttr);
838 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
840 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
841 _PTR(AttributePixMap) aPixmap(anAttr);
842 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
844 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
845 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
851 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
853 DEBTRACE("HEXABLOCKGUI::setResource");
854 _myresource = new HEXABLOCKGUI_Resource(r);
855 _myresource->preferencesChanged();
858 void HEXABLOCKGUI::createPreferences()
860 DEBTRACE("HEXABLOCKGUI::createPreferences");
861 _myresource->createPreferences(this);
864 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
866 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
867 _myresource->preferencesChanged(sect, name);
868 // if(name=="userCatalog")
869 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
872 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
874 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
875 QVariant currentAssocVariant;
876 QString currentAssocEntry;
878 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
879 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
880 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
881 QMenu menu( _patternDataTreeView );
883 QAction *clearAct = menu.addAction( "Remove association(s)" );
884 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
885 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
889 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
890 if (currentVtkGraphicView == NULL) return;
891 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
893 //We don't do anything for single items
894 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
895 item->type() == QUADITEM || item->type() == HEXAITEM)
898 //No associations for HEXA
899 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
900 if ( !treeVariant.isValid() ) return;
901 int eltType = treeVariant.toInt();
902 if (eltType == HEXA_DIR_TREE) return;
903 QMenu menu( _patternDataTreeView );
905 //Show association(s)
906 QAction *showAssocAct = menu.addAction( "Show associations" );
907 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
909 //Clear all associations
910 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
911 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
913 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
918 void HEXABLOCKGUI::createAndFillDockWidget()
921 QMainWindow *aParent = application()->desktop();
923 // Create dock widget (3 dock)
925 //1) *********** user input panel ( contain user's edit dialog box )
926 _dwInputPanel = new QDockWidget(aParent);
927 _dwInputPanel->setVisible(false);
928 _dwInputPanel->setWindowTitle("Input Panel");
929 _dwInputPanel->setObjectName("hexablockInputPanelDock");
930 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
932 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
934 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
936 _dwPattern = new QDockWidget(aParent);
937 _dwPattern->setVisible(false);
938 _dwPattern->setWindowTitle("Model");
939 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
940 _dwPattern->setObjectName("hexablockModelDock");
942 QFrame* patternFrame = new QFrame(_dwPattern);
943 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
944 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
945 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
946 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
947 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
948 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
949 _patternGeomTreeView = new QTreeView(patternFrame);
950 splitter->addWidget(_patternDataTreeView);
951 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
952 splitter->addWidget(_patternGeomTreeView);
953 patternLayout->addWidget(splitter);
955 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
956 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
957 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
960 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
961 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
963 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
964 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
966 _dwPattern->setWidget(patternFrame);
967 patternFrame->show();
970 _dwGroups = new QDockWidget(aParent);
972 _dwGroups->setVisible(false);
973 _dwGroups->setWindowTitle("Groups");
974 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
975 _dwGroups->setObjectName("hexablockGroupsDock");
976 _groupsTreeView = new QTreeView(_dwGroups);
977 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
978 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
979 _dwGroups->setWidget(_groupsTreeView);
980 _groupsTreeView->show();
983 _dwMesh = new QDockWidget(aParent);
984 _dwMesh->setVisible(false);
985 _dwMesh->setWindowTitle("Mesh");
986 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
987 _dwMesh->setObjectName("hexablockMeshDock");
988 _meshTreeView = new QTreeView(_dwMesh);
989 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
990 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
991 // _meshTreeView->setItemDelegate(_treeViewDelegate);
992 _dwMesh->setWidget(_meshTreeView);
993 _meshTreeView->show();
995 // QDockWidget *_dwObjectBrowser = 0;
996 QWidget* wid = getApp()->objectBrowser()->treeView();
997 QWidget *w = wid->parentWidget();
998 while ( w && !_dwObjectBrowser ) {
999 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1000 w = w->parentWidget();
1002 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1003 _dwObjectBrowser->setWindowTitle("Study");
1005 // dock widget position
1006 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1007 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1009 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1010 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1011 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1013 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1014 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1015 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1017 #if QT_VERSION >= 0x040500
1018 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1021 // popup menu on data tree view
1022 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1023 connect(_patternDataTreeView,
1024 SIGNAL(customContextMenuRequested(const QPoint &)),
1026 SLOT(treeContextMenu(const QPoint &)),
1027 Qt::UniqueConnection );
1030 void HEXABLOCKGUI::createActions()
1032 QMainWindow *aParent = application()->desktop();
1033 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1036 _newAct = createAction(_menuId++,
1037 tr("Create a new document"),
1038 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1040 tr("Create a new document"),
1041 0, aParent, false, this, SLOT(newDocument()));
1042 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1044 _importAct = createAction(_menuId++,
1045 tr("Load a document"),
1046 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1047 tr("Load Document"),
1048 tr("Load a document"),
1049 0, aParent, false, this, SLOT(loadDocument()));
1050 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1052 _saveAct = createAction(_menuId++,
1053 tr("Save the document"),
1054 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1055 tr("Save Document"),
1056 tr("Save the document"),
1057 0, aParent, false, this, SLOT(saveDocument()));
1059 // Pattern Data creation
1060 _addVertex = createAction(_menuId++,
1061 tr("Create a vertex"),
1062 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1064 tr("Create a new vertex"),
1065 0, aParent, false, this, SLOT(addVertex()));
1067 _addEdge = createAction(_menuId++,
1068 tr("Create an edge"),
1069 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1071 tr("Create a new edge"),
1072 0, aParent, false, this, SLOT(addEdge()));
1074 _addQuad = createAction(_menuId++,
1075 tr("Create a quadrangle"),
1076 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1077 tr("Add Quadrangle"),
1078 tr("Create a new quadrangle"),
1079 0, aParent, false, this, SLOT(addQuad()));
1081 _addHexa = createAction(_menuId++,
1082 tr("Create an hexahedron"),
1083 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1084 tr("Add Hexahedron"),
1085 tr("Create a new hexahedron"),
1086 0, aParent, false, this, SLOT(addHexa()));
1088 // Builder Data creation
1089 _addVector = createAction(_menuId++,
1090 tr("Create a vector"),
1091 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1093 tr("Create a new vector"),
1094 0, aParent, false, this, SLOT(addVector()));
1096 // _addCylinder = createAction(_menuId++,
1097 // tr("Create a cylinder"),
1098 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1099 // tr("Add Cylinder"),
1100 // tr("Create a new cylinder"),
1101 // 0, aParent, false, this, SLOT(addCylinder()));
1103 // _addPipe = createAction(_menuId++,
1104 // tr("Create a pipe"),
1105 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1107 // tr("Create a new pipe"),
1108 // 0, aParent, false, this, SLOT(addPipe()));
1110 _makeGrid = createAction(_menuId++,
1112 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1115 0, aParent, false, this, SLOT(makeGrid()));
1117 _makeCylinder = createAction(_menuId++,
1118 tr("Make a cylinder"),
1119 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1120 tr("Make Cylinder"),
1121 tr("Make a cylinder"),
1122 0, aParent, false, this, SLOT(makeCylinder()));
1124 _makePipe = createAction(_menuId++,
1126 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1129 0, aParent, false, this, SLOT(makePipe()));
1131 _makeCylinders = createAction(_menuId++,
1132 tr("Make cylinders"),
1133 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1134 tr("Make Cylinders"),
1135 tr("Make cylinders"),
1136 0, aParent, false, this, SLOT(makeCylinders()));
1138 _makePipes = createAction(_menuId++,
1140 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1143 0, aParent, false, this, SLOT(makePipes()));
1145 _makeHemiSphere = createAction(_menuId++,
1146 tr("Make an hemisphere"),
1147 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1148 tr("Make Hemisphere"),
1149 tr("Make an hemisphere"),
1150 0, aParent, false, this, SLOT(makeHemiSphere()));
1152 // Pattern Data edition
1153 _removeHexa = createAction(_menuId++,
1154 tr("Remove hexahedra"),
1155 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1156 tr("Remove Hexahedra"),
1157 tr("Remove hexahedra"),
1158 0, aParent, false, this, SLOT(removeHexa()));
1160 _prismQuad = createAction(_menuId++,
1161 tr("Prism quadrangles"),
1162 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1163 tr("Prism Quadrangles"),
1164 tr("Prism quadrangles"),
1165 0, aParent, false, this, SLOT(prismQuad()));
1167 _joinQuad = createAction(_menuId++,
1168 tr("Join quadrangles"),
1169 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1170 tr("Join Quadrangles"),
1171 tr("Join quadrangles with hexahedra"),
1172 0, aParent, false, this, SLOT(joinQuad()));
1174 _merge = createAction(_menuId++,
1176 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1179 0, aParent, false, this, SLOT(merge()));
1181 _disconnect = createAction(_menuId++,
1183 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1185 tr("Disconnect edges, vertexes or quadrangles"),
1186 0, aParent, false, this, SLOT(disconnectElts()));
1188 _cutEdge = createAction(_menuId++,
1190 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1193 0, aParent, false, this, SLOT(cutEdge()));
1195 _makeTransformation = createAction(_menuId++,
1196 tr("Make transformation"),
1197 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1198 tr("Make Transformation"),
1199 tr("Make transformation"),
1200 0, aParent, false, this, SLOT(makeTransformation()));
1202 _makeSymmetry = createAction(_menuId++,
1203 tr("Make symmetry"),
1204 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1205 tr("Make Symmetry"),
1206 tr("Make symmetry"),
1207 0, aParent, false, this, SLOT(makeSymmetry()));
1209 _performTransformation = createAction(_menuId++,
1210 tr("Perform transformation"),
1211 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1212 tr("Perform Transformation"),
1213 tr("Perform transformation"),
1214 0, aParent, false, this, SLOT(performTransformation()));
1216 _performSymmetry = createAction(_menuId++,
1217 tr("Perform symmetry"),
1218 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1219 tr("Perform Symmetry"),
1220 tr("Perform symmetry"),
1221 0, aParent, false, this, SLOT(performSymmetry()));
1223 _replaceHexa = createAction(_menuId++,
1224 tr("Replace hexahedron"),
1225 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1226 tr("Replace Hexahedron"),
1227 tr("Replace hexahedron"),
1228 0, aParent, false, this, SLOT(replaceHexa()));
1230 _quadRevolution = createAction(_menuId++,
1231 tr("Quad revolution"),
1232 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1233 tr("Quad Revolution"),
1234 tr("Quad revolution"),
1235 0, aParent, false, this, SLOT(quadRevolution()));
1238 _assocVertex = createAction(_menuId++,
1239 tr("Make vertex association"),
1240 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1241 tr("Make Vertex association"),
1242 tr("Make vertex association"),
1243 0, aParent, false, this, SLOT(assocVertex()));
1245 _assocEdge = createAction(_menuId++,
1246 tr("Make edge association"),
1247 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1248 tr("Make Edge Association"),
1249 tr("Make edge association"),
1250 0, aParent, false, this, SLOT(assocEdge()));
1252 _assocQuad = createAction(_menuId++,
1253 tr("Make quad association"),
1254 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1255 tr("Make Quad Association"),
1256 tr("Make quad association"),
1257 0, aParent, false, this, SLOT(assocQuad()));
1260 _addGroup = createAction(_menuId++,
1262 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1265 0, aParent, false, this, SLOT(addGroup()));
1267 _removeGroup = createAction(_menuId++,
1268 tr("Remove a group"),
1269 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1271 tr("Remove a group"),
1272 0, aParent, false, this, SLOT(removeGroup()));
1275 _addLaw = createAction(_menuId++,
1277 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1280 0, aParent, false, this, SLOT(addLaw()));
1282 _removeLaw = createAction(_menuId++,
1284 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1287 0, aParent, false, this, SLOT(removeLaw()));
1289 _setPropagation = createAction(_menuId++,
1290 tr("Set propagation"),
1291 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1292 tr("Set Propagation"),
1293 tr("Set propagation"),
1294 0, aParent, false, this, SLOT(setPropagation()));
1296 _computeMesh = createAction(_menuId++,
1298 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1301 0, aParent, false, this, SLOT(computeMesh()));
1303 _showModelInfoAct = createAction(_menuId++,
1304 tr("Show Model Info"),
1305 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1308 0, aParent, false, this, SLOT(showModelInfo()));
1310 _addShapeAct = createAction(_menuId++,
1312 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1315 0, aParent, false, this, SLOT(addShape()));
1317 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1318 // QAction* createAction(const int id,
1319 // const QString& toolTip,
1320 // const QIcon& icon,
1321 // const QString& menu,
1322 // const QString& status,
1323 // const int shortCut,
1324 // QObject* parent =0,
1325 // bool checkable = false,
1326 // QObject* receiver =0,
1327 // const char* member =0);
1329 _sep1 = separator();
1330 _sep2 = separator();
1331 _sep3 = separator();
1332 _sep4 = separator();
1336 void HEXABLOCKGUI::createMenus()
1338 int aMenuId, subMenuId,aMenuIdMain;
1340 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1342 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1343 createMenu( actionId(_newAct), aMenuId );
1344 createMenu( actionId(_importAct), aMenuId );
1345 createMenu( _saveAct, aMenuId );
1348 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1349 createMenu( _newAct, aMenuDocId );//, 10
1350 createMenu( _importAct, aMenuDocId );
1351 createMenu( _saveAct, aMenuDocId );
1353 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1354 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1355 createMenu( _addVertex, subMenuId );
1356 createMenu( _addEdge, subMenuId );
1357 createMenu( _addQuad, subMenuId );
1358 createMenu( _addHexa, subMenuId );
1359 createMenu( _sep1, subMenuId);
1362 createMenu( _addVector, subMenuId );
1363 // createMenu( _addCylinder, subMenuId );
1364 // createMenu( _addPipe, subMenuId );
1366 createMenu( _sep2, subMenuId);
1368 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1369 createMenu( _makeHemiSphere,subMenuId );
1371 createMenu( _sep3, subMenuId);
1373 createMenu( _makeCylinder, subMenuId );
1374 createMenu( _makePipe, subMenuId );
1375 createMenu( _makeCylinders,subMenuId );
1376 createMenu( _makePipes, subMenuId );
1378 // Pattern Data Edition
1379 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1380 createMenu( _removeHexa, subMenuId );
1381 createMenu( _prismQuad, subMenuId );
1382 createMenu( _joinQuad, subMenuId );
1383 createMenu( _merge, subMenuId );
1384 createMenu( _disconnect, subMenuId );
1385 createMenu( _cutEdge, subMenuId );
1386 createMenu( _makeTransformation, subMenuId );
1387 createMenu( _makeSymmetry, subMenuId );
1388 createMenu( _performTransformation, subMenuId );
1389 createMenu( _performSymmetry, subMenuId );
1390 createMenu( _replaceHexa, subMenuId );
1391 createMenu( _quadRevolution, subMenuId );
1392 createMenu( _sep4, aMenuId );
1393 createMenu( _showModelInfoAct, aMenuId );
1396 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1397 createMenu( _addShapeAct, aMenuId );
1398 createMenu( _assocVertex, aMenuId );
1399 createMenu( _assocEdge, aMenuId );
1400 createMenu( _assocQuad, aMenuId );
1403 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1404 createMenu( _addGroup, aMenuId );
1405 createMenu( _removeGroup, aMenuId ); //CS_TODO
1408 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1409 createMenu( _addLaw, aMenuId );
1410 createMenu( _removeLaw, aMenuId );
1411 createMenu( _setPropagation, aMenuId );
1412 createMenu( _computeMesh, aMenuId );
1414 //show model infomation menu
1415 QString aRule = "$component={'HEXABLOCK'}";
1416 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1417 popupMgr()->setRule( _showModelInfoAct, aRule);
1419 //associate shape to a document menu
1420 popupMgr()->insert( _addShapeAct, -1, -1 );
1421 popupMgr()->setRule( _addShapeAct, aRule );
1423 //-------------------------------------------------
1425 //-------------------------------------------------
1426 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1427 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1428 // QString isNotEmpty("numberOfNodes <> 0");
1429 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1430 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1431 //// aType = aType.arg( mesh_part );
1433 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1434 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1435 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1437 // popupMgr()->insert( separator(), -1, -1 );
1438 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1439 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1440 // // MESSAGE("aClient = " << aClient.toStdString());
1441 // // MESSAGE("aType = " << aType.toStdString());
1442 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1443 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1444 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1445 // // MESSAGE("aRule = " << aRule.toStdString());
1446 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1447 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1449 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1450 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1452 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1453 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1455 // popupMgr()->insert( separator(), -1, -1 );
1459 void HEXABLOCKGUI::createTools()
1463 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1464 createTool( _newAct, aToolId );
1465 createTool( _importAct, aToolId );
1466 createTool( _saveAct, aToolId );
1467 createTool( _showModelInfoAct, aToolId );
1468 // createTool( _testAct, aToolId );
1469 //createTool( separator(), aToolId );
1472 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1473 createTool( _addVertex, aToolId );
1474 createTool( _addEdge, aToolId );
1475 createTool( _addQuad, aToolId );
1476 createTool( _addHexa, aToolId );
1478 createTool( _sep1, aToolId );
1481 createTool( _addVector, aToolId );
1482 // createTool( _addCylinder, aToolId );
1483 // createTool( _addPipe, aToolId );
1485 createTool( _sep2, aToolId );
1487 createTool( _makeGrid, aToolId );
1488 createTool( _makeHemiSphere, aToolId );
1490 createTool( _sep3, aToolId );
1492 createTool( _makeCylinder, aToolId );
1493 createTool( _makePipe, aToolId );
1494 createTool( _makeCylinders,aToolId );
1495 createTool( _makePipes, aToolId );
1497 // Pattern Data Edition
1498 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1499 createTool( _removeHexa, aToolId );
1500 createTool( _prismQuad, aToolId );
1501 createTool( _joinQuad, aToolId );
1502 createTool( _merge, aToolId );
1503 createTool( _disconnect, aToolId );
1504 createTool( _cutEdge, aToolId );
1505 createTool( _makeTransformation, aToolId );
1506 createTool( _makeSymmetry, aToolId );
1507 createTool( _performTransformation, aToolId );
1508 createTool( _performSymmetry, aToolId );
1509 createTool( _replaceHexa, aToolId );
1510 createTool( _quadRevolution, aToolId );
1513 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1514 createTool( _assocVertex, aToolId );
1515 createTool( _assocEdge, aToolId );
1516 createTool( _assocQuad, aToolId );
1517 createTool( _addShapeAct, aToolId );
1520 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1521 createTool( _addGroup, aToolId );
1522 createTool( _removeGroup, aToolId ); //CS_TODO
1525 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1526 createTool( _addLaw, aToolId );
1527 createTool( _removeLaw, aToolId );
1528 createTool( _setPropagation, aToolId );
1529 createTool( _computeMesh, aToolId );
1533 void HEXABLOCKGUI::initialMenus()
1535 showDocumentMenus( true );
1536 showPatternMenus( false );
1537 showAssociationMenus( false );
1538 showGroupsMenus( false );
1539 showMeshMenus( false );
1542 void HEXABLOCKGUI::showAllMenus()
1544 showDocumentMenus( true );
1545 showPatternMenus( true );
1546 showAssociationMenus( true );
1547 showGroupsMenus( true );
1548 showMeshMenus( true );
1551 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1553 enableDocumentMenus( enable );
1554 enablePatternMenus( enable );
1555 enableAssociationMenus( enable );
1556 enableGroupsMenus( enable );
1557 enableMeshMenus( enable );
1559 menusEnabled = enable;
1562 void HEXABLOCKGUI::showDocumentMenus(bool show)
1564 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1566 setMenuShown(_newAct, show);
1567 setToolShown(_newAct, show);
1568 setMenuShown(_importAct, show);
1569 setToolShown(_importAct, show);
1570 setMenuShown(_showModelInfoAct, show);
1571 setToolShown(_showModelInfoAct, show);
1572 setMenuShown(_saveAct, show);
1573 setToolShown(_saveAct, show);
1576 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1578 _newAct->setEnabled(enable);
1579 // setToolShown(_newAct, enable);
1581 _importAct->setEnabled(enable);
1582 // setToolShown(_importAct, enable);
1584 _showModelInfoAct->setEnabled(enable);
1585 // setToolShown(_showModelInfoAct, enable);
1587 _saveAct->setEnabled(enable);
1588 // setToolShown(_saveAct, enable);
1592 void HEXABLOCKGUI::showPatternMenus(bool show)
1594 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1595 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1596 if ( show && !getCurrentModel() ) return;
1598 setMenuShown(_addVertex, show );
1599 setToolShown(_addVertex, show);
1600 setMenuShown(_addEdge, show );
1601 setToolShown(_addEdge, show);
1602 setMenuShown(_addQuad, show );
1603 setToolShown(_addQuad, show);
1604 setMenuShown(_addHexa, show );
1605 setToolShown(_addHexa, show);
1607 setMenuShown(_sep1, show );
1608 setToolShown(_sep1, show);
1610 setMenuShown( _addVector, show );
1611 setToolShown( _addVector, show);
1612 // setMenuShown( _addCylinder, show );
1613 // setToolShown( _addCylinder, show);
1614 // setMenuShown( _addPipe, show );
1615 // setToolShown( _addPipe, show);
1617 setMenuShown(_sep2, show );
1618 setToolShown(_sep2, show);
1620 setMenuShown( _makeGrid, show );
1621 setToolShown( _makeGrid, show);
1622 setMenuShown( _makePipe, show );
1623 setToolShown( _makePipe, show);
1625 setMenuShown(_sep3, show );
1626 setToolShown(_sep3, show);
1628 setMenuShown( _makeCylinder, show );
1629 setToolShown( _makeCylinder, show);
1630 setMenuShown( _makeCylinders, show );
1631 setToolShown( _makeCylinders, show);
1632 setMenuShown( _makePipes, show );
1633 setToolShown( _makePipes, show);
1634 setMenuShown( _makeHemiSphere, show );
1635 setToolShown( _makeHemiSphere, show);
1637 // Pattern Data Edition
1638 setMenuShown( _removeHexa, show );
1639 setToolShown( _removeHexa, show);
1640 setMenuShown( _prismQuad, show );
1641 setToolShown( _prismQuad, show);
1642 setMenuShown( _joinQuad, show );
1643 setToolShown( _joinQuad, show);
1644 setMenuShown( _merge, show );
1645 setToolShown( _merge, show);
1646 setMenuShown( _disconnect, show );
1647 setToolShown( _disconnect, show);
1648 setMenuShown( _cutEdge, show );
1649 setToolShown( _cutEdge, show);
1650 setMenuShown( _makeTransformation, show );
1651 setToolShown( _makeTransformation, show);
1652 setMenuShown( _makeSymmetry, show );
1653 setToolShown( _makeSymmetry, show);
1654 setMenuShown( _performTransformation, show );
1655 setToolShown( _performTransformation, show);
1656 setMenuShown( _performSymmetry, show );
1657 setToolShown( _performSymmetry, show);
1658 setMenuShown( _replaceHexa, show );
1659 setToolShown( _replaceHexa, show);
1660 setMenuShown( _quadRevolution, show );
1661 setToolShown( _quadRevolution, show);
1663 setMenuShown( _sep4, show );
1664 setMenuShown( _showModelInfoAct, show );
1667 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1669 if ( enable && !getCurrentModel() ) return;
1671 _addVertex->setEnabled(enable);
1672 // setToolShown(_addVertex, enable);
1674 _addEdge->setEnabled(enable);
1675 // setToolShown(_addEdge, enable);
1677 _addQuad->setEnabled(enable);
1678 // setToolShown(_addQuad, enable);
1680 _addHexa->setEnabled(enable);
1681 // setToolShown(_addHexa, enable);
1683 // setMenuShown(_sep1, enable );
1684 // setToolShown(_sep1, enable);
1686 _addVector->setEnabled(enable);
1687 // setToolShown( _addVector, enable);
1689 // setMenuShown(_sep2, enable );
1690 // setToolShown(_sep2, enable);
1692 _makeGrid->setEnabled(enable);
1693 // setToolShown( _makeGrid, enable);
1695 _makePipe->setEnabled(enable);
1696 // setToolShown( _makePipe, enable);
1698 // setMenuShown(_sep3, enable );
1699 // setToolShown(_sep3, enable);
1701 _makeCylinder->setEnabled(enable);
1702 // setToolShown( _makeCylinder, enable);
1704 _makeCylinders->setEnabled(enable);
1705 // setToolShown( _makeCylinders, enable);
1707 _makePipes->setEnabled(enable);
1708 // setToolShown( _makePipes, enable);
1710 _makeHemiSphere->setEnabled(enable);
1711 // setToolShown( _makeHemiSphere, enable);
1713 // Pattern Data Edition
1714 _removeHexa->setEnabled(enable);
1715 // setToolShown( _removeHexa, enable);
1717 _prismQuad->setEnabled(enable);
1718 // setToolShown( _prismQuad, enable);
1720 _joinQuad->setEnabled(enable);
1721 // setToolShown( _joinQuad, enable);
1723 _merge->setEnabled(enable);
1724 // setToolShown( _merge, enable);
1726 _disconnect->setEnabled(enable);
1727 // setToolShown( _disconnect, enable);
1729 _cutEdge->setEnabled(enable);
1730 // setToolShown( _cutEdge, enable);
1732 _makeTransformation->setEnabled(enable);
1733 // setToolShown( _makeTransformation, enable);
1735 _makeSymmetry->setEnabled(enable);
1736 // setToolShown( _makeSymmetry, enable);
1738 _performTransformation->setEnabled(enable);
1739 // setToolShown( _performTransformation, enable);
1741 _performSymmetry->setEnabled(enable);
1742 // setToolShown( _performSymmetry, enable);
1744 _replaceHexa->setEnabled(enable);
1745 // setToolShown( _replaceHexa, enable);
1747 _quadRevolution->setEnabled(enable);
1748 // setToolShown( _quadRevolution, enable);
1750 // setMenuShown( _sep4, enable );
1751 _showModelInfoAct->setEnabled(enable);
1755 void HEXABLOCKGUI::showAssociationMenus(bool show)
1757 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1758 if ( show && !getCurrentModel() ) return;
1760 // Association Edition
1761 setMenuShown( _assocVertex, show );
1762 setToolShown( _assocVertex, show );
1764 setMenuShown( _assocEdge, show );
1765 setToolShown( _assocEdge, show );
1767 setMenuShown( _assocQuad, show );
1768 setToolShown( _assocQuad, show );
1770 setMenuShown( _addShapeAct, show );
1771 setToolShown( _addShapeAct, show );
1774 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1776 if ( enable && !getCurrentModel() )
1779 // Association Edition
1780 _assocVertex->setEnabled(enable);
1781 // setToolShown( _assocVertex, enable );
1783 _assocEdge->setEnabled(enable);
1784 // setToolShown( _assocEdge, enable );
1786 _assocQuad->setEnabled(enable);
1787 // setToolShown( _assocQuad, enable );
1789 _addShapeAct->setEnabled(enable);
1790 // setToolShown( _addShapeAct, enable );
1793 void HEXABLOCKGUI::showGroupsMenus(bool show)
1795 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1796 if ( show && !getCurrentModel() ) return;
1797 setMenuShown( _addGroup, show );
1798 setToolShown( _addGroup, show);
1799 setMenuShown( _removeGroup , show );
1800 setToolShown( _removeGroup , show);
1803 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1805 if ( enable && !getCurrentModel() )
1808 _addGroup->setEnabled(enable);
1809 // setToolShown( _addGroup, enable);
1811 _removeGroup->setEnabled(enable);
1812 // setToolShown( _removeGroup , enable);
1815 void HEXABLOCKGUI::showMeshMenus(bool show)
1817 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1818 if ( show && !getCurrentModel() ) return;
1819 setMenuShown( _addLaw, show );
1820 setToolShown( _addLaw, show);
1821 setMenuShown( _removeLaw, show );
1822 setToolShown( _removeLaw, show);;
1823 setMenuShown( _setPropagation, show );
1824 setToolShown( _setPropagation, show);
1825 setMenuShown( _computeMesh, show);
1826 setToolShown( _computeMesh, show);
1829 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1831 if ( enable && !getCurrentModel() )
1834 _addLaw->setEnabled(enable);
1835 // setToolShown( _addLaw, enable);
1837 _removeLaw->setEnabled(enable);
1838 // setToolShown( _removeLaw, enable);
1840 _setPropagation->setEnabled(enable);
1841 // setToolShown( _setPropagation, enable);
1843 _computeMesh->setEnabled(enable);
1844 // setToolShown( _computeMesh, enable);
1847 void HEXABLOCKGUI::showVtkActor()
1849 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1850 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1851 currentVtkGView->getDocumentActor() == NULL)
1854 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1855 if (vtkView == NULL)
1858 SUIT_ViewManager* vman = vtkView->getViewManager();
1859 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1861 //show only the current actor -----------------
1862 vtkView->setFocus();
1863 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1864 Document_Actor *lastDocActor;
1865 if (lastVtkDocGView != NULL)
1867 lastDocActor = lastVtkDocGView->getDocumentActor();
1868 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1869 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1871 vtkView->Erase(lastActorIO);
1872 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1873 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1876 currentVtkGView->update();
1877 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1878 if (!anIO.IsNull() && anIO->hasEntry())
1880 vtkView->Display(anIO);
1881 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1882 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1884 vtkView->onFitAll();
1887 void HEXABLOCKGUI::showOccActor()
1889 if (currentOccGView == NULL)
1891 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1892 if (occView == NULL)
1894 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1898 if (lastOccPrs != NULL)
1899 vf->Erase(lastOccPrs);
1900 currentOccGView->globalSelection();
1901 SOCC_Prs* prs = getOccPrs(currentDocGView);
1902 currentOccGView->setPrs(prs);
1905 occView->onFitAll();
1908 void HEXABLOCKGUI::hideVtkActor()
1910 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1911 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1912 currentVtkGView->getViewWindow() == NULL ||
1913 currentVtkGView->getDocumentActor() == NULL) return;
1915 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1916 currentVtkGView->getViewWindow()->onResetView();
1918 //update the visibility state now
1919 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1920 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1921 if (aStudy == NULL || vman == NULL) return;
1923 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1924 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1925 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1928 void HEXABLOCKGUI::hideOccActor()
1930 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1931 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1932 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1933 if (occView == NULL || docModel == NULL)
1935 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1939 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1940 if (currentOccPrs != NULL)
1941 vf->Erase(currentOccPrs);
1943 occView->onResetView();
1946 void HEXABLOCKGUI::showOnlyActor()
1952 void HEXABLOCKGUI::hideActor()
1959 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1961 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1963 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1965 if (_dwPattern) _dwPattern->setVisible(isVisible);
1966 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1968 if (_dwMesh) _dwMesh->setVisible(isVisible);
1969 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1971 if (_dwGroups) _dwGroups->setVisible(isVisible);
1972 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1976 //clear all used dialogs by the current model
1977 void HEXABLOCKGUI::clearDialogs()
1979 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1980 fin (currentModelDialogs.end());
1981 for(;debut!=fin;++debut) (*debut)->clear();
1983 currentModelDialogs.clear(); //empty the used dialogs list
1986 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1988 if (!gViewDlgBox.contains(dgview)) return NULL;
1989 return gViewDlgBox[dgview];
1992 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1994 if (dgview == NULL) return;
1996 switchOffGraphicView(dgview, false); //to avoid double connect
1999 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2000 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
2001 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2002 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2003 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2004 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2005 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2006 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2007 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2008 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2009 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2010 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2015 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
2017 if (dgview == NULL) return;
2019 //disconnect signals
2020 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2021 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2022 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2023 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2024 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2025 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2026 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2027 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2028 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2029 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2030 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2031 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2034 gViewDlgBox[dgview] = currentDialog;
2036 //close opened dialog
2037 if (currentDialog != NULL) currentDialog->close();
2038 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2044 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2046 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2050 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2054 //switch off the current document graphic view (disconnect signals...)
2055 if (currentDocGView != NULL)
2057 //Hide current actor
2059 switchOffGraphicView(currentDocGView);
2062 //clear the dialogs used by the current model so they can be used by the new model
2063 if (currentDocGView != dgview) clearDialogs();
2065 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2066 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2067 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2068 _groupsTreeView->setModel(dgview->getGroupsModel());
2069 _meshTreeView->setModel(dgview->getMeshModel());
2071 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2072 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2074 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2075 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2077 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2078 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2080 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2081 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2083 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2084 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2087 // = * init occ view * =
2088 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2090 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2091 currentOccGView->getViewWindow()->installEventFilter(this);
2096 // = * init vtk view * =
2097 if (currentDocGView != NULL)
2099 if (currentDocGView->getViewWindow() != NULL)
2100 dgview->setViewWindow(currentDocGView->getViewWindow());
2103 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2104 dgview->getViewWindow()->installEventFilter(this);
2110 switchOnGraphicView(dgview);
2112 if (currentDocGView != NULL)
2114 lastVtkDocGView = currentDocGView;
2115 lastOccPrs = getOccPrs(currentDocGView);
2119 lastVtkDocGView = dgview;
2120 lastOccPrs = getOccPrs(dgview);
2123 currentDocGView = dgview;
2125 currentDocGView->getDocumentModel()->refresh();
2126 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2129 setAllMenusEnabled(true);
2132 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2134 if (currentDocGView == NULL) return NULL;
2135 return currentDocGView->getDocumentModel();
2139 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2141 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2142 if (anApp == NULL) return UNKNOWN;
2143 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2144 if (activeVm == NULL) return UNKNOWN;
2146 QString vmType = activeVm->getType();
2147 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2149 else if ( vmType == OCCViewer_Viewer::Type() )
2155 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2157 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2161 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2164 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2166 // Create Document from HEXABLOCK ENGINE
2167 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2168 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2170 // looking doc impl ( c++ )
2171 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2172 // ^Hexa6 ASSERT( dServant );
2173 // ^Hexa6 if ( dServant)
2174 // ^Hexa6 doc = dServant->GetImpl();
2176 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2177 QString docEntry = addDocInStudy (doc);
2179 // looking for docEntry
2180 /* ****************************************************************
2181 if ( !CORBA::is_nil(docIn) ){
2182 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2183 QString docIOR = anIOR.in();
2184 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2185 if ( !docIOR.isEmpty() ) {
2186 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2188 docEntry = SO->GetID().c_str();
2191 **************************************************************** */
2192 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2194 return make_pair (docEntry, doc);
2198 void HEXABLOCKGUI::newDocument()
2200 DEBTRACE("HEXABLOCKGUI::newDocument");
2203 QMainWindow *aParent = application()->desktop();
2204 QWidget *central = aParent->centralWidget();
2206 central->setFocus();
2208 DEBTRACE("No Central Widget");
2211 if (currentOccGView == NULL)
2213 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2214 application()->desktop());
2215 currentOccGView->getViewWindow()->installEventFilter(this);
2217 else if (currentOccGView->getViewWindow() == NULL)
2219 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2220 currentOccGView->getViewWindow()->installEventFilter(this);
2224 // Create Document from HEXABLOCK ENGINE
2225 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2227 VtkDocumentGraphicView* newGraphicView = NULL;
2228 //One document at a time
2229 if (currentDocGView != NULL)
2231 if (currentDocGView->getViewWindow() == NULL)
2233 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2234 currentDocGView->getViewWindow()->installEventFilter(this);
2237 // Create a new document with the current window
2238 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2239 new DocumentModel( docEntry_Doc.second,
2240 docEntry_Doc.first, this ),
2241 currentDocGView->getViewWindow(),
2242 application()->desktop() );
2246 // Create the new Document Graphic View with a new window
2247 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2248 new DocumentModel( docEntry_Doc.second,
2249 docEntry_Doc.first, this ),
2250 graphicViewsHandler->createVtkWindow(),
2251 application()->desktop() );
2252 newGraphicView->getViewWindow()->installEventFilter(this);
2255 if (newGraphicView == NULL)
2256 //We couldn't create a new document graphic view
2257 //we'd better show a dialog box info to inform the user
2260 docs[docEntry_Doc.first] = newGraphicView;
2261 switchModel(newGraphicView); //select the corresponding document in the browser instead
2263 getApp()->updateObjectBrowser();
2268 //Loads the model from the xmlFile in the current graphic view
2269 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2271 DEBTRACE("HEXABLOCKGUI::loadDocument");
2274 QMainWindow *aParent = application()->desktop();
2275 QString selectedFile;
2277 if ( inFile.isNull() ){
2278 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2279 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2280 dialog.setHistory( getQuickDirList() );
2282 //use the last path as default
2283 if (!(loadDocLastPath->absolutePath()).isEmpty())
2284 dialog.setDirectory(*loadDocLastPath);
2287 QStringList selectedFiles = dialog.selectedFiles();
2288 if (!selectedFiles.isEmpty())
2289 selectedFile = selectedFiles.first();
2291 //remember the selected path
2292 *loadDocLastPath = dialog.directory();
2295 selectedFile = inFile;
2297 if (selectedFile.isEmpty())
2300 //we create a new document if necessary
2301 if (currentDocGView == NULL)
2302 //Need a new document
2304 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2306 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2307 currentDocGView->getViewWindow()->installEventFilter(this);
2310 if (!currentDocGView->isEmpty())
2311 //we can only have one document for a graphic view
2314 //we load the selected file in the current graphic view
2315 currentDocGView->loadDocument(selectedFile);
2316 DocumentModel* currentModel = getCurrentModel();
2317 renameObject( currentModel->documentEntry(), currentModel->getName() );
2322 void HEXABLOCKGUI::saveDocument()
2324 QMainWindow *aParent = application()->desktop();
2326 QString aDocName = "document", aFilename;
2328 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2329 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2331 //use the last selected directory as default path for file selection
2332 aFilename = saveDocLastPath->absolutePath();
2333 if (!aFilename.isEmpty())
2334 aFilename += QString("/") + aDocName;
2336 //show the dialog for file selection
2337 aFilename = SUIT_FileDlg::getFileName( aParent,
2340 tr( "Save HexaBlock Document" ),
2343 //save the document in the selected file
2344 if ( !aFilename.isEmpty() ) {
2345 getCurrentVtkGraphicView()->saveDocument( aFilename );
2347 //Remember the path for next save
2348 QFileInfo fileInfo(aFilename);
2349 *saveDocLastPath = fileInfo.dir();
2355 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2357 _patternDataTreeView->openPersistentEditor( topLeft );
2360 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2362 if (diag == NULL || _dwInputPanel == NULL ||
2363 getCurrentVtkGraphicView() == NULL) return;
2365 //mark this dialog as used by the current model
2366 currentModelDialogs.insert(diag);
2368 //close the current dialog box info
2369 // if (_treeViewDelegate != NULL)
2370 // _treeViewDelegate->closeDialog();
2372 // if (_dwInputPanel->widget())
2373 // _dwInputPanel->widget()->close();
2375 //Temporary for debugging EdgeAssoc Faked InfoDialog
2376 if (diag == _edgeAssocDiag)
2377 diag->debugEdgeAssoc = true;
2379 diag->debugEdgeAssoc = false;
2381 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2382 diag == _quadAssocDiag || diag == _addShapeDiag)
2383 assocInProgress = true;
2385 assocInProgress = false;
2387 //show the dialog box in the dockwidget
2388 diag->resetSizeAndShow(_dwInputPanel);
2390 //clear the current selections
2391 selectionMgr()->clearSelected();
2393 currentDialog = diag;
2396 if (currentDocGView != NULL)
2397 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2400 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2402 if (vertex == NULL || _dwInputPanel == NULL)
2405 if (_vertexInfoDialog == NULL)
2406 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2408 _vertexInfoDialog->setValue(vertex);
2409 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2410 currentDialog = _vertexInfoDialog;
2413 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2415 if (edge == NULL || _dwInputPanel == NULL)
2418 if (_edgeInfoDialog == NULL)
2419 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2421 _edgeInfoDialog->setValue(edge);
2422 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2423 currentDialog = _edgeInfoDialog;
2426 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2428 if (quad == NULL || _dwInputPanel == NULL)
2431 if (_quadInfoDialog == NULL)
2432 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2434 _quadInfoDialog->setValue(quad);
2435 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2436 currentDialog = _quadInfoDialog;
2439 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2441 if (hexa == NULL || _dwInputPanel == NULL)
2444 if (_hexaInfoDialog == NULL)
2445 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2447 _hexaInfoDialog->setValue(hexa);
2448 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2449 currentDialog = _hexaInfoDialog;
2452 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2454 if (vector == NULL || _dwInputPanel == NULL)
2457 if (_vectorInfoDialog == NULL)
2458 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2460 _vectorInfoDialog->setValue(vector);
2461 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2462 currentDialog = _vectorInfoDialog;
2465 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2467 if (group == NULL || _dwInputPanel == NULL)
2470 if (_groupInfoDialog == NULL)
2471 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2473 _groupInfoDialog->setValue(group);
2474 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2475 currentDialog = _groupInfoDialog;
2478 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2480 if (law == NULL || _dwInputPanel == NULL)
2483 if (_lawInfoDialog == NULL)
2484 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2486 _lawInfoDialog->setValue(law);
2487 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2488 currentDialog = _lawInfoDialog;
2491 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2493 if (propagation == NULL || _dwInputPanel == NULL)
2496 if (_propagationInfoDialog == NULL)
2497 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2499 _propagationInfoDialog->setValue(propagation);
2500 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2501 currentDialog = _propagationInfoDialog;
2504 void HEXABLOCKGUI::addVertex()
2506 if ( !_vertexDiag ){
2507 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2509 _showDialogBox( _vertexDiag );
2512 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2513 if (_vertexDiag != NULL && doc != NULL)
2514 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2517 void HEXABLOCKGUI::addEdge()
2520 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2522 _showDialogBox( _edgeDiag );
2525 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2526 if (_edgeDiag != NULL && doc != NULL)
2527 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2530 void HEXABLOCKGUI::addQuad()
2533 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2536 _showDialogBox( _quadDiag );
2539 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2540 if (_quadDiag != NULL && doc != NULL)
2541 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2544 void HEXABLOCKGUI::addHexa()
2547 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2549 _showDialogBox( _hexaDiag );
2552 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2553 if (_hexaDiag != NULL && doc != NULL)
2554 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2557 void HEXABLOCKGUI::addVector()
2559 if ( !_vectorDiag ){
2560 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2562 _showDialogBox( _vectorDiag );
2565 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2566 if (_vectorDiag != NULL && doc != NULL)
2567 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2570 //void HEXABLOCKGUI::addCylinder()
2572 // if ( !_cylinderDiag ){
2573 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2575 // _showDialogBox( _cylinderDiag );
2577 // //set default name
2578 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2579 // if (_cylinderDiag != NULL && doc != NULL)
2580 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2584 //void HEXABLOCKGUI::addPipe()
2586 // if ( !_pipeDiag){
2587 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2589 // _showDialogBox( _pipeDiag );
2591 // //set default name
2592 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2593 // if (_pipeDiag != NULL && doc != NULL)
2594 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2598 void HEXABLOCKGUI::makeGrid()
2600 if ( !_makeGridDiag ){
2601 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2603 _showDialogBox( _makeGridDiag );
2607 void HEXABLOCKGUI::makeCylinder()
2609 if ( !_makeCylinderDiag ){
2610 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2612 _showDialogBox( _makeCylinderDiag );
2615 void HEXABLOCKGUI::makePipe()
2617 if ( !_makePipeDiag ){
2618 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2620 _showDialogBox( _makePipeDiag );
2623 void HEXABLOCKGUI::makeCylinders()
2625 if ( !_makeCylindersDiag ){
2626 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2628 _showDialogBox( _makeCylindersDiag );
2631 void HEXABLOCKGUI::makePipes()
2633 if ( !_makePipesDiag ){
2634 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2636 _showDialogBox( _makePipesDiag );
2640 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2642 if ( !_makeHemiSphereDiag ){
2643 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2645 _showDialogBox( _makeHemiSphereDiag );
2649 void HEXABLOCKGUI::removeHexa()
2651 if ( !_removeHexaDiag ){
2652 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2654 _showDialogBox( _removeHexaDiag );
2658 void HEXABLOCKGUI::prismQuad()
2660 if ( !_prismQuadDiag ){
2661 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2663 _showDialogBox( _prismQuadDiag );
2667 void HEXABLOCKGUI::joinQuad()
2669 if ( !_joinQuadDiag ){
2670 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2672 _showDialogBox( _joinQuadDiag );
2675 void HEXABLOCKGUI::merge()
2678 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2680 _showDialogBox( _mergeDiag );
2683 void HEXABLOCKGUI::disconnectElts()
2685 if ( !_disconnectDiag ){
2686 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2688 _showDialogBox( _disconnectDiag );
2691 void HEXABLOCKGUI::cutEdge()
2693 if ( !_cutEdgeDiag ){
2694 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2696 _showDialogBox( _cutEdgeDiag );
2699 void HEXABLOCKGUI::makeTransformation()
2701 if ( !_makeTransformationDiag ){
2702 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2704 _showDialogBox( _makeTransformationDiag );
2708 void HEXABLOCKGUI::makeSymmetry()
2710 if ( !_makeSymmetryDiag ){
2711 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2713 _showDialogBox( _makeSymmetryDiag );
2717 void HEXABLOCKGUI::performTransformation()
2719 if ( !_performTransformationDiag ){
2720 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2722 _showDialogBox( _performTransformationDiag );
2726 void HEXABLOCKGUI::performSymmetry()
2728 if ( !_performSymmetryDiag ){
2729 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2731 _showDialogBox( _performSymmetryDiag );
2735 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2737 if ( !_replaceHexaDiag ){
2738 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2740 _showDialogBox( _replaceHexaDiag );
2744 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2746 if ( !_quadRevolutionDiag ){
2747 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2749 _showDialogBox( _quadRevolutionDiag );
2753 void HEXABLOCKGUI::assocVertex()
2755 if (!_dwInputPanel) return;
2756 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2757 if ( !_vertexAssocDiag )
2758 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2759 _showDialogBox( _vertexAssocDiag );
2763 void HEXABLOCKGUI::assocEdge()
2765 if ( !_edgeAssocDiag )
2766 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2767 _showDialogBox( _edgeAssocDiag );
2770 void HEXABLOCKGUI::assocQuad()
2772 if ( !_quadAssocDiag )
2773 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2774 _showDialogBox( _quadAssocDiag );
2778 void HEXABLOCKGUI::addGroup()
2781 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2783 _showDialogBox( _groupDiag );
2784 if (_groupDiag != NULL && getCurrentModel() != NULL)
2786 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2787 if (doc == NULL) return;
2788 char defaultName[16];
2789 sprintf (defaultName, "g%04d", doc->countGroup());
2790 _groupDiag->name_le->setText(defaultName);
2794 void HEXABLOCKGUI::removeGroup()
2796 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2797 if (currentDGView == NULL) return;
2799 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2800 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2801 int nbGroupsRemoved = 0;
2804 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2805 tr( "No group selected!" ) );
2809 foreach( QModelIndex selected, l ){
2810 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2811 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2812 Q_ASSERT(selected.isValid());
2814 //Confirm the deletion of the group
2815 if (SUIT_MessageBox::question(
2818 tr("Remove group : %1 ?").arg(selected.data().toString()),
2819 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2820 SUIT_MessageBox::Cancel
2821 ) == SUIT_MessageBox::Cancel) return;
2823 bool removed = getCurrentModel()->removeGroup( selected );
2825 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2826 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2832 if (!nbGroupsRemoved)
2833 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2834 tr( "No group selected!" ) );
2837 void HEXABLOCKGUI::addLaw()
2840 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2842 _showDialogBox( _lawDiag );
2843 if (_lawDiag != NULL && getCurrentModel() != NULL)
2845 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2846 if (doc == NULL) return;
2847 char defaultName[16];
2848 sprintf (defaultName, "l%04d", doc->countLaw());
2849 _lawDiag->name_le->setText(defaultName);
2853 void HEXABLOCKGUI::removeLaw()
2855 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2856 if (currentDGView == NULL) return;
2858 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2859 int nbLawsRemoved = 0;
2862 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2863 tr( "No law selected!" ) );
2867 foreach( QModelIndex selected, l ){
2868 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2869 selected = currentDGView->getMeshModel()->mapToSource( selected );
2870 Q_ASSERT(selected.isValid());
2872 //Confirm the deletion of the law
2873 if (SUIT_MessageBox::question(
2876 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2877 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2878 SUIT_MessageBox::Cancel
2879 ) == SUIT_MessageBox::Cancel) return;
2881 bool removed = getCurrentModel()->removeLaw(selected);
2883 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2884 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2891 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2892 tr( "No law selected!" ) );
2897 void HEXABLOCKGUI::setPropagation()
2899 if ( !_propagationDiag )
2900 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2902 _showDialogBox( _propagationDiag );
2905 // Dialog box to compute a mesh from a document
2906 // --------------------------------------------
2907 void HEXABLOCKGUI::computeMesh()
2909 if ( !_computeMeshDiag )
2910 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2912 _showDialogBox( _computeMeshDiag );
2915 void HEXABLOCKGUI::clearAssociations()
2917 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2918 if (currentDGView == NULL) return;
2920 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2921 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2922 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2924 getCurrentModel()->clearEltAssociations(iModel);
2926 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2929 void HEXABLOCKGUI::showModelInfo()
2931 //create the info dialog if not yet
2932 if (_modelInfoDiag == NULL)
2933 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2935 //show the model informations dialog
2936 _showDialogBox( _modelInfoDiag );
2939 void HEXABLOCKGUI::addShape()
2941 //create the info dialog if not yet
2942 if (_addShapeDiag == NULL)
2943 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2945 //show the model informations dialog
2946 _showDialogBox( _addShapeDiag );
2949 void HEXABLOCKGUI::clearAllAssociations()
2951 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2952 if (currentDGView == NULL) return;
2954 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2955 if (!currentIndex.isValid()) return;
2956 QVariant currentAssocVariant;
2957 QString currentAssocEntry;
2959 //Confirm the deletion of the associations
2960 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2961 if ( !treeVariant.isValid() ) return;
2962 int eltType = treeVariant.toInt();
2963 QString typeStr = "";
2964 HEXA_NS::EnumElt hexaType;
2965 if (eltType == VERTEX_DIR_TREE)
2967 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2968 hexaType = HEXA_NS::EL_VERTEX;
2970 else if (eltType == EDGE_DIR_TREE)
2972 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2973 hexaType = HEXA_NS::EL_EDGE;
2975 else if (eltType == QUAD_DIR_TREE)
2977 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2978 hexaType = HEXA_NS::EL_QUAD;
2981 if (SUIT_MessageBox::question(
2983 tr("CLEAR_ASSOCIATIONS"),
2984 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2985 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2986 SUIT_MessageBox::Cancel
2987 ) == SUIT_MessageBox::Cancel) return;
2990 DocumentModel* docModel = getCurrentModel();
2991 if (docModel == NULL) return;
2992 docModel->clearAssociation(hexaType);
2995 void HEXABLOCKGUI::showAssociations()
2997 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2998 if (currentDGView == NULL) return;
3000 QModelIndexList elts;
3001 int currentChildIndex = 0;
3002 QVariant currentAssocVariant;
3003 QString currentAssocEntry;
3004 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
3005 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
3007 while( currentChild.isValid() ) {
3009 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
3010 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
3011 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
3012 elts << currentChild;
3014 currentChild = currentChild.sibling(currentChildIndex++, 0);
3016 currentDocGView->highlight(elts);
3017 currentOccGView->highlight(elts, false);
3021 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3023 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3025 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3030 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3032 if ( event->type() == QEvent::Enter )
3033 { // *** ENTER EVENT
3035 if (currentDialog == NULL || !currentDialog->isVisible())
3036 return QObject::eventFilter(obj, event);
3038 // ** The window acquire the focus when the cursor enter
3040 //OCC - window enter
3041 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3042 if ( occWindow != NULL)
3043 currentDialog->onWindowActivated(occWindow->getViewManager());
3045 //VTK - window enter
3047 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3048 if ( vtkWindow != NULL)
3049 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3053 //standard event processing
3054 return QObject::eventFilter(obj, event);
3057 QStringList HEXABLOCKGUI::getQuickDirList()
3059 QStringList dirList;
3060 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3062 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3068 // --- Export the module
3072 HEXABLOCK_EXPORT CAM_Module* createModule()
3074 return new HEXABLOCKGUI();
3077 HEXABLOCK_EXPORT char* getModuleVersion()
3079 return (char*)HEXABLOCK_VERSION_STR;
3085 // ******************** TESTS ***************************************************
3087 void HEXABLOCKGUI::testDocument()
3091 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3092 // QStandardItem *myItem = new QStandardItem("MyItem");
3093 // parentItem->appendRow(myItem);
3095 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3096 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3097 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3098 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3099 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3100 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3101 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3102 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3105 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3106 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3107 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3108 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3109 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3110 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3112 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3113 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3114 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3115 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3120 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3121 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3122 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3123 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3131 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3132 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3134 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3135 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3139 // newMesh( "toto", 3, "FactoryServer");
3143 void HEXABLOCKGUI::test_make_cart_grid()
3145 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3146 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3147 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3148 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3149 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3150 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3152 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3153 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3160 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3161 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3162 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3163 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3164 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3165 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3170 void HEXABLOCKGUI::test_make_elmts_transform()
3177 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3178 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3181 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3182 // orig.setScalar(2);
3184 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3185 // getCurrentModel()->saveVtk(file_name)
3187 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3188 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3190 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3191 // getCurrentModel()->saveVtk(file_name)
3193 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3196 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3197 // getCurrentModel()->saveVtk(file_name);
3200 // print "...test make elements by transforming elements OK"
3202 // =============================================================== addDocInSudy
3203 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3207 if (document == NULL)
3210 QString docName = document->getName ();
3212 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3213 if (app_study == NULL)
3216 SALOMEDS::Study_var ds_study = ClientStudy();
3217 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3218 QString entry = app_study->centry("HEXABLOCK");
3219 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3220 if (aFatherSO->_is_nil())
3223 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3226 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3227 docEntry = aSO->GetID(); //the entry of the published object
3232 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3234 void HEXABLOCKGUI::test()
3236 DEBTRACE("HEXABLOCKGUI::test");
3237 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3238 if (currentDGView == NULL) return;
3239 currentDGView->update();
3243 void HEXABLOCKGUI::test_association()
3245 DEBTRACE("HEXABLOCKGUI::test_association");
3248 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3250 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3251 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3252 DocumentModel::GeomObj q0AssocA, q0AssocB;
3254 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3255 QList<DocumentModel::GeomObj> e1Assocs_test;
3256 DocumentModel::GeomObj q0Assoc_test;
3258 v0 = getCurrentModel()->addVertex(0, 0, 0);
3259 v1 = getCurrentModel()->addVertex(1, 0, 0);
3260 v2 = getCurrentModel()->addVertex(1, 1, 0);
3261 v3 = getCurrentModel()->addVertex(0, 1, 0);
3262 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3263 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3264 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3267 // >>> face3.GetEntry()'0:1:4'
3268 // >>> e1.GetEntry()'0:1:8'
3269 // >>> e2.GetEntry()'0:1:9'
3270 // >>> e3.GetEntry()'0:1:10'
3271 // >>> e4.GetEntry()'0:1:11'
3272 // >>> v1.GetEntry()'0:1:12'
3273 // >>> v2.GetEntry()'0:1:13'
3274 // >>> v3.GetEntry()'0:1:14'
3275 // >>> v4.GetEntry()'0:1:15'
3278 // v0Assoc.name = "geomV0";
3279 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3280 // v0Assoc.brep = "brepV0";
3281 // v1Assoc.name = "geomV1";
3282 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3283 // v1Assoc.brep = "brepV1";
3284 // v2Assoc.name = "geomV2";
3285 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3286 // v2Assoc.brep = "brepV2";
3287 // v3Assoc.name = "geomV3";
3288 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3289 // v3Assoc.brep = "brepV3";
3293 // e0AssocA.name = "geomE0a";
3294 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3295 // e0AssocA.brep = "brepE0a";
3296 // e0AssocA.start = 0.10;
3297 // e0AssocA.end = 0.95;
3301 // e1AssocA.name = "geomE1a";
3302 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3303 // e1AssocA.brep = "brepE1a";
3304 // e1AssocA.start = 0.12;
3305 // e1AssocA.end = 0.89;
3306 // e1AssocB.name = "geomE1b";
3307 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3308 // e1AssocB.brep = "brepE1b";
3309 // e1AssocB.start = 0.20;
3310 // e1AssocB.end = 0.80;
3311 // e1AssocC.name = "geomE1c";
3312 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3313 // e1AssocC.brep = "brepE1c";
3314 // e1AssocC.start = 0.16;
3315 // e1AssocC.end = 0.96;
3317 // q0AssocA.name = "geomQuad";
3318 // q0AssocA.entry = "0:1:1:1:3";
3319 // q0AssocA.brep = "brepq0";
3321 // q0AssocB.name = "geomQuad";
3322 // q0AssocB.entry = "0:1:1:1:4";
3323 // q0AssocB.brep = "brepq0";
3325 // getCurrentModel()->addAssociation( v0, v0Assoc );
3326 // getCurrentModel()->addAssociation( v1, v1Assoc );
3327 // getCurrentModel()->addAssociation( v2, v2Assoc );
3328 // getCurrentModel()->addAssociation( v3, v3Assoc );
3331 // getCurrentModel()->addAssociation( e0, e0AssocA );
3333 // getCurrentModel()->addAssociation( e1, e1AssocA );
3334 // getCurrentModel()->addAssociation( e1, e1AssocB );
3335 // getCurrentModel()->addAssociation( e1, e1AssocC );
3337 // getCurrentModel()->addAssociation( q0, q0AssocA );
3338 // getCurrentModel()->addAssociation( q0, q0AssocB );
3344 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3345 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3346 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3347 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3348 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3349 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3350 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3351 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3352 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3353 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3354 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3355 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3358 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3359 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3360 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3361 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3362 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3363 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3364 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3365 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3366 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3367 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3368 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3369 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3370 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3372 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3373 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3374 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3377 DEBTRACE("HEXABLOCKGUI::test_association fin");