SOURCE_GROUP ("Resource Files" FILES ${XML_RESOURCES})
-ADD_DEFINITIONS(-DCONFIG_EXPORTS)
+ADD_DEFINITIONS(-DCONFIG_EXPORTS -D_SCL_SECURE_NO_WARNINGS)
+# -D_SCL_SECURE_NO_WARNINGS - to disable warnings 4996
+
ADD_LIBRARY(Config SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
TARGET_LINK_LIBRARIES(Config ${PROJECT_LIBRARIES})
#include <vector>
//! Class wihich let to register properties
-class CONFIG_EXPORT Config_PropManager
+class Config_PropManager
{
public:
* \param theValue - initial value of the property
* Returns True if the property succesfully registered
*/
- static bool registerProp(const std::string& theSection, const std::string& theName,
+ CONFIG_EXPORT static bool registerProp(const std::string& theSection, const std::string& theName,
const std::string& theTitle, Config_Prop::PropType theType,
const std::string& theValue);
- static Config_Prop* findProp(const std::string& theSection, const std::string& theName);
+ CONFIG_EXPORT static Config_Prop* findProp(const std::string& theSection, const std::string& theName);
- static Config_Properties getProperties();
+ CONFIG_EXPORT static Config_Properties getProperties();
//! Returns list of registered section names.
- static std::list<std::string> getSections();
+ CONFIG_EXPORT static std::list<std::string> getSections();
//! Returns list of properties by its owner and section.
- static Config_Properties getProperties(const std::string& theSection);
+ CONFIG_EXPORT static Config_Properties getProperties(const std::string& theSection);
//! Returns value of the property by its owner, section, and name
- static std::string string(const std::string& theSection, const std::string& theName,
+ CONFIG_EXPORT static std::string string(const std::string& theSection, const std::string& theName,
const std::string& theDefault);
- static std::vector<int> color(const std::string& theSection, const std::string& theName,
+ CONFIG_EXPORT static std::vector<int> color(const std::string& theSection, const std::string& theName,
const std::string& theDefault);
- static int integer(const std::string& theSection, const std::string& theName,
+ CONFIG_EXPORT static int integer(const std::string& theSection, const std::string& theName,
const std::string& theDefault);
- static double real(const std::string& theSection, const std::string& theName,
+ CONFIG_EXPORT static double real(const std::string& theSection, const std::string& theName,
const std::string& theDefault);
private:
- static Config_Properties myProps;
+ CONFIG_EXPORT static Config_Properties myProps;
};
#endif
string aName(theName);
map<string, char*>::iterator aFound = CREATED_EVENTS.find(aName);
if (aFound == CREATED_EVENTS.end()) { //not created yet
+#ifdef WIN32
+ aResult = _strdup(theName); // copy to make unique internal pointer
+#else
aResult = strdup(theName); // copy to make unique internal pointer
+#endif
CREATED_EVENTS[aName] = aResult;
} else
aResult = aFound->second;
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_ResultBody.h>
#include <GeomAlgoAPI_Boolean.h>
void FeaturesPlugin_Boolean::initAttributes()
{
- data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeReference::type());
+ data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::type());
data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::type());
data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::type());
}
void FeaturesPlugin_Boolean::execute()
{
+ boost::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeInteger>(data()->attribute(FeaturesPlugin_Boolean::TYPE_ID()));
+ if (!aTypeAttr)
+ return;
+ int aType = aTypeAttr->value();
+
boost::shared_ptr<GeomAPI_Shape> aObject = this->getShape(FeaturesPlugin_Boolean::OBJECT_ID());
if (!aObject)
return;
return;
boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
- aResult->store(GeomAlgoAPI_Boolean::makeCut(aObject, aTool));
+ switch (aType) {
+ case BOOL_CUT:
+ aResult->store(GeomAlgoAPI_Boolean::makeCut(aObject, aTool));
+ break;
+ case BOOL_FUSE:
+ aResult->store(GeomAlgoAPI_Boolean::makeFuse(aObject, aTool));
+ break;
+ case BOOL_COMMON:
+ aResult->store(GeomAlgoAPI_Boolean::makeCommon(aObject, aTool));
+ break;
+ }
setResult(aResult);
}
\ No newline at end of file
return MY_TOOL_ID;
}
+ enum {
+ BOOL_CUT,
+ BOOL_FUSE,
+ BOOL_COMMON
+ };
/// Returns the kind of a feature
label="Main object"
icon=":icons/cut_shape.png"
tooltip="Select an object to cut"
- activate="true"
- shape_types="solid,shell"
+ shape_types="solid shell"
/>
<selector id="tool_object"
label="Tool object"
icon=":icons/cut_tool.png"
tooltip="Select a tool"
- activate="false"
shape_types="solid"
/>
+ <choice id="bool_type"
+ label="Type"
+ tooltip="Type of boolean operation"
+ string_list="Cut Fuse Common"
+ />
</source>
#include "GeomAlgoAPI_Boolean.h"
#include <BRepAlgoAPI_Cut.hxx>
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepAlgoAPI_Fuse.hxx>
boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Boolean::makeCut(
}
return boost::shared_ptr<GeomAPI_Shape>();
}
+
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Boolean::makeFuse(
+ boost::shared_ptr<GeomAPI_Shape> theShape,
+ boost::shared_ptr<GeomAPI_Shape> theTool)
+{
+ const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aTool = theTool->impl<TopoDS_Shape>();
+
+ BRepAlgoAPI_Fuse aFuse(aShape, aTool);
+ if (aFuse.IsDone()) {
+ boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
+ aResult->setImpl(new TopoDS_Shape(aFuse.Shape()));
+ return aResult;
+ }
+ return boost::shared_ptr<GeomAPI_Shape>();
+}
+
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Boolean::makeCommon(
+ boost::shared_ptr<GeomAPI_Shape> theShape,
+ boost::shared_ptr<GeomAPI_Shape> theTool)
+{
+ const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aTool = theTool->impl<TopoDS_Shape>();
+
+ BRepAlgoAPI_Common aCommon(aShape, aTool);
+ if (aCommon.IsDone()) {
+ boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
+ aResult->setImpl(new TopoDS_Shape(aCommon.Shape()));
+ return aResult;
+ }
+ return boost::shared_ptr<GeomAPI_Shape>();
+}
\ No newline at end of file
{
public:
/* \brief Creates cut boolean operation
- * \param[in] theShape face or wire to be extruded
+ * \param[in] theShape the main shape
* \param[in] theTool toole shape for boolean
* \return a solid as result of operation
*/
static boost::shared_ptr<GeomAPI_Shape> makeCut(boost::shared_ptr<GeomAPI_Shape> theShape,
boost::shared_ptr<GeomAPI_Shape> theTool);
+ /* \brief Creates fuse boolean operation
+ * \param[in] theShape the main shape
+ * \param[in] theTool second shape
+ * \return a solid as result of operation
+ */
+ static boost::shared_ptr<GeomAPI_Shape> makeFuse(boost::shared_ptr<GeomAPI_Shape> theShape,
+ boost::shared_ptr<GeomAPI_Shape> theTool);
+
+ /* \brief Creates common boolean operation
+ * \param[in] theShape the main shape
+ * \param[in] theTool second shape
+ * \return a solid as result of operation
+ */
+ static boost::shared_ptr<GeomAPI_Shape> makeCommon(boost::shared_ptr<GeomAPI_Shape> theShape,
+ boost::shared_ptr<GeomAPI_Shape> theTool);
};
#endif
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
// Create event for first Feature, send it to make "created" earlier than "updated"
- Events_Loop::loop()->flush(anEvent);
+ //Events_Loop::loop()->flush(anEvent);
} else { // update
*aResIter = theResult;
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
#include "ModuleBase_WidgetChoice.h"
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_Data.h>
#include <Config_WidgetAPI.h>
#include <QWidget>
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
myLabel = new QLabel(aLabelText, myContainer);
- myLabel->setPixmap(QPixmap(aLabelIcon));
+ if (!aLabelIcon.isEmpty())
+ myLabel->setPixmap(QPixmap(aLabelIcon));
aLayout->addWidget(myLabel);
myCombo = new QComboBox(myContainer);
- aLayout->addWidget(myCombo);
+ aLayout->addWidget(myCombo, 1);
+
+ std::string aTypes = theData->getProperty("string_list");
+ QStringList aList = QString(aTypes.c_str()).split(' ');
+ myCombo->addItems(aList);
+
connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
}
bool ModuleBase_WidgetChoice::storeValue() const
{
+ DataPtr aData = myFeature->data();
+ boost::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
+
+ aIntAttr->setValue(myCombo->currentIndex());
+ updateObject(myFeature);
return true;
}
bool ModuleBase_WidgetChoice::restoreValue()
{
+ DataPtr aData = myFeature->data();
+ boost::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
+
+ bool isBlocked = myCombo->blockSignals(true);
+ myCombo->setCurrentIndex(aIntAttr->value());
+ myCombo->blockSignals(isBlocked);
return true;
}
void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex)
{
+ emit valuesChanged();
+ emit focusOutWidget(this);
}
\ No newline at end of file
#include <ModuleBase_WidgetBoolValue.h>
#include <ModuleBase_WidgetPoint2dDistance.h>
#include <ModuleBase_WidgetFileSelector.h>
+#include <ModuleBase_WidgetChoice.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IModule.h>
} else if (theType == WDG_DOUBLEVALUE_EDITOR) {
result = doubleValueEditor(theParent);
+ } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
+ result = doubleValueEditor(theParent);
+
} else if (theType == WDG_POINT2D_DISTANCE) {
result = point2dDistanceControl(theParent);
+
} else if (theType == WDG_FILE_SELECTOR) {
result = fileSelectorControl(theParent);
+
+ } else if (theType == WDG_CHOICE) {
+ result = choiceControl(theParent);
+
} else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
result = createContainer(theType, theParent);
} else {
return aFileSelectorWgt->getControl();
}
+
+QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent)
+{
+ ModuleBase_WidgetChoice* aChoiceWgt = new ModuleBase_WidgetChoice(theParent, myWidgetApi,
+ myParentId);
+ myModelWidgets.append(aChoiceWgt);
+
+ return aChoiceWgt->getControl();
+}
+
QWidget* booleanControl(QWidget* theParent);
QWidget* point2dDistanceControl(QWidget* theParent);
QWidget* fileSelectorControl(QWidget* theParent);
+ QWidget* choiceControl(QWidget* theParent);
/// Check whether the XML definition for the given type contains internal property
/// \param theType the widget type
bool ModuleBase_WidgetFeature::storeValue() const
{
//FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
- //if (!aFeature)
- // return false;
+ if (!myObject)
+ return false;
+
boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
+ double aX = myXSpin->value();
+ double aY = myYSpin->value();
aPoint->setValue(myXSpin->value(), myYSpin->value());
updateObject(myFeature);
that->blockSignals(isBlocked);
const Config_WidgetAPI* theData,
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId),
- myWorkshop(theWorkshop),
- myActivateOnStart(false)
+ myWorkshop(theWorkshop)
{
myContainer = new QWidget(theParent);
QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
myLabel = new QLabel(aLabelText, myContainer);
- myLabel->setPixmap(QPixmap(aLabelIcon));
+ if (!aLabelIcon.isEmpty())
+ myLabel->setPixmap(QPixmap(aLabelIcon));
aLayout->addWidget(myLabel);
myBasePalet = myTextLine->palette();
myInactivePalet = myBasePalet;
myInactivePalet.setBrush(QPalette::Base, QBrush(Qt::gray, Qt::Dense6Pattern));
+ myTextLine->setPalette(myInactivePalet);
- aLayout->addWidget(myTextLine);
+ aLayout->addWidget(myTextLine, 1);
myActivateBtn = new QToolButton(myContainer);
myActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
aLayout->addWidget(myActivateBtn);
- QString aActivateTxt = QString::fromStdString(theData->getProperty("activate"));
- if (!aActivateTxt.isNull()) {
- myActivateOnStart = (aActivateTxt == "true");
- }
-
std::string aTypes = theData->getProperty("shape_types");
- myShapeTypes = QString(aTypes.c_str()).split(',');
+ myShapeTypes = QString(aTypes.c_str()).split(' ');
}
//********************************************************************
bool ModuleBase_WidgetSelector::eventFilter(QObject* theObj, QEvent* theEvent)
{
if (theObj == myTextLine) {
- if (theEvent->type() == QEvent::Polish) {
- myActivateBtn->setChecked(myActivateOnStart);
- onSelectionChanged();
- }
+ //if (theEvent->type() == QEvent::Polish) {
+ // myActivateBtn->setChecked(myActivateOnStart);
+ // onSelectionChanged();
+ //}
}
return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
}
/// \return a control list
virtual QList<QWidget*> getControls() const;
- void setActivationOnStart(bool toActivate)
- {
- myActivateOnStart = toActivate;
- }
- bool activateOnStart() const
- {
- return myActivateOnStart;
- }
-
ObjectPtr selectedFeature() const
{
return mySelectedObject;
ModuleBase_IWorkshop* myWorkshop;
- bool myActivateOnStart;
-
ObjectPtr mySelectedObject;
QStringList myShapeTypes;
Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
if (aFmt == "PS")
+#ifdef WIN32
+ a3dView->Export(_strdup(qPrintable(aFileName)), Graphic3d_EF_PostScript);
+#else
a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_PostScript);
+#endif
else if (aFmt == "EPS")
+#ifdef WIN32
+ a3dView->Export(_strdup(qPrintable(aFileName)), Graphic3d_EF_EnhPostScript);
+#else
a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_EnhPostScript);
+#endif
else
aPicture.save(aFileName, aFmt.toLatin1());
QApplication::restoreOverrideCursor();