#define MY_PNT static_cast<gp_Pnt*>(myImpl)
GeomAPI_Shape::GeomAPI_Shape()
- : GeomAPI_Interface(new TopoDS_Shape())
-{}
+ : GeomAPI_Interface(new TopoDS_Shape()) {
+}
+
+bool GeomAPI_Shape::isNull()
+{
+ return MY_SHAPE->IsNull();
+}
* \ingroup DataModel
* \brief Interface to the topological shape object
*/
+class TopoDS_Shape;
+
+#define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
class GEOMAPI_EXPORT GeomAPI_Shape: public GeomAPI_Interface
{
public:
/// Creation of empty (null) shape
GeomAPI_Shape();
+
+ bool isNull();
+
};
#endif
TARGET_LINK_LIBRARIES(ModelAPI ${PROJECT_LIBRARIES})
INCLUDE_DIRECTORIES(
- ../Config ../Events
+ ../Config
+ ../Events
+ ../GeomAPI
)
SET(CMAKE_SWIG_FLAGS "")
#include "ModelAPI_Validator.h"
#include "ModelAPI_AttributeRefList.h"
#include "ModelAPI_Result.h"
+ #include "ModelAPI_ResultConstruction.h"
+
+ template<class T> boost::shared_ptr<T> castTo(boost::shared_ptr<ModelAPI_Result> theObject)
+ {
+ return boost::dynamic_pointer_cast<T>(theObject);
+ }
+
+
%}
// to avoid error on this
#define MODELAPI_EXPORT
+#define GEOMAPI_EXPORT
// standard definitions
%include "typemaps.i"
%shared_ptr(ModelAPI_AttributeRefAttr)
%shared_ptr(ModelAPI_AttributeRefList)
%shared_ptr(ModelAPI_Result)
+%shared_ptr(ModelAPI_ResultConstruction)
// all supported interfaces
%include "ModelAPI_Document.h"
%include "ModelAPI_Validator.h"
%include "ModelAPI_AttributeRefList.h"
%include "ModelAPI_Result.h"
+%include "ModelAPI_ResultConstruction.h"
%template(ObjectList) std::list<boost::shared_ptr<ModelAPI_Object> >;
+%template(ResultList) std::list<boost::shared_ptr<ModelAPI_Result> >;
+
+template<class T> boost::shared_ptr<T> castTo(boost::shared_ptr<ModelAPI_Result> theObject);
+%template(modelAPI_ResultConstruction) castTo<ModelAPI_ResultConstruction>;
boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
{
ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
- if (aBody)
- return aBody->shape();
-
+ if (aBody) return aBody->shape();
ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
- if (aConstruct)
- return aConstruct->shape();
-
+ if (aConstruct) return aConstruct->shape();
return boost::shared_ptr<GeomAPI_Shape>();
}
return aFeature;
}
-}
\ No newline at end of file
+}
aDisplayer->closeLocalContexts();
}
-void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
+void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
{
// bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
// if (isDisplay) {
// connect the operation
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
- this, SLOT(onFeatureConstructed(FeaturePtr, int)));
+ connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)),
+ this, SLOT(onFeatureConstructed(ObjectPtr, int)));
connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)),
this, SLOT(onLaunchOperation(std::string, ObjectPtr)));
connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
/// SLOT, to visualize the feature in another local context mode
/// \param theFeature the feature to be put in another local context mode
/// \param theMode the mode appeared on the feature
- void onFeatureConstructed(FeaturePtr theFeature,
- int theMode);
+ void onFeatureConstructed(ObjectPtr theFeature, int theMode);
/// Slot which reacts to the point 2d set to the feature. Creates a constraint
/// \param the feature
bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
if(aHasShift && !theHighlighted.empty()) {
QList<ObjectPtr> aSelected;
- aSelected.push_back(feature());
- aSelected.push_back(theHighlighted.front().object());
+ std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
+ for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
+ aSelected.append((*aIt).object());
+ /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) {
+ if (!aSelected.contains((*aIt).object()))
+ aSelected.append((*aIt).object());
+ }*/
+ //aSelected.push_back(feature());
+ //aSelected.push_back(theHighlighted.front().object());
emit setSelection(aSelected);
}
else if (aFeature) {
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <ModelAPI_Events.h>
// deselected in the viewer by blockSelection signal in the startOperation method.
bool isSelected = false;
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
- // TODO
- /*for (; anIt != aLast && !isSelected; anIt++) {
- isSelected = (*anIt).feature() == feature();
- }*/
+ for (; anIt != aLast && !isSelected; anIt++) {
+ isSelected = ModuleBase_Tools::feature((*anIt).object()) == feature();
+ }
if (!isSelected)
myFeatures = theHighlighted;
else
aSketchFeature->move(aDeltaX, aDeltaY);
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
- // TODO
- /*for (; anIt != aLast; anIt++) {
- FeaturePtr aFeature = (*anIt).feature();
- if (!aFeature || aFeature == feature())
+ for (; anIt != aLast; anIt++) {
+ ObjectPtr aObject = (*anIt).object();
+ if (!aObject || aObject == feature())
continue;
- aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- aSketchFeature->move(aDeltaX, aDeltaY);
- }*/
+ FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+ if (aFeature) {
+ aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if (aSketchFeature)
+ aSketchFeature->move(aDeltaX, aDeltaY);
+ }
+ }
}
sendFeatures();
std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
commit();
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
- // TODO
- /*for (; anIt != aLast; anIt++) {
- FeaturePtr aFeature = (*anIt).feature();
+ for (; anIt != aLast; anIt++) {
+ ObjectPtr aFeature = (*anIt).object();
if (aFeature) {
emit featureConstructed(aFeature, FM_Deactivation);
- }
- }*/
+ }
+ }
}
void PartSet_OperationFeatureEditMulti::startOperation()
std::list<FeaturePtr > aFeatures;
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
- // TODO
- /*for (; anIt != aLast; anIt++) {
- FeaturePtr aFeature = (*anIt).feature();
+ for (; anIt != aLast; anIt++) {
+ ObjectPtr aFeature = (*anIt).object();
if (!aFeature)
continue;
ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
- }*/
+ }
Events_Loop::loop()->flush(anEvent);
flushUpdated();
}
/// theName the operation name
/// theFeature the operation argument
void launchOperation(std::string theName, ObjectPtr theFeature);
+
/// Signal about the feature construing is finished
/// \param theFeature the result feature
/// \param theMode the mode of the feature modification
- void featureConstructed(FeaturePtr theFeature,
- int theMode);
+ void featureConstructed(ObjectPtr theFeature, int theMode);
+
/// Signal about the features should be selected
/// \param theSelected the list of selected presentations
void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
+
/// signal to enable/disable multi selection in the viewer
/// \param theEnabled the boolean state
void multiSelectionEnabled(bool theEnabled);
/// \param theFeatures a list of features to be disabled
/// \param theToStop the boolean state whether it it stopped or non stopped
void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
+
/// signal to set selection in the viewer
/// \param theFeatures a list of features to be disabled
void setSelection(const QList<ObjectPtr>& theFeatures);
from GeomDataAPI import *
from ModelAPI import *
-__updated__ = "2014-07-23"
+__updated__ = "2014-07-24"
aPluginManager = ModelAPI_PluginManager.get()
aDocument = aPluginManager.rootDocument()
-aDocument.startOperation()
#===============================================================================
# Test ModelAPI static methods
# TODO: Move this test in the ModelAPI progect
#=========================================================================
# Creation of a sketch
#=========================================================================
+aDocument.startOperation()
aSketchFeature = aDocument.addFeature("Sketch")
assert (aSketchFeature.getKind() == "Sketch")
aSketchFeatureData = aSketchFeature.data()
assert (norm.x() == 0)
assert (norm.y() == 0)
assert (norm.z() == 1)
+aDocument.finishOperation()
#=========================================================================
# Creation of a point
#=========================================================================
+aDocument.startOperation()
aSketchReflist = aSketchFeatureData.reflist("Features")
assert (not aSketchReflist.isInitialized())
assert(aSketchReflist.size() == 0)
coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
assert (coords.x() == 10.0)
assert (coords.y() == 10.0)
+aDocument.finishOperation()
#===============================================================================
# Creation of a line
#===============================================================================
+aDocument.startOperation()
aSketchLine = aDocument.addFeature("SketchLine")
aSketchReflist.append(aSketchLine)
assert (aSketchReflist.size() == 2)
assert (aLineStartPoint.y() == 50.0)
assert (aLineEndPoint.x() == 60.0)
assert (aLineEndPoint.y() == 60.0)
-aSketchLine.firstResult()
+aDocument.finishOperation()
+#===============================================================================
+# Check results
+#===============================================================================
+aResult = aSketchLine.firstResult()
+assert (aResult is not None)
+aResultConstruction = modelAPI_ResultConstruction(aResult)
+aShape = aResult.shape()
+assert (aShape is not None)
+assert (not aShape.isNull())
#==============================================================================
# Finish the test
#==============================================================================
-aDocument.finishOperation()
-
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
if (aPart) {
aHasPart = true;
- } else {
+ // If a feature is created from the aplication's python console
+ // it doesn't stored in the operation mgr and doesn't displayed
+ } else if(myOperationMgr->hasOperation()) {
ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
if (aOperation->hasObject(*aIt)) { // Display only current operation results
myDisplayer->display(*aIt, false);