NPAL14167: Keep the parameters of the object after a transformation.

This commit is contained in:
jfa 2008-04-02 11:07:08 +00:00
parent 06cf8f676b
commit 204e0ea91a
30 changed files with 1034 additions and 491 deletions

View File

@ -2639,7 +2639,7 @@ module GEOM
void Redo (in long theStudyID);
/*!
* Publishing manangement
* Publishing management
* Adds in theStudy a object theObject under with a name theName,
* if theFather is not NULL the object is placed under thFather's SObject.
* Returns a SObject where theObject is placed
@ -2649,6 +2649,44 @@ module GEOM
in string theName,
in GEOM_Object theFather);
/*!
* Publish sub-shapes, standing for arguments and sub-shapes of arguments
* To be used from python scripts out of geompy.addToStudy (non-default usage)
* \param theStudy the study, in which theObject is published already,
* and in which the arguments will be published
* \param theObject published GEOM object, arguments of which will be published
* \param theArgs list of GEOM_Object, operation arguments to be published.
* If this list is empty, all operation arguments will be published
* \param isTrsf If True, search sub-shapes by indices, as in case of
* transformation they cannot be found by GetInPlace.
* The argument itself is not published in this case,
* because the whole shape corresponds to the argument.
* \return True in case of success, False otherwise.
*/
boolean RestoreSubShapesO (in SALOMEDS::Study theStudy,
in GEOM_Object theObject,
in ListOfGO theArgs,
in boolean isTrsf);
/*!
* Publish sub-shapes, standing for arguments and sub-shapes of arguments
* To be used from GUI and from geompy.addToStudy
* \param theStudy the study, in which theObject is published already,
* and in which the arguments will be published
* \param theSObject study object, referencing GEOM object, arguments of which will be published
* \param theArgs list of GEOM_Object, operation arguments to be published.
* If this list is empty, all operation arguments will be published
* \param isTrsf If True, search sub-shapes by indices, as in case of
* transformation they cannot be found by GetInPlace.
* The argument itself is not published in this case,
* because the whole shape corresponds to the argument.
* \return True in case of success, False otherwise.
*/
boolean RestoreSubShapesSO (in SALOMEDS::Study theStudy,
in SALOMEDS::SObject theSObject,
in ListOfGO theArgs,
in boolean isTrsf);
/*!
* Methods to access interfaces for objects creation and transformation
*/

View File

@ -35,6 +35,7 @@
#include "LightApp_SelectionMgr.h"
#include <qlabel.h>
#include <qcheckbox.h>
using namespace std;
@ -130,6 +131,8 @@ BooleanGUI_Dialog::~BooleanGUI_Dialog()
//=================================================================================
void BooleanGUI_Dialog::Init()
{
GroupBoxPublish->show();
/* init variables */
myEditCurrentArgument = myGroup->LineEdit1;
@ -306,3 +309,16 @@ bool BooleanGUI_Dialog::execute( ObjectList& objects )
return true;
}
//=================================================================================
// function : restoreSubShapes
// purpose :
//=================================================================================
void BooleanGUI_Dialog::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/false);
}
}

View File

@ -52,6 +52,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
int myOperation;

View File

@ -34,6 +34,7 @@
#include "LightApp_SelectionMgr.h"
#include <qlabel.h>
#include <qcheckbox.h>
//=================================================================================
// class : BuildGUI_CompoundDlg()
@ -96,6 +97,8 @@ void BuildGUI_CompoundDlg::Init()
myOkShapes = false;
GroupBoxPublish->show();
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -229,3 +232,16 @@ bool BuildGUI_CompoundDlg::execute( ObjectList& objects )
return true;
}
//=================================================================================
// function : restoreSubShapes
// purpose :
//=================================================================================
void BuildGUI_CompoundDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/false);
}
}

View File

