-// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2009-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <cassert>
-
+#include <QDir>
#include <QInputDialog>
#include <QIcon>
#include <QStackedWidget>
+#include <QMenu>
+#include <QSplitter>
#include <QtxTreeView.h>
#include <SUIT_MessageBox.h>
#include <SALOME_ListIO.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
#include <SALOME_LifeCycleCORBA.hxx>
// #include "HexDocument_impl.hxx" del Hexa6
#include "Hex.hxx"
-
-#include <Visual3d_ViewManager.hxx>
//#include <V3d_PerspectiveView.hxx>
#include <V3d_AmbientLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <utilities.h>
#define DW_MINIMUM_WIDTH 50
#define DWINPUT_MINIMUM_HEIGHT 50
using namespace std;
using namespace HEXABLOCK::GUI;
-int HEXABLOCKGUI::_oldStudyId = -1;
-
// HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
//
VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
_dwAssociation(0),
_dwGroups(0),
_dwMesh(0),
- _dwObjectBrowser(0),
+// _dwObjectBrowser(0),
_dwInputPanel(0),
_patternDataTreeView(0),
// _patternBuilderTreeView(0),
createActions();
createMenus();
createTools();
- studyActivated();
}
void HEXABLOCKGUI::viewManagers( QStringList& list ) const
connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
- connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
- this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
+ if ( getApp()->objectBrowser() ) {
+ connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
+ this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
+ }
LightApp_SelectionMgr* sm = getApp()->selectionMgr();
this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
}
- /* ************************************ TODO Hexa6
- _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
- if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
- if ( _PTR(Study) aStudy = s->studyDS()) {
- _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
- updateObjBrowser(); // objects can be removed
- }
- ************************************ */
-
if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
currentOccGView->getViewWindow()->installEventFilter(this);
hideActor();
+ if(currentOccGView) {
+ delete currentOccGView;
+ currentOccGView = NULL;
+ }
+
+ if(currentDocGView) {
+ delete currentDocGView;
+ currentDocGView = NULL;
+ }
+
return bOk;
}
-SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
+SALOMEDS::Study_var HEXABLOCKGUI::getStudyServant()
{
- SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
- CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
- int aStudyID = theStudy->StudyId();
- SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
+ SALOME_NamingService_Abstract *aNamingService = SalomeApp_Application::namingService();
+ CORBA::Object_var aSMObject = aNamingService->Resolve("/Study");
+ SALOMEDS::Study_var aDSStudy = SALOMEDS::Study::_narrow(aSMObject);
return aDSStudy._retn();
}
SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
if(!appStudy) return;
- _PTR(Study) aStudy = appStudy->studyDS();
- SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
+ SALOMEDS::Study_var aDSStudy = getStudyServant();
SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
QString entry = currentDocGView->getDocumentModel()->documentEntry();
SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
SOCC_Prs* prs = getOccPrs(currentDocGView);
if (prs == NULL)
{
- prs = new SOCC_Prs();
+ prs = new SOCC_Prs(0);
isNewPrs = true;
}
if (dgview == NULL || dgview->getDocumentModel() == NULL)
return result;
- SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
- SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
-
- if(!appStudy)
- return result;
-
- _PTR(Study) aStudy = appStudy->studyDS();
-
- if(!aStudy)
- return result;;
-
- _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
+ _PTR(SObject) obj ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(entry)) );
_PTR(GenericAttribute) anAttr;
if ( obj ){
- if ( obj->FindAttribute(anAttr, "AttributeName") ){
- _PTR(AttributeName) aName (anAttr);
- DocumentModel* docModel = dgview->getDocumentModel();
- docModel->setName( name );
- aName->SetValue( name.toLatin1().data() );
- getApp()->updateObjectBrowser();
-// _dwPattern->setWindowTitle( name );
- result = true;
- }
+ if ( obj->FindAttribute(anAttr, "AttributeName") ) {
+ _PTR(AttributeName) aName (anAttr);
+ DocumentModel* docModel = dgview->getDocumentModel();
+ docModel->setName( name );
+ aName->SetValue( name.toLatin1().data() );
+ getApp()->updateObjectBrowser();
+// _dwPattern->setWindowTitle( name );
+ result = true;
+ }
}
return result;
}
DEBTRACE("HEXABLOCKGUI::windows");
theMap.clear();
theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+#ifndef DISABLE_PYCONSOLE
theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
+#endif
}
QString HEXABLOCKGUI::engineIOR() const
DEBTRACE("HEXABLOCKGUI::createSComponent");
// --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
- _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
_PTR(GenericAttribute) anAttr;
_PTR(AttributeName) aName;
// _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
}
-void HEXABLOCKGUI::studyActivated() //CS_TODO
-{
- int newStudyId = getApp()->activeStudy()->id();
- DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
-// if (_oldStudyId != -1)
-// {
-// _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
-// if (_studyContextMap.count(newStudyId))
-// {
-// DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
-// QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
-// }
-// else
-// {
-// DEBTRACE("no switch to null context");
-// }
-// }
- _oldStudyId = newStudyId;
-}
-
void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
{
QModelIndex currentIndex = _patternDataTreeView->currentIndex();
+
+ // if nothing is selected, return
+ if (! currentIndex.isValid())
+ return;
+
QVariant currentAssocVariant;
QString currentAssocEntry;
_dwInputPanel = new QDockWidget(aParent);
_dwInputPanel->setVisible(false);
_dwInputPanel->setWindowTitle("Input Panel");
+ _dwInputPanel->setObjectName("hexablockInputPanelDock");
// _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
// _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
_dwPattern->setVisible(false);
_dwPattern->setWindowTitle("Model");
_dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
+ _dwPattern->setObjectName("hexablockModelDock");
QFrame* patternFrame = new QFrame(_dwPattern);
patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
_dwGroups->setVisible(false);
_dwGroups->setWindowTitle("Groups");
_dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
+ _dwGroups->setObjectName("hexablockGroupsDock");
_groupsTreeView = new QTreeView(_dwGroups);
_groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
// _groupsTreeView->setItemDelegate(_treeViewDelegate);
_dwMesh->setVisible(false);
_dwMesh->setWindowTitle("Mesh");
_dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
+ _dwMesh->setObjectName("hexablockMeshDock");
_meshTreeView = new QTreeView(_dwMesh);
_meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
_meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
_dwMesh->setWidget(_meshTreeView);
_meshTreeView->show();
- QDockWidget *_dwObjectBrowser = 0;
- QWidget* wid = getApp()->objectBrowser()->treeView();
- QWidget *w = wid->parentWidget();
- while ( w && !_dwObjectBrowser ) {
- _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
- w = w->parentWidget();
+// QDockWidget *_dwObjectBrowser = 0;
+ QWidget* wid = 0;
+ if ( getApp()->objectBrowser() )
+ wid = getApp()->objectBrowser()->treeView();
+ while ( wid && !_dwObjectBrowser ) {
+ _dwObjectBrowser = ::qobject_cast<QDockWidget*>( wid );
+ wid = wid->parentWidget();
+ }
+
+ if ( _dwObjectBrowser ) {
+ _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
+ _dwObjectBrowser->setWindowTitle("Study");
}
- _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
- _dwObjectBrowser->setWindowTitle("Study");
// dock widget position
- aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
+ if ( _dwObjectBrowser ) {
+ aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
+ }
aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
// aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
// aParent->tabifyDockWidget( _dwGroups, _dwPattern );
// aParent->tabifyDockWidget( _dwMesh, _dwGroups );
- aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
+ if ( _dwObjectBrowser ) {
+ aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
+ }
aParent->tabifyDockWidget( _dwPattern, _dwGroups );
aParent->tabifyDockWidget( _dwGroups, _dwMesh );
-
-#if QT_VERSION >= 0x040500
aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
-#endif
// popup menu on data tree view
_patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
{
int aToolId;
- aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
+ aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
createTool( _newAct, aToolId );
createTool( _importAct, aToolId );
createTool( _saveAct, aToolId );
//createTool( separator(), aToolId );
// Pattern Data
- aToolId = createTool ( tr( "Construction" ) );
+ aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
createTool( _addVertex, aToolId );
createTool( _addEdge, aToolId );
createTool( _addQuad, aToolId );
createTool( _makePipes, aToolId );
// Pattern Data Edition
- aToolId = createTool ( tr( "Operation" ) );
+ aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
createTool( _removeHexa, aToolId );
createTool( _prismQuad, aToolId );
createTool( _joinQuad, aToolId );
createTool( _quadRevolution, aToolId );
// Association
- aToolId = createTool ( tr( "Association" ) );
+ aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
createTool( _assocVertex, aToolId );
createTool( _assocEdge, aToolId );
createTool( _assocQuad, aToolId );
createTool( _addShapeAct, aToolId );
// Group
- aToolId = createTool ( tr( "Group" ) );
+ aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
createTool( _addGroup, aToolId );
createTool( _removeGroup, aToolId ); //CS_TODO
// Law
- aToolId = createTool ( tr( "Mesh" ) );
+ aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
createTool( _addLaw, aToolId );
createTool( _removeLaw, aToolId );
createTool( _setPropagation, aToolId );
DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
- if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
if (_dwPattern) _dwPattern->setVisible(isVisible);
if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
if (app_study == NULL)
return docEntry;
- _PTR(Study) study = app_study->studyDS();
- SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
+ SALOMEDS::Study_var ds_study = getStudyServant();
SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
QString entry = app_study->centry("HEXABLOCK");
SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );