return mySize->Get();
}
+int Model_AttributeSelectionList::selectionType()
+{
+ return (int) mySelectionType->Get();
+}
+
+void Model_AttributeSelectionList::setSelectionType(int theType)
+{
+ mySelectionType->Set((double) theType);
+}
+
boost::shared_ptr<ModelAPI_AttributeSelection>
Model_AttributeSelectionList::value(const int theIndex)
{
myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True;
if (!myIsInitialized) {
mySize = TDataStd_Integer::Set(theLabel, 0);
+ mySelectionType = TDataStd_Real::Set(theLabel, 0);
} else { // recollect mySubs
int aNum = mySize->Get();
TDF_ChildIterator aSubIter(theLabel);
#include "Model_AttributeSelection.h"
#include <ModelAPI_AttributeSelectionList.h>
#include <TDataStd_Integer.hxx>
+#include <TDataStd_Real.hxx>
#include <vector>
/**\class Model_AttributeSelectionList
class Model_AttributeSelectionList : public ModelAPI_AttributeSelectionList
{
Handle(TDataStd_Integer) mySize; ///< Contains size of this list
+ Handle(TDataStd_Real) mySelectionType; ///< Contains current index, TODO: make it integer, not real
std::vector<boost::shared_ptr<Model_AttributeSelection> > mySubs; /// the selection attributes
public:
/// Adds the new reference to the end of the list
/// Returns the number ofselection attributes in the list
MODEL_EXPORT virtual int size();
+ MODEL_EXPORT virtual int selectionType();
+
+ MODEL_EXPORT virtual void setSelectionType(int);
+
/// Returns the attribute selection by the index (zero based)
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex);
/// Returns the number ofselection attributes in the list
virtual int size() = 0;
+ virtual int selectionType() = 0;
+
+ virtual void setSelectionType(int) = 0;
+
/// Returns the attribute selection by the index (zero based)
virtual boost::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex) = 0;
myTypeCombo = new QComboBox(myMainWidget);
// There is no sence to paramerize list of types while we can not parametrize selection mode
QString aTypesStr("Vertices Edges Faces Solids");
- myShapeTypes = aTypesStr.split(' ');
- myTypeCombo->addItems(myShapeTypes);
+ QStringList aShapeTypes = aTypesStr.split(' ');
+ myTypeCombo->addItems(aShapeTypes);
aMainLay->addWidget(myTypeCombo, 0, 1);
QLabel* aListLabel = new QLabel(tr("Selected objects:"), myMainWidget);
if (aSelectionListAttr && (mySelection.size() > 0)) {
aSelectionListAttr->clear();
+ // Store shapes type
+ TopAbs_ShapeEnum aCurrentType =
+ ModuleBase_WidgetShapeSelector::shapeType(myTypeCombo->currentText());
+ aSelectionListAttr->setSelectionType((int) aCurrentType);
+ // Store selection in the attribute
foreach (GeomSelection aSelec, mySelection) {
aSelectionListAttr->append(aSelec.first, aSelec.second);
}
if (aSelectionListAttr) {
mySelection.clear();
+ // Restore shape type
+ TopAbs_ShapeEnum aShapeType = (TopAbs_ShapeEnum) aSelectionListAttr->selectionType();
+ setCurrentShapeType(aShapeType);
+ // Restore selection in the list
for (int i = 0; i < aSelectionListAttr->size(); i++) {
AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
mySelection.append(GeomSelection(aSelectAttr->context(), aSelectAttr->value()));
}
}
+
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum theShapeType)
+{
+ QString aShapeTypeName;
+ for (int idx = 0; idx < myTypeCombo->count(); ++idx) {
+ aShapeTypeName = myTypeCombo->currentText();
+ TopAbs_ShapeEnum aRefType = ModuleBase_WidgetShapeSelector::shapeType(aShapeTypeName);
+ if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
+ myTypeCombo->setCurrentIndex(idx);
+ break;
+ }
+ }
+}
+
//********************************************************************
void ModuleBase_WidgetMultiSelector::activateSelection(bool toActivate)
{
protected:
void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
NCollection_List<TopoDS_Shape>& theResult);
+ void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
private:
void updateSelectionList();
ModuleBase_IWorkshop* myWorkshop;
/// If true then local selector has to be activated in context
- QStringList myShapeTypes;
bool myUseSubShapes;
bool myIsActive;