From 19aa46de591011f9df721c688d9e8dc6cc9b9938 Mon Sep 17 00:00:00 2001 From: mzn Date: Wed, 19 Mar 2014 07:32:02 +0000 Subject: [PATCH] Draft version of Z levels dialog. --- src/ZLEVEL/HYDROGUI_ListModel.cxx | 55 +++++++++++++++++++++ src/ZLEVEL/HYDROGUI_ListModel.h | 50 +++++++++++++++++++ src/ZLEVEL/HYDROGUI_ZLevelsDlg.cxx | 77 ++++++++++++++++++++++++++++++ src/ZLEVEL/HYDROGUI_ZLevelsDlg.h | 57 ++++++++++++++++++++++ src/ZLEVEL/gen.bat | 9 ++++ src/ZLEVEL/main.cpp | 15 ++++++ src/ZLEVEL/zlevel.pro | 6 +++ 7 files changed, 269 insertions(+) create mode 100644 src/ZLEVEL/HYDROGUI_ListModel.cxx create mode 100644 src/ZLEVEL/HYDROGUI_ListModel.h create mode 100644 src/ZLEVEL/HYDROGUI_ZLevelsDlg.cxx create mode 100644 src/ZLEVEL/HYDROGUI_ZLevelsDlg.h create mode 100755 src/ZLEVEL/gen.bat create mode 100644 src/ZLEVEL/main.cpp create mode 100644 src/ZLEVEL/zlevel.pro diff --git a/src/ZLEVEL/HYDROGUI_ListModel.cxx b/src/ZLEVEL/HYDROGUI_ListModel.cxx new file mode 100644 index 00000000..04ec0390 --- /dev/null +++ b/src/ZLEVEL/HYDROGUI_ListModel.cxx @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 "HYDROGUI_ListModel.h" + +HYDROGUI_ListModel::HYDROGUI_ListModel( QObject* theParent ) + : QAbstractListModel( theParent ) +{ +} + +HYDROGUI_ListModel::~HYDROGUI_ListModel() +{ +} + +QVariant HYDROGUI_ListModel::data( const QModelIndex &theIndex, int theRole ) const +{ + QVariant aVariant; + + int aRow = theIndex.row(); + if ( theIndex.isValid() && aRow < myObjects.count() && + theRole == Qt::DisplayRole ) { + aVariant = myObjects.at( aRow ); + } + + return aVariant; +} + +int HYDROGUI_ListModel::rowCount( const QModelIndex &theParent ) const +{ + return myObjects.count(); +} + +void HYDROGUI_ListModel::setObjects( const QList& theObjects ) +{ + myObjects = theObjects; +} \ No newline at end of file diff --git a/src/ZLEVEL/HYDROGUI_ListModel.h b/src/ZLEVEL/HYDROGUI_ListModel.h new file mode 100644 index 00000000..09dc5d17 --- /dev/null +++ b/src/ZLEVEL/HYDROGUI_ListModel.h @@ -0,0 +1,50 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 HYDROGUI_LISTMODEL_H +#define HYDROGUI_LISTMODEL_H + +#include + +/** + * \class HYDROGUI_ListModel + * \brief The class representing custom list model + */ +class HYDROGUI_ListModel : public QAbstractListModel +{ + Q_OBJECT + +public: + HYDROGUI_ListModel( QObject* theParent = 0 ); + ~HYDROGUI_ListModel(); + + virtual QVariant data( const QModelIndex &theIndex, int theRole = Qt::DisplayRole ) const; + + virtual int rowCount( const QModelIndex &theParent = QModelIndex() ) const; + + void setObjects( const QList& theObjects ); + +private: + QList myObjects; +}; + +#endif diff --git a/src/ZLEVEL/HYDROGUI_ZLevelsDlg.cxx b/src/ZLEVEL/HYDROGUI_ZLevelsDlg.cxx new file mode 100644 index 00000000..a6663624 --- /dev/null +++ b/src/ZLEVEL/HYDROGUI_ZLevelsDlg.cxx @@ -0,0 +1,77 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 "HYDROGUI_ZLevelsDlg.h" +#include "HYDROGUI_ListModel.h" + +#include +#include +#include +#include + + +HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent ) +: QDialog( theParent ) +{ + QVBoxLayout* aMainLayout = new QVBoxLayout( this ); + aMainLayout->setMargin( 5 ); + + QHBoxLayout* aListLayout = new QHBoxLayout(); + + myList = new QListView( this ); + myList->setModel( new HYDROGUI_ListModel ); + + myTop = new QPushButton( tr("TOP") ); + myUp = new QPushButton( tr("UP") ); + myDown = new QPushButton( tr("DOWN") ); + myBottom = new QPushButton( tr("BOTTOM") ); + QVBoxLayout* aListButtonsLayout = new QVBoxLayout(); + aListButtonsLayout->addWidget( myTop ); + aListButtonsLayout->addWidget( myUp ); + aListButtonsLayout->addWidget( myDown ); + aListButtonsLayout->addWidget( myBottom ); + aListButtonsLayout->addStretch(); + aListLayout->addWidget( myList ); + aListLayout->addLayout( aListButtonsLayout ); + aMainLayout->addLayout( aListLayout ); + + myAllObjects = new QCheckBox( tr( "ALL_OBJECTS" ) ); + aMainLayout->addWidget( myAllObjects ); + + QHBoxLayout* aDlgButtonsLayout = new QHBoxLayout(); + myApply = new QPushButton( tr("APPLY") ); + myClose = new QPushButton( tr("CLOSE") ); + aDlgButtonsLayout->addWidget( myApply ); + aDlgButtonsLayout->addWidget( myClose ); + aDlgButtonsLayout->addStretch(); + aMainLayout->addLayout( aDlgButtonsLayout ); +} + +HYDROGUI_ZLevelsDlg::~HYDROGUI_ZLevelsDlg() +{ +} + +void HYDROGUI_ZLevelsDlg::setObjects( const QList& theObjects ) +{ + HYDROGUI_ListModel* aModel = dynamic_cast( myList->model() ); + aModel->setObjects( theObjects ); +} \ No newline at end of file diff --git a/src/ZLEVEL/HYDROGUI_ZLevelsDlg.h b/src/ZLEVEL/HYDROGUI_ZLevelsDlg.h new file mode 100644 index 00000000..140e772e --- /dev/null +++ b/src/ZLEVEL/HYDROGUI_ZLevelsDlg.h @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 HYDROGUI_ZLEVELSPANEL_H +#define HYDROGUI_ZLEVELSPANEL_H + +#include + +class QCheckBox; +class QListView; +class QPushButton; + +/** + * \class HYDROGUI_ZLevelsDlg + * \brief The class representing widget for managing Z levels + */ +class HYDROGUI_ZLevelsDlg : public QDialog +{ + Q_OBJECT + +public: + HYDROGUI_ZLevelsDlg( QWidget* theParent ); + virtual ~HYDROGUI_ZLevelsDlg(); + + void setObjects( const QList& theObjects ); + +private: + QListView* myList; + QPushButton* myTop; + QPushButton* myUp; + QPushButton* myDown; + QPushButton* myBottom; + QCheckBox* myAllObjects; + QPushButton* myApply; + QPushButton* myClose; +}; + +#endif diff --git a/src/ZLEVEL/gen.bat b/src/ZLEVEL/gen.bat new file mode 100755 index 00000000..84d4206e --- /dev/null +++ b/src/ZLEVEL/gen.bat @@ -0,0 +1,9 @@ +call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" x86 +SET appendix="Visual Studio 9 2008" + +@SET PDIR=..\..\..\..\..\PRODUCTSD +call %PDIR%\env_compile.bat + +echo %PATH% + +qmake -tp vc -spec win32-msvc2008 zlevel.pro -r \ No newline at end of file diff --git a/src/ZLEVEL/main.cpp b/src/ZLEVEL/main.cpp new file mode 100644 index 00000000..8c51cb3d --- /dev/null +++ b/src/ZLEVEL/main.cpp @@ -0,0 +1,15 @@ +#include "HYDROGUI_ZLevelsDlg.h" + +#include + +int main( int argc, char** argv ){ + QApplication app(argc, argv); + + HYDROGUI_ZLevelsDlg* aDlg = new HYDROGUI_ZLevelsDlg( 0 ); + QList< QString > anObjects; + anObjects << "A" << "B" << "C" << "D" << "E" << "F" << "G" << "H"; + aDlg->setObjects( anObjects ); + aDlg->exec(); + + return app.exec(); +} \ No newline at end of file diff --git a/src/ZLEVEL/zlevel.pro b/src/ZLEVEL/zlevel.pro new file mode 100644 index 00000000..0d71118b --- /dev/null +++ b/src/ZLEVEL/zlevel.pro @@ -0,0 +1,6 @@ +HEADERS = HYDROGUI_ZLevelsDlg.h HYDROGUI_ListModel.h + +SOURCES = main.cpp HYDROGUI_ZLevelsDlg.cxx HYDROGUI_ListModel.cxx +CONFIG += qt + +TEMPLATE = app \ No newline at end of file -- 2.39.2