#include <ModelAPI_AttributeStringArray.h>
#include <AIS_ColorScale.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_PointAspect.hxx>
IMPLEMENT_STANDARD_RTTIEXT(PartSet_FieldStepPrs, ViewerData_AISShape);
+#define POINT_SIZE 8
+
void emptyDeleter(ModelAPI_ResultField* theF)
{
// Make shared_ptr which will not delete original pointer after exit
std::shared_ptr<ModelAPI_ResultField> aFieldPtr(aField, emptyDeleter);
myFeature = ModelAPI_Feature::feature(aFieldPtr);
+
+ Handle(Prs3d_Drawer) aDrawer = Attributes();
+ if (aDrawer->HasOwnPointAspect()) {
+ aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_POINT);
+ aDrawer->PointAspect()->SetScale(POINT_SIZE);
+ }
+ else
+ aDrawer->SetPointAspect(
+ new Prs3d_PointAspect(Aspect_TOM_POINT, Quantity_NOC_YELLOW, POINT_SIZE));
}
const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode)
{
ModelAPI_AttributeTables::ValueType aType = dataType();
+ DataPtr aData = myFeature->data();
if ((aType == ModelAPI_AttributeTables::DOUBLE) ||
(aType == ModelAPI_AttributeTables::INTEGER)) {
double aMin, aMax;
QList<double> aShapeData = range(aMin, aMax);
int aNbIntertvals = 20;
- DataPtr aData = myFeature->data();
AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID());
for (int i = 0; i < aSelList->size(); i++) {
AttributeSelectionPtr aSelection = aSelList->value(i);
SetCustomColor(aShape, aColor);
}
}
+ else if (aType == ModelAPI_AttributeTables::BOOLEAN) {
+ QList<double> aShapeData = booleanValues();
+
+ AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID());
+ for (int i = 0; i < aSelList->size(); i++) {
+ AttributeSelectionPtr aSelection = aSelList->value(i);
+ GeomShapePtr aShapePtr = aSelection->value();
+ TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
+ double aValue = aShapeData.at(i);
+ Quantity_Color aColor;
+ if (AIS_ColorScale::FindColor(aValue, 0., 1. + Precision::Confusion(), 2, aColor))
+ SetCustomColor(aShape, aColor);
+ }
+ }
ViewerData_AISShape::Compute(thePrsMgr, thePrs, theMode);
}
+
+QList<double> PartSet_FieldStepPrs::booleanValues() const
+{
+ DataPtr aData = myFeature->data();
+ int aStep = myStep->id();
+ AttributeTablesPtr aTablesAttr = aData->tables(CollectionPlugin_Field::VALUES_ID());
+ int aRows = aTablesAttr->rows();
+ int aCols = aTablesAttr->columns();
+ QList<int> aFieldStepData;
+ for (int j = 0; j < aCols; j++) {
+ for (int k = 1; k < aRows; k++) { // Do not use default values
+ ModelAPI_AttributeTables::Value aVal = aTablesAttr->value(k, j, aStep);
+ aFieldStepData << (aVal.myBool ? 1 : 0);
+ }
+ }
+ QList<double> aShapeData;
+ double aRangeMin = aFieldStepData.first(), aRangeMax = aFieldStepData.last();
+ for (int aRow = 0; aRow < aRows - 1; aRow++) {
+ double aNorm = 0;
+ int aBaseIndex = aRow * aCols;
+ for (int aCol = 0; aCol < aCols; aCol++) {
+ aNorm += aFieldStepData.at(aCol + aBaseIndex);
+ }
+ aNorm /= aCols;
+ aShapeData << aNorm;
+ }
+ return aShapeData;
+}