@ -51,6 +51,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& msg );
virtual bool execute( ObjectList& objects );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form implementation generated from reading ui file 'DlgRef_Skeleton_QTD.ui'
**
** Created: Wed Feb 13 17:37:30 2008
** Created: Wed Mar 26 12:14:14 2008
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
@ -11,11 +11,12 @@
#include <qvariant.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qbuttongroup.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
@ -38,37 +39,6 @@ DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, boo
Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1");
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 6 );
GroupButtons->layout()->setMargin( 11 );
GroupButtonsLayout = new QVBoxLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
layout3 = new QGridLayout( 0, 1, 1, 0, 6, "layout3");
Spacer1 = new QSpacerItem( 90, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
layout3->addItem( Spacer1, 0, 3 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
layout3->addWidget( buttonOk, 0, 2 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
layout3->addWidget( buttonApply, 0, 0 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
layout3->addWidget( buttonCancel, 0, 1 );
buttonHelp = new QPushButton( GroupButtons, "buttonHelp" );
layout3->addWidget( buttonHelp, 0, 4 );
GroupButtonsLayout->addLayout( layout3 );
Layout1->addWidget( GroupButtons, 3, 0 );
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
@ -101,20 +71,68 @@ DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, boo
GroupBoxNameLayout = new QGridLayout( GroupBoxName->layout() );
GroupBoxNameLayout->setAlignment( Qt::AlignTop );
Layout66 = new QGridLayout( 0, 1, 1, 0, 6, "Layout66");
ResultName = new QLineEdit( GroupBoxName, "ResultName" );
Layout66->addWidget( ResultName, 0, 1 );
Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4");
NameLabel = new QLabel( GroupBoxName, "NameLabel" );
Layout66->addWidget( NameLabel, 0, 0 );
Layout4->addWidget( NameLabel, 0, 0 );
GroupBoxNameLayout->addLayout( Layout66, 0, 0 );
ResultName = new QLineEdit( GroupBoxName, "ResultName" );
Layout4->addWidget( ResultName, 0, 1 );
GroupBoxNameLayout->addLayout( Layout4, 0, 0 );
Layout1->addWidget( GroupBoxName, 1, 0 );
GroupBoxPublish = new QGroupBox( this, "GroupBoxPublish" );
GroupBoxPublish->setColumnLayout(0, Qt::Vertical );
GroupBoxPublish->layout()->setSpacing( 6 );
GroupBoxPublish->layout()->setMargin( 11 );
GroupBoxPublishLayout = new QGridLayout( GroupBoxPublish->layout() );
GroupBoxPublishLayout->setAlignment( Qt::AlignTop );
Layout5 = new QGridLayout( 0, 1, 1, 0, 6, "Layout5");
CheckBoxRestoreSS = new QCheckBox( GroupBoxPublish, "CheckBoxRestoreSS" );
Layout5->addWidget( CheckBoxRestoreSS, 0, 0 );
GroupBoxPublishLayout->addLayout( Layout5, 0, 0 );
Layout1->addWidget( GroupBoxPublish, 3, 0 );
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 6 );
GroupButtons->layout()->setMargin( 11 );
GroupButtonsLayout = new QVBoxLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3");
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
Layout3->addWidget( buttonApply, 0, 0 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
Layout3->addWidget( buttonCancel, 0, 1 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
Layout3->addWidget( buttonOk, 0, 2 );
Spacer1 = new QSpacerItem( 90, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
Layout3->addItem( Spacer1, 0, 3 );
buttonHelp = new QPushButton( GroupButtons, "buttonHelp" );
Layout3->addWidget( buttonHelp, 0, 4 );
GroupButtonsLayout->addLayout( Layout3 );
Layout1->addWidget( GroupButtons, 4, 0 );
DlgRef_Skeleton_QTDLayout->addLayout( Layout1, 0, 0 );
languageChange();
resize( QSize(615, 682).expandedTo(minimumSizeHint()) );
@ -135,17 +153,5 @@ DlgRef_Skeleton_QTD::~DlgRef_Skeleton_QTD()
*/
void DlgRef_Skeleton_QTD::languageChange()
{
setCaption( tr( "DlgRef_Skeleton_QTD" ) );
GroupButtons->setTitle( QString::null );
buttonOk->setText( QString::null );
buttonApply->setText( QString::null );
buttonCancel->setText( QString::null );
buttonHelp->setText( QString::null );
GroupConstructors->setTitle( QString::null );
RadioButton1->setText( QString::null );
RadioButton2->setText( QString::null );
RadioButton3->setText( QString::null );
RadioButton4->setText( QString::null );
GroupBoxName->setTitle( QString::null );
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form interface generated from reading ui file 'DlgRef_Skeleton_QTD.ui'
**
** Created: Wed Feb 13 17:37:30 2008
** Created: Wed Mar 26 12:14:12 2008
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
@ -17,12 +17,13 @@ class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class QGroupBox;
class QPushButton;
class QButtonGroup;
class QRadioButton;
class QLineEdit;
class QGroupBox;
class QLabel;
class QLineEdit;
class QCheckBox;
class QPushButton;
class DlgRef_Skeleton_QTD : public QDialog
{
@ -32,30 +33,34 @@ public:
DlgRef_Skeleton_QTD( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~DlgRef_Skeleton_QTD();
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonApply;
QPushButton* buttonCancel;
QPushButton* buttonHelp;
QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1;
QRadioButton* RadioButton2;
QRadioButton* RadioButton3;
QRadioButton* RadioButton4;
QGroupBox* GroupBoxName;
QLineEdit* ResultName;
QLabel* NameLabel;
QLineEdit* ResultName;
QGroupBox* GroupBoxPublish;
QCheckBox* CheckBoxRestoreSS;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonCancel;
QPushButton* buttonOk;
QPushButton* buttonHelp;
protected:
QGridLayout* DlgRef_Skeleton_QTDLayout;
QGridLayout* Layout1;
QVBoxLayout* GroupButtonsLayout;
QGridLayout* layout3;
QSpacerItem* Spacer1;
QHBoxLayout* GroupConstructorsLayout;
QHBoxLayout* Layout2;
QGridLayout* GroupBoxNameLayout;
QGridLayout* Layout66;
QGridLayout* Layout4;
QGridLayout* GroupBoxPublishLayout;
QGridLayout* Layout5;
QVBoxLayout* GroupButtonsLayout;
QGridLayout* Layout3;
QSpacerItem* Spacer1;
protected slots:
virtual void languageChange();

View File

@ -20,9 +20,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="caption">
<string>DlgRef_Skeleton_QTD</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
@ -50,92 +47,6 @@
<property name="spacing">
<number>6</number>
</property>
<widget class="QGroupBox" row="3" column="0">
<property name="name">
<cstring>GroupButtons</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string></string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout3</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<spacer row="0" column="3">
<property name="name">
<cstring>Spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>90</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton" row="0" column="2">
<property name="name">
<cstring>buttonOk</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QPushButton" row="0" column="0">
<property name="name">
<cstring>buttonApply</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QPushButton" row="0" column="1">
<property name="name">
<cstring>buttonCancel</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QPushButton" row="0" column="4">
<property name="name">
<cstring>buttonHelp</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
</grid>
</widget>
</vbox>
</widget>
<widget class="QButtonGroup" row="0" column="0">
<property name="name">
<cstring>GroupConstructors</cstring>
@ -148,9 +59,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string></string>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
@ -179,33 +87,21 @@
<property name="name">
<cstring>RadioButton1</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>RadioButton2</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>RadioButton3</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>RadioButton4</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
</hbox>
</widget>
@ -215,9 +111,6 @@
<property name="name">
<cstring>GroupBoxName</cstring>
</property>
<property name="title">
<string></string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
@ -230,7 +123,7 @@
</property>
<widget class="QLayoutWidget" row="0" column="0">
<property name="name">
<cstring>Layout66</cstring>
<cstring>Layout4</cstring>
</property>
<grid>
<property name="name">
@ -242,20 +135,128 @@
<property name="spacing">
<number>6</number>
</property>
<widget class="QLineEdit" row="0" column="1">
<property name="name">
<cstring>ResultName</cstring>
</property>
</widget>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>NameLabel</cstring>
</property>
</widget>
<widget class="QLineEdit" row="0" column="1">
<property name="name">
<cstring>ResultName</cstring>
</property>
</widget>
</grid>
</widget>
</grid>
</widget>
<widget class="QGroupBox" row="3" column="0">
<property name="name">
<cstring>GroupBoxPublish</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QLayoutWidget" row="0" column="0">
<property name="name">
<cstring>Layout5</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QCheckBox" row="0" column="0">
<property name="name">
<cstring>CheckBoxRestoreSS</cstring>
</property>
</widget>
</grid>
</widget>
</grid>
</widget>
<widget class="QGroupBox" row="4" column="0">
<property name="name">
<cstring>GroupButtons</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>Layout3</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton" row="0" column="0">
<property name="name">
<cstring>buttonApply</cstring>
</property>
</widget>
<widget class="QPushButton" row="0" column="1">
<property name="name">
<cstring>buttonCancel</cstring>
</property>
</widget>
<widget class="QPushButton" row="0" column="2">
<property name="name">
<cstring>buttonOk</cstring>
</property>
</widget>
<spacer row="0" column="3">
<property name="name">
<cstring>Spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>90</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton" row="0" column="4">
<property name="name">
<cstring>buttonHelp</cstring>
</property>
</widget>
</grid>
</widget>
</vbox>
</widget>
</grid>
</widget>
</grid>

View File

@ -523,10 +523,31 @@ void GEOMBase_Helper::addInStudy( GEOM::GEOM_Object_ptr theObj, const char* theN
if ( !aStudy || theObj->_is_nil() )
return;
SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy);
GEOM::GEOM_Object_ptr aFatherObj = getFather( theObj );
getGeomEngine()->AddInStudy(GeometryGUI::ClientStudyToStudy(aStudy),
theObj, theName, aFatherObj);
SALOMEDS::SObject_var aSO =
getGeomEngine()->AddInStudy(aStudyDS, theObj, theName, aFatherObj);
// Each dialog is responsible for this method implementation,
// default implementation does nothing
restoreSubShapes(aStudyDS, aSO);
}
//================================================================
// Function : restoreSubShapes
// Purpose : restore tree of argument's sub-shapes under the resulting shape
//================================================================
void GEOMBase_Helper::restoreSubShapes (SALOMEDS::Study_ptr /*theStudy*/,
SALOMEDS::SObject_ptr /*theSObject*/)
{
// do nothing by default
// example of implementation in particular dialog:
// GEOM::ListOfGO anArgs;
// anArgs.length(0); // empty list means that all arguments should be restored
// getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs, /*isTrsf=*/false);
}
//================================================================
@ -753,7 +774,8 @@ bool GEOMBase_Helper::checkViewWindow()
//================================================================
bool GEOMBase_Helper::onAccept (const bool publish, const bool useTransaction)
{
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
SalomeApp_Study* appStudy =
dynamic_cast<SalomeApp_Study*>(SUIT_Session::session()->activeApplication()->activeStudy());
if (!appStudy) return false;
_PTR(Study) aStudy = appStudy->studyDS();

View File

@ -171,6 +171,9 @@ protected:
// It should perform the required operation and put all new or modified objects into
// <objects> argument.Should return <false> if some error occurs during its execution.
virtual void restoreSubShapes (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject);
// This method is called by addInStudy().
virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr theObj );
// This method is called by addInStudy(). It should return a father object
// for <theObj> or a nil reference if <theObj> should be published

View File

@ -38,6 +38,7 @@
#include <qlabel.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
using namespace std;
@ -61,6 +62,9 @@ GEOMBase_Skeleton::GEOMBase_Skeleton(GeometryGUI* theGeometryGUI, QWidget* paren
GroupBoxName->setTitle(tr("GEOM_RESULT_NAME_GRP"));
NameLabel->setText(tr("GEOM_RESULT_NAME_LBL"));
GroupBoxPublish->setTitle(tr("GEOM_PUBLISH_RESULT_GRP"));
CheckBoxRestoreSS->setText(tr("GEOM_RESTORE_SUB_SHAPES"));
buttonCancel->setText(tr("GEOM_BUT_CLOSE"));
buttonOk->setText(tr("GEOM_BUT_APPLY_AND_CLOSE"));
buttonApply->setText(tr("GEOM_BUT_APPLY"));
@ -71,7 +75,6 @@ GEOMBase_Skeleton::GEOMBase_Skeleton(GeometryGUI* theGeometryGUI, QWidget* paren
Init();
}
//=================================================================================
// function : ~GEOMBase_Skeleton()
// purpose : Destroys the object and frees any allocated resources
@ -82,7 +85,6 @@ GEOMBase_Skeleton::~GEOMBase_Skeleton()
myGeomGUI->SetActiveDialogBox( 0 );
}
//=================================================================================
// function : Init()
// purpose :
@ -94,6 +96,7 @@ void GEOMBase_Skeleton::Init()
myGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
/* init variables */
if (myGeomGUI)
myGeomGUI->SetActiveDialogBox(this);
/* signals and slots connections */
@ -111,10 +114,10 @@ void GEOMBase_Skeleton::Init()
RadioButton1->setChecked(TRUE);
RadioButton4->hide();
return;
CheckBoxRestoreSS->setChecked(FALSE);
GroupBoxPublish->hide();
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
@ -124,7 +127,6 @@ void GEOMBase_Skeleton::ClickOnCancel()
close();
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
@ -142,11 +144,8 @@ void GEOMBase_Skeleton::LineEditReturnPressed()
if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
myEditCurrentArgument->setText(objectUserName);
return;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
@ -155,12 +154,11 @@ void GEOMBase_Skeleton::DeactivateActiveDialog()
{
this->setEnabled(false);
globalSelection();
disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
if (myGeomGUI) myGeomGUI->SetActiveDialogBox(0);
return;
if (myGeomGUI) {
myGeomGUI->SetActiveDialogBox(0);
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
}
}
//=================================================================================
// function : ActivateThisDialog()
@ -172,20 +170,17 @@ void GEOMBase_Skeleton::ActivateThisDialog()
if (myGeomGUI) myGeomGUI->EmitSignalDeactivateDialog();
this->setEnabled(true);
if (myGeomGUI) myGeomGUI->SetActiveDialogBox((QDialog*)this);
return;
}
//=================================================================================
// function : closeEvent()
// purpose : same than click on cancel button
//=================================================================================
void GEOMBase_Skeleton::closeEvent(QCloseEvent* e)
{
SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
if(app) {
disconnect( app->selectionMgr(), 0, this, 0);
app->updateActions();
if (myGeomGUI) {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->updateActions();
}
QDialog::closeEvent( e );
}
@ -243,11 +238,11 @@ void GEOMBase_Skeleton::ClickOnHelp()
QObject::tr("BUT_OK"));
}
}
//=================================================================================
// function : setHelpFileName()
// purpose : set name for help file html
//=================================================================================
void GEOMBase_Skeleton::setHelpFileName(const QString& theName)
{
myHelpFileName = theName;

View File

@ -3129,6 +3129,12 @@ msgstr "Result name"
msgid "GEOM_RESULT_NAME_LBL"
msgstr "Name"
msgid "GEOM_PUBLISH_RESULT_GRP"
msgstr "Advanced options"
msgid "GEOM_RESTORE_SUB_SHAPES"
msgstr "Set presentation parameters and subshapes from arguments"
msgid "GEOM_ERR_GET_ENGINE"
msgstr "Failed to obtain GEOM Engine component. Reload Geometry module and try again."

View File

@ -68,6 +68,7 @@ using namespace std;
#include <TDF_Tool.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
@ -2812,19 +2813,17 @@ static bool GetInPlaceOfShape (const Handle(GEOM_Function)& theWhereFunction,
void GEOMImpl_IShapesOperations::GetShapeProperties( const TopoDS_Shape aShape, Standard_Real tab[],
gp_Pnt & aVertex )
{
GProp_GProps SProps, VProps;
GProp_GProps theProps;
gp_Pnt aCenterMass;
TopoDS_Shape aPntShape;
Standard_Real aShapeSize;
BRepGProp::VolumeProperties(aShape, VProps);
aCenterMass = VProps.CentreOfMass();
aShapeSize = VProps.Mass();
if (aShape.ShapeType() == TopAbs_FACE) {
BRepGProp::SurfaceProperties(aShape, SProps);
aCenterMass = SProps.CentreOfMass();
aShapeSize = SProps.Mass();
}
if (aShape.ShapeType() == TopAbs_EDGE) BRepGProp::LinearProperties(aShape, theProps);
else if (aShape.ShapeType() == TopAbs_FACE) BRepGProp::SurfaceProperties(aShape, theProps);
else BRepGProp::VolumeProperties(aShape, theProps);
aCenterMass = theProps.CentreOfMass();
aShapeSize = theProps.Mass();
aPntShape = BRepBuilderAPI_MakeVertex(aCenterMass).Shape();
aVertex = BRep_Tool::Pnt( TopoDS::Vertex( aPntShape ) );
@ -2849,6 +2848,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
TopoDS_Shape aWhere = theShapeWhere->GetValue();
TopoDS_Shape aWhat = theShapeWhat->GetValue();
TopoDS_Shape aPntShape;
TopoDS_Vertex aVertex;
if (aWhere.IsNull() || aWhat.IsNull()) {
SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null.");
@ -2871,6 +2872,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
bool isFound = false;
Standard_Integer iType = TopAbs_SOLID;
Standard_Integer compType = TopAbs_SOLID;
Standard_Real aWhat_Mass = 0., aWhere_Mass = 0.;
Standard_Real tab_aWhat[4], tab_aWhere[4];
Standard_Real dl_l = 1e-3;
@ -2878,15 +2880,23 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
gp_Pnt aPnt, aPnt_aWhat;
GProp_GProps aProps;
// 2D or 3D shapes
if ( aWhat.ShapeType() == TopAbs_COMPOUND ||
aWhat.ShapeType() == TopAbs_SHELL ||
aWhat.ShapeType() == TopAbs_COMPSOLID ) {
TopExp_Explorer Exp( aWhat, TopAbs_ShapeEnum( iType ) );
if ( ! Exp.More() ) iType = TopAbs_FACE;
// Find the iType of the aWhat shape
if ( aWhat.ShapeType() == TopAbs_EDGE || aWhat.ShapeType() == TopAbs_WIRE ) iType = TopAbs_EDGE;
else if ( aWhat.ShapeType() == TopAbs_FACE || aWhat.ShapeType() == TopAbs_SHELL ) iType = TopAbs_FACE;
else if ( aWhat.ShapeType() == TopAbs_SOLID || aWhat.ShapeType() == TopAbs_COMPSOLID ) iType = TopAbs_SOLID;
else if ( aWhat.ShapeType() == TopAbs_COMPOUND ) {
// Only the iType of the first shape in the compound is taken into account
TopoDS_Iterator It (aWhat, Standard_True, Standard_True);
compType = It.Value().ShapeType();
if ( compType == TopAbs_EDGE || compType == TopAbs_WIRE ) iType = TopAbs_EDGE;
else if ( compType == TopAbs_FACE || compType == TopAbs_SHELL) iType = TopAbs_FACE;
else if ( compType == TopAbs_SOLID || compType == TopAbs_COMPSOLID) iType = TopAbs_SOLID;
}
else {
cout << endl;
cout << "WARNING : shape to be extracted is of unknown type !" << endl;
cout << endl;
}
else if ( aWhat.ShapeType() == TopAbs_FACE )
iType = TopAbs_FACE;
TopExp_Explorer Exp_aWhat( aWhat, TopAbs_ShapeEnum( iType ) );
TopExp_Explorer Exp_aWhere( aWhere, TopAbs_ShapeEnum( iType ) );
@ -2905,29 +2915,31 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
Tol_3D = dl_l * ( min_l * min_l * min_l ) * ( 3. + (3 * dl_l) + (dl_l * dl_l) );
Tol_Mass = Tol_3D;
if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D;
if ( iType == TopAbs_EDGE ) Tol_Mass = Tol_1D;
else if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D;
// Compute the ShapeWhat Mass
for ( ; Exp_aWhat.More(); Exp_aWhat.Next() ) {
if ( iType == TopAbs_SOLID ) BRepGProp::VolumeProperties(Exp_aWhat.Current(), aProps);
if ( iType == TopAbs_EDGE ) BRepGProp::LinearProperties(Exp_aWhat.Current(), aProps);
else if ( iType == TopAbs_FACE ) BRepGProp::SurfaceProperties(Exp_aWhat.Current(), aProps);
else BRepGProp::VolumeProperties(Exp_aWhat.Current(), aProps);
aWhat_Mass += aProps.Mass();
}
// Finding the Sub-ShapeWhere
// Searching for the sub-shapes inside the ShapeWhere shape
for ( Exp_aWhere.ReInit(); Exp_aWhere.More(); Exp_aWhere.Next() ) {
GetShapeProperties( Exp_aWhere.Current(), tab_aWhere, aPnt );
for ( Exp_aWhat.ReInit(); Exp_aWhat.More(); Exp_aWhat.Next() ) {
GetShapeProperties( Exp_aWhat.Current(), tab_aWhat, aPnt_aWhat );
if ( fabs(tab_aWhat[3] - tab_aWhere[3]) <= Tol_Mass && aPnt_aWhat.Distance(aPnt) <= Tol_1D )
isFound = true;
else if ( tab_aWhat[3] - ( tab_aWhere[3] > Tol_Mass) ) {
BRepClass3d_SolidClassifier SC_aWhere (Exp_aWhere.Current(), aPnt, Precision::Confusion());
BRepClass3d_SolidClassifier SC_aWhat (Exp_aWhat.Current(), aPnt, Precision::Confusion());
// Block construction 3D
if ( SC_aWhere.State() == TopAbs_IN && SC_aWhat.State() == TopAbs_IN ) isFound = true;
// Block construction 2D
else if ( SC_aWhere.State() == TopAbs_ON && SC_aWhat.State() == TopAbs_ON ) isFound = true;
if ( fabs(tab_aWhat[3] - tab_aWhere[3]) <= Tol_Mass && aPnt_aWhat.Distance(aPnt) <= Tol_1D ) isFound = true;
else {
if ( (tab_aWhat[3] - tab_aWhere[3]) > Tol_Mass ) {
aPntShape = BRepBuilderAPI_MakeVertex( aPnt ).Shape();
aVertex = TopoDS::Vertex( aPntShape );
BRepExtrema_DistShapeShape aWhereDistance ( aVertex, Exp_aWhere.Current() );
BRepExtrema_DistShapeShape aWhatDistance ( aVertex, Exp_aWhat.Current() );
if ( fabs(aWhereDistance.Value() - aWhatDistance.Value()) <= Tol_1D ) isFound = true;
}
}
if ( isFound ) {
aWhereIndex = aWhereIndices.FindIndex(Exp_aWhere.Current());

View File

@ -522,7 +522,10 @@ char* GEOM_Gen_i::ComponentDataType()
// function : AddInStudy
// purpose :
//============================================================================
SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy(SALOMEDS::Study_ptr theStudy, GEOM::GEOM_Object_ptr theObject, const char* theName, GEOM::GEOM_Object_ptr theFather)
SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject,
const char* theName,
GEOM::GEOM_Object_ptr theFather)
{
SALOMEDS::SObject_var aResultSO;
if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO;
@ -559,6 +562,322 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy(SALOMEDS::Study_ptr theStudy, GEOM:
return aResultSO._retn();
}
//============================================================================
// function : RestoreSubShapes
// purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
// To be used from python scripts out of geompy.addToStudy (non-default usage)
//============================================================================
CORBA::Boolean GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject,
const GEOM::ListOfGO& theArgs,
CORBA::Boolean isTrsf)
{
if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject))
return false;
// find SObject in the study
CORBA::String_var anIORo = _orb->object_to_string(theObject);
SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(anIORo.in());
if (CORBA::is_nil(aSO))
return false;
return RestoreSubShapes(theStudy, theObject, aSO, theArgs, isTrsf);
}
//============================================================================
// function : RestoreSubShapes
// purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
// To be used from GUI and from geompy.addToStudy
//============================================================================
CORBA::Boolean GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject,
const GEOM::ListOfGO& theArgs,
CORBA::Boolean isTrsf)
{
if (CORBA::is_nil(theStudy) || CORBA::is_nil(theSObject))
return false;
SALOMEDS::GenericAttribute_var anAttr;
if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
return false;
SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var anIORso = anAttrIOR->Value();
// get Object from SObject
GEOM::GEOM_Object_var anO = GEOM::GEOM_Object::_narrow(_orb->string_to_object(anIORso));
if (CORBA::is_nil(anO))
return false;
return RestoreSubShapes(theStudy, anO, theSObject, theArgs, isTrsf);
}
//============================================================================
// function : RestoreSubShapes
// purpose : Private method. Works only if both theObject and theSObject
// are defined, and does not check, if they correspond to each other.
//============================================================================
CORBA::Boolean GEOM_Gen_i::RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject,
SALOMEDS::SObject_ptr theSObject,
const GEOM::ListOfGO& theArgs,
CORBA::Boolean isTrsf)
{
if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) || CORBA::is_nil(theSObject))
return false;
if (isTrsf && theArgs.length() > 1)
// only one (the first) argument of transformation
// (the transformed shape) can be restored
return false;
// Arguments to be published
GEOM::ListOfGO_var aList;
// If theArgs list is empty, we try to publish all arguments,
// otherwise publish only passed args
Standard_Integer nbArgsActual = -1; // -1 means unknown
Standard_Integer aLength = theArgs.length();
if (aLength > 0) {
aList = new GEOM::ListOfGO;
aList->length(aLength);
for (int i = 0; i < aLength; i++) {
aList[i] = theArgs[i];
}
}
else {
// Get all arguments
aList = theObject->GetDependency();
aLength = aList->length();
nbArgsActual = aLength;
}
if (aLength < 1)
return false;
if (isTrsf) {
// In case of transformation we do not publish argument's reflection,
// but only reconstruct its published sub-shapes
GEOM::GEOM_Object_var anArgO = aList[0];
CORBA::String_var anIOR = _orb->object_to_string(anArgO);
SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
GEOM::ListOfGO_var aParts =
RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject, isTrsf);
// set the color of the transformed shape to the color of initial shape
theObject->SetColor(aList[0]->GetColor());
return (aParts->length() > 0);
}
else {
// in this case (not a transformation) we cannot detect, if the final
// shape should have the same color, as one of arguments, and we apply
// the same color only in case of single argument
if (nbArgsActual == 1) {
// set the color of the new shape to the color of its single argument
theObject->SetColor(aList[0]->GetColor());
}
}
// Get interface, containing method GetInPlace, which we will use to reconstruct sub-shapes
GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
// Reconstruct arguments and tree of sub-shapes of the arguments
CORBA::String_var anIOR;
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
for (Standard_Integer i = 0; i < aLength; i++)
{
GEOM::GEOM_Object_var anArgO = aList[i];
if (!CORBA::is_nil(anArgO)) {
anIOR = _orb->object_to_string(anArgO);
SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
TCollection_AsciiString anArgName;
if (CORBA::is_nil(anArgSO)) {
anArgName = "arg_";
anArgName += TCollection_AsciiString(i);
}
else {
anArgName = anArgSO->GetName();
}
// Find a sub-shape of theObject in place of the argument
GEOM::GEOM_Object_var aSubO = aShapesOp->GetInPlace(theObject, anArgO);
if (!CORBA::is_nil(aSubO)) {
// Publish the sub-shape
TCollection_AsciiString aSubName ("from_");
aSubName += anArgName;
SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(theSObject);
aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
// Restore color
aSubO->SetColor(anArgO->GetColor());
if (!CORBA::is_nil(anArgSO)) {
// Restore published sub-shapes of the argument
RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, aSubO, isTrsf);
}
}
else { // GetInPlace failed, try to build from published parts
if (!CORBA::is_nil(anArgSO)) {
SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(theSObject);
// Restore published sub-shapes of the argument
GEOM::ListOfGO_var aParts =
RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, theObject, isTrsf);
if (aParts->length() > 0) {
// try to build an argument from a set of its sub-shapes,
// that published and will be reconstructed
if (aParts->length() > 1) {
aSubO = aShapesOp->MakeCompound(aParts);
}
else {
aSubO = aParts[0];
}
if (!CORBA::is_nil(aSubO)) {
// Publish the sub-shape
TCollection_AsciiString aSubName ("from_parts_of_");
aSubName += anArgName;
aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
// Restore color
aSubO->SetColor(anArgO->GetColor());
}
}
else {
// remove created aSubSO, because no parts have been found
aStudyBuilder->RemoveObject(aSubSO);
}
}
} // try to build from published parts
}
} // process arguments
return true;
}
//============================================================================
// function : RestoreSubShapesOneLevel
// purpose : Private method
//============================================================================
GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theOldSO,
SALOMEDS::SObject_ptr theNewSO,
GEOM::GEOM_Object_ptr theNewO,
CORBA::Boolean isTrsf)
{
int i = 0;
GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
if (CORBA::is_nil(theStudy) || CORBA::is_nil(theOldSO) ||
CORBA::is_nil(theNewO) || CORBA::is_nil(theNewSO))
return aParts._retn();
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
// Get interface, containing method GetInPlace, which we will use to reconstruct sub-shapes
GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
// Reconstruct published sub-shapes
SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
int aLen = 0;
for (it->Init(); it->More(); it->Next()) {
aLen++;
}
aParts->length(aLen);
for (it->Init(); it->More(); it->Next()) {
SALOMEDS::SObject_var anOldSubSO = it->Value();
TCollection_AsciiString anArgName = anOldSubSO->GetName();
SALOMEDS::GenericAttribute_var anAttr;
if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) {
SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
GEOM::GEOM_Object_var anOldSubO =
GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value()));
if (!CORBA::is_nil(anOldSubO)) {
// Find a sub-shape of theNewO in place of anOldSubO
GEOM::GEOM_Object_var aNewSubO;
if (isTrsf) {
// transformation, cannot use GetInPlace, operate with indices
GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices();
if (anIDs->length() > 1) {
// group
aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO));
if (!CORBA::is_nil(aNewSubO))
aGroupOp->UnionIDs(aNewSubO, anIDs);
}
else {
// single sub-shape
aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]);
}
}
else {
// not a transformation, so use GetInPlace
aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
}
if (!CORBA::is_nil(aNewSubO)) {
// add the part to the list
aParts[i] = aNewSubO;
i++;
// Publish the sub-shape
TCollection_AsciiString aSubName ("from_");
aSubName += anArgName;
SALOMEDS::SObject_var aNewSubSO = aStudyBuilder->NewObject(theNewSO);
aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
// Restore color
aNewSubO->SetColor(anOldSubO->GetColor());
// Restore published sub-shapes of the argument
RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, aNewSubO, isTrsf);
}
else { // GetInPlace failed, try to build from published parts
SALOMEDS::SObject_var aNewSubSO = aStudyBuilder->NewObject(theNewSO);
// Restore published sub-shapes of the argument
GEOM::ListOfGO_var aParts =
RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, theNewO, isTrsf);
if (aParts->length() > 0) {
// try to build an object from a set of its sub-shapes,
// that published and will be reconstructed
if (aParts->length() > 1) {
aNewSubO = aShapesOp->MakeCompound(aParts);
}
else {
aNewSubO = aParts[0];
}
if (!CORBA::is_nil(aNewSubO)) {
// add the part to the list
aParts[i] = aNewSubO;
i++;
// Publish the sub-shape
TCollection_AsciiString aSubName = "from_parts_of_";
aSubName += anArgName;
aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
// Restore color
aNewSubO->SetColor(anOldSubO->GetColor());
}
}
else {
// remove created aSubSO, because no parts have been found
aStudyBuilder->RemoveObject(aNewSubSO);
}
} // try to build from published parts
}
}
} // iterate on published sub-shapes
aParts->length(i);
return aParts._retn();
}
//============================================================================
// function : register()
// purpose : register 'name' in 'name_service'

