#include "ModuleBase_FilterValidated.h"
#include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_IViewer.h"
#include <ModuleBase_IModule.h>
#include <ModuleBase_IPropertyPanel.h>
IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter);
IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter);
-//#define DEBUG_CURRENT_SELECTION
-
Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
{
bool aValid = true;
ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
if (anOperation) {
-#ifdef DEBUG_CURRENT_SELECTION
- QString aPrefix = "ModuleBase_FilterValidated::IsOk: ";
- QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(ModuleBase_ISelection::Viewer);
- QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
- QStringList anInfo;
- ModuleBase_ViewerPrsPtr aPrs;
- for (; anIt != aLast; anIt++) {
- aPrs = (*anIt);
- if (!aPrs.get())
- continue;
+ ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+ Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
- //GeomShapePtr aShape = aPrs->shape();
- ObjectPtr anObject = aPrs->object();
- QString anObjectInfo = anObject.get() ? ModuleBase_Tools::objectInfo(anObject) : "";
- anInfo.append(anObjectInfo);
- }
- QString anInfoStr = anInfo.join(";\t");
- qDebug(QString("%1: %2, %3").arg(aPrefix).arg(anInfo.size()).arg(anInfoStr).toStdString().c_str());
-#endif
+ ModuleBase_Tools::selectionInfo(aContext, "ModuleBase_FilterValidated::IsOk");
ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
ModuleBase_ModelWidget* aCurrentWidget = aPanel->preselectionWidget();
#include <SketchPlugin_ConstraintRadius.h>
#include <SketcherPrs_SymbolPrs.h>
+#include <SketcherPrs_Coincident.h>
#include <SketcherPrs_Tools.h>
#include <Events_Loop.h>
aPrs->SetConflictingConstraint(isConflicting, aColor);
aCustomized = true;
}
+ } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
+ Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
+ if (!aPrs.IsNull()) {
+ std::vector<int> aColor;
+ myOverconstraintListener->getConflictingColor(aColor);
+ aPrs->SetConflictingConstraint(isConflicting, aColor);
+ aCustomized = true;
+ }
}
}
}
SketcherPrs_Coincident::SketcherPrs_Coincident(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_InteractiveObject(), myConstraint(theConstraint), mySketcherPlane(thePlane),
- myPoint(gp_Pnt(0.0, 0.0, 0.0))
+ myPoint(gp_Pnt(0.0, 0.0, 0.0)), myIsConflicting(false)
{
}
}
// Create the presentation as a combination of standard point markers
+ bool aValid = !myIsConflicting;
// The external yellow contour
aPtA->SetType(Aspect_TOM_RING3);
aPtA->SetScale(2.);
- aPtA->SetColor(Quantity_NOC_YELLOW);
+ aPtA->SetColor(aValid ? Quantity_NOC_YELLOW : Quantity_NOC_BLACK);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
aGroup->SetPrimitivesAspect(aPtA);
hasOwnColor=Standard_True;
myOwnColor=aCol;
}
+
+void SketcherPrs_Coincident::SetConflictingConstraint(const bool& theConflicting,
+ const std::vector<int>& theColor)
+{
+ myIsConflicting = theConflicting;
+
+ /*if (theConflicting)
+ {
+ if (!myAspect.IsNull())
+ myAspect->SetColor (Quantity_Color (theColor[0] / 255., theColor[1] / 255., theColor[2] / 255.,
+ Quantity_TOC_RGB));
+ myIsConflicting = true;
+ }
+ else
+ {
+ if (!myAspect.IsNull())
+ myAspect->SetColor (Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB));
+ myIsConflicting = false;
+ }*/
+}
/// \param aColor a color name
Standard_EXPORT virtual void SetColor(const Quantity_NameOfColor aColor);
+ /// Set state of the presentation, in case of conflicting state, the icon of the presentation is
+ /// visualized in error color. The state is stored in an internal field, so should be changed when
+ /// constraint become not conflicting
+ /// \param theConflicting a state
+ /// \param theColor a color for conflicting object
+ Standard_EXPORT void SetConflictingConstraint(const bool& theConflicting, const std::vector<int>& theColor);
+
/// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
ModelAPI_Feature* myConstraint;
std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
gp_Pnt myPoint;
+ bool myIsConflicting; /// state if the presentation is visualized in error state
};