+++ /dev/null
-// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
-//
-// 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.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "HEXABLOCKGUI_Browser.hxx"
-#include "HEXABLOCKGUI.hxx"
-
-#include "Hex.hxx"
-#include "HexDocument.hxx"
-
-#include <LightApp_Module.h>
-#include <LightApp_Study.h>
-#include <LightApp_Application.h>
-#include <LightApp_DataModel.h>
-#include <LightApp_DataObject.h>
-
-// --------------------------------------------------- classe SaLObject
-class SalObject : public LightApp_DataObject
-{
-public :
- SalObject (cpchar nom="") : LightApp_DataObject (NULL)
- { obj_name = nom ; obj_entry = "6.6.66" ; }
-
- virtual ~SalObject () { cout << "SalObject::delete" << endl ; }
- virtual QString name () const { return obj_name ; }
- virtual QString entry () const { return obj_entry ; }
- void rename (cpchar nom) { obj_name = nom ; }
-
-private :
- QString obj_name;
- QString obj_entry;
-};
-//--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
-// --------------------------------------------------- classe SaLModel
-class SalModel : public LightApp_DataModel
-{
-public :
- SalModel (HEXABLOCKGUI* guy);
- void clear ();
- void addItem (cpchar fils);
-
-private :
- CAM_ModuleObject* obj_root;
-};
-
-// =================================================== Constructeur SalModel
-SalModel::SalModel (HEXABLOCKGUI* guy)
- : LightApp_DataModel (guy)
-{
-/* **********************************************
- LightApp_Study* study = (LightApp_Study*) guy->activeStudy();
- obj_root = createModuleObject (study->root());
-
- obj_root ->setDataModel (this);
- setRoot (obj_root);
-
- SalObject* obj1 = new SalObject ("Document1");
- SalObject* obj2 = new SalObject ("Document2");
-
- PutData (obj1->name ().toStdString());
- PutData (obj2->name ().toStdString());
-
- obj_root->appendChild (obj1);
- obj_root->appendChild (obj2);
- PutData (obj_root->childCount());
-
- ********************************************** */
-}
-// ================================================================ clear
-void SalModel::clear ()
-{
- const bool nodel = false;
- while (true)
- {
- SUIT_DataObject* obj = obj_root->firstChild ();
- if (obj==NULL)
- return;
- obj_root->removeChild (obj, nodel);
- cout << " Delete object " << obj->name ().toStdString()
- << endl;
- }
-}
-// ================================================================ addItem
-void SalModel::addItem (cpchar name)
-{
- SalObject* obj1 = new SalObject (name);
- obj_root->appendChild (obj1);
-}
-//--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
-// =================================================== Constructeur H.G.Browser
-HEXABLOCKGUI_Browser::HEXABLOCKGUI_Browser (HEXABLOCKGUI* guy)
-{
- hexa_gui = guy;
- hexa_root = HEXA_NS::Hex::getInstance ();
- data_model = NULL;
-}
-
-// =============================================================== rebuildTree
-void HEXABLOCKGUI_Browser::rebuildTree ()
-{
- if (data_model==NULL)
- data_model = new SalModel (hexa_gui);
-
- data_model->clear ();
-
- int nbre = hexa_root->countDocument ();
- for (int nro=0 ; nro<nbre ; nro++)
- {
- Document* doc = hexa_root->getDocument (nro);
- cpchar nom = doc->getName ();
- data_model->addItem (nom);
- }
-
- hexa_gui->updateObjBrowser( true );
-}
-
+++ /dev/null
-// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
-//
-// 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.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _HEXABLOCKGUI_BROWSER_HXX_
-#define _HEXABLOCKGUI_BROWSER_HXX_
-
-//--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
-
-#include "hexa_base.hxx"
-#include "HEXABLOCKGUI_Export.hxx"
-
-using namespace Hex;
-
-class HEXABLOCKGUI;
-class SalModel;
-
-class HEXABLOCK_EXPORT HEXABLOCKGUI_Browser
-{
-public :
- HEXABLOCKGUI_Browser (HEXABLOCKGUI* dad);
- void rebuildTree ();
-
-
-private :
- Hex::Hex* hexa_root;
- SalModel* data_model;
- HEXABLOCKGUI* hexa_gui;
-};
-#endif
+++ /dev/null
-
-// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
-//
-// 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.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include <iostream>
-#include <QtGui>
-#include <qpixmap.h>
-#include <qrect.h>
-#include <qstyle.h>
-
-
-#include "utilities.h"
-#include "HEXABLOCKGUI.hxx"
-
-
-#include "HEXABLOCKGUI_DocumentDelegate.hxx"
-
-using namespace std;
-using namespace HEXABLOCK::GUI;
-
-
-//QWidget* currentEditor = NULL;
-
-DocumentDelegate::DocumentDelegate(QDockWidget *dw, QObject *parent)
- : QItemDelegate(parent),
- _dw(dw),
- _currentEditor(NULL)
-{
-}
-
-
-QWidget *DocumentDelegate::createEditor( QWidget *parent,
- const QStyleOptionViewItem &option,
- const QModelIndex &index ) const
-{
- //close current editor if there's one before creating a new one
- if (_currentEditor != NULL)
- {
- delete _currentEditor;
- _currentEditor = NULL;
- }
-
- HexaBaseDialog *editor = NULL;
-
- if (_dw->widget()) _dw->widget()->close();
- if ( !_dw->isVisible() ) _dw->setVisible(true);
-
- switch ( index.data(HEXA_TREE_ROLE).toInt() )
- {
- case VERTEX_TREE : editor = new VertexDialog(_dw, HexaBaseDialog::INFO_MODE); break;
- case EDGE_TREE : editor = new EdgeDialog(_dw, HexaBaseDialog::INFO_MODE); break;
- case QUAD_TREE : editor = new QuadDialog(_dw, HexaBaseDialog::INFO_MODE); break;
- case HEXA_TREE : editor = new HexaDialog(_dw, HexaBaseDialog::INFO_MODE); break;
- case VECTOR_TREE : editor = new VectorDialog(_dw, HexaBaseDialog::INFO_MODE); break;
-
-// case ELEMENTS_DIR_TREE : trouver le type exact (cylinder ou pipe) et creer la boite d'info en fonction.
-
- // * OBSOLETE ******
-// case CYLINDER_TREE : editor = new CylinderDialog(_dw, HexaBaseDialog::INFO_MODE); break;
-// case PIPE_TREE : editor = new PipeDialog(_dw, HexaBaseDialog::INFO_MODE); break;
- // ******************
-
- case GROUP_TREE : editor = new GroupDialog(_dw, HexaBaseDialog::INFO_MODE/*UPDATE_MODE*/); break;
- case LAW_TREE : editor = new LawDialog(_dw, HexaBaseDialog::INFO_MODE); break;
- case PROPAGATION_TREE : editor = new PropagationDialog(_dw, HexaBaseDialog::INFO_MODE); break;
- }
-
- if ( editor != NULL )
- {
- HEXABLOCKGUI::assocInProgress = false;
-
- //show the editor in the dockwidget
- editor->resetSizeAndShow(_dw);
- }
- else
- _dw->close();
-
- _currentEditor = editor;
-
- return editor;
-}
-
-//Close the current edition dialog
-void DocumentDelegate::closeDialog()
-{
- if (_currentEditor!=NULL)
- {
- _currentEditor->close();
- emit closeEditor(_currentEditor, NoHint); //Problem
- delete _currentEditor;
- _currentEditor = NULL;
- }
-}
-
-void DocumentDelegate::setEditorData( QWidget *editor,
- const QModelIndex &index) const
-{
- HexaBaseDialog* hexaEditor = dynamic_cast<HexaBaseDialog*>( editor );
- if (hexaEditor == NULL) return;
- DocumentModel* documentModel = hexaEditor->getDocumentModel();
- if (documentModel == NULL) return;
-
- switch ( index.data(HEXA_TREE_ROLE).toInt() ){
- case VERTEX_TREE : {
- HEXA_NS::Vertex *value = documentModel->getHexaPtr<HEXA_NS::Vertex *>(index);
- VertexDialog *vertexEditor = static_cast<VertexDialog*>(editor);
- vertexEditor->setValue(value);
- }
- break;
- case EDGE_TREE : {
- HEXA_NS::Edge *value = documentModel->getHexaPtr<HEXA_NS::Edge*>(index);
- EdgeDialog *edgeEditor = static_cast<EdgeDialog*>(editor);
- edgeEditor->setValue(value);
- }
- break;
- case QUAD_TREE : {
- HEXA_NS::Quad *value = documentModel->getHexaPtr<HEXA_NS::Quad*>(index);
- QuadDialog *quadEditor = static_cast<QuadDialog*>(editor);
- quadEditor->setValue(value);
- }
- break;
- case HEXA_TREE : {
- HEXA_NS::Hexa *value = documentModel->getHexaPtr<HEXA_NS::Hexa*>(index);
- HexaDialog *hexaEditor = static_cast<HexaDialog*>(editor);
- hexaEditor->setValue(value);
- }
- break;
- case VECTOR_TREE : {
- HEXA_NS::Vector *value = documentModel->getHexaPtr<HEXA_NS::Vector*>(index);
- VectorDialog *vectorEditor = static_cast<VectorDialog*>(editor);
- vectorEditor->setValue(value);
- }
- break;
-
- /*
- case ELEMENTS_DIR_TREE : {
- HEXA_NS::Elements* value = documentModel->getHexaPtr<HEXA_NS::Elements*>(index);
- // trouver le type exact (cylinder ou pipe) pour choisir le bon editor
- // editor->setValue(value)
- }
- break;
- */
-
- // ************ OBSOLETE ********************
-// case CYLINDER_TREE : {
-// HEXA_NS::Cylinder *value = documentModel->getHexaPtr<HEXA_NS::Cylinder*>(index);
-// CylinderDialog *cylinderEditor = static_cast<CylinderDialog*>(editor);
-// cylinderEditor->setValue(value);
-// }
-// break;
-// case PIPE_TREE : {
-// HEXA_NS::Pipe *value = documentModel->getHexaPtr<HEXA_NS::Pipe*>(index);
-// PipeDialog *pipeEditor= static_cast<PipeDialog*>(editor);
-// pipeEditor->setValue(value);
-// }
-// break;
- // ************ FIN OBSOLETE *****************
-
- case GROUP_TREE : {
- HEXA_NS::Group *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Group* >();
- GroupDialog *groupEditor = static_cast<GroupDialog*>(editor);
- groupEditor->setValue(value);
- }
- break;
- case LAW_TREE : {
- HEXA_NS::Law *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Law* >();
- LawDialog *lawEditor = static_cast<LawDialog*>(editor);
- lawEditor->setValue(value);
- }
- break;
- case PROPAGATION_TREE : {
- HEXA_NS::Propagation *value = index.data( HEXA_DATA_ROLE ).value< HEXA_NS::Propagation* >();
- PropagationDialog *propagationEditor = static_cast<PropagationDialog*>(editor);
- propagationEditor->setValue(value);
- }
- break;
- }
-}
-
-
-bool DocumentDelegate::editorEvent ( QEvent *event,
- QAbstractItemModel *model,
- const QStyleOptionViewItem &option,
- const QModelIndex &index )
-{
- return QItemDelegate::editorEvent ( event, model, option, index );
-}
-
-bool DocumentDelegate::eventFilter ( QObject * editor, QEvent * event )
-{
- if ( event->type() == QEvent::FocusOut ){
- return true; //do nothing for this signal
- }
- else if (event->type() == QEvent::HideToParent && editor != NULL)
- {
- //close the current editor when the tree is reduced
- ((QWidget*) editor->parent())->close();
- }
-
- return false;
-}
+++ /dev/null
-// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
-//
-// 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.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __HEXABLOCKGUI_DOCUMENTDELEGATE_HXX_
-#define __HEXABLOCKGUI_DOCUMENTDELEGATE_HXX_
-
-#include "HEXABLOCKGUI_Export.hxx"
-// QEvent * event, QAbstractItemModel
-
-#include <QEvent>
-#include <QItemDelegate>
-#include <QModelIndex>
-#include <QObject>
-#include <QSize>
-#include <QSpinBox>
-
-#include <QDockWidget>
-
-#include "HEXABLOCKGUI_DocumentModel.hxx"
-#include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
-#include "HEXABLOCKGUI_DocumentItem.hxx"
-#include "HEXABLOCKGUI_DocumentPanel.hxx"
-
-namespace HEXABLOCK
-{
- namespace GUI
- {
- class HEXABLOCK_EXPORT DocumentDelegate : public QItemDelegate
- {
- Q_OBJECT
-
- public:
- /// close the editor
- void closeDialog();
-
- DocumentDelegate( QDockWidget *dw, QObject *parent = 0);
-
- /// create the editor
- QWidget *createEditor( QWidget *parent,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-
- /// set editor's data
- void setEditorData( QWidget *editor, const QModelIndex &index) const;
-
- /// set the editor's model
- void setModelData( QWidget *editor,
- QAbstractItemModel *model,
- const QModelIndex &index ) const {};
-
- virtual void updateEditorGeometry( QWidget *editor,
- const QStyleOptionViewItem &option,
- const QModelIndex &index ) const {};
-
- protected:
- mutable QWidget* _currentEditor;
- virtual bool editorEvent ( QEvent * event,
- QAbstractItemModel * model,
- const QStyleOptionViewItem & option, const QModelIndex & index );
- virtual bool eventFilter ( QObject * editor, QEvent * event );
-
- private:
- QDockWidget* _dw; // creator's container
-
- private slots:
- // void commitEditor();
-
- };
- }
-}
-
-#endif