filter-TopoConnectedFaces.xml
)
+SET(TEXT_RESOURCES
+ FiltersPlugin_msg_en.ts
+ FiltersPlugin_msg_fr.ts
+)
+
SOURCE_GROUP ("XML Files" FILES ${XML_RESOURCES})
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
ADD_DEFINITIONS(-DFILTERS_EXPORTS ${OpenCASCADE_DEFINITIONS})
-ADD_LIBRARY(FiltersPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+ADD_LIBRARY(FiltersPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES})
TARGET_LINK_LIBRARIES(FiltersPlugin ${PROJECT_LIBRARIES})
INCLUDE_DIRECTORIES(
INSTALL(TARGETS FiltersPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
INSTALL(FILES ${PROJECT_PYFILES} DESTINATION ${SHAPER_INSTALL_ADDONS})
+INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
ADD_UNIT_TESTS(
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+
+ <!-- workshop -->
+ <context>
+ <name>workshop</name>
+ <message>
+ <source>Selection filters</source>
+ <translation>Selection filters</translation>
+ </message>
+ </context>
+
+ <!-- FiltersSelection -->
+ <context>
+ <name>FiltersSelection</name>
+ <message>
+ <source></source>
+ <translation></translation>
+ </message>
+ <message>
+ <source>Selection filters</source>
+ <translation>Selection filters</translation>
+ </message>
+ <message>
+ <source>Filters</source>
+ <translation>Filters</translation>
+ </message>
+ <message>
+ <source>Add new filter...</source>
+ <translation>Add new filter...</translation>
+ </message>
+ <message>
+ <source>Delete the filter</source>
+ <translation>Delete the filter</translation>
+ </message>
+ <message>
+ <source>Reverse the filter</source>
+ <translation>Reverse the filter</translation>
+ </message>
+ <message>
+ <source>Selection by filters</source>
+ <translation>Selection by filters</translation>
+ </message>
+ <message>
+ <source>Number of selected objects:</source>
+ <translation>Number of selected objects:</translation>
+ </message>
+ <message>
+ <source>Select</source>
+ <translation>Select</translation>
+ </message>
+ <message>
+ <source>Selection is empty</source>
+ <translation>Selection is empty</translation>
+ </message>
+ <message>
+ <source>Show only</source>
+ <translation>Show only</translation>
+ </message>
+ <message>
+ <source>Belongs to</source>
+ <translation>Belongs to</translation>
+ </message>
+ <message>
+ <source>External faces</source>
+ <translation>External faces</translation>
+ </message>
+ <message>
+ <source>Horizontal faces</source>
+ <translation>Horizontal faces</translation>
+ </message>
+ <message>
+ <source>On geometry</source>
+ <translation>On geometry</translation>
+ </message>
+ <message>
+ <source>On line</source>
+ <translation>On line</translation>
+ </message>
+ <message>
+ <source>On plane</source>
+ <translation>On plane</translation>
+ </message>
+ <message>
+ <source>On plane side</source>
+ <translation>On plane side</translation>
+ </message>
+ <message>
+ <source>On/In/Out a solid</source>
+ <translation>On/In/Out a solid</translation>
+ </message>
+ <message>
+ <source>Opposite to an edge</source>
+ <translation>Opposite to an edge</translation>
+ </message>
+ <message>
+ <source>Topologically connected faces</source>
+ <translation>Topologically connected faces</translation>
+ </message>
+ <message>
+ <source>Vertical faces</source>
+ <translation>Vertical faces</translation>
+ </message>
+ <message>
+ <source>Attribute "%1" is not initialized.</source>
+ <translation>Select a shape.</translation>
+ </message>
+ </context>
+ <context>
+ <name>FiltersSelection:FiltersPlugin_ShapeType</name>
+ <message>
+ <source>Unknown error.</source>
+ <translation>Unknown error.</translation>
+ </message>
+ </context>
+ <context>
+ <name>FiltersSelection:GeomValidators_ShapeType</name>
+ <message>
+ <source>It does not contain element with acceptable shape type. The type should be one of the next: %1</source>
+ <translation>It does not contain element with acceptable shape type. The type should be one of the next: %1</translation>
+ </message>
+ <message>
+ <source>The object is empty</source>
+ <translation>The object is empty</translation>
+ </message>
+ </context>
+
+ <!-- BelongsTo -->
+ <context>
+ <name>BelongsTo</name>
+ <message>
+ <source>Objects:</source>
+ <translation>Objects:</translation>
+ </message>
+ <message>
+ <source>Select objects to limit selection.</source>
+ <translation>Select objects to limit selection.</translation>
+ </message>
+ </context>
+
+ <!-- OnGeometry -->
+ <context>
+ <name>OnGeometry</name>
+ <message>
+ <source>Select objects to limit selection.</source>
+ <translation>Select objects to limit selection.</translation>
+ </message>
+ <message>
+ <source>Shapes:</source>
+ <translation>Shapes:</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnGeometry:FiltersPlugin_ShapeType</name>
+ <message>
+ <source>Unknown error.</source>
+ <translation>Unknown error.</translation>
+ </message>
+ </context>
+
+ <!-- OnLine -->
+ <context>
+ <name>OnLine</name>
+ <message>
+ <source>Lines:</source>
+ <translation>Lines:</translation>
+ </message>
+ <message>
+ <source>Select vertices or segments.</source>
+ <translation>Select vertices or segments.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnLine:GeomValidators_ShapeType</name>
+ <message>
+ <source>It does not contain element with acceptable shape type. The type should be one of the next: %1</source>
+ <translation>It does not contain element with acceptable shape type. The type should be one of the next: %1</translation>
+ </message>
+ </context>
+
+ <!-- OnPlane -->
+ <context>
+ <name>OnPlane</name>
+ <message>
+ <source>Planes:</source>
+ <translation>Planes:</translation>
+ </message>
+ <message>
+ <source>Select planes or planar faces.</source>
+ <translation>Select planes or planar faces.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnPlane:GeomValidators_ShapeType</name>
+ <message>
+ <source>It does not contain element with acceptable shape type. The type should be one of the next: %1</source>
+ <translation>It does not contain element with acceptable shape type. The type should be one of the next: %1</translation>
+ </message>
+ </context>
+
+ <!-- OnPlaneSide -->
+ <context>
+ <name>OnPlaneSide</name>
+ <message>
+ <source>Plane:</source>
+ <translation>Plane:</translation>
+ </message>
+ <message>
+ <source>Select plane or planar face.</source>
+ <translation>Select plane or planar face.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnPlaneSide:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>The object is empty</translation>
+ </message>
+ </context>
+
+ <!-- OppositeToEdge -->
+ <context>
+ <name>OppositeToEdge</name>
+ <message>
+ <source>Edge:</source>
+ <translation>Edge:</translation>
+ </message>
+ <message>
+ <source>Select edge.</source>
+ <translation>Select edge.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OppositeToEdge:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>The object is empty</translation>
+ </message>
+ </context>
+
+ <!-- RelativeToSolid -->
+ <context>
+ <name>RelativeToSolid</name>
+ <message>
+ <source>In</source>
+ <translation>In</translation>
+ </message>
+ <message>
+ <source>In & On</source>
+ <translation>In & On</translation>
+ </message>
+ <message>
+ <source>Not On</source>
+ <translation>Not On</translation>
+ </message>
+ <message>
+ <source>On</source>
+ <translation>On</translation>
+ </message>
+ <message>
+ <source>On & Out</source>
+ <translation>On & Out</translation>
+ </message>
+ <message>
+ <source>Out</source>
+ <translation>Out</translation>
+ </message>
+ <message>
+ <source>Select a solid.</source>
+ <translation>Select a solid.</translation>
+ </message>
+ <message>
+ <source>Solid:</source>
+ <translation>Solid:</translation>
+ </message>
+ </context>
+ <context>
+ <name>RelativeToSolid:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>The object is empty</translation>
+ </message>
+ </context>
+
+ <!-- TopoConnectedFaces -->
+ <context>
+ <name>TopoConnectedFaces</name>
+ <message>
+ <source>Propagation</source>
+ <translation>Propagation</translation>
+ </message>
+ <message>
+ <source>Select vertex, edge or face.</source>
+ <translation>Select vertex, edge or face.</translation>
+ </message>
+ <message>
+ <source>Shape:</source>
+ <translation>Shape:</translation>
+ </message>
+ </context>
+ <context>
+ <name>TopoConnectedFaces:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>The object is empty</translation>
+ </message>
+ </context>
+
+</TS>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+
+
+ <!-- workshop -->
+ <context>
+ <name>workshop</name>
+ <message>
+ <source>Selection filters</source>
+ <translation>Filtres de sélection</translation>
+ </message>
+ </context>
+
+ <!-- FiltersSelection -->
+ <context>
+ <name>FiltersSelection</name>
+ <message>
+ <source></source>
+ <translation></translation>
+ </message>
+ <message>
+ <source>Selection filters</source>
+ <translation>Filtres de sélection</translation>
+ </message>
+ <message>
+ <source>Filters</source>
+ <translation>Filtres</translation>
+ </message>
+ <message>
+ <source>Add new filter...</source>
+ <translation>Ajouter un nouveau filtre ...</translation>
+ </message>
+ <message>
+ <source>Delete the filter</source>
+ <translation>Supprimer le filtre</translation>
+ </message>
+ <message>
+ <source>Reverse the filter</source>
+ <translation>Inversez le filtre</translation>
+ </message>
+ <message>
+ <source>Selection by filters</source>
+ <translation>Sélection par filtres</translation>
+ </message>
+ <message>
+ <source>Number of selected objects:</source>
+ <translation>Nombre d'objets sélectionnés:</translation>
+ </message>
+ <message>
+ <source>Select</source>
+ <translation>Sélectionner</translation>
+ </message>
+ <message>
+ <source>Selection is empty</source>
+ <translation>La sélection est vide</translation>
+ </message>
+ <message>
+ <source>Show only</source>
+ <translation>Montrer seulement</translation>
+ </message>
+ <message>
+ <source>Belongs to</source>
+ <translation>Appartient à</translation>
+ </message>
+ <message>
+ <source>External faces</source>
+ <translation>Externe faces</translation>
+ </message>
+ <message>
+ <source>Horizontal faces</source>
+ <translation>Faces horizontales</translation>
+ </message>
+ <message>
+ <source>On geometry</source>
+ <translation>Sur la géométrie</translation>
+ </message>
+ <message>
+ <source>On line</source>
+ <translation>En ligne</translation>
+ </message>
+ <message>
+ <source>On plane</source>
+ <translation>En plan</translation>
+ </message>
+ <message>
+ <source>On plane side</source>
+ <translation>En côté plan</translation>
+ </message>
+ <message>
+ <source>On/In/Out a solid</source>
+ <translation>Sur/Dans/Dehors un solide</translation>
+ </message>
+ <message>
+ <source>Opposite to an edge</source>
+ <translation>En face d'un bord</translation>
+ </message>
+ <message>
+ <source>Topologically connected faces</source>
+ <translation>Faces topologiquement connectés</translation>
+ </message>
+ <message>
+ <source>Vertical faces</source>
+ <translation>Faces verticales</translation>
+ </message>
+ <message>
+ <source>Attribute "%1" is not initialized.</source>
+ <translation>Sélectionnez un objet.</translation>
+ </message>
+ </context>
+ <context>
+ <name>FiltersSelection:FiltersPlugin_ShapeType</name>
+ <message>
+ <source>Unknown error.</source>
+ <translation>Erreur inconnue.</translation>
+ </message>
+ </context>
+ <context>
+ <name>FiltersSelection:GeomValidators_ShapeType</name>
+ <message>
+ <source>It does not contain element with acceptable shape type. The type should be one of the next: %1</source>
+ <translation>Il ne contient pas d'élément avec un type de forme acceptable. Le type doit être l'un des prochains: %1</translation>
+ </message>
+ <message>
+ <source>The object is empty</source>
+ <translation>L'objet est vide.</translation>
+ </message>
+ </context>
+
+ <!-- BelongsTo -->
+ <context>
+ <name>BelongsTo</name>
+ <message>
+ <source>Objects:</source>
+ <translation>Objets:</translation>
+ </message>
+ <message>
+ <source>Select objects to limit selection.</source>
+ <translation>Sélectionner des objets pour limiter la sélection</translation>
+ </message>
+ </context>
+
+ <!-- OnGeometry -->
+ <context>
+ <name>OnGeometry</name>
+ <message>
+ <source>Select objects to limit selection.</source>
+ <translation>Sélectionner des objets pour limiter la sélection</translation>
+ </message>
+ <message>
+ <source>Shapes:</source>
+ <translation>Objets:</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnGeometry:FiltersPlugin_ShapeType</name>
+ <message>
+ <source>Unknown error.</source>
+ <translation>Erreur inconnue.</translation>
+ </message>
+ </context>
+
+ <!-- OnLine -->
+ <context>
+ <name>OnLine</name>
+ <message>
+ <source>Lines:</source>
+ <translation>Lignes:</translation>
+ </message>
+ <message>
+ <source>Select vertices or segments.</source>
+ <translation>AZV Select vertices or segments.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnLine:GeomValidators_ShapeType</name>
+ <message>
+ <source>It does not contain element with acceptable shape type. The type should be one of the next: %1</source>
+ <translation>Il ne contient pas d'élément avec un type de forme acceptable. Le type doit être l'un des prochains: %1</translation>
+ </message>
+ </context>
+
+ <!-- OnPlane -->
+ <context>
+ <name>OnPlane</name>
+ <message>
+ <source>Planes:</source>
+ <translation>Plans:</translation>
+ </message>
+ <message>
+ <source>Select planes or planar faces.</source>
+ <translation>Sélectionnez des plans ou des faces planes.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnPlane:GeomValidators_ShapeType</name>
+ <message>
+ <source>It does not contain element with acceptable shape type. The type should be one of the next: %1</source>
+ <translation>Il ne contient pas d'élément avec un type de forme acceptable. Le type doit être l'un des prochains: %1</translation>
+ </message>
+ </context>
+
+ <!-- OnPlaneSide -->
+ <context>
+ <name>OnPlaneSide</name>
+ <message>
+ <source>Plane:</source>
+ <translation>Plan:</translation>
+ </message>
+ <message>
+ <source>Select plane or planar face.</source>
+ <translation>Sélectionnez un plan ou une face plane.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OnPlaneSide:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>L'objet est vide.</translation>
+ </message>
+ </context>
+
+ <!-- OppositeToEdge -->
+ <context>
+ <name>OppositeToEdge</name>
+ <message>
+ <source>Edge:</source>
+ <translation>Arête:</translation>
+ </message>
+ <message>
+ <source>Select edge.</source>
+ <translation>Sélectionnez le arête.</translation>
+ </message>
+ </context>
+ <context>
+ <name>OppositeToEdge:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>L'objet est vide.</translation>
+ </message>
+ </context>
+
+ <!-- RelativeToSolid -->
+ <context>
+ <name>RelativeToSolid</name>
+ <message>
+ <source>In</source>
+ <translation>Dans</translation>
+ </message>
+ <message>
+ <source>In & On</source>
+ <translation>Dans et Sur</translation>
+ </message>
+ <message>
+ <source>Not On</source>
+ <translation>Pas Sur</translation>
+ </message>
+ <message>
+ <source>On</source>
+ <translation>Sur</translation>
+ </message>
+ <message>
+ <source>On & Out</source>
+ <translation>Sur et Dehors</translation>
+ </message>
+ <message>
+ <source>Out</source>
+ <translation>Dehors</translation>
+ </message>
+ <message>
+ <source>Select a solid.</source>
+ <translation>Sélectionnez un solide.</translation>
+ </message>
+ <message>
+ <source>Solid:</source>
+ <translation>Solide:</translation>
+ </message>
+ </context>
+ <context>
+ <name>RelativeToSolid:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>L'objet est vide.</translation>
+ </message>
+ </context>
+
+ <!-- TopoConnectedFaces -->
+ <context>
+ <name>TopoConnectedFaces</name>
+ <message>
+ <source>Propagation</source>
+ <translation>Propagation</translation>
+ </message>
+ <message>
+ <source>Select vertex, edge or face.</source>
+ <translation>Sélectionnez le sommet, l'arête ou la face.</translation>
+ </message>
+ <message>
+ <source>Shape:</source>
+ <translation>Objet:</translation>
+ </message>
+ </context>
+ <context>
+ <name>TopoConnectedFaces:GeomValidators_ShapeType</name>
+ <message>
+ <source>The object is empty</source>
+ <translation>L'objet est vide.</translation>
+ </message>
+ </context>
+
+</TS>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Feature.h>
+#include <ModelAPI_FiltersFeature.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Session.h>
aFeatureFind->second.find(*it) == aFeatureFind->second.end()) {
theError = "Attribute \"%1\" is not initialized.";
theError.addParameter(anAttr->id());
- theError.setContext(theFeature->getKind() + ":" + anAttr->id());
+ // workaround for the filters selection feature: do not append the attribute id
+ if (std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theFeature))
+ theError.setContext(theFeature->getKind());
+ else
+ theError.setContext(theFeature->getKind() + ":" + anAttr->id());
return false;
}
}
if (!feature().get())
return anError;
- std::string aFeatureID = feature()->getKind();
std::string anAttributeID = attributeID();
AttributePtr anAttribute = feature()->attribute(anAttributeID);
if (!anAttribute.get())
anErrorMsg = "Unknown error.";
if (anErrorMsg.context().empty()) {
- anErrorMsg.setContext(aFeatureID + ":" + anAttributeID + ":" + aValidatorID);
+ anErrorMsg.setContext(context() + ":" + aValidatorID);
}
}
/// \return Context for translation
virtual std::string context() const {
-
+ bool isAppendAttr = true;
std::string aContext = myFeatureId;
if(!aContext.empty() && !myAttributeID.empty()) {
- aContext += ":";
+ // workaround for ModelAPI_Filter's attributes:
+ // do not keep attribute name, because it may be changed
+ // if the same filter is selected twice or more.
+ if (myAttributeID.find(aContext + "__") != std::string::npos)
+ isAppendAttr = false;
+ else
+ aContext += ":";
}
- aContext += myAttributeID;
+ if (isAppendAttr)
+ aContext += myAttributeID;
return aContext;
}
ModuleBase_Tools::adjustMargins(aMainLayout);
aMainLayout->addStretch(1);
- QPushButton* aLaunchBtn = new QPushButton(tr("Selection by filters"), this);
+ QPushButton* aLaunchBtn = new QPushButton(
+ ModuleBase_Tools::translate("FiltersSelection", "Selection by filters"), this);
connect(aLaunchBtn, SIGNAL(clicked()), SLOT(onFiltersLaunch()));
aMainLayout->addWidget(aLaunchBtn);
}
void ModuleBase_FilterItem::addItemRow(QWidget* theParent)
{
+ std::string aContext = mySelection->getKind();
QHBoxLayout* aLayout = new QHBoxLayout(theParent);
ModuleBase_Tools::zeroMargins(aLayout);
myRevBtn->setIcon(QIcon(":pictures/reverce.png"));
else
myRevBtn->setIcon(QIcon(":pictures/add.png"));
- myRevBtn->setToolTip(tr("Reverse the filter"));
+ myRevBtn->setToolTip(ModuleBase_Tools::translate(aContext, "Reverse the filter"));
connect(myRevBtn, SIGNAL(toggled(bool)), SLOT(onReverse(bool)));
aLayout->addWidget(myRevBtn);
const std::string& aFilterName = ModelAPI_Session::get()->filters()->filter(myFilterID)->name();
- aLayout->addWidget(new QLabel(aFilterName.c_str(), theParent), 1);
+ aLayout->addWidget(new QLabel(ModuleBase_Tools::translate(aContext, aFilterName), theParent), 1);
QToolButton* aDelBtn = new QToolButton(theParent);
aDelBtn->setIcon(QIcon(":pictures/delete.png"));
aDelBtn->setAutoRaise(true);
- aDelBtn->setToolTip(tr("Delete the filter"));
+ aDelBtn->setToolTip(ModuleBase_Tools::translate(aContext, "Delete the filter"));
connect(aDelBtn, SIGNAL(clicked(bool)), SLOT(onDelete()));
aLayout->addWidget(aDelBtn);
}
QVBoxLayout* aMainLayout = new QVBoxLayout(this);
ModuleBase_Tools::adjustMargins(aMainLayout);
- QGroupBox* aFiltersGroup = new QGroupBox(tr("Filters"), this);
+ QGroupBox* aFiltersGroup = new QGroupBox(translate("Filters"), this);
QVBoxLayout* aGroupLayout = new QVBoxLayout(aFiltersGroup);
aGroupLayout->setContentsMargins(0, 0, 0, 0);
aGroupLayout->setSpacing(0);
aGroupLayout->addWidget(myFiltersWgt);
myFiltersCombo = new QComboBox(aFiltersGroup);
- myFiltersCombo->addItem(tr("Add new filter..."));
+ myFiltersCombo->addItem(translate("Add new filter..."));
SessionPtr aSession = ModelAPI_Session::get();
std::list<FilterPtr> allFilters =
aSession->filters()->filters((GeomAPI_Shape::ShapeType) mySelectionType);
+ storeFilters(allFilters);
QStringList aItems;
std::list<FilterPtr>::const_iterator aIt;
for (aIt = allFilters.cbegin(); aIt != allFilters.cend(); aIt++) {
- aItems.push_back((*aIt)->name().c_str());
+ aItems.push_back(translate((*aIt)->name().c_str()));
}
myFiltersCombo->addItems(aItems);
connect(myFiltersCombo, SIGNAL(currentIndexChanged(int)), SLOT(onAddFilter(int)));
aBtnLayout->addStretch(1);
- mySelectBtn = new QPushButton(tr("Select"), aBtnWgt);
+ mySelectBtn = new QPushButton(translate("Select"), aBtnWgt);
connect(mySelectBtn, SIGNAL(clicked()), SLOT(onSelect()));
aBtnLayout->addWidget(mySelectBtn);
QHBoxLayout* aLblLayout = new QHBoxLayout(aLblWgt);
ModuleBase_Tools::zeroMargins(aLblLayout);
- aLblLayout->addWidget(new QLabel(tr("Number of selected objects:"), aLblWgt));
+ aLblLayout->addWidget(new QLabel(translate("Number of selected objects:"), aLblWgt));
myNbLbl = new QLabel("0", aLblWgt);
aLblLayout->addWidget(myNbLbl);
// Show only button
- myShowBtn = new QCheckBox(tr("Show only"), this);
+ myShowBtn = new QCheckBox(translate("Show only"), this);
connect(myShowBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool)));
aLblLayout->addWidget(myShowBtn);
return;
ModelAPI_FiltersFactory* aFactory = ModelAPI_Session::get()->filters();
- std::list<FilterPtr> aFilters = aFactory->filters((GeomAPI_Shape::ShapeType) mySelectionType);
FiltersFeaturePtr aFiltersFeature =
std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
std::list<FilterPtr>::iterator aIt;
int i;
std::string aFilter;
- for (aIt = aFilters.begin(), i = 0; aIt != aFilters.cend(); i++, aIt++) {
- if (aText == (*aIt)->name()) {
- aFilter = aFactory->id(*aIt);
- break;
- }
+ std::map<std::string, FilterPtr>::const_iterator aFound = myFilters.find(aText);
+ if (aFound == myFilters.end()) {
+ std::list<FilterPtr> aFilters = aFactory->filters((GeomAPI_Shape::ShapeType) mySelectionType);
+ storeFilters(aFilters);
+ aFound = myFilters.find(aText);
}
+ if (aFound != myFilters.end())
+ aFilter = aFactory->id(aFound->second);
+
aFiltersFeature->addFilter(aFilter);
updateObject(myFeature);
{
int aNb = myValues.size();
myNbLbl->setText(QString::number(aNb));
- //QString aErr = () ? tr("Selection is empty") : "";
if (aNb == 0)
- myFeature->setError(tr("Selection is empty").toStdString(), false, false);
+ myFeature->setError(translate("Selection is empty").toStdString(), false, false);
else {
myFeature->setError("", false, false);
myFeature->data()->execState(ModelAPI_StateDone);
QString aErrorMsg = ModuleBase_ModelWidget::getError(theValueStateChecked);
if (aErrorMsg.isEmpty()) {
if (myValues.size() == 0)
- aErrorMsg = tr("Selection is empty");
+ aErrorMsg = translate("Selection is empty");
}
return aErrorMsg;
}
ModelAPI_EventCreator::get()->sendUpdated(myFeature, EVENT_DISP);
Events_Loop::loop()->flush(EVENT_DISP);
}
+
+void ModuleBase_WidgetSelectionFilter::storeFilters(const std::list<FilterPtr>& theFilters)
+{
+ for (std::list<FilterPtr>::const_iterator anIt = theFilters.begin();
+ anIt != theFilters.end(); ++anIt) {
+ std::string aName = translate((*anIt)->name()).toStdString();
+ myFilters[aName] = *anIt;
+ }
+}
+
+QString ModuleBase_WidgetSelectionFilter::translate(const std::string& theString) const
+{
+ return ModuleBase_Tools::translate(myFeatureId, theString);
+}
class QPushButton;
class QCheckBox;
+class ModelAPI_Filter;
+
class ModuleBase_IWorkshop;
/**
/// Return currently created filter items
QList<ModuleBase_FilterItem*> itemsList() const;
+ /// Translate a string
+ QString translate(const std::string& theString) const;
+
+ /// Store translated names of filters and their instances
+ void storeFilters(const std::list<std::shared_ptr<ModelAPI_Filter> >& theFilters);
+
private:
ModuleBase_IWorkshop* myWorkshop;
/// Attribute name which will get result of filtering
std::string mySelectorAttribute;
+
+ /// Translated name and the corresponding filter
+ std::map<std::string, std::shared_ptr<ModelAPI_Filter> > myFilters;
};