View File

@ -133,6 +133,22 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
const char* theName,
GEOM::GEOM_Object_ptr theFather);
/*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
* To be used from python scripts out of geompy.addToStudy (non-default usage)
*/
CORBA::Boolean RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject,
const GEOM::ListOfGO& theArgs,
CORBA::Boolean isTrsf);
/*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
* To be used from GUI and from geompy.addToStudy
*/
CORBA::Boolean RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject,
const GEOM::ListOfGO& theArgs,
CORBA::Boolean isTrsf);
//-----------------------------------------------------------------------//
// Transaction methods //
//-----------------------------------------------------------------------//
@ -219,6 +235,19 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
private:
GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theOldSO,
SALOMEDS::SObject_ptr theNewSO,
GEOM::GEOM_Object_ptr theNewO,
CORBA::Boolean isTrsf);
CORBA::Boolean RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject,
SALOMEDS::SObject_ptr theSObject,
const GEOM::ListOfGO& theArgs,
CORBA::Boolean isTrsf);
private:
::GEOMImpl_Gen* _impl;

View File

@ -126,10 +126,21 @@ class geompyDC(GEOM._objref_GEOM_Gen):
## Publish in study aShape with name aName
#
# \param aShape the shape to be published
# \param aName the name for the shape
# \param doRestoreSubShapes if True, finds and publishes also
# sub-shapes of \a aShape, corresponding to its arguments
# and published sub-shapes of arguments
# \param theArgs,isTrsf see geompy.RestoreSubShapes for these arguments description
# \return study entry of the published shape in form of string
#
# Example: see GEOM_TestAll.py
def addToStudy(self,aShape, aName):
def addToStudy(self, aShape, aName,
doRestoreSubShapes=False, theArgs=[], isTrsf=False):
try:
aSObject = self.AddInStudy(self.myStudy, aShape, aName, None)
if doRestoreSubShapes:
self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs, isTrsf)
except:
print "addToStudy() failed"
return ""
@ -146,6 +157,23 @@ class geompyDC(GEOM._objref_GEOM_Gen):
return ""
return aShape.GetStudyEntry()
## Publish sub-shapes, standing for arguments and sub-shapes of arguments
# To be used from python scripts out of geompy.addToStudy (non-default usage)
# \param theStudy the study, in which theObject is published already,
# and in which the arguments will be published
# \param theObject published GEOM object, arguments of which will be published
# \param theArgs list of GEOM_Object, operation arguments to be published.
# If this list is empty, all operation arguments will be published
# \param isTrsf If True, search sub-shapes by indices, as in case of
# transformation they cannot be found by GetInPlace.
# The argument itself is not published in this case,
# because the whole shape corresponds to the argument.
# \return True in case of success, False otherwise.
#
# Example: see GEOM_TestAll.py
def RestoreSubShapes (self, theObject, theArgs=[], isTrsf=False):
return self.RestoreSubShapesO(self.myStudy, theObject, theArgs, isTrsf)
# -----------------------------------------------------------------------------
# Basic primitives
# -----------------------------------------------------------------------------

