From 6c2ee27d457fe387b43fc9a13739adf0e7282cce Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 3 Oct 2013 14:12:04 +0000 Subject: [PATCH] ILMAB project. A dialog box for creating/editing the Field on Geometry implemented --- resources/CMakeLists.txt | 2 + resources/field_edit.png | Bin 0 -> 1377 bytes resources/field_new.png | Bin 0 -> 1214 bytes src/EntityGUI/CMakeLists.txt | 2 + src/EntityGUI/EntityGUI.cxx | 95 +- src/EntityGUI/EntityGUI_FieldDlg.cxx | 1938 +++++++++++++++++++++++++ src/EntityGUI/EntityGUI_FieldDlg.h | 136 ++ src/GEOM/GEOM_BaseObject.cxx | 6 +- src/GEOMGUI/GEOMGUI_Selection.cxx | 30 +- src/GEOMGUI/GEOMGUI_Selection.h | 3 +- src/GEOMGUI/GEOM_images.ts | 16 + src/GEOMGUI/GEOM_msg_en.ts | 186 +++ src/GEOMGUI/GeometryGUI.cxx | 55 +- src/GEOMGUI/GeometryGUI_Operations.h | 3 + src/GEOMImpl/GEOMImpl_FieldDriver.cxx | 2 +- 15 files changed, 2434 insertions(+), 40 deletions(-) create mode 100644 resources/field_edit.png create mode 100644 resources/field_new.png create mode 100644 src/EntityGUI/EntityGUI_FieldDlg.cxx create mode 100644 src/EntityGUI/EntityGUI_FieldDlg.h diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 274162faa..937bc6e60 100755 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -234,6 +234,8 @@ SET( _res_files subblock.png group_new.png group_edit.png + field_new.png + field_edit.png glue.png check_blocks_compound.png get_non_blocks.png diff --git a/resources/field_edit.png b/resources/field_edit.png new file mode 100644 index 0000000000000000000000000000000000000000..3b8f4158a444d5953da12d2eb7e34cdbd822672c GIT binary patch literal 1377 zcmV-n1)lneP)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ=*GWV{RCwBAw6?bX|NHlE1`s%P>J%f04hRVN&(6-y zuyW-}Fh3z7;XjC8uwVh0pO%&e=Fgfni_z89^?z`|Muxk$E;C$s{gweBfEbO8jQ*cH zcTN&0&jG|gfcOIg1PDNBoP2L@@8Px0K4rLe?HYq$=2C_Scds#Adh?E9`i@41D7QQY{uf^v00M{wY9q*H zFQAyAqod>hS4k&^pTGYyeEso<;rp*Y48MN=WB3n*9}iDp2+Uc|@bK<+hO2MiGtAuC z#1H{AjPLnphUaWw7ytr@$=%%@WY`0k%Rq*Gmv#jk_8I7vk6(W=y#M?Y7)C!C-W}*= z2*`#Qb{S~cG@#4EU2+(BpMGF?&is+#+>9~?fB<3v#U>22wY7m`{QvEZ48OmBXZZQ? zBg1zf{t0CN`0<0GdzC-K-~ZDYw2Z$pWcu%72zSn6;Cb?n;Tg*(hKsZ77#JBD82|!^ z5gOPMQ15<#hN&SCD?%d*49v{TYNzcCX87|DX!x%$46mPkW>_>`pWy}52Zl=v8ySB7 z{CNqe>@z?BvA{HRb#*-l*#L4OP?F)>w{Hv|K73&K^5qM|l`B^mrtI)%`2FuQ!`E+L z8Q#76%JBB(SBB?|?-?#HYyzpj3pC;@5MKfaAeQLp=;uq9E*1Rs>lec}8Fz+XfBu2P z@7vEm44(vkf$4XLlEH?3`TT?7{hO~0?_Ymo`267q!{tRy3>+LBAOpVx4Z9*KDVYfn zKrA4Gz=;bOMn8W2W%&IUV&ESj{rBI01|VX1|NcG0$M@eDKE3}AH1HckLEsv&9(G{` z2Ie2H8KB8+7aJQ}DnJ0StX{nuluH!;{skHWN_Rkm{(%gF8U_NO^cSo*8%%>R4-XH+ zA9hg&MrLLPPEJmck}II(`S9UGNq_)if`uU{;eyiI_g@h2eg)!hKYueE=m})d4r^x+ z)^cXx;^G2%?*=HWS-JQbI0YoZh6BMPApQno00a<|udgpS9e(}#mEi+0&At2dli|&$ z9}Mq4eq;Fd`8|VPbRWZyk1v6)VTHNoG00$UQF#U~5m^Rkvik`ll$4a70|XEgEDXN` z)7s~6zknDRmS4Xx{QCMHh(9p=`1G3L&yO!a*GMo33JQXh9^vKXWnkwKV&Hyzmf_N+ zOU*D}f?N&|KrB0V?gWP+$iQzuelh(1_L1Sw&uY2#kR-5AzBm z(9pk7%YlYDL30<#u=CKe;D@@p`g4E)VgaQ;5ZJqSFQ^E!gl0KH;0M%@_b|g?5&!|j z0&>2xvhsUSI(+cpffq;+nBwPw(%Xv{FOt9|tAxZnkSm`*e-7fmke8P~#>B+LaR2^& jPN>WNgVck}0thew%$RpO(V~YV00000NkvXXu0mjfWt?~O literal 0 HcmV?d00001 diff --git a/resources/field_new.png b/resources/field_new.png new file mode 100644 index 0000000000000000000000000000000000000000..9e365e1d166ea159d558cac2e3b78fd82f6a4a7b GIT binary patch literal 1214 zcmV;v1VQ_WP)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ=G)Y83RCwBAw6?bX|NHlE1`s%P>J%f04hRVN&(6-y zuyW-}Fh4mt`9C8gBg33IbHM!U?Ck&l{{3U9=>E+h&ohV7+uQs9moHx!K7Rbj01!Y7 zMn*>efoddxSOH3NK(PcN{(~+ItLt z|9@im^Y1l-roeeapq3v%EC~=mj7T=WfMSM@j*kC7W!)Hl{{GAG?dKmb{`DJZIMA@V zv^JoM-wgl${{-UC4Da6lV)*#}FT>BD{}=+T?`Z-A5R<#R`*Wa*2QZg`4Erwa3O4NX z_umX3zWic%|M@4wJ0J$pRmuDes(kyi|Nj5T@b&9&hR+}WGI*KXNdg+?q@bX19Uy>M zK(Pq}ZEbDf82^8JBg60S-x+=aW9>T-{{*r@-UWfxTedV``=B*dOW zi?{!o7wh>T2oxLu0fg@55700Lg^40GGSC4iteyjt%Dl4P+YB|S;tYomA1(%pT?gq0 z2p|@is;;iC=b*F(a^cUPKN-G#`^NC$!v_XX`T~i8TnNG&Hf#t2f_3jz;(@wK(Jgup z5I`)^(b3PBE?p}4>(?)aZ!+!-zyAD#N5&_CUtszlFtvfa!*y*oNaKAbCMK{6)l+I2 z7#U{44FiQCKmf6T3<8V%_`&ew7chzZg&6n;NdEn1~>`*`OWb6&rb#> zNZ5XdMJhl5v8-ObS`rj)p!D_!C^#!NHuV241eE9l{;oYa73~xUDV0icO8^gEH?-_o6egnooKD`DT1OlK41Mz=- z`v}fSFrcKQ^c*07;9&?-{P`O&5`O$*`1|Vz!=GQ@82@h62!0{&T*Vp%8mw^ra^&M!|Ke!87paz1{ z|#2M8b*Q2GOby?gh9iZDxPmLmjyKn-~hGYlpH5I`&-=PN5K zzXyd2Fdcb;Q?8`sJWx`3@!~}iIN?c1%mcad`Sa%>{tJ0|`D38ma{vB)PN>WNgVQR| cEPwz50Apm0TWdqR=Kufz07*qoM6N<$f=i$z`v3p{ literal 0 HcmV?d00001 diff --git a/src/EntityGUI/CMakeLists.txt b/src/EntityGUI/CMakeLists.txt index 31c381aac..27ccc7bd2 100755 --- a/src/EntityGUI/CMakeLists.txt +++ b/src/EntityGUI/CMakeLists.txt @@ -110,6 +110,7 @@ SET(EntityGUI_HEADERS # header files / to be processed by moc SET(_moc_HEADERS EntityGUI_Widgets.h + EntityGUI_FieldDlg.h EntityGUI_SketcherDlg.h EntityGUI_3DSketcherDlg.h EntityGUI_SubShapeDlg.h @@ -128,6 +129,7 @@ QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) SET(EntityGUI_SOURCES EntityGUI.cxx EntityGUI_Widgets.cxx + EntityGUI_FieldDlg.cxx EntityGUI_SketcherDlg.cxx EntityGUI_3DSketcherDlg.cxx EntityGUI_SubShapeDlg.cxx diff --git a/src/EntityGUI/EntityGUI.cxx b/src/EntityGUI/EntityGUI.cxx index 705138e36..d31b09d58 100644 --- a/src/EntityGUI/EntityGUI.cxx +++ b/src/EntityGUI/EntityGUI.cxx @@ -26,18 +26,21 @@ // #include "EntityGUI.h" -#include +#include "GeometryGUI.h" #include "GeometryGUI_Operations.h" -#include -#include -#include -#include +#include #include -#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include +#include #include #include @@ -53,6 +56,10 @@ #include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE #include "EntityGUI_FeatureDetectorDlg.h" // Feature Detection #include "EntityGUI_PictureImportDlg.h" // Import Picture in viewer +#include "EntityGUI_FieldDlg.h" // Create/Edit Field + +#include "GEOMImpl_Types.hxx" + //======================================================================= // function : EntityGUI() @@ -104,13 +111,85 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case GEOMOp::OpPictureImport: // IMPORT PICTURE IN VIEWER aDlg = new EntityGUI_PictureImportDlg( getGeometryGUI(), parent ); break; + case GEOMOp::OpCreateField: // CREATE FIELD + aDlg = new EntityGUI_FieldDlg (getGeometryGUI(), GEOM::GEOM_Field::_nil(), 0, + parent); + break; + case GEOMOp::OpEditField: // EDIT FIELD + case GEOMOp::OpEditFieldPopup: + { + SALOME_ListIO aList; + aList.Clear(); + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if (aSelMgr) + aSelMgr->selectedObjects(aList); + SALOME_ListIteratorOfListIO anIter (aList); + + GEOM::GEOM_Field_var field; + GEOM::GEOM_FieldStep_var step; + + SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + if ( aList.Extent() > 0 && study ) { + for ( ; anIter.More(); anIter.Next() ) + { + Handle(SALOME_InteractiveObject) anIObj = anIter.Value(); + if ( !anIObj.IsNull() && anIObj->hasEntry() ) + if ( _PTR(SObject) obj = study->studyDS()->FindObjectID( anIObj->getEntry() )) + { + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( obj ); + GEOM::GEOM_BaseObject_var bo = GEOM::GEOM_BaseObject::_narrow( corbaObj ); + GEOM::GEOM_Field_var f; + GEOM::GEOM_FieldStep_var s; + switch ( bo->GetType() ) { + case GEOM_FIELD: + f = GEOM::GEOM_Field::_narrow( corbaObj ); break; + case GEOM_FIELD_STEP: + step = GEOM::GEOM_FieldStep::_narrow( corbaObj ); + if ( !step->_is_nil() ) + f = step->GetField(); + break; + default: + continue; + } + if ( !f->_is_nil() ) + { + if ( !field->_is_nil() && !f->_is_equivalent( field )) + { + field = GEOM::GEOM_Field::_nil(); // several field selected + break; + } + field = f; + } + } + } + } + + if ( !field->_is_nil()) { + int stepID; + if ( !step->_is_nil() ) { + stepID = step->GetID(); + } + else { + GEOM::ListOfLong_var stepIDs = field->GetSteps(); + if ( stepIDs->length() > 0 ) + stepID = stepIDs[0]; + else + stepID = 0; + } + aDlg = new EntityGUI_FieldDlg (getGeometryGUI(), field, stepID, parent); + break; + } + SUIT_MessageBox::warning(parent, tr("WRN_WARNING"), tr("NO_FIELD")); + break; + } default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } if ( aDlg ) aDlg->show(); - + return true; } diff --git a/src/EntityGUI/EntityGUI_FieldDlg.cxx b/src/EntityGUI/EntityGUI_FieldDlg.cxx new file mode 100644 index 000000000..7fd1adf9d --- /dev/null +++ b/src/EntityGUI/EntityGUI_FieldDlg.cxx @@ -0,0 +1,1938 @@ +// 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 + +// File : EntityGUI_FieldDlg.cxx + +#include "EntityGUI_FieldDlg.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + + +const int theIntLimit = std::numeric_limits::max() - 10; + +/* + Class : EntityGUI_FieldDlg::CheckItem + Description : Bool item. +*/ +class EntityGUI_FieldDlg::CheckItem : public QTableWidgetItem +{ +public: + static int Type(); + + CheckItem( bool = false ); + ~CheckItem(); + + void setValue( bool ); + bool value() const; +}; + +int EntityGUI_FieldDlg::CheckItem::Type() +{ + return QTableWidgetItem::UserType + 2; +} + +EntityGUI_FieldDlg::CheckItem::CheckItem( bool value ) + : QTableWidgetItem( Type() ) +{ + Qt::ItemFlags f = flags(); + f = f | Qt::ItemIsUserCheckable; + f = f & ~Qt::ItemIsTristate; + f = f & ~Qt::ItemIsEditable; + setFlags( f ); + setValue(value); +} + +EntityGUI_FieldDlg::CheckItem::~CheckItem() +{ +} + +void EntityGUI_FieldDlg::CheckItem::setValue( bool value ) +{ + setCheckState( value ? Qt::Checked : Qt::Unchecked ); +} + +bool EntityGUI_FieldDlg::CheckItem::value() const +{ + return checkState() == Qt::Checked; +} + +/* + Class : EntityGUI_FieldDlg::IntSpinItem + Description : Integer spin table item. +*/ + +class EntityGUI_FieldDlg::IntSpinItem : public QTableWidgetItem +{ +public: + static int Type(); + + IntSpinItem( const int theValue ); + + int value() const; + void setValue( const int theValue ); + + void clear(); +}; + +int EntityGUI_FieldDlg::IntSpinItem::Type() +{ + return QTableWidgetItem::UserType + 3; +} + +EntityGUI_FieldDlg::IntSpinItem::IntSpinItem( const int theValue ) + : QTableWidgetItem( Type() ) +{ + setValue( theValue ); +} + +int EntityGUI_FieldDlg::IntSpinItem::value() const +{ + bool ok = false; + int value = data( Qt::UserRole ).toInt( &ok ); + return ok ? value : 0; +} + +void EntityGUI_FieldDlg::IntSpinItem::setValue( const int theValue ) +{ + setData( Qt::UserRole, theValue ); + setText( QString::number( theValue ) ); +} + +void EntityGUI_FieldDlg::IntSpinItem::clear() +{ + setText( "" ); +} + +/* + Class : EntityGUI_FieldDlg::DoubleSpinItem + Description : Double spin table item. +*/ + +class EntityGUI_FieldDlg::DoubleSpinItem : public QTableWidgetItem +{ +public: + static int Type(); + + DoubleSpinItem( const double theValue, const int thePrecision=6 ); + + double value() const; + void setValue( const double theValue ); + + int precision() const; + void setPrecision( const int thePrecision ); + + void clear(); +}; + +int EntityGUI_FieldDlg::DoubleSpinItem::Type() +{ + return QTableWidgetItem::UserType + 4; +} + +EntityGUI_FieldDlg::DoubleSpinItem::DoubleSpinItem( const double theValue, + const int thePrecision) + : QTableWidgetItem( Type() ) +{ + setValue( theValue ); + setPrecision( thePrecision ); +} + +double EntityGUI_FieldDlg::DoubleSpinItem::value() const +{ + bool ok = false; + double value = data( Qt::UserRole ).toDouble( &ok ); + return ok ? value : 0; +} + +void EntityGUI_FieldDlg::DoubleSpinItem::setValue( const double theValue ) +{ + setData( Qt::UserRole, theValue ); + setText( QString::number( theValue ) ); +} + +int EntityGUI_FieldDlg::DoubleSpinItem::precision() const +{ + bool ok = false; + int precision = data( Qt::UserRole + 1 ).toInt( &ok ); + return ok ? precision : 0; +} + +void EntityGUI_FieldDlg::DoubleSpinItem::setPrecision( const int thePrecision ) +{ + setData( Qt::UserRole + 1, thePrecision ); +} + +void EntityGUI_FieldDlg::DoubleSpinItem::clear() +{ + setText( "" ); +} + +/* + Class : EntityGUI_FieldDlg::ComboDelegate + Description : Table used by this widget +*/ + +class EntityGUI_FieldDlg::Delegate : public QItemDelegate +{ +public: + Delegate( QObject* = 0 ); + ~Delegate(); + + QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, + const QModelIndex& ) const; + + void setEditorData( QWidget*, const QModelIndex& ) const; + void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const; + + void updateEditorGeometry( QWidget*, const QStyleOptionViewItem&, + const QModelIndex& ) const; +private: + StepTable* myTable; +}; + +/* + Class : EntityGUI_FieldDlg::StepTable + Description : Table widget +*/ + +class EntityGUI_FieldDlg::StepTable : public QTableWidget +{ + //Q_OBJECT + + int myDataType; + int myStepID; + int myStamp; + GEOM::GEOM_FieldStep_var myStep; + bool myIsChanged; + + QTableWidgetItem * newDefaultItem(); +public: + StepTable( int stepID, int dataType, int nbRows, int nbColumns, + QString shapeName, QStringList headers, + GEOM::GEOM_FieldStep_ptr stepVar, QWidget* = 0 ); + virtual ~StepTable(); + + QSize minimumSizeHint() const; + + void setEditable( bool, int, int ); + bool isEditable( int, int ) const; + + void setReadOnly( bool ); + bool isReadOnly() const; + + void insertRows( int, int = 1 ); + QString text( int, int ); + + QList selectedRows(); + void selectRows(const QList& rows); + + void setDim( int nbRows, QString shapeName, bool setDefault=true ); + void setNbComps( int nbComps ); + void setDataType( int dataType ); + void setStamp( int stamp ) { myStamp = stamp; } + int getStamp() { return myStamp; } + int getStepID() { return myStepID; } + QStringList getHeaders(); + void setHeaders(const QStringList& headers); + GEOM::GEOM_FieldStep_var getStep() { return myStep; } + void setValues(GEOM::GEOM_FieldStep_var& step); + + void setIsChanged() { myIsChanged = true; } +}; + +EntityGUI_FieldDlg::Delegate::Delegate( QObject* parent ) + : QItemDelegate( parent ), + myTable( dynamic_cast( parent ) ) +{ +} + +EntityGUI_FieldDlg::Delegate::~Delegate() +{ +} + +QWidget* EntityGUI_FieldDlg::Delegate::createEditor( QWidget* parent, + const QStyleOptionViewItem& option, + const QModelIndex& index ) const +{ + QVariant aData = index.data( Qt::UserRole ); + QVariant::Type aDataType = aData.type(); + if( aDataType == QVariant::Int ) { + bool ok = false; + int aValue = aData.toInt( &ok ); + if ( ok ) { + SalomeApp_IntSpinBox* intSpin = new SalomeApp_IntSpinBox( -theIntLimit, theIntLimit, 1, parent, false, true ); + intSpin->setFrame( false ); + intSpin->setValue( aValue ); + return intSpin; + } + } + else if( aDataType == QVariant::Double ) { + bool ok = false; + double aValue = aData.toDouble( &ok ); + if ( ok ) { + int aPrecision = index.data( Qt::UserRole + 1 ).toInt( &ok ); + if ( !ok ) + aPrecision = 0; + + SalomeApp_DoubleSpinBox* dblSpin = new SalomeApp_DoubleSpinBox( -1.e20, 1.e20, 1, aPrecision, 20, parent, false, true ); + dblSpin->setFrame( false ); + dblSpin->setValue( aValue ); + return dblSpin; + } + } + return QItemDelegate::createEditor( parent, option, index ); +} + +void EntityGUI_FieldDlg::Delegate::setEditorData( QWidget* editor, + const QModelIndex& index ) const +{ + QVariant data = index.model()->data( index, Qt::DisplayRole ); + QString value = data.toString(); + bool bOk = false; + if ( SalomeApp_DoubleSpinBox* dblSpin = dynamic_cast( editor ) ) { + if( data.type() == QVariant::Double ) { + double valueDouble = data.toDouble( &bOk ); + if( bOk ) + dblSpin->setValue( valueDouble ); + } + } + if ( !bOk ) QItemDelegate::setEditorData( editor, index ); +} + +void EntityGUI_FieldDlg::Delegate::setModelData( QWidget* editor, + QAbstractItemModel* model, + const QModelIndex& index) const +{ + QString oldData = myTable->text( index.row(), index.column() ); + + if( SalomeApp_IntSpinBox* intSpin = dynamic_cast( editor ) ) + model->setData( index, intSpin->value(), Qt::DisplayRole ); + else if( SalomeApp_DoubleSpinBox* dblSpin = dynamic_cast( editor ) ) + model->setData( index, dblSpin->value(), Qt::DisplayRole ); + else + QItemDelegate::setModelData( editor, model, index ); + + QString newData = myTable->text( index.row(), index.column() ); + if ( newData != oldData ) + myTable->setIsChanged(); +} + +void EntityGUI_FieldDlg::Delegate::updateEditorGeometry( QWidget* editor, + const QStyleOptionViewItem& option, + const QModelIndex& index ) const +{ + editor->setGeometry( option.rect ); +} + +//======================================================================= +// name : EntityGUI_FieldDlg::StepTable::Table +// Purpose : Constructor +//======================================================================= +EntityGUI_FieldDlg::StepTable::StepTable (int stepID, int dataType, + int nbRows, int nbComps, + QString shapeName, QStringList headers, + GEOM::GEOM_FieldStep_ptr stepVar, + QWidget* parent) + : QTableWidget(0, nbComps+1, parent), + myDataType( dataType ), + myStepID( stepID ), + myStamp( 0 ), + myStep( GEOM::GEOM_FieldStep::_duplicate( stepVar )), + myIsChanged( false ) +{ + setDim( nbRows, shapeName, stepVar->_is_nil() ); + + setHorizontalHeaderLabels( headers ); + verticalHeader()->hide(); + + // set custom item delegate + setItemDelegate( new Delegate(this) ); + // set edit triggers by default + setReadOnly( false ); + + if ( stepVar->_is_nil() ) + return; + + myStamp = stepVar->GetStamp(); + + const int nbColumns = nbComps + 1; + + switch ( dataType ) + { + case 0: + { + GEOM::GEOM_BoolFieldStep_var bs = GEOM::GEOM_BoolFieldStep::_narrow( stepVar ); + if ( !bs->_is_nil() ) + { + GEOM::short_array_var vals = bs->GetValues(); + if ( vals->length() == nbRows * nbComps ) + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + setItem( iR, iC, new CheckItem( vals[ iV++ ])); + } + break; + } + case 1: + { + GEOM::GEOM_IntFieldStep_var is = GEOM::GEOM_IntFieldStep::_narrow( stepVar ); + if ( !is->_is_nil() ) + { + GEOM::ListOfLong_var vals = is->GetValues(); + if ( vals->length() == nbRows * nbComps ) + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + setItem( iR, iC, new IntSpinItem( vals[ iV++ ])); + } + break; + } + case 2: + { + GEOM::GEOM_DoubleFieldStep_var ds = GEOM::GEOM_DoubleFieldStep::_narrow( stepVar ); + if ( !ds->_is_nil() ) + { + GEOM::ListOfDouble_var vals = ds->GetValues(); + if ( vals->length() == nbRows * nbComps ) + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + setItem( iR, iC, new DoubleSpinItem( vals[ iV++ ])); + } + break; + } + default: + GEOM::GEOM_StringFieldStep_var ss = GEOM::GEOM_StringFieldStep::_narrow( stepVar ); + if ( !ss->_is_nil() ) + { + GEOM::string_array_var vals = ss->GetValues(); + if ( vals->length() == nbRows * nbComps ) + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + setItem( iR, iC, new QTableWidgetItem( vals[ iV++ ].in() )); + } + break; + } +} + +//======================================================================= +// name : EntityGUI_FieldDlg::StepTable::~StepTable +// Purpose : Destructor +//======================================================================= +EntityGUI_FieldDlg::StepTable::~StepTable() +{ +} + +//======================================================================= +// name : EntityGUI_FieldDlg::StepTable::minimumSizeHint +// Purpose : Get minimum size for the table +//======================================================================= +QSize EntityGUI_FieldDlg::StepTable::minimumSizeHint() const +{ + QSize s = QTableWidget::minimumSizeHint(); + QHeaderView* hv = horizontalHeader(); + if ( hv ) + s.setWidth( qMax( s.width(), hv->length() ) ); + return s; +} + +//======================================================================= +// name : EntityGUI_FieldDlg::StepTable::setEditable +// Purpose : Set editable of specified cell +//======================================================================= +void EntityGUI_FieldDlg::StepTable::setEditable (bool isEditable, + int row, int col) +{ + QTableWidgetItem* anItem = item( row, col ); + if ( anItem ) { + bool isSignalsBlocked = signalsBlocked(); + blockSignals( true ); + + Qt::ItemFlags f = anItem->flags(); + if ( !isEditable ) f = f & ~Qt::ItemIsEditable; + else f = f | Qt::ItemIsEditable; + anItem->setFlags( f ); + + blockSignals( isSignalsBlocked ); + } +} + +//======================================================================= +// name : EntityGUI_FieldDlg::StepTable::isEditable +// Purpose : Verify wheter cell is editable +//======================================================================= +bool EntityGUI_FieldDlg::StepTable::isEditable (int row, int col) const +{ + QTableWidgetItem* anItem = item( row, col ); + return anItem == 0 || anItem->flags() & Qt::ItemIsEditable; +} + +void EntityGUI_FieldDlg::StepTable::setReadOnly( bool on ) +{ + setEditTriggers( on ? + QAbstractItemView::NoEditTriggers : + QAbstractItemView::AllEditTriggers ); +} + +bool EntityGUI_FieldDlg::StepTable::isReadOnly() const +{ + return editTriggers() == QAbstractItemView::NoEditTriggers; +} + +//======================================================================= +// name : EntityGUI_FieldDlg::StepTable::insertRows +// Purpose : Insert rows (virtual redefined) +//======================================================================= +void EntityGUI_FieldDlg::StepTable::insertRows (int row, int count) +{ + while ( count-- ) insertRow( row ); +} + +//======================================================================= +// name : EntityGUI_FieldDlg::StepTable::text +// Purpose : Get text from cell (virtual redefined) +//======================================================================= +QString EntityGUI_FieldDlg::StepTable::text (int row, int col) +{ + closePersistentEditor( currentItem() ); + QTableWidgetItem* anItem = item( row, col ); + return anItem ? anItem->text() : QString(); +} + +QList EntityGUI_FieldDlg::StepTable::selectedRows() +{ + QList selItems = selectedItems(); + QTableWidgetItem* anItem; + QList rows; + + foreach( anItem, selItems ) { + int r = row( anItem ); + if ( !rows.contains( r ) ) rows.append( r ); + } + + qSort( rows ); + return rows; +} + +//======================================================================= +//function : selectRows +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::StepTable::selectRows(const QList& rows) +{ + closePersistentEditor( currentItem() ); + + QList ranges = selectedRanges(); + for ( int i = 0; i < ranges.count(); ++i ) + setRangeSelected( ranges[i], false ); + + QList::const_iterator row = rows.begin(); + for ( ; row != rows.end(); ++row ) + // QTableWidgetSelectionRange ( int top, int left, int bottom, int right ) + setRangeSelected ( QTableWidgetSelectionRange(*row,0,*row,0), true ); +} + +//======================================================================= +//function : setDim +//purpose : change nb rows in the table +//======================================================================= + +void EntityGUI_FieldDlg::StepTable::setDim( int nbRows, QString shapeName, bool setDefault ) +{ + closePersistentEditor( currentItem() ); + int curNbRows = rowCount(); + if ( nbRows < curNbRows ) + { + while ( nbRows < curNbRows ) + removeRow( --curNbRows ); + } + else if ( nbRows > curNbRows ) + { + int nbColumns = columnCount(); + for ( ; nbRows > curNbRows; ++curNbRows ) + { + insertRow( curNbRows ); + if ( setDefault ) + for ( int iC = 1; iC < nbColumns; ++iC ) + setItem( curNbRows, iC, newDefaultItem() ); + } + } + + int indexWidth = 1, maxNbR = 10; + while ( nbRows >= maxNbR ) + ++indexWidth, maxNbR *= 10; + shapeName = shapeName.toLower() + "_%1"; + for ( int iR = 0; iR < nbRows; ++iR ) + { + setItem( iR, 0, new QTableWidgetItem( shapeName.arg( iR+1, indexWidth, 10, QChar('0') ))); + setEditable( false, iR, 0 ); + } +} + +//======================================================================= +//function : setNbComps +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::StepTable::setNbComps( int nbComps ) +{ + closePersistentEditor( currentItem() ); + nbComps++; // add sub-shape column + int curNbCols = columnCount(); + if ( nbComps < curNbCols ) + { + while ( nbComps < curNbCols ) + removeColumn( --curNbCols ); + } + else if ( nbComps > curNbCols ) + { + int nbRows = rowCount(); + for ( ; nbComps > curNbCols; ++curNbCols ) + { + insertColumn( curNbCols ); + setHorizontalHeaderItem( curNbCols, + new QTableWidgetItem(QString("Comp %1").arg( curNbCols ))); + for ( int iR = 0; iR < nbRows; ++iR ) + setItem( iR, curNbCols, newDefaultItem() ); + } + } +} + +//======================================================================= +//function : setDataType +//purpose : change type of data +//======================================================================= + +void EntityGUI_FieldDlg::StepTable::setDataType( int dataType ) +{ + myDataType = dataType; + + int nbRows = rowCount(); + int nbColumns = columnCount(); + + for ( int iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + setItem( iR, iC, newDefaultItem() ); +} + +//======================================================================= +//function : newDefaultItem +//purpose : creates a table item with a default value +//======================================================================= + +QTableWidgetItem * EntityGUI_FieldDlg::StepTable::newDefaultItem() +{ + switch( myDataType ) { + case 0: return new CheckItem(false); + case 1: return new IntSpinItem(0); + case 2: return new DoubleSpinItem(0); + default:; + } + return new QTableWidgetItem(""); // string +} + +//======================================================================= +//function : getHeaders +//purpose : +//======================================================================= + +QStringList EntityGUI_FieldDlg::StepTable::getHeaders() +{ + QStringList headers; + int nbColumns = columnCount(); + for ( int iC = 0; iC < nbColumns; ++iC ) + headers << horizontalHeaderItem( iC )->text(); + return headers; +} + +//======================================================================= +//function : setHeaders +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::StepTable::setHeaders(const QStringList& headers) +{ + setHorizontalHeaderLabels( headers ); +} + +//======================================================================= +//function : setValues +//purpose : store values from this table to a field step +//======================================================================= + +void EntityGUI_FieldDlg::StepTable::setValues(GEOM::GEOM_FieldStep_var& step) +{ + closePersistentEditor( currentItem() ); + + if ( step->GetStamp() != myStamp ) + step->SetStamp( myStamp ); + + if ( step->_is_equivalent( myStep ) && !myIsChanged ) + return; + + const int nbColumns = columnCount(); + const int nbComps = nbColumns - 1; + const int nbRows = rowCount(); + + switch ( myDataType ) { + case 0: + { + GEOM::GEOM_BoolFieldStep_var bs = GEOM::GEOM_BoolFieldStep::_narrow( step ); + if ( !bs->_is_nil() ) + { + GEOM::short_array_var vals = new GEOM::short_array(); + vals->length( nbRows * nbComps ); + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + vals[ iV++ ] = ((CheckItem*)item( iR, iC ))->value(); + bs->SetValues( vals ); + } + break; + } + case 1: + { + GEOM::GEOM_IntFieldStep_var is = GEOM::GEOM_IntFieldStep::_narrow( step ); + if ( !is->_is_nil() ) + { + GEOM::ListOfLong_var vals = new GEOM::ListOfLong(); + vals->length( nbRows * nbComps ); + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + vals[ iV++ ] = text( iR, iC ).toInt(); + is->SetValues( vals ); + } + break; + } + case 2: + { + GEOM::GEOM_DoubleFieldStep_var ds = GEOM::GEOM_DoubleFieldStep::_narrow( step ); + if ( !ds->_is_nil() ) + { + GEOM::ListOfDouble_var vals = new GEOM::ListOfDouble(); + vals->length( nbRows * nbComps ); + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + vals[ iV++ ] = text( iR, iC ).toDouble(); + ds->SetValues( vals ); + } + break; + } + default: + + GEOM::GEOM_StringFieldStep_var ss = GEOM::GEOM_StringFieldStep::_narrow( step ); + if ( !ss->_is_nil() ) + { + GEOM::string_array_var vals = new GEOM::string_array(); + vals->length( nbRows * nbComps ); + for ( int iV = 0, iR = 0; iR < nbRows; ++iR ) + for ( int iC = 1; iC < nbColumns; ++iC ) + vals[ iV++ ] = item( iR, iC )->text().toLatin1().constData(); + ss->SetValues( vals ); + } + } + + myIsChanged = false; + + return; +} + +//======================================================================= +//function : EntityGUI_FieldDlg +//purpose : +//======================================================================= + +EntityGUI_FieldDlg::EntityGUI_FieldDlg (GeometryGUI* theGeometryGUI, + GEOM::GEOM_Field_ptr theField, int stepID, + QWidget* parent, + bool modal, Qt::WindowFlags fl) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl), + myIsCreation( CORBA::is_nil( theField )), + myField( GEOM::GEOM_Field::_duplicate( theField )), + myCurStepID( stepID ), + myCurStepTable( NULL ), + myIsHiddenMain( false ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + QPixmap iconSelect (resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(myIsCreation ? tr("CREATE_FIELD_TITLE") : tr("EDIT_FIELD_TITLE")); + + // Shape type button group + mainFrame()->GroupConstructors->hide(); + + // Field name + mainFrame()->GroupBoxName->setTitle(tr("FIELD_NAME")); + + // Field properties + + QGroupBox* propGroup = new QGroupBox(tr("PROPERTIES"), centralWidget()); + QGridLayout* propLayout = new QGridLayout(propGroup); + propLayout->setMargin(9); + propLayout->setSpacing(6); + + // shape + QLabel* shapeLabel = new QLabel(tr("SHAPE"), propGroup); + myShapeSelBtn = new QPushButton(propGroup); + myShapeSelBtn->setIcon(iconSelect); + myShapeSelBtn->setEnabled( myIsCreation ); + myShapeName = new QLineEdit(propGroup); + myShapeName->setReadOnly(true); + myShapeName->setEnabled( myIsCreation ); + + // data type + QLabel* typeLabel = new QLabel( tr("DATA_TYPE"), propGroup ); + myTypeCombo = new QComboBox( propGroup ); + myTypeCombo->insertItem( GEOM::FDT_Bool, tr("BOOL")); + myTypeCombo->insertItem( GEOM::FDT_Int, tr("INT")); + myTypeCombo->insertItem( GEOM::FDT_Double, tr("DOUBLE")); + myTypeCombo->insertItem( GEOM::FDT_String, tr("STRING")); + myTypeCombo->setCurrentIndex( GEOM::FDT_Double ); // double + + // dimension + QLabel* dimLabel = new QLabel( tr("SHAPE_TYPE"), propGroup ); + myDimCombo = new QComboBox( propGroup ); + + // nb components + QLabel* nbCompsLabel = new QLabel( tr("NB_COMPS"), propGroup ); + myNbCompsSpin = new SalomeApp_IntSpinBox( 1, 1000, 1, propGroup, true, true ); + myNbCompsSpin->setValue( 1 ); + propLayout->addWidget(shapeLabel, 0, 0); + propLayout->addWidget(myShapeSelBtn, 0, 1); + propLayout->addWidget(myShapeName, 0, 2); + propLayout->addWidget(typeLabel, 1, 0, 1, 2); + propLayout->addWidget(myTypeCombo, 1, 2); + propLayout->addWidget(dimLabel, 2, 0, 1, 2); + propLayout->addWidget(myDimCombo, 2, 2); + propLayout->addWidget(nbCompsLabel, 3, 0, 1, 2); + propLayout->addWidget(myNbCompsSpin, 3, 2); + // propLayout->addWidget(shapeLabel, 0, 0); + // propLayout->addWidget(myShapeName, 0, 1); + // propLayout->addWidget(typeLabel, 1, 0); + // propLayout->addWidget(myTypeCombo, 1, 1); + // propLayout->addWidget(dimLabel, 2, 0); + // propLayout->addWidget(myDimCombo, 2, 1); + // propLayout->addWidget(nbCompsLabel, 3, 0); + // propLayout->addWidget(myNbCompsSpin, 3, 1); + + propLayout->setColumnStretch(2, 5); + + // Field values + + QGroupBox* valsGroup = new QGroupBox(tr("VALUES"), centralWidget()); + QGridLayout* valsLayout = new QGridLayout(valsGroup); + valsLayout->setMargin(9); + valsLayout->setSpacing(6); + + // value table + mySwitchTableWdg = new QWidget(valsGroup); + QVBoxLayout* switchTableGrpLayout = new QVBoxLayout(mySwitchTableWdg); + switchTableGrpLayout->setMargin(0); + switchTableGrpLayout->setSpacing(0); + + // step browse controls + myPrevStepBtn = new QPushButton( tr("PREV_STEP"), valsGroup ); + QLabel* curStepLbl = new QLabel(tr("STEP"), valsGroup ); + myStepsCombo = new QComboBox(valsGroup); + myNextStepBtn = new QPushButton( tr("NEXT_STEP"), valsGroup ); + + // step add/rm controls + QPushButton* addStepBtn = new QPushButton( tr("ADD_STEP"), valsGroup ); + QLabel* stampLbl = new QLabel(tr("STAMP"), valsGroup ); + myStampSpin = new SalomeApp_IntSpinBox( -theIntLimit, theIntLimit, 1, valsGroup, true, true); + myRmStepBtn = new QPushButton( tr("REMOVE_STEP"), valsGroup ); + + valsLayout->addWidget(mySwitchTableWdg, 0, 0, 1, 4); + valsLayout->addWidget(myPrevStepBtn, 1, 0); + valsLayout->addWidget(curStepLbl, 1, 1); + valsLayout->addWidget(myStepsCombo, 1, 2); + valsLayout->addWidget(myNextStepBtn, 1, 3); + valsLayout->addWidget(addStepBtn, 2, 0); + valsLayout->addWidget(stampLbl, 2, 1); + valsLayout->addWidget(myStampSpin, 2, 2); + valsLayout->addWidget(myRmStepBtn, 2, 3); + + valsLayout->setColumnStretch(2, 5); + valsLayout->setRowStretch (0, 5); + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(propGroup); + layout->addWidget(valsGroup); + + setHelpFileName("geom_field_page.html"); + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + connect(aSelMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + connect(myPrevStepBtn, SIGNAL(clicked()), this, SLOT( onPrevStep() )); + connect(myNextStepBtn, SIGNAL(clicked()), this, SLOT( onNextStep() )); + connect(addStepBtn, SIGNAL(clicked()), this, SLOT( onAddStep() )); + connect(myRmStepBtn, SIGNAL(clicked()), this, SLOT( onRmStep() )); + connect(myStampSpin, SIGNAL(valueChanged(int)), this, SLOT( onStampChange() )); + connect(myStepsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT( showCurStep() )); + connect(myStepsCombo, SIGNAL(activated(int)), this, SLOT( showCurStep() )); + + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + Init(); + //updateState(); +} + +//======================================================================= +//function : ~EntityGUI_FieldDlg +//purpose : +//======================================================================= + +EntityGUI_FieldDlg::~EntityGUI_FieldDlg() +{ + GEOM_Displayer* aDisplayer = getDisplayer(); + if (myIsHiddenMain) { + aDisplayer->Display(myShape); + myIsHiddenMain = false; + } + // if ( !myField->_is_nil()) + // aDisplayer->Display(myField); +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void EntityGUI_FieldDlg::Init() +{ + myDmMode = -1; + myStepsCombo->clear(); + + if ( myIsCreation || myField->_is_nil() ) + { + myIsCreation = true; + myStepTables.clear(); + if ( myCurStepTable ) + myCurStepTable->hide(); + myCurStepTable = NULL; + myCurStepID = 0; + + initName(tr("FIELD_PREFIX")); + myStampSpin->setValue(0); + + SelectionIntoArgument(); + + onAddStep(); + + connect(myShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT( onTypeChange())); + connect(myDimCombo, SIGNAL(currentIndexChanged(int)), this, SLOT( onDimChange())); + connect(myNbCompsSpin, SIGNAL(valueChanged(int)), this, SLOT( onNbCompsChange())); + + } + else // edition + { + myIsCreation = false; + + CORBA::String_var fName = myField->GetName(); + myMainFrame->ResultName->setText( fName.in() ); + + myShape = myField->GetShape(); + CORBA::String_var sName; + if ( !myShape->_is_nil() ) + sName = myShape->GetName(); + myShapeName->setText( sName.in() ? sName.in() : ""); + + myTypeCombo->setCurrentIndex( myField->GetDataType() ); + + updateDims( myField->GetDimension() ); + updateShapeIDs(); + + GEOM::string_array_var compNames = myField->GetComponents(); + myNbCompsSpin->setValue( compNames->length() ); + + myShapeSelBtn->setEnabled( false ); + myShapeName->setEnabled( false ); + myTypeCombo->setEnabled( false ); + myDimCombo->setEnabled( false ); + myNbCompsSpin->setEnabled( false ); + + // get and sort step IDs + GEOM::ListOfLong_var stepIDs = myField->GetSteps(); + QList< int > stepsList; + for ( size_t i = 0; i < stepIDs->length(); ++i ) + stepsList.push_back( stepIDs[i] ); + qSort( stepsList.begin(), stepsList.end() ); + + myStepsCombo->blockSignals( true ); + for ( size_t i = 0; i < stepIDs->length(); ++i ) + { + myStepsCombo->insertItem( i, QString::number( stepsList[i] )); + if ( myCurStepID == stepsList[i] ) + myStepsCombo->setCurrentIndex( i ); + } + // if ( myStepsCombo->count() == 0 ) + // myStepsCombo->insertItem( 0, QString::number( myCurStepID )); + myStepsCombo->blockSignals( false ); + + showCurStep(); + activateSelection(); + } +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void EntityGUI_FieldDlg::enterEvent(QEvent* e) +{ + if (!buttonCancel()->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void EntityGUI_FieldDlg::ClickOnOk() +{ + setIsApplyAndClose(true); + if (ClickOnApply()) + ClickOnCancel(); + setIsApplyAndClose(false); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool EntityGUI_FieldDlg::ClickOnApply() +{ + if(!isApplyAndClose()) { + setIsDisableBrowsing( true ); + setIsDisplayResult( false ); + } + + QString msg; + if ( !isValid( msg ) ) { + showError( msg ); + return false; + } + SUIT_OverrideCursor wc; + SUIT_Session::session()->activeApplication()->putInfo( "" ); + + try { + if ( openCommand() ) + if (!execute (/*isApplyAndClose()*/)) + { + abortCommand(); + showError(); + return false; + } + } + catch( const SALOME::SALOME_Exception& e ) { + SalomeApp_Tools::QtCatchCorbaException( e ); + abortCommand(); + return false; + } + commitCommand(); + + if(!isApplyAndClose()) { + setIsDisableBrowsing( false ); + setIsDisplayResult( true ); + } + + if ( myIsCreation ) + { + myField = GEOM::GEOM_Field::_nil(); + if ( !isApplyAndClose() ) + Init(); + } + return true; +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void EntityGUI_FieldDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + activateSelection(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void EntityGUI_FieldDlg::SetEditCurrentArgument() +{ + myEditCurrentArgument = myShapeName; + SelectionIntoArgument(); +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void EntityGUI_FieldDlg::SelectionIntoArgument() +{ + if (myEditCurrentArgument == myShapeName || // Selection of a shape is active + myShape->_is_nil()) + { + myShapeName->setText(""); + myShape = GEOM::GEOM_Object::_nil(); + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + int nbSel = aSelList.Extent(); + + if (nbSel == 1) { + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(aSelList.First()); + + if ( GEOMBase::IsShape(anObj) && anObj->IsMainShape() ) { + if (myIsHiddenMain) { + GEOM_Displayer* aDisplayer = getDisplayer(); + aDisplayer->Display(myShape); + myIsHiddenMain = false; + } + myShapeName->setText(GEOMBase::GetName(anObj)); + + if ( !anObj->_is_nil() && !anObj->IsSame( myShape )) + { + myShape = anObj; + myShapeMap.Clear(); + myEditCurrentArgument = 0; + + // re-fill myDimCombo + const int curDim = getDim(); + updateDims( curDim ); + + // update table + onDimChange(); + } + } + } + else { + if (myIsHiddenMain) { + GEOM_Displayer* aDisplayer = getDisplayer(); + aDisplayer->Display(myShape); + myIsHiddenMain = false; + } + } + } + else // select rows of a table according to shape selection + { + if ( !myCurStepTable ) + return; + + bool isSignalsBlocked = myCurStepTable->signalsBlocked(); + myCurStepTable->blockSignals(true); + + QList< int > rowsToSelect; + TColStd_IndexedMapOfInteger aMapIndex; + if ( getSelectedSubshapes(aMapIndex )) + for (int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++) { + const int shapeID = aMapIndex( ii ); + for (int row = 0, n = myShapeIDs.size(); row < n; row++) + if ( myShapeIDs[row] == shapeID ) { + rowsToSelect.push_back( row ); + break; + } + } + myCurStepTable->selectRows( rowsToSelect ); + + myCurStepTable->blockSignals(isSignalsBlocked); + } +} + +//================================================================================= +// function : onDimChange() +// purpose : update dialog at change of dimension +//================================================================================= +void EntityGUI_FieldDlg::onDimChange() +{ + // get order of sub-shapes - myShapeIDs + updateShapeIDs(); + + // update size of tables + const int nbRows = myShapeIDs.size(); + QString subName = ( getDim() == -1 ) ? tr("WHOLE_SHAPE_VHEADER") : myDimCombo->currentText(); + QMap< int, StepTable* >::iterator tblIt = myStepTables.begin(); + for ( ; tblIt != myStepTables.end(); ++tblIt ) + if ( tblIt.value() ) + tblIt.value()->setDim( nbRows, subName ); + + activateSelection(); +} + +//======================================================================= +//function : onNbCompsChange +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::onNbCompsChange() +{ + QMap< int, StepTable* >::iterator tblIt = myStepTables.begin(); + for ( ; tblIt != myStepTables.end(); ++tblIt ) + if ( tblIt.value() ) + tblIt.value()->setNbComps( getNbComps() ); +} + +//======================================================================= +//function : onTypeChange +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::onTypeChange() +{ + QMap< int, StepTable* >::iterator tblIt = myStepTables.begin(); + for ( ; tblIt != myStepTables.end(); ++tblIt ) + if ( tblIt.value() ) + tblIt.value()->setDataType( myTypeCombo->currentIndex() ); +} + +//================================================================================= +// function : onPrevStep() +// purpose : +//================================================================================= +void EntityGUI_FieldDlg::onPrevStep() +{ + int i = myStepsCombo->currentIndex(); + if ( i > 0 ) + { + myStepsCombo->setCurrentIndex( i-1 ); + showCurStep(); + } +} + +//================================================================================= +// function : onNextStep() +// purpose : +//================================================================================= +void EntityGUI_FieldDlg::onNextStep() +{ + int i = myStepsCombo->currentIndex(); + if ( i+1 < myStepsCombo->count() ) + { + myStepsCombo->setCurrentIndex( i+1 ); + showCurStep(); + } +} + +//======================================================================= +//function : onAddStep +//purpose : +//======================================================================= +void EntityGUI_FieldDlg::onAddStep() +{ + if ( myStepsCombo->count() > 0 ) + myCurStepID = myStepsCombo->itemText( myStepsCombo->count()-1 ).toInt() + 1; + + myStepsCombo->insertItem( myStepsCombo->count(), QString::number( myCurStepID )); + myStepsCombo->setCurrentIndex( myStepsCombo->count() - 1 ); + myRemovedSteps.remove( getCurStepID() ); + //showCurStep(); +} + +//======================================================================= +//function : onRmStep +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::onRmStep() +{ + if ( myStepsCombo->count() > 1 ) + { + myStepTables.remove( getCurStepID() ); + myRemovedSteps.insert( getCurStepID() ); + if ( myCurStepTable ) + myCurStepTable->hide(); + myCurStepTable = NULL; + myStepsCombo->removeItem( myStepsCombo->currentIndex() ); + //showCurStep(); + } +} + +//======================================================================= +//function : onStampChange +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::onStampChange() +{ + if ( myCurStepTable ) + myCurStepTable->setStamp( myStampSpin->value() ); +} + +//======================================================================= +//function : showCurStep +//purpose : +//======================================================================= + +void EntityGUI_FieldDlg::showCurStep() +{ + myCurStepID = getCurStepID(); + + QStringList headers; + if ( myCurStepTable ) + { + if ( myCurStepTable->getStepID() == myCurStepID ) + { + myCurStepTable->show(); + return; + } + else + { + myCurStepTable->hide(); + headers = myCurStepTable->getHeaders(); + myCurStepTable->getStamp(); + } + } + + if ( myStepTables.count ( myCurStepID )) + { + myCurStepTable = myStepTables[ myCurStepID ]; + myCurStepTable->setHeaders( headers ); + } + else + { + // if ( myStepsCombo->count() == 0 ) + // return; // edit a field with no steps + + // get step values + GEOM::GEOM_FieldStep_var stepVar; + if ( !myField->_is_nil() ) + stepVar = myField->GetStep( myCurStepID ); + + int nbComps = getNbComps(); + if ( headers.count() == 0 ) + { + headers << tr("SUB_SHAPE_HEADER"); + if ( !myIsCreation && !myField->_is_nil() ) + { + GEOM::string_array_var compNames = myField->GetComponents(); + for ( int iC = 0; iC < compNames->length(); ++iC ) + headers << compNames[ iC ].in(); + } + else + { + for ( int iC = 0; iC < nbComps; ++iC ) + headers << QString("Comp %1").arg( iC + 1 ); + } + } + QString subName = ( getDim() == -1 ) ? tr("WHOLE_SHAPE_VHEADER") : myDimCombo->currentText(); + myCurStepTable = new StepTable( myCurStepID, getDataType(), myShapeIDs.size(), + nbComps, subName, headers, stepVar, mySwitchTableWdg ); + myStepTables[ myCurStepID ] = myCurStepTable; + mySwitchTableWdg->layout()->addWidget( myCurStepTable ); + } + myCurStepTable->show(); + myStampSpin->setValue( myCurStepTable->getStamp() ); + + connect(myCurStepTable, SIGNAL(itemSelectionChanged()), this, SLOT( highlightSubShapes() )); + + myPrevStepBtn->setEnabled( myStepsCombo->currentIndex() > 0 ); + myNextStepBtn->setEnabled( myStepsCombo->currentIndex()+1 < myStepsCombo->count() ); + myRmStepBtn->setEnabled( myStepsCombo->count() > 1 ); +} + +//================================================================================= +// function : getSelectedSubshapes +// purpose : +//================================================================================= +int EntityGUI_FieldDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex) +{ + theMapIndex.Clear(); + + SalomeApp_Application* app = myGeomGUI->getApp(); + if (!app || myShape->_is_nil()) + return 0; + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + // try to find out and process the global selection + // (of not published objects and of published sub-shapes) + { + SALOME_ListIteratorOfListIO anIter (aSelList); + for (int i = 0; anIter.More(); anIter.Next(), i++) + { + Handle(SALOME_InteractiveObject) anIObj = anIter.Value(); + QString anEntry = anIObj->getEntry(); + QString str = "_"; + int index = anEntry.lastIndexOf(str); + if (index > 0) // selection among special preview + { + anEntry.remove(0, index+1); + int anIndex = anEntry.toInt(); + if (anIndex) + theMapIndex.Add(anIndex); + } + else // selection among published shapes + { + SalomeApp_Study* appStudy = dynamic_cast(app->activeStudy()); + if (!appStudy) return 0; + _PTR(Study) aStudy = appStudy->studyDS(); + + _PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData())); + GEOM::GEOM_Object_var aGeomObj = + GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj)); + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aGeomObj, aShape)) { + if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == getShapeType()) + { + TopExp_Explorer anExp (aShape, getShapeType()); + for (; anExp.More(); anExp.Next()) { + TopoDS_Shape aSubShape = anExp.Current(); + int anIndex = myShapeMap.FindIndex(aSubShape); + if (anIndex == 0) { + SUIT_MessageBox::warning(app->desktop(), QObject::tr("WRN_WARNING"), + tr("WRN_NOT_SUBSHAPE")); + } + theMapIndex.Add(anIndex); + } + } + } + } + } // for aSelList + } + + return theMapIndex.Extent(); +} + +//================================================================================= +// function : getShapeType() +// purpose : +//================================================================================= +TopAbs_ShapeEnum EntityGUI_FieldDlg::getShapeType(int* dim) const +{ + + switch ( dim ? *dim : getDim() ) + { + case 0: return TopAbs_VERTEX; + case 1: return TopAbs_EDGE; + case 2: return TopAbs_FACE; + case 3: return TopAbs_SOLID; + default: return TopAbs_SHAPE; + } +} + +//======================================================================= +//function : getDim +//purpose : +//======================================================================= + +int EntityGUI_FieldDlg::getDim() const +{ + int i = myDimCombo->currentIndex(); + return ( i < 0 ) ? -1 : myDimCombo->itemData( i ).toInt(); +} + +//======================================================================= +//function : getDataType +//purpose : +//======================================================================= + +int EntityGUI_FieldDlg::getDataType() const +{ + return myTypeCombo->currentIndex(); +} + +//======================================================================= +//function : getCurStepID +//purpose : +//======================================================================= + +int EntityGUI_FieldDlg::getCurStepID() const +{ + if ( myStepsCombo->count() > 0 ) + return myStepsCombo->currentText().toInt(); + return myCurStepID; +} + +//======================================================================= +//function : getNbComps +//purpose : +//======================================================================= + +int EntityGUI_FieldDlg::getNbComps() const +{ + return myNbCompsSpin->value(); +} + +//================================================================================= +// function : updateShapeIDs() +// purpose : update myShapeIDs +//================================================================================= +void EntityGUI_FieldDlg::updateShapeIDs() +{ + myShapeIDs.clear(); + //myShapeMap.Clear(); + if ( !myShape->_is_nil() ) + { + TopoDS_Shape aShape = + GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myShape); + if ( myShapeMap.IsEmpty() ) + TopExp::MapShapes(aShape, myShapeMap); + TopAbs_ShapeEnum shapeType = getShapeType(); + if ( shapeType == TopAbs_SHAPE ) + { + myShapeIDs.push_back( 1 ); + } + else + { + TopTools_IndexedMapOfShape dimSubShapesMap; + TopExp::MapShapes(aShape, shapeType, dimSubShapesMap); + myShapeIDs.resize( dimSubShapesMap.Extent() ); + for ( int i = 1; i <= dimSubShapesMap.Extent(); ++i ) + myShapeIDs[i-1] = myShapeMap.FindIndex( dimSubShapesMap(i) ); + } + } +} + +//======================================================================= +//function : updateDims +//purpose : update myDimCombo +//======================================================================= + +void EntityGUI_FieldDlg::updateDims(int curDim) +{ + myDimCombo->blockSignals( true ); + myDimCombo->clear(); + TopoDS_Shape aShape = + GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myShape); + + if ( !aShape.IsNull() ) + { + const char* subNames[4] = { "VERTEX","EDGE","FACE","SOLID" }; + TopExp_Explorer exp; + for ( int dim = 0; dim < 4; ++dim ) + { + exp.Init( aShape, getShapeType(&dim)); + if ( exp.More() && !aShape.IsSame( exp.Current() )) + { + myDimCombo->insertItem( dim, tr( subNames[dim] ), dim ); + if ( dim == curDim ) // restore current dim + myDimCombo->setCurrentIndex( myDimCombo->count()-1 ); + } + } + myDimCombo->insertItem( 4, tr("WHOLE"), -1 ); + if ( getDim() != curDim ) + myDimCombo->setCurrentIndex( myDimCombo->count()-1 ); + } + myDimCombo->blockSignals( false ); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate local selection +//================================================================================= +void EntityGUI_FieldDlg::activateSelection() +{ + bool isApply = ((QPushButton*)sender() == buttonApply()); + if(!isApplyAndClose()) + erasePreview(false); + + // local selection + if (!myShape->_is_nil() && + !myEditCurrentArgument && + myShapeIDs.size() > 1 ) // shape type is already choosen by user + { + GEOM_Displayer* aDisplayer = getDisplayer(); + CORBA::String_var aMainEntry = myShape->GetStudyEntry(); + + //display mode for main shape + if ( myDmMode == -1 ) { + SALOME_View* view = GEOM_Displayer::GetActiveView(); + if (view) { + Handle(SALOME_InteractiveObject) io = + new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO"); + if ( view->isVisible( io ) ) { + Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIOinGEOMAISShape( io, true ); + if(!aSh.IsNull()) { + myDmMode = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode(); + } + // Hide main shape, if explode on VERTEX + if(getShapeType() != TopAbs_VERTEX) { + aDisplayer->Erase(myShape, false, false); + myIsHiddenMain = true; + } + } + else + myDmMode = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "display_mode" ); + } + } + aDisplayer->SetDisplayMode(myDmMode); + + // Mantis issue 0021421: do not hide main shape, if explode on VERTEX + if (getShapeType() == TopAbs_VERTEX) { + if (myIsHiddenMain) + aDisplayer->Display(myShape); + } + //aDisplayer->Erase(myField, false, false); ------- NOR YET implemented + + QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", "editField_color" ); + Quantity_NameOfColor aCol = SalomeApp_Tools::color( aColor ).Name(); + + if(!isApplyAndClose()) { + SUIT_ViewWindow* aViewWindow = 0; + SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy(); + if (activeStudy) + aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); + if (aViewWindow == 0) return; + + SUIT_ViewManager* aViewManager = aViewWindow->getViewManager(); + if (aViewManager->getType() != OCCViewer_Viewer::Type() && + aViewManager->getType() != SVTK_Viewer::Type()) + return; + + SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); + SALOME_View* aView = dynamic_cast(aViewModel); + if (aView == 0) return; + + TopoDS_Shape aMainShape = myShapeMap(1); + for ( int i = 0; i < myShapeIDs.size(); ++i ) + { + int index = myShapeIDs[ i ]; + TopoDS_Shape aSubShape = myShapeMap( index ); + QString anEntry = QString( "TEMP_" ) + aMainEntry.in() + QString("_%1").arg(index); + Handle(SALOME_InteractiveObject) io = + new SALOME_InteractiveObject(anEntry.toAscii(), "GEOM", "TEMP_IO"); + aDisplayer->SetColor( aCol ); + SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView); + if (aPrs) { + displayPreview(aPrs, true, false); // append, do not update + // TODO: map or delete Prs + } + } + aDisplayer->UnsetDisplayMode(); + aDisplayer->UnsetColor(); + aDisplayer->UpdateViewer(); + } + } + + globalSelection(GEOM_ALLSHAPES); + + SelectionIntoArgument(); +} + +//================================================================================= +// function : highlightSubShapes +// purpose : select objects corresponding to selected table rows +//================================================================================= +void EntityGUI_FieldDlg::highlightSubShapes() +{ + if (CORBA::is_nil(myShape) || !myCurStepTable ) + return; + + TColStd_MapOfInteger anIds; + QList rows = myCurStepTable->selectedRows(); + int ii = 0, nn = rows.count(); + for (; ii < nn; ii++) + { + int shapeNum = rows[ ii ]; + if ( shapeNum < myShapeIDs.size() ) + anIds.Add( myShapeIDs[ shapeNum ]); + } + + SalomeApp_Application* app = myGeomGUI->getApp(); + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + aSelMgr->clearSelected(); + if ( anIds.IsEmpty() ) + return; + + SUIT_ViewWindow* aViewWindow = 0; + SUIT_Study* activeStudy = app->activeStudy(); + if (activeStudy) + aViewWindow = app->desktop()->activeWindow(); + if (aViewWindow == 0) return; + + SUIT_ViewManager* aViewManager = aViewWindow->getViewManager(); + if (aViewManager->getType() != OCCViewer_Viewer::Type() && + aViewManager->getType() != SVTK_Viewer::Type()) + return; + + SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); + SALOME_View* aView = dynamic_cast(aViewModel); + if (aView == 0) return; + + // TODO??: use here GEOMBase_Helper::myPreview instead of ic->DisplayedObjects() + + OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)aViewManager)->getOCCViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + AIS_ListOfInteractive List; + //ic->DisplayedObjects(List); + ic->ObjectsInside(List); // Mantis issue 0021367 + + SALOME_ListIO aSelList; + + // To highlight the selected sub-shape in Object Browser, if it's already published under the main shape + GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations(getStudyId()); + QMap childsMap; + SalomeApp_Study* appStudy = dynamic_cast(app->activeStudy()); + if (appStudy) { + _PTR(Study) aStudy = appStudy->studyDS(); + CORBA::String_var aMainEntry = myShape->GetStudyEntry(); + _PTR(SObject) aSObj = aStudy->FindObjectID( aMainEntry.in() ); + _PTR(ChildIterator) anIt = aStudy->NewChildIterator(aSObj); + for (anIt->InitEx(true); anIt->More(); anIt->Next()) { + GEOM::GEOM_Object_var aChild = + GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anIt->Value())); + if (!CORBA::is_nil(aChild)) { + int index = aLocOp->GetSubShapeIndex(myShape, aChild); + if ( anIds.Contains( index )) { + CORBA::String_var aChildEntry = aChild->GetStudyEntry(); + //childsMap.insert(index, aChildEntry.in()); + Handle(SALOME_InteractiveObject) tmpIO = + new SALOME_InteractiveObject( aChildEntry.in(), "GEOM", "TEMP_IO"); + aSelList.Append(tmpIO); + } + } + } + } + + AIS_ListIteratorOfListOfInteractive ite (List); + for (; ite.More(); ite.Next()) { + if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + if (aSh->hasIO()) { + Handle(SALOME_InteractiveObject) anIO = aSh->getIO(); + QString anEntry = anIO->getEntry(); + int index = anEntry.lastIndexOf("_"); + anEntry.remove(0, index+1); + int anIndex = anEntry.toInt(); + if (anIds.Contains(anIndex)) { + aSelList.Append(anIO); + // if (childsMap.contains (anIndex)) { + // Handle(SALOME_InteractiveObject) tmpIO = new SALOME_InteractiveObject(childsMap.value(anIndex).toLatin1().constData(), "GEOM", "TEMP_IO"); + // aSelList.Append(tmpIO); + // } + } + } + } + } + aSelMgr->setSelectedObjects(aSelList); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr EntityGUI_FieldDlg::createOperation() +{ + return getGeomEngine()->GetIFieldOperations(getStudyId()); +} + +#define RETURN_WITH_MSG(a, b) \ + if ((a)) { \ + theMessage += (b); \ + return false; \ + } + +//================================================================================= +// function : isValid() +// purpose : Verify validity of input data +//================================================================================= +bool EntityGUI_FieldDlg::isValid(QString& theMessage) +{ + SalomeApp_Study* study = getStudy(); + RETURN_WITH_MSG (!study, tr("GEOM_NO_STUDY")) + RETURN_WITH_MSG (study->studyDS()->GetProperties()->IsLocked(), tr("GEOM_STUDY_LOCKED")) + + if ( myIsCreation ) { + RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_SHAPE")) + } + else { + RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD")) + } + + QString aName = getNewObjectName().trimmed(); + RETURN_WITH_MSG (aName.isEmpty(), tr("EMPTY_NAME")) + + RETURN_WITH_MSG ( !myCurStepTable, tr("NO_VALUES")) + return true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool EntityGUI_FieldDlg::execute() +{ + SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy( getStudy()->studyDS() ); + SALOMEDS::StudyBuilder_var aBuilder = aStudyDS->NewBuilder(); + + QString aName = getNewObjectName().trimmed(); + QStringList anEntryList; + + if ( myField->_is_nil() ) // create field + { + QStringList columnNames = myCurStepTable->getHeaders(); + int nbComps = columnNames.count() - 1; + GEOM::string_array_var compNames = new GEOM::string_array(); + compNames->length( nbComps ); + for ( int iC = 0; iC < nbComps; ++iC ) + compNames[ iC ] = columnNames[ iC+1 ].toLatin1().constData(); + + GEOM::GEOM_IFieldOperations_var anOper = GEOM::GEOM_IFieldOperations::_narrow(getOperation()); + myField = anOper->CreateField( myShape, + aName.toLatin1().constData(), + GEOM::field_data_type( getDataType() ), + CORBA::Short( getDim() ), + compNames ); + if ( myField->_is_nil() ) + return false; + + SALOMEDS::SObject_wrap aSO = + getGeomEngine()->AddInStudy( aStudyDS, myField, aName.toLatin1().constData(), myShape ); + if ( !aSO->_is_nil() ) { + myField->UnRegister(); + CORBA::String_var entry = aSO->GetID(); + anEntryList << entry.in(); + } + } + else // update field name + { + myField->SetName( aName.toLatin1().constData() ); + + CORBA::String_var entry = myField->GetStudyEntry(); + if ( entry.in() ) { + SALOMEDS::SObject_wrap SO = aStudyDS->FindObjectID( entry.in() ); + if ( !SO->_is_nil() ) { + aBuilder->SetName(SO, aName.toLatin1().constData()); + } + } + } + + // create / update steps + QMap< int, StepTable* >::iterator i_tbl = myStepTables.begin(); + for ( ; i_tbl != myStepTables.end(); ++i_tbl ) + { + StepTable* tbl = i_tbl.value(); + GEOM::GEOM_FieldStep_var step = tbl->getStep(); + if ( step->_is_nil() ) + { + step = myField->GetStep( tbl->getStepID() ); + if ( step->_is_nil() ) + { + step = myField->AddStep( tbl->getStepID(), tbl->getStamp() ); + + QString stepName = (tr("STEP")+" %1 %2").arg( tbl->getStepID() ).arg( tbl->getStamp() ); + SALOMEDS::SObject_wrap aSO = + getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toLatin1().constData(), myField ); + if ( /*!myIsCreation &&*/ !aSO->_is_nil() ) { + step->UnRegister(); + CORBA::String_var entry = aSO->GetID(); + anEntryList << entry.in(); + } + } + } + tbl->setValues( step ); + } + + // remove steps + if ( !myIsCreation ) + { + QSet< int >::iterator stepID = myRemovedSteps.begin(); + for ( ; stepID != myRemovedSteps.end(); ++stepID ) + { + GEOM::GEOM_FieldStep_var step = myField->GetStep( *stepID ); + if ( !step->_is_nil() ) + { + CORBA::String_var entry = step->GetStudyEntry(); + myField->RemoveStep( *stepID ); + + if ( entry.in() ) { + SALOMEDS::SObject_wrap SO = aStudyDS->FindObjectID( entry.in() ); + if ( !SO->_is_nil() ) + aBuilder->RemoveObjectWithChildren( SO ); + } + } + } + } + myRemovedSteps.clear(); + + updateObjBrowser(); + + if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) { + LightApp_Application* aLightApp = dynamic_cast( anApp ); + if( aLightApp && !isDisableBrowsing() && anEntryList.count() ) + { + aLightApp->browseObjects( anEntryList, isApplyAndClose(), isOptimizedBrowsing() ); + anApp->putInfo( QObject::tr("GEOM_PRP_DONE") ); + } + } + + return true; +} diff --git a/src/EntityGUI/EntityGUI_FieldDlg.h b/src/EntityGUI/EntityGUI_FieldDlg.h new file mode 100644 index 000000000..c5c7b2120 --- /dev/null +++ b/src/EntityGUI/EntityGUI_FieldDlg.h @@ -0,0 +1,136 @@ +// 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 +// + +// GEOM GEOMGUI : GUI for Geometry component +// File : EntityGUI_FieldDlg.h + +#ifndef EntityGUI_FieldDlg_H +#define EntityGUI_FieldDlg_H + +#include + +#include +#include +#include +#include + +#include +#include +#include + +class QGroupBox; +class QLineEdit; +class QPushButton; +class QComboBox; +class SalomeApp_IntSpinBox; + +//================================================================================= +// class : EntityGUI_FieldDlg +// purpose : +//================================================================================= +class EntityGUI_FieldDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + + class StepTable; + class IntSpinItem; + class DoubleSpinItem; + class CheckItem; + class Delegate; + +public: + + EntityGUI_FieldDlg (GeometryGUI* theGeometryGUI, + GEOM::GEOM_Field_ptr theField, int stepID=0, + QWidget* parent=0, + bool modal=false, Qt::WindowFlags fl=0); + ~EntityGUI_FieldDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (); + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + + void onPrevStep(); + void onNextStep(); + void onAddStep(); + void onRmStep(); + void onStampChange(); + void onDimChange(); + void onTypeChange(); + void onNbCompsChange(); + void showCurStep(); + void highlightSubShapes(); + +private: + void Init(); + void enterEvent (QEvent*); + void activateSelection(); + + TopAbs_ShapeEnum getShapeType(int* dim=0) const; + int getDim() const; + int getDataType() const; + int getCurStepID() const; + int getNbComps() const; + void updateShapeIDs(); + void updateDims(int curDim=-1); + int getSelectedSubshapes (TColStd_IndexedMapOfInteger& map); + +private: + + bool myIsCreation; + GEOM::GEOM_Field_var myField; + GEOM::GEOM_Object_var myShape; + QVector< int > myShapeIDs; + TopTools_IndexedMapOfShape myShapeMap; + + int myCurStepID; + StepTable* myCurStepTable; + QMap< int, StepTable* > myStepTables; + QSet< int > myRemovedSteps; + + int myDmMode; + bool myIsHiddenMain; + + QPushButton* myShapeSelBtn; + QLineEdit* myShapeName; + QComboBox* myTypeCombo; + QComboBox* myDimCombo; + QPushButton* myPrevStepBtn; + QPushButton* myNextStepBtn; + QPushButton* myRmStepBtn; + + SalomeApp_IntSpinBox* myNbCompsSpin; + QWidget* mySwitchTableWdg; + QComboBox* myStepsCombo; + SalomeApp_IntSpinBox* myStampSpin; +}; + +#endif diff --git a/src/GEOM/GEOM_BaseObject.cxx b/src/GEOM/GEOM_BaseObject.cxx index 043350664..005c409ef 100644 --- a/src/GEOM/GEOM_BaseObject.cxx +++ b/src/GEOM/GEOM_BaseObject.cxx @@ -221,10 +221,12 @@ GEOM_BaseObject::~GEOM_BaseObject() //============================================================================= int GEOM_BaseObject::GetType() { + int type = -1; Handle(TDataStd_Integer) aType; - if(!_label.FindChild(TYPE_LABEL).FindAttribute(TDataStd_Integer::GetID(), aType)) return -1; + if(_label.FindChild(TYPE_LABEL).FindAttribute(TDataStd_Integer::GetID(), aType)) + type = aType->Get(); - return aType->Get(); + return type; } //============================================================================= diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 9ae0a597f..c7b82dfd0 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -120,7 +120,7 @@ void GEOMGUI_Selection::init( const QString& context, LightApp_SelectionMgr* sel _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) ); if ( aSO ) { CORBA::Object_var varObj = GeometryGUI::ClientSObjectToObject( aSO ); - myObjects[idx] = GEOM::GEOM_Object::_narrow( varObj ); + myObjects[idx] = GEOM::GEOM_BaseObject::_narrow( varObj ); } } } @@ -199,15 +199,19 @@ QString GEOMGUI_Selection::typeName( const int index ) const static QString aGroup( "Group" ); static QString aShape( "Shape" ); + static QString aField( "Field" ); + static QString aFieldStep( "FieldStep" ); static QString anUnknown( "Unknown" ); - GEOM::GEOM_Object_var anObj = getObject( index ); + GEOM::GEOM_BaseObject_var anObj = getBaseObject( index ); if ( !CORBA::is_nil( anObj ) ) { const int aGeomType = anObj->GetType(); - if ( aGeomType == GEOM_GROUP ) - return aGroup; - else - return aShape; + switch ( aGeomType ) { + case GEOM_GROUP : return aGroup; + case GEOM_FIELD : return aField; + case GEOM_FIELD_STEP: return aFieldStep; + default : return aShape; + } } return anUnknown; } @@ -473,8 +477,8 @@ int GEOMGUI_Selection::nbChildren( const int index ) const if ( study && !anEntry.isEmpty() ) { _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) ); if ( aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) { - _PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO ); - for (it->Init(false); it->More(); it->Next()) nb++; + _PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO ); + for (it->Init(false); it->More(); it->Next()) nb++; } } } @@ -539,7 +543,15 @@ GEOM::GEOM_Object_ptr GEOMGUI_Selection::getObject( const int index ) const { GEOM::GEOM_Object_var o; if ( 0 <= index && index < myObjects.size() ) - o = GEOM::GEOM_Object::_duplicate( myObjects[index] ); + o = GEOM::GEOM_Object::_narrow( myObjects[index] ); + return o._retn(); +} + +GEOM::GEOM_BaseObject_ptr GEOMGUI_Selection::getBaseObject( const int index ) const +{ + GEOM::GEOM_BaseObject_var o; + if ( 0 <= index && index < myObjects.size() ) + o = GEOM::GEOM_BaseObject::_duplicate( myObjects[index] ); return o._retn(); } diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index 1d470c963..b2738f75f 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -79,6 +79,7 @@ private: bool isComponent( const int ) const; bool isFolder( const int ) const; GEOM::GEOM_Object_ptr getObject( const int ) const; + GEOM::GEOM_BaseObject_ptr getBaseObject( const int ) const; bool hasImported() const; bool allImported() const; @@ -86,7 +87,7 @@ private: QVariant visibleProperty( const QString&, const QString& ) const; private: - typedef QVector GeomObjectVector; + typedef QVector GeomObjectVector; private: GeomObjectVector myObjects; diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 19abbc79f..97faa85cf 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -963,6 +963,18 @@ ICO_GROUP_EDIT group_edit.png + + ICO_FIELD_CREATE + field_new.png + + + ICO_FIELD_EDIT + field_edit.png + + + ICO_ADD_FIELD_STEP + field_new.png + ICO_HEX_SOLID box.png @@ -1079,6 +1091,10 @@ ICO_POP_CREATE_GROUP group_new.png + + ICO_POP_EDIT_FIELD + field_edit.png + ICO_PROPAGATE propagate.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 454082125..3320ee1fd 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -2636,6 +2636,22 @@ Please, select face, shell or solid and try again MEN_GROUP_CUT Cut Groups + + MEN_FIELD + Field + + + MEN_FIELD_CREATE + Create Field + + + MEN_FIELD_EDIT + Edit Field + + + MEN_ADD_FIELD_STEP + Add Field Step + MEN_RELOAD_IMPORTED Reload From Disk @@ -2756,6 +2772,10 @@ Please, select face, shell or solid and try again MEN_POP_CREATE_GROUP Create Group + + MEN_POP_EDIT_FIELD + Edit Field + MEN_POP_DISCLOSE_CHILDREN Disclose child items @@ -3468,6 +3488,14 @@ Please, select face, shell or solid and try again STB_GROUP_CUT Cut Groups + + STB_FIELD_CREATE + Create a Field + + + STB_FIELD_EDIT + Edit a Field + STB_RELOAD_IMPORTED Reload imported shape from its original place on disk @@ -3576,6 +3604,10 @@ Please, select face, shell or solid and try again STB_POP_CREATE_GROUP Create Group + + STB_POP_EDIT_FIELD + Edit Field + STB_POP_UNPUBLISH_OBJ Unpublish object @@ -4100,6 +4132,14 @@ Please, select face, shell or solid and try again TOP_GROUP_CUT Cut Groups + + TOP_FIELD_CREATE + Create a Field + + + TOP_FIELD_EDIT + Edit a Field + TOP_HEX_SOLID Hexahedral Solid @@ -4212,6 +4252,10 @@ Please, select face, shell or solid and try again TOP_POP_CREATE_GROUP Create Group + + TOP_POP_EDIT_FIELD + Edit Field + TOP_POP_UNPUBLISH_OBJ Unpublish object @@ -5408,6 +5452,148 @@ Number of sketch points too small The selected shape is not a sub-shape of the main shape. Hide all extra shapes in the viewer for more suitable selection. + + EntityGUI + + NO_FIELD + Please, select a field to edit + + + + EntityGUI_FieldDlg + + CREATE_FIELD_TITLE + Create Field + + + EDIT_FIELD_TITLE + Edit Field + + + FIELD_NAME + Field name + + + PROPERTIES + Properties + + + SHAPE + Shape + + + DATA_TYPE + Type + + + + + + + BOOL + Boolean + + + INT + Integer + + + DOUBLE + Double + + + STRING + String + + + SHAPE_TYPE + Sub-shape + + + VERTEX + Vertex + + + EDGE + Edge + + + FACE + Face + + + SOLID + Solid + + + WHOLE + Whole shape + + + NB_COMPS + Nb. components + + + VALUES + Values + + + PREV_STEP + Previous step + + + STEP + Step + + + NEXT_STEP + Next step + + + ADD_STEP + Add step + + + STAMP + Stamp + + + REMOVE_STEP + Remove step + + + FIELD_PREFIX + Field + + + GEOM_NO_STUDY + No study availabel + + + NO_SHAPE + Shape not selected + + + NO_FIELD + Field not selected + + + EMPTY_NAME + Please, specify a non-empty field name + + + NO_VALUES + No steps added to the field + + + SUB_SHAPE_HEADER + Sub-shape + + + WHOLE_SHAPE_VHEADER + Shape + + MeasureGUI_1Sel1TextView1Check_QTD diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index c447d1434..85242c959 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -550,6 +550,9 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION #endif case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER + case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD + case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD + case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD libName = "EntityGUI"; break; case GEOMOp::OpEdge: // MENU BUILD - EDGE @@ -908,6 +911,9 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" ); createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" ); + createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" ); + createGeomAction( GEOMOp::OpEditField, "FIELD_EDIT" ); + createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" ); createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" ); @@ -1034,6 +1040,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" ); createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" ); createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" ); + createGeomAction( GEOMOp::OpEditFieldPopup, "POP_EDIT_FIELD" ); createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" ); createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" ); createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" ); @@ -1132,6 +1139,12 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( separator(), newEntId, -1 ); + int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 ); + createMenu( GEOMOp::OpCreateField, fieldId, -1 ); + createMenu( GEOMOp::OpEditField, fieldId, -1 ); + + createMenu( separator(), newEntId, -1 ); + int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 ); createMenu( GEOMOp::OpQuadFace, blocksId, -1 ); createMenu( GEOMOp::OpHexaSolid, blocksId, -1 ); @@ -1418,13 +1431,15 @@ void GeometryGUI::initialize( CAM_Application* app ) QtxPopupMgr* mgr = popupMgr(); mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete - mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder'} and selcount>0"), QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); + mgr->insert( action( GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field + mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule ); - mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal shild items + mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); @@ -1496,7 +1511,7 @@ void GeometryGUI::initialize( CAM_Application* app ) QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ", onlyComponent = "((type='Component') and selcount=1)", rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")", - types = "'Shape' 'Group'"; + types = "'Shape' 'Group' 'FieldStep'"; mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule ); @@ -1542,7 +1557,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object - mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule ); @@ -1886,6 +1901,8 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win ) action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group + action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field + action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION } @@ -2047,7 +2064,7 @@ void GeometryGUI::onAutoBringToFront() SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow(); if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() ) - return; + return; SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() ); if (!appStudy) return; @@ -2995,12 +3012,12 @@ bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const if ( dataObj ) { _PTR(SObject) aSO = dataObj->object(); if ( aSO ) { - _PTR(GenericAttribute) anAttr; - _PTR(SObject) aFatherSO = aSO->GetStudy()->GetUseCaseBuilder()->GetFather( aSO ); - if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) { - _PTR(AttributeLocalID) aLocalID( anAttr ); - anObjectInFolder = aLocalID->Value() == 999; - } + _PTR(GenericAttribute) anAttr; + _PTR(SObject) aFatherSO = aSO->GetStudy()->GetUseCaseBuilder()->GetFather( aSO ); + if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) { + _PTR(AttributeLocalID) aLocalID( anAttr ); + anObjectInFolder = aLocalID->Value() == 999; + } } } } @@ -3031,11 +3048,11 @@ bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const if ( dataObj ) { _PTR(SObject) aSO = dataObj->object(); if ( aSO ) { - _PTR(GenericAttribute) anAttr; - if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) { - _PTR(AttributeLocalID) aLocalID( anAttr ); - isFolder = aLocalID->Value() == 999; - } + _PTR(GenericAttribute) anAttr; + if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) { + _PTR(AttributeLocalID) aLocalID( anAttr ); + isFolder = aLocalID->Value() == 999; + } } } } @@ -3062,7 +3079,7 @@ bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const \sa isDraggable(), isDropAccepted() */ void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where, - const int row, Qt::DropAction action ) + const int row, Qt::DropAction action ) { if (action != Qt::CopyAction && action != Qt::MoveAction) return; // unsupported action @@ -3102,8 +3119,8 @@ void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* wher // call engine function GetGeomGen()->Move( objects.in(), // what - _CAST(SObject, parentObj)->GetSObject(), // where - row ); // row + _CAST(SObject, parentObj)->GetSObject(), // where + row ); // row // update Object browser getApp()->updateObjectBrowser( false ); diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index bb1b4292b..3deee9fe3 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -112,6 +112,9 @@ namespace GEOMOp { OpFeatureDetect = 3303, // MENU NEW ENTITY - FEATURE DETECTION #endif OpPictureImport = 3304, // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER + OpCreateField = 3305, // MENU FIELD - CREATE FIELD + OpEditField = 3306, // MENU FIELD - EDIT FIELD + OpEditFieldPopup = 3307, // POPUP MENU - EDIT FIELD // BuildGUI --------------------//-------------------------------- OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE diff --git a/src/GEOMImpl/GEOMImpl_FieldDriver.cxx b/src/GEOMImpl/GEOMImpl_FieldDriver.cxx index f52236985..23f118b01 100644 --- a/src/GEOMImpl/GEOMImpl_FieldDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FieldDriver.cxx @@ -67,7 +67,7 @@ GetCreationInformation(std::string& theOperationName, if ( funType == GEOM_Field::FUN_ADD_FIELD ) { - theOperationName = "ADD_FIELD"; + theOperationName = "FIELD_CREATE"; // geompy.CreateField(shape, name, type, dimension, componentNames) Handle(GEOM_Field) f = GEOM_Field::GetField( function->GetOwnerEntry() ); AddParam( theParams, "Shape", data.GetShape() ); -- 2.39.2