the color correction for sketch plane.
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
if (isDisplay) {
boost::shared_ptr<GeomAPI_Shape> aPreview = aPreviewOp->preview(theFeature);
- aDisplayer->Redisplay(theFeature,
- aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
+ bool isAISCreated = aDisplayer->Redisplay(theFeature, aPreview ?
+ aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
+ if (isAISCreated) {
+ PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+ if (aSketchOp) {
+ Handle(AIS_InteractiveObject) anAIS = aDisplayer->GetAISObject(theFeature);
+ aSketchOp->correctPresentation(anAIS);
+ }
+ }
}
else
aDisplayer->Erase(theFeature, false);
#include <AIS_Shape.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <AIS_InteractiveObject.hxx>
#include <V3d_View.hxx>
#ifdef _DEBUG
using namespace std;
+const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color
+const int SKETCH_WIDTH = 4; /// the plane edge width
+
PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId,
QObject* theParent)
: PartSet_OperationSketchBase(theId, theParent)
return hasSketchPlane();
}
+void PartSet_OperationSketch::correctPresentation(Handle(AIS_InteractiveObject) thePresentation)
+{
+ Handle(AIS_Shape) anAIS = Handle(AIS_Shape)::DownCast(thePresentation);
+ if (anAIS.IsNull())
+ return;
+
+ anAIS->SetColor(Quantity_Color(SKETCH_PLANE_COLOR));
+ anAIS->SetWidth(SKETCH_WIDTH);
+ anAIS->Redisplay();
+}
+
void PartSet_OperationSketch::startOperation()
{
if (!feature()) {
#include <PartSet_OperationSketchBase.h>
#include <QObject>
+class Handle_AIS_InteractiveObject;
+
/*!
\class PartSet_OperationSketch
* \brief The operation for the sketch feature creation
/// \return enabled state
virtual bool isNestedOperationsEnabled() const;
+ /// Corrects the presentation settings by the operation
+ /// thePresentation an operation presentation
+ void correctPresentation(Handle_AIS_InteractiveObject thePresentation);
+
signals:
/// signal about the sketch plane is selected
/// \param theX the value in the X direction of the plane
UpdateViewer();
}
-void XGUI_Displayer::Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
+bool XGUI_Displayer::Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
const TopoDS_Shape& theShape, const bool isUpdateViewer)
{
+ bool isCreated = false;
Handle(AIS_InteractiveContext) aContext = AISContext();
// Open local context if there is no one
if (!aContext->HasOpenedContext()) {
anAIS = new AIS_Shape(theShape);
myFeature2AISObjectMap[theFeature] = anAIS;
aContext->Display(anAIS, false);
+ isCreated = true;
}
if (isUpdateViewer)
UpdateViewer();
+
+ return isCreated;
}
void XGUI_Displayer::ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
/// \param theShape a shape
/// \param theMode a local selection mode
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
- void Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ /// \returns true if the presentation is created
+ bool Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
const TopoDS_Shape& theShape, const bool isUpdateViewer = true);
/// Display the shape and activate selection of sub-shapes
void UpdateViewer();
/// Searches the interactive object by feature
- /// \param feature the feature or NULL if it not visualized
+ /// \param theFeature the feature or NULL if it not visualized
/// \return theIO an interactive object
- Handle(AIS_InteractiveObject) GetAISObject(boost::shared_ptr<ModelAPI_Feature>) const;
+ Handle(AIS_InteractiveObject) GetAISObject(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
protected:
/// Searches the feature by interactive object