View File

@ -36,6 +36,7 @@
#include "LightApp_SelectionMgr.h"
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qcombobox.h>
#include <qlabel.h>
@ -111,6 +112,8 @@ void OperationGUI_PartitionDlg::Init()
GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX"));
GroupPoints->radioButton4->setChecked(FALSE);
GroupBoxPublish->show();
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -124,8 +127,6 @@ void OperationGUI_PartitionDlg::Init()
connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
connect(GroupPoints->radioButton4, SIGNAL(stateChanged(int)), this, SLOT(ReverseSense(int)));
connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
@ -389,16 +390,18 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects )
return res;
}
//=================================================================================
// function : closeEvent
// function : restoreSubShapes
// purpose :
//=================================================================================
void OperationGUI_PartitionDlg::closeEvent( QCloseEvent* e )
void OperationGUI_PartitionDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
GEOMBase_Skeleton::closeEvent( e );
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/false);
}
}
//=======================================================================
//function : ComboTextChanged
@ -415,7 +418,6 @@ void OperationGUI_PartitionDlg::ComboTextChanged()
//GroupPoints->PushButton4->setEnabled(IsEnabled);
}
//=================================================================================
// function : GetLimit()
// purpose :

View File

@ -54,8 +54,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void closeEvent( QCloseEvent* e );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();

