0022747: [EDF] Improvement of Get Shared Shapes operation

Additional improvement:
- In the dialog box, automatically, propose only allowed types of sub-shapes according to the current selection
This commit is contained in:
vsr 2014-12-26 16:05:13 +03:00
parent 528f4842f4
commit 0f1846a8c0
2 changed files with 64 additions and 33 deletions

View File

@ -40,6 +40,24 @@
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
namespace
{
GEOM::shape_type maxShapeType(const GEOM::ListOfGO& objs)
{
GEOM::shape_type r = GEOM::SHAPE;
for ( int i = 0; i < objs.length(); i++ ) {
GEOM::shape_type t = objs[i]->GetShapeType();
if ( t == GEOM::COMPOUND || t == GEOM::COMPSOLID )
t = objs[i]->GetMaxShapeType();
else if ( t < GEOM::VERTEX )
t = GEOM::shape_type( (int)t+1 );
r = qMin( r, t );
if ( r <= GEOM::SOLID ) break;
}
return r;
}
}
//=================================================================================
// class : OperationGUI_GetSharedShapesDlg()
// purpose : Constructs a OperationGUI_GetSharedShapesDlg which is a child of 'parent', with the
@ -103,15 +121,7 @@ OperationGUI_GetSharedShapesDlg::~OperationGUI_GetSharedShapesDlg()
//=================================================================================
void OperationGUI_GetSharedShapesDlg::Init()
{
/* type for sub-shape selection */
GroupPoints->ComboBox1->addItem(tr("GEOM_SOLID"));
GroupPoints->ComboBox1->addItem(tr("GEOM_SHELL"));
GroupPoints->ComboBox1->addItem(tr("GEOM_FACE"));
GroupPoints->ComboBox1->addItem(tr("GEOM_WIRE"));
GroupPoints->ComboBox1->addItem(tr("GEOM_EDGE"));
GroupPoints->ComboBox1->addItem(tr("GEOM_VERTEX"));
GroupPoints->ComboBox1->setCurrentIndex(0);
initTypes();
showOnlyPreviewControl();
@ -127,6 +137,8 @@ void OperationGUI_GetSharedShapesDlg::Init()
connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
connect(GroupPoints->CheckButton1, SIGNAL(clicked()), this, SLOT(processPreview()));
connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
@ -137,6 +149,35 @@ void OperationGUI_GetSharedShapesDlg::Init()
GroupPoints->PushButton1->click();
}
void OperationGUI_GetSharedShapesDlg::initTypes()
{
GEOM::shape_type t = maxShapeType( myListShapes );
int idx = GroupPoints->ComboBox1->count() > 0 ?
GroupPoints->ComboBox1->itemData( GroupPoints->ComboBox1->currentIndex() ).toInt() : -1;
GroupPoints->ComboBox1->clear();
if ( t == GEOM::SHAPE || t <= GEOM::SOLID )
GroupPoints->ComboBox1->addItem( tr( "GEOM_SOLID" ), int( GEOM::SOLID ) );
if ( t == GEOM::SHAPE || t <= GEOM::SHELL )
GroupPoints->ComboBox1->addItem( tr( "GEOM_SHELL" ), int( GEOM::SHELL ) );
if ( t == GEOM::SHAPE || t <= GEOM::FACE )
GroupPoints->ComboBox1->addItem( tr( "GEOM_FACE" ), int( GEOM::FACE ) );
if ( t == GEOM::SHAPE || t <= GEOM::WIRE )
GroupPoints->ComboBox1->addItem( tr( "GEOM_WIRE" ), int( GEOM::WIRE ) );
if ( t == GEOM::SHAPE || t <= GEOM::EDGE )
GroupPoints->ComboBox1->addItem( tr( "GEOM_EDGE" ), int( GEOM::EDGE ) );
if ( t == GEOM::SHAPE || t <= GEOM::VERTEX )
GroupPoints->ComboBox1->addItem( tr( "GEOM_VERTEX" ), int( GEOM::VERTEX ) );
idx = GroupPoints->ComboBox1->findData( idx );
GroupPoints->ComboBox1->setCurrentIndex( idx >= 0 ? idx : 0 );
if ( idx < 0 )
ComboTextChanged();
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
@ -148,7 +189,6 @@ void OperationGUI_GetSharedShapesDlg::ConstructorsClicked (int constructorId)
myListShapes.length(0);
GroupPoints->ComboBox1->setCurrentIndex(0);
GroupPoints->PushButton1->setDown(true);
myEditCurrentArgument = GroupPoints->LineEdit1;
@ -210,6 +250,9 @@ void OperationGUI_GetSharedShapesDlg::SelectionIntoArgument()
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
initTypes();
if (!myListShapes.length())
return;
@ -278,19 +321,8 @@ void OperationGUI_GetSharedShapesDlg::ComboTextChanged()
//=================================================================================
int OperationGUI_GetSharedShapesDlg::GetType() const
{
int aLimit = GroupPoints->ComboBox1->currentIndex();
switch (aLimit) {
case 0: aLimit = GEOM::SOLID ; break;
case 1: aLimit = GEOM::SHELL ; break;
case 2: aLimit = GEOM::FACE ; break;
case 3: aLimit = GEOM::WIRE ; break;
case 4: aLimit = GEOM::EDGE ; break;
case 5: aLimit = GEOM::VERTEX; break;
default: aLimit = GEOM::SHAPE ;
}
return aLimit;
return GroupPoints->ComboBox1->count() > 0 ?
GroupPoints->ComboBox1->itemData( GroupPoints->ComboBox1->currentIndex() ).toInt() : (int)GEOM::SHAPE;
}
//=================================================================================
@ -359,16 +391,14 @@ QString OperationGUI_GetSharedShapesDlg::getPrefixByType () const
{
QString aPref;
int aLimit = GroupPoints->ComboBox1->currentIndex();
switch (aLimit) {
case 0: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SOLID")) ; break;
case 1: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SHELL")) ; break;
case 2: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_FACE")) ; break;
case 3: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_WIRE")) ; break;
case 4: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_EDGE")) ; break;
case 5: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_VERTEX")); break;
default: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SHAPE")) ;
switch ( GetType() ) {
case GEOM::SOLID: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SOLID")) ; break;
case GEOM::SHELL: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SHELL")) ; break;
case GEOM::FACE: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_FACE")) ; break;
case GEOM::WIRE: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_WIRE")) ; break;
case GEOM::EDGE: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_EDGE")) ; break;
case GEOM::VERTEX: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_VERTEX")); break;
default: aPref = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SHAPE")) ; break;
}
return aPref;

View File

@ -53,6 +53,7 @@ private:
void Init();
void enterEvent (QEvent*);
int GetType() const;
void initTypes();
private:
GEOM::ListOfGO myListShapes;