// Created: 2 June 2014
// Author: Vitaly Smetannikov
-
#include "ModuleBase_WidgetSelector.h"
#include "ModuleBase_IWorkshop.h"
#include <stdexcept>
-
typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
static ShapeTypes MyShapeTypes;
MyShapeTypes["shell"] = TopAbs_SHELL;
MyShapeTypes["solid"] = TopAbs_SOLID;
}
- if (MyShapeTypes.contains(theType))
+ if (MyShapeTypes.contains(theType))
return MyShapeTypes[theType];
throw std::invalid_argument("Shape type defined in XML is not implemented!");
}
-
-
-
-ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent,
- ModuleBase_IWorkshop* theWorkshop,
+ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const std::string& theParentId)
-: ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop), myActivateOnStart(false)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId),
+ myWorkshop(theWorkshop),
+ myActivateOnStart(false)
{
myContainer = new QWidget(theParent);
QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
bool ModuleBase_WidgetSelector::storeValue() const
{
FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(mySelectedObject);
- if (aSelectedFeature == myFeature) // In order to avoid selection of the same object
+ if (aSelectedFeature == myFeature) // In order to avoid selection of the same object
return false;
DataPtr aData = myFeature->data();
- boost::shared_ptr<ModelAPI_AttributeReference> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
+ boost::shared_ptr<ModelAPI_AttributeReference> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeReference>(aData->attribute(attributeID()));
ObjectPtr aObject = aRef->value();
if (!(aObject && aObject->isSame(mySelectedObject))) {
bool isBlocked = this->blockSignals(true);
mySelectedObject = aRef->value();
- updateSelectionName();
+ updateSelectionName();
this->blockSignals(isBlocked);
return true;
return;
// Check that the selection corresponds to selection type
- if (!isAccepted(aObject)) return;
+ if (!isAccepted(aObject))
+ return;
mySelectedObject = aObject;
if (mySelectedObject) {
{
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theResult);
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
- if (!aShapePtr) return false;
+ if (!aShapePtr)
+ return false;
TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
- if (aShape.IsNull()) return false;
+ if (aShape.IsNull())
+ return false;
TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
if (aShapeType == TopAbs_COMPOUND) {
- foreach (QString aType, myShapeTypes) {
+ foreach (QString aType, myShapeTypes)
+ {
TopExp_Explorer aEx(aShape, shapeType(aType));
if (aEx.More())
return true;
}
} else {
- foreach (QString aType, myShapeTypes) {
+ foreach (QString aType, myShapeTypes)
+ {
if (shapeType(aType) == aShapeType)
return true;
}
{
if (mySelectedObject) {
std::string aName = mySelectedObject->data()->name();
-
+
myTextLine->setText(QString::fromStdString(aName));
- } else
+ } else
myTextLine->setText("");
}
{
QWidget* aParent = myContainer->parentWidget();
QList<QWidget*> aChldList = aParent->findChildren<QWidget*>();
- foreach(QWidget* aWgt, aChldList) {
- if ((aWgt != myLabel) && (aWgt != myActivateBtn) && (aWgt != myTextLine) && (aWgt != myContainer))
+ foreach(QWidget* aWgt, aChldList)
+ {
+ if ((aWgt != myLabel) && (aWgt != myActivateBtn) && (aWgt != myTextLine)
+ && (aWgt != myContainer))
aWgt->setEnabled(toEnable);
}
}
while (!aParent->inherits("QDockWidget")) {
aLastPanel = aParent;
aParent = aParent->parentWidget();
- if (!aParent) return;
+ if (!aParent)
+ return;
}
if (aParent->inherits("QDockWidget")) {
QDockWidget* aTabWgt = (QDockWidget*) aParent;