View File

@ -121,6 +121,8 @@ void TransformationGUI_MirrorDlg::Init()
GroupPoints->CheckButton1->setChecked(true);
CreateCopyModeChanged(true);
GroupBoxPublish->show();
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -408,14 +410,16 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects )
if (toCreateCopy)
for (int i = 0; i < myObjects.length(); i++)
{
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPointCopy( myObjects[i], myArgument );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
MirrorPointCopy( myObjects[i], myArgument );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
else
for (int i = 0; i < myObjects.length(); i++)
{
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPoint( myObjects[i], myArgument );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
MirrorPoint( myObjects[i], myArgument );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
@ -427,14 +431,16 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects )
if (toCreateCopy)
for (int i = 0; i < myObjects.length(); i++)
{
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorAxisCopy( myObjects[i], myArgument );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
MirrorAxisCopy( myObjects[i], myArgument );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
else
for (int i = 0; i < myObjects.length(); i++)
{
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorAxis( myObjects[i], myArgument );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
MirrorAxis( myObjects[i], myArgument );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
@ -446,14 +452,16 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects )
if (toCreateCopy)
for (int i = 0; i < myObjects.length(); i++)
{
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlaneCopy( myObjects[i], myArgument );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
MirrorPlaneCopy( myObjects[i], myArgument );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
else
for (int i = 0; i < myObjects.length(); i++)
{
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlane( myObjects[i], myArgument );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
MirrorPlane( myObjects[i], myArgument );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
@ -466,14 +474,17 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects )
}
//=================================================================================
// function : closeEvent
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_MirrorDlg::closeEvent( QCloseEvent* e )
void TransformationGUI_MirrorDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
GEOMBase_Skeleton::closeEvent( e );
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true);
}
}
//=================================================================================
// function : CreateCopyModeChanged()

