diff --git a/CMakeLists.txt b/CMakeLists.txt index cd8078e3d..ebd1da1e4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,7 +300,7 @@ ENDIF(SALOME_SMESH_ENABLE_MEFISTO) IF(SALOME_BUILD_GUI) LIST(APPEND _${PROJECT_NAME}_exposed_targets - SMESHObject SMESHFiltersSelection SMESH GeomSelectionTools StdMeshersGUI + SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI ) ENDIF(SALOME_BUILD_GUI) diff --git a/SalomeSMESHConfig.cmake.in b/SalomeSMESHConfig.cmake.in index 5b4233425..6fe86346c 100644 --- a/SalomeSMESHConfig.cmake.in +++ b/SalomeSMESHConfig.cmake.in @@ -145,7 +145,7 @@ IF(SALOME_SMESH_ENABLE_MEFISTO) SET(SMESH_MEFISTO2D MEFISTO2D) ENDIF(SALOME_SMESH_ENABLE_MEFISTO) SET(SMESH_SMESHObject SMESHObject) -SET(SMESH_GeomSelectionTools GeomSelectionTools) +SET(SMESH_PluginUtils PluginUtils) SET(SMESH_SMDS SMDS) SET(SMESH_SMESHimpl SMESHimpl) SET(SMESH_SMESHEngine SMESHEngine) diff --git a/src/PluginUtils/CMakeLists.txt b/src/PluginUtils/CMakeLists.txt index 2c2613c90..b72bb89ae 100644 --- a/src/PluginUtils/CMakeLists.txt +++ b/src/PluginUtils/CMakeLists.txt @@ -35,6 +35,7 @@ INCLUDE_DIRECTORIES( # additional preprocessor / compiler flags ADD_DEFINITIONS( + ${QT_DEFINITIONS} ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS} ${OMNIORB_DEFINITIONS} @@ -47,6 +48,8 @@ SET(_link_LIBRARIES ${KERNEL_SalomeLifeCycleCORBA} ${CAS_TKBRep} ${CAS_TKV3d} + ${QT_LIBRARIES} + ${QT_MT_LIBS} ${GUI_SalomeObject} ${GUI_suit} ${GUI_LightApp} @@ -58,21 +61,28 @@ SET(_link_LIBRARIES # --- headers --- # header files / to be processed by moc -SET(GeomSelectionTools_HEADERS +SET(PluginUtils_HEADERS GeomSelectionTools.h + SMESH_PluginUtils.h + SMESH_AdvOptionsWdg.h ) # --- sources --- +# sources / moc wrappings +QT_WRAP_MOC(_moc_SOURCES SMESH_AdvOptionsWdg.h) + # sources / static -SET(GeomSelectionTools_SOURCES +SET(PluginUtils_SOURCES GeomSelectionTools.cxx + SMESH_AdvOptionsWdg.cxx + ${_moc_SOURCES} ) # --- rules --- -ADD_LIBRARY(GeomSelectionTools ${GeomSelectionTools_SOURCES}) -TARGET_LINK_LIBRARIES(GeomSelectionTools ${_link_LIBRARIES} ) -INSTALL(TARGETS GeomSelectionTools EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) +ADD_LIBRARY(PluginUtils ${PluginUtils_SOURCES}) +TARGET_LINK_LIBRARIES(PluginUtils ${_link_LIBRARIES} ) +INSTALL(TARGETS PluginUtils EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) -INSTALL(FILES ${GeomSelectionTools_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) +INSTALL(FILES ${PluginUtils_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/PluginUtils/GeomSelectionTools.h b/src/PluginUtils/GeomSelectionTools.h index 55337150c..c4013ff99 100644 --- a/src/PluginUtils/GeomSelectionTools.h +++ b/src/PluginUtils/GeomSelectionTools.h @@ -25,18 +25,10 @@ #ifndef _GEOMSELECTIONTOOLS_H_ #define _GEOMSELECTIONTOOLS_H_ -#ifdef WIN32 -# ifdef GeomSelectionTools_EXPORTS -# define GEOMSELECTIONTOOLS_EXPORT __declspec( dllexport ) -# else -# define GEOMSELECTIONTOOLS_EXPORT __declspec( dllimport ) -# endif -#else -# define GEOMSELECTIONTOOLS_EXPORT -#endif +#include "SMESH_PluginUtils.h" -#include "SALOMEDSClient.hxx" -#include "SALOME_InteractiveObject.hxx" +#include +#include #include #include @@ -54,7 +46,7 @@ class LightApp_SelectionMgr; * */ -class GEOMSELECTIONTOOLS_EXPORT GeomSelectionTools +class PLUGINUTILS_EXPORT GeomSelectionTools { private: @@ -84,7 +76,7 @@ public: namespace PluginUtils { - GEOMSELECTIONTOOLS_EXPORT QString PrintDoubleValue( double, int = 16 ); + PLUGINUTILS_EXPORT QString PrintDoubleValue( double, int = 16 ); }; #endif // _GEOMSELECTIONTOOLS_H_ diff --git a/src/PluginUtils/SMESH_AdvOptionsWdg.cxx b/src/PluginUtils/SMESH_AdvOptionsWdg.cxx new file mode 100644 index 000000000..5ae7c92ee --- /dev/null +++ b/src/PluginUtils/SMESH_AdvOptionsWdg.cxx @@ -0,0 +1,155 @@ +// Copyright (C) 2007-2016 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, 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 +// 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 +// + +// File : SMESH_AdvOptionsWdg.h +// Author : Open CASCADE S.A.S. + +#include "SMESH_AdvOptionsWdg.h" + +#include +#include +#include +#include +#include + +#define SPACING 6 +#define MARGIN 11 + +namespace +{ + const int IS_CUSTOM = Qt::UserRole; +} + +SMESH_AdvOptionsWdg::SMESH_AdvOptionsWdg( QWidget* parent ) + : QWidget( parent ) +{ + myTable = new QTableWidget( /*nbrows=*/0, /*nbcol=*/3, this ); + QPushButton* addBtn = new QPushButton( tr("ADD_OPTION_BTN"), this ); + + myTable->setHorizontalHeaderLabels + ( QStringList() << tr("CHOICE") << tr("OPTION_NAME") << tr("OPTION_VALUE") ); + QHeaderView * header = myTable->horizontalHeader(); + header->setSectionResizeMode( 0, QHeaderView::ResizeToContents ); + header->setSectionResizeMode( 1, QHeaderView::Stretch ); + header->setSectionResizeMode( 2, QHeaderView::ResizeToContents ); + + QGridLayout* lay = new QGridLayout( this ); + lay->setMargin( MARGIN ); + lay->setSpacing( SPACING ); + lay->addWidget( myTable, 0,0, 1,3 ); + lay->addWidget( addBtn, 1,0 ); + + connect( addBtn, SIGNAL( clicked() ), SLOT( onAdd() )); +} + +SMESH_AdvOptionsWdg::~SMESH_AdvOptionsWdg() +{ +} + +void SMESH_AdvOptionsWdg::AddOption( QString name, QString value, bool isDefault, bool isCustom ) +{ + int row = myTable->rowCount(); + myTable->insertRow( row ); + + QTableWidgetItem* nameItem = new QTableWidgetItem( name ); + QTableWidgetItem* valueItem = new QTableWidgetItem( value ); + if ( !name.isEmpty() ) + nameItem->setFlags( nameItem->flags() & ~Qt::ItemIsEditable ); + myTable->setItem( row, 1, nameItem ); + myTable->setItem( row, 2, valueItem ); + nameItem->setData( IS_CUSTOM, isCustom ); + + QCheckBox* chkBox = new QCheckBox(); + QWidget* wdg = new QWidget(); + QHBoxLayout* lay = new QHBoxLayout( wdg ); + lay->setContentsMargins(0,0,0,0); + lay->addStretch(); + lay->addWidget(chkBox); + lay->addStretch(); + myTable->setCellWidget( row, 0, wdg ); + connect( chkBox, SIGNAL(toggled(bool)), this, SLOT(onToggle())); + myTable->setCurrentCell( row, 1, QItemSelectionModel::NoUpdate ); + chkBox->setChecked( !isDefault ); + + if ( name.isEmpty() ) + myTable->editItem( nameItem ); +} + +void SMESH_AdvOptionsWdg::SetCustomOptions( const QString& text ) +{ + QStringList nameVals = text.split(" "); + for ( int i = 1; i < nameVals.count(); i += 2 ) + AddOption( nameVals[i-1], nameVals[i], false, true ); +} + +void SMESH_AdvOptionsWdg::onAdd() +{ + AddOption( "", "", false, true ); + +} +void SMESH_AdvOptionsWdg::onToggle() +{ + int row = myTable->currentRow(); + QTableWidgetItem* valueItem = myTable->item( row, 2 ); + + bool isActive = isChecked( row ); + int c = isActive ? 0 : 150; + valueItem->setForeground( QBrush( QColor( c, c, c ))); + if ( isActive ) + valueItem->setFlags( valueItem->flags() | Qt::ItemIsEditable ); + else + valueItem->setFlags( valueItem->flags() & ~Qt::ItemIsEditable ); +} + +void SMESH_AdvOptionsWdg::GetOption( int row, + QString& name, + QString& value, + bool& isDefault, + bool & isCustom) +{ + if ( row < myTable->rowCount() ) + { + name = myTable->item( row, 1 )->text(); + value = myTable->item( row, 2 )->text(); + isDefault = !isChecked( row ); + isCustom = myTable->item( row, 1 )->data( IS_CUSTOM ).toInt(); + } +} + +QString SMESH_AdvOptionsWdg::GetCustomOptions() +{ + QString text, value, name; + bool isDefault, isCustom; + for ( int row = 0; row < myTable->rowCount(); ++row ) + { + GetOption( row, name, value, isDefault, isCustom ); + if ( !name.isEmpty() && !value.isEmpty() && isCustom && !isDefault ) + text += name + " " + value + " "; + } + return text; +} + +bool SMESH_AdvOptionsWdg::isChecked( int row ) +{ + QCheckBox* cb = myTable->cellWidget( row, 0 )->findChild(); + return cb->isChecked(); +} diff --git a/src/PluginUtils/SMESH_AdvOptionsWdg.h b/src/PluginUtils/SMESH_AdvOptionsWdg.h new file mode 100644 index 000000000..3ba3e35a4 --- /dev/null +++ b/src/PluginUtils/SMESH_AdvOptionsWdg.h @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2016 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, 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 +// 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 +// + +// File : SMESH_AdvOptionsWdg.h +// Author : Open CASCADE S.A.S. +// +#ifndef SMESH_ADVOPTIONSWDG_H +#define SMESH_ADVOPTIONSWDG_H + +#include "SMESH_PluginUtils.h" + +// Qt includes +#include + +class QTableWidget; + +/*! + * \brief Widget for entering options as strings + */ +class PLUGINUTILS_EXPORT SMESH_AdvOptionsWdg : public QWidget +{ + Q_OBJECT + +public: + SMESH_AdvOptionsWdg( QWidget* parent = 0 ); + ~SMESH_AdvOptionsWdg(); + + void AddOption( QString name, QString value, bool isDefault, bool isCustom ); + void SetCustomOptions( const QString& text ); + + int GetNbRows(); + void GetOption( int row, QString& name, QString& value, bool& isDefault, bool &isCustom); + QString GetCustomOptions(); + +private slots: + + void onAdd(); + void onToggle(); + +private: + + bool isChecked( int row ); + + QTableWidget* myTable; +}; + +#endif diff --git a/src/PluginUtils/SMESH_PluginUtils.h b/src/PluginUtils/SMESH_PluginUtils.h new file mode 100644 index 000000000..3f4484b4a --- /dev/null +++ b/src/PluginUtils/SMESH_PluginUtils.h @@ -0,0 +1,39 @@ +// Copyright (C) 2007-2016 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, 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 +// 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 +// + +// File : SMESH_StdMeshersGUI.hxx +// Author : Alexander BORODIN, Open CASCADE S.A.S. +// +#ifndef SMESH_PLUGINUTILS_HXX +#define SMESH_PLUGINUTILS_HXX + +#ifdef WIN32 + #if defined PLUGINUTILS_EXPORTS || defined PluginUtils_EXPORTS + #define PLUGINUTILS_EXPORT __declspec( dllexport ) + #else + #define PLUGINUTILS_EXPORT __declspec( dllimport ) + #endif +#else + #define PLUGINUTILS_EXPORT +#endif + +#endif // SMESH_PLUGINUTILS_HXX diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index 6f944e520..205544cfa 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -1072,6 +1072,10 @@ void SMESHGUI_ExtrusionDlg::ClickOnRadio() SelectorWdg->SetEnabled( false, SMESH::EDGE ); } + BasePointGrp->setEnabled( !ExtrMethod_RBut2->isChecked() ); + ScalesGrp ->setEnabled( !ExtrMethod_RBut2->isChecked() ); + + CheckIsEnable(); onDisplaySimulation(true); diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index b86138e08..b539eee98 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -185,18 +185,19 @@ private: QCheckBox* UseInputElemsOnlyCheck; QCheckBox* MakeGroupsCheck; - QCheckBox* LinearScalesCheck; - QGroupBox* ScalesGrp; - QListWidget* ScalesList; - QToolButton* AddScaleButton; - QToolButton* RemoveScaleButton; - SMESHGUI_SpinBox* ScaleSpin; QGroupBox* BasePointGrp; QPushButton* SelectBasePointButton; SMESHGUI_SpinBox* BasePoint_XSpin; SMESHGUI_SpinBox* BasePoint_YSpin; SMESHGUI_SpinBox* BasePoint_ZSpin; + QGroupBox* ScalesGrp; + QListWidget* ScalesList; + QToolButton* AddScaleButton; + QToolButton* RemoveScaleButton; + SMESHGUI_SpinBox* ScaleSpin; + QCheckBox* LinearScalesCheck; + QGroupBox* GroupButtons; QPushButton* buttonOk; QPushButton* buttonCancel; diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 76a91b73b..f6ab2b98a 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -4352,6 +4352,10 @@ It can't be deleted STB_SORT_CHILD_ITEMS Sort child items + + SMESH_ADVANCED + Advanced + SMESHGUI_FieldSelectorWdg @@ -8074,4 +8078,23 @@ as they are of improper type: At least one entity type should be chosen! + + SMESH_AdvOptionsWdg + + ADD_OPTION_BTN + Add option + + + CHOICE + Choice + + + OPTION_NAME + Option name + + + OPTION_VALUE + Option value + +