#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
//=================================================================================
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();
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()));
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
myListShapes.length(0);
- GroupPoints->ComboBox1->setCurrentIndex(0);
GroupPoints->PushButton1->setDown(true);
myEditCurrentArgument = GroupPoints->LineEdit1;
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
+
+ initTypes();
+
if (!myListShapes.length())
return;
//=================================================================================
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;
}
//=================================================================================
{
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;