View File

@ -53,7 +53,7 @@ protected:
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void addSubshapesToStudy();
virtual void closeEvent( QCloseEvent* e );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();

View File

@ -115,6 +115,8 @@ void TransformationGUI_OffsetDlg::Init()
GroupPoints->CheckButton1->setChecked(true);
CreateCopyModeChanged(true);
GroupBoxPublish->show();
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -281,7 +283,6 @@ bool TransformationGUI_OffsetDlg::isValid( QString& msg )
return true;
}
//=================================================================================
// function : execute
// purpose :
@ -315,15 +316,17 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects )
}
//=================================================================================
// function : closeEvent
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_OffsetDlg::closeEvent( QCloseEvent* e )
void TransformationGUI_OffsetDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
// myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::closeEvent( e );
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true);
}
}
//=================================================================================
// function : GetOffset()
@ -334,7 +337,6 @@ double TransformationGUI_OffsetDlg::GetOffset() const
return GroupPoints->SpinBox_DX->GetValue();
}
//=================================================================================
// function : CreateCopyModeChanged()
// purpose :

View File

@ -50,8 +50,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void closeEvent( QCloseEvent* e );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();

View File

@ -123,6 +123,8 @@ void TransformationGUI_PositionDlg::Init()
Group1->CheckBox1->setChecked(true);
CreateCopyModeChanged(true);
GroupBoxPublish->show();
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -381,9 +383,11 @@ bool TransformationGUI_PositionDlg::execute( ObjectList& objects )
{
for (int i = 0; i < myObjects.length(); i++) {
if (toCreateCopy)
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShapeCopy( myObjects[i], myObjects[i], myEndLCS );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
PositionShapeCopy( myObjects[i], myObjects[i], myEndLCS );
else
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShape( myObjects[i], myObjects[i], myEndLCS );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
PositionShape( myObjects[i], myObjects[i], myEndLCS );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
@ -395,9 +399,11 @@ bool TransformationGUI_PositionDlg::execute( ObjectList& objects )
{
for (int i = 0; i < myObjects.length(); i++) {
if (toCreateCopy)
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShapeCopy( myObjects[i], myStartLCS, myEndLCS );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
PositionShapeCopy( myObjects[i], myStartLCS, myEndLCS );
else
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShape( myObjects[i], myStartLCS, myEndLCS );
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
PositionShape( myObjects[i], myStartLCS, myEndLCS );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
@ -410,14 +416,17 @@ bool TransformationGUI_PositionDlg::execute( ObjectList& objects )
}
//=================================================================================
// function : closeEvent
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::closeEvent( QCloseEvent* e )
void TransformationGUI_PositionDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
GEOMBase_Skeleton::closeEvent( e );
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true);
}
}
//=================================================================================
// function : CreateCopyModeChanged()

