if (isSendMessage) {
// send message to highlight the failed vertices
- std::shared_ptr<ModelAPI_Fillet1DFailedMessage> aMessage(
- new ModelAPI_Fillet1DFailedMessage(Events_Loop::eventByName(EVENT_1DFILLET_FAILED)));
- aMessage->setVertices(myFailedVertices);
+ std::shared_ptr<ModelAPI_ShapesFailedMessage> aMessage(
+ new ModelAPI_ShapesFailedMessage(Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED)));
+ aMessage->setShapes(myFailedVertices);
Events_Loop::loop()->send(aMessage);
}
}
-// ===== ModelAPI_Fillet1DFailedMessage =====
-ModelAPI_Fillet1DFailedMessage::ModelAPI_Fillet1DFailedMessage(const Events_ID theID,
+// ===== ModelAPI_ShapesFailedMessage =====
+ModelAPI_ShapesFailedMessage::ModelAPI_ShapesFailedMessage(const Events_ID theID,
const void* theSender)
: Events_Message(theID, theSender)
{}
-ModelAPI_Fillet1DFailedMessage::~ModelAPI_Fillet1DFailedMessage()
+ModelAPI_ShapesFailedMessage::~ModelAPI_ShapesFailedMessage()
{}
-void ModelAPI_Fillet1DFailedMessage::setVertices(const ListOfShape& theVertices)
+void ModelAPI_ShapesFailedMessage::setShapes(const ListOfShape& theShapes)
{
- myVertices = theVertices;
+ myShapes = theShapes;
}
-const ListOfShape& ModelAPI_Fillet1DFailedMessage::vertices() const
+const ListOfShape& ModelAPI_ShapesFailedMessage::shapes() const
{
- return myVertices;
+ return myShapes;
}
/// Event ID that requests updates visual attributes for presentations
static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes";
-/// Event ID that 1D-fillet failed (comes with ModelAPI_Fillet1DFailedMessage)
-static const char * EVENT_1DFILLET_FAILED = "1DFilletFailed";
+/// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage)
+static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
/// Message that feature was changed (used for Object Browser update): moved, updated and deleted
class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
};
/// Message that sends the failed vertices of 1D-fillet to highlight them in 3D viewer
-class ModelAPI_Fillet1DFailedMessage : public Events_Message
+class ModelAPI_ShapesFailedMessage : public Events_Message
{
public:
/// Creates an message
- MODELAPI_EXPORT ModelAPI_Fillet1DFailedMessage(const Events_ID theID, const void* theSender = 0);
+ MODELAPI_EXPORT ModelAPI_ShapesFailedMessage(const Events_ID theID, const void* theSender = 0);
/// Default destructor
- MODELAPI_EXPORT virtual ~ModelAPI_Fillet1DFailedMessage();
+ MODELAPI_EXPORT virtual ~ModelAPI_ShapesFailedMessage();
/// Static. Returns EventID of the message.
MODELAPI_EXPORT static Events_ID eventId()
{
- return Events_Loop::eventByName(EVENT_1DFILLET_FAILED);
+ return Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED);
}
/// Sets list of failed vertices
- MODELAPI_EXPORT void setVertices(const std::list< std::shared_ptr<GeomAPI_Shape> >& theVertices);
+ MODELAPI_EXPORT void setShapes(const std::list< std::shared_ptr<GeomAPI_Shape> >& theVertices);
/// Returns list of failed vertices
- MODELAPI_EXPORT const std::list< std::shared_ptr<GeomAPI_Shape> >& vertices() const;
+ MODELAPI_EXPORT const std::list< std::shared_ptr<GeomAPI_Shape> >& shapes() const;
private:
- std::list< std::shared_ptr<GeomAPI_Shape> > myVertices;
+ std::list< std::shared_ptr<GeomAPI_Shape> > myShapes;
};
#endif
#include <Config_PropManager.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
{
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED));
initPresentation(ModuleBase_IModule::CustomizeArguments);
initPresentation(ModuleBase_IModule::CustomizeResults);
{
myIsActive[theFlag] = false;
erasePresentation(theFlag, theUpdateViewer);
+ if (theFlag == ModuleBase_IModule::CustomizeResults)
+ clearErrorShape();
return true;
}
clearPresentation(ModuleBase_IModule::CustomizeArguments);
clearPresentation(ModuleBase_IModule::CustomizeResults);
clearPresentation(ModuleBase_IModule::CustomizeHighlightedObjects);
+ clearErrorShape();
+}
+
+void PartSet_CustomPrs::clearErrorShape()
+{
+ if (!myErrorShapes.IsNull()) {
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ if (aContext->IsDisplayed(myErrorShapes))
+ aContext->Remove(myErrorShapes, true);
+ }
}
void PartSet_CustomPrs::processEvent(const std::shared_ptr<Events_Message>& theMessage)
{
if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION))
myPresentationIsEmpty = true; /// store state to analize it after display/erase is finished
+ else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED)) {
+ std::shared_ptr<ModelAPI_ShapesFailedMessage> aErrMsg =
+ std::dynamic_pointer_cast<ModelAPI_ShapesFailedMessage>(theMessage);
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ ListOfShape aShapes = aErrMsg->shapes();
+ if (aShapes.size() > 0) {
+ GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
+ TopoDS_Shape aErrShape = aCompound->impl<TopoDS_Shape>();
+ if (myErrorShapes.IsNull()) {
+ myErrorShapes = new AIS_Shape(aErrShape);
+ myErrorShapes->SetColor(Quantity_NOC_RED);
+ Handle(Prs3d_Drawer) aDrawer = myErrorShapes->Attributes();
+ aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_RING1, Quantity_NOC_RED, 2.));
+ aDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 2.));
+ aContext->Display(myErrorShapes, true);
+ aContext->Deactivate(myErrorShapes);
+ }
+ else {
+ myErrorShapes->Set(aErrShape);
+ aContext->Redisplay(myErrorShapes, true);
+ }
+ }
+ else {
+ if (!myErrorShapes.IsNull()) {
+ aContext->Remove(myErrorShapes, true);
+ }
+ }
+ }
}
void PartSet_CustomPrs::initPresentation(
/// \return theShapeColor a color
Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
+ /// Removes error shapes presentation
+ void clearErrorShape();
+
private:
bool myPresentationIsEmpty; /// Boolean state about empty presentation
FeaturePtr myFeature; /// Reference to a feature object
QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, bool> myIsActive;
int myDisabledMode;
+
+ Handle(AIS_Shape) myErrorShapes;
};
#endif
thePresentation->Clear();
bool aReadyToDisplay = !myShapeToPrsMap.IsEmpty();
- XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
Handle(Prs3d_Drawer) aDrawer = Attributes();
// create presentations on the base of the shapes
BRep_Builder aBuilder;
GeomShapePtr theGeomShape,
QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
{
- XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
- // VSV: Do not use isVisible checking because it can be used when state "Show Only" is ON
- //if (XGUI_Displayer::isVisible(aDisplayer, theObject)) {
- if (theGeomShape.get()) {
- if (theObjectShapes.contains(theObject))
- theObjectShapes[theObject].append(theGeomShape);
- else {
- QList<GeomShapePtr> aShapes;
- aShapes.append(theGeomShape);
- theObjectShapes[theObject] = aShapes;
- }
- } else {
- #ifdef DEBUG_EMPTY_SHAPE
- qDebug(QString("Empty shape in result, result: %1")
- .arg(ModuleBase_Tools::objectInfo(theObject)).toStdString().c_str());
- #endif
+ if (theGeomShape.get()) {
+ if (theObjectShapes.contains(theObject))
+ theObjectShapes[theObject].append(theGeomShape);
+ else {
+ QList<GeomShapePtr> aShapes;
+ aShapes.append(theGeomShape);
+ theObjectShapes[theObject] = aShapes;
}
- //}
+ } else {
+#ifdef DEBUG_EMPTY_SHAPE
+ qDebug(QString("Empty shape in result, result: %1")
+ .arg(ModuleBase_Tools::objectInfo(theObject)).toStdString().c_str());
+#endif
+ }
}
void PartSet_OperationPrs::getFeatureShapes(const FeaturePtr& theFeature,
if (!theFeature.get())
return;
- XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
-
std::list<ResultPtr> aResults;
ModelAPI_Tools::allResults(theFeature, aResults);
std::list<ResultPtr>::const_iterator aRIt = aResults.begin(),