View File

@ -52,8 +52,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void closeEvent( QCloseEvent* e );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();

View File

@ -106,6 +106,8 @@ TransformationGUI_RotationDlg::TransformationGUI_RotationDlg
GroupPoints->CheckButton1->setChecked(true);
CreateCopyModeChanged(true);
GroupBoxPublish->show();
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -502,16 +504,18 @@ bool TransformationGUI_RotationDlg::execute( ObjectList& objects )
return res;
}
//=================================================================================
// function : closeEvent
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_RotationDlg::closeEvent( QCloseEvent* e )
void TransformationGUI_RotationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
GEOMBase_Skeleton::closeEvent( e );
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true);
}
}
//=================================================================================
// function : GetAngle()

View File

@ -50,7 +50,7 @@ protected:
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void addSubshapesToStudy();
virtual void closeEvent( QCloseEvent* e );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();

View File

@ -98,6 +98,8 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg(GeometryGUI* theGeometryG
GroupPoints->CheckButton1->setChecked(true);
CreateCopyModeChanged(true);
GroupBoxPublish->show();
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -370,16 +372,18 @@ bool TransformationGUI_ScaleDlg::execute( ObjectList& objects )
return res;
}
//=================================================================================
// function : closeEvent
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_ScaleDlg::closeEvent( QCloseEvent* e )
void TransformationGUI_ScaleDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
GEOMBase_Skeleton::closeEvent( e );
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true);
}
}
//=================================================================================
// function : GetFactor()

View File

@ -51,7 +51,7 @@ protected:
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void addSubshapesToStudy();
virtual void closeEvent( QCloseEvent* e );
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private :
void Init();

View File

@ -128,6 +128,8 @@ void TransformationGUI_TranslationDlg::Init()
GroupPoints->CheckBox2->setChecked(true);
CreateCopyModeChanged(true);
GroupBoxPublish->show();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
@ -333,7 +335,8 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument()
}
else
aSelectedObject = aFindedObject;
} else // Global Selection
}
else // Global Selection
{
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
@ -578,6 +581,18 @@ bool TransformationGUI_TranslationDlg::execute( ObjectList& objects )
return res;
}
//=================================================================================
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_TranslationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
if (CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true);
}
}
//=================================================================================
// function : CreateCopyModeChanged()

View File

@ -51,6 +51,7 @@ protected:
virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects );
virtual void addSubshapesToStudy();
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();