+ updateColorScaleVisibility();
+ displayer()->updateViewer();
+}
+
+
+//**************************************************************
+void XGUI_Workshop::updateColorScaleVisibility()
+{
+ QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
+ viewer()->setColorScaleShown(false);
+ if (aObjects.size() == 1) {
+ FieldStepPtr aStep =
+ std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObjects.first());
+ if (aStep.get() && myDisplayer->isVisible(aStep)) {
+ AISObjectPtr aAisPtr = myDisplayer->getAISObject(aStep);
+ Handle(AIS_InteractiveObject) aIO = aAisPtr->impl<Handle(AIS_InteractiveObject)>();
+ ModuleBase_IStepPrs* aPrs = dynamic_cast<ModuleBase_IStepPrs*>(aIO.get());
+ if (aPrs) {
+ ModelAPI_AttributeTables::ValueType aType = aPrs->dataType();
+ if ((aType == ModelAPI_AttributeTables::DOUBLE) ||
+ (aType == ModelAPI_AttributeTables::INTEGER) ||
+ (aType == ModelAPI_AttributeTables::BOOLEAN)) {
+ myViewerProxy->setupColorScale();
+ if (aType == ModelAPI_AttributeTables::BOOLEAN) {
+ myViewerProxy->setColorScaleIntervals(2);
+ myViewerProxy->setColorScaleRange(0., 1.);
+ }
+ else {
+ double aMin, aMax;
+ aPrs->dataRange(aMin, aMax);
+ myViewerProxy->setColorScaleRange(aMin, aMax);
+ }
+ myViewerProxy->setColorScaleTitle(aStep->name().c_str());
+ myViewerProxy->setColorScaleShown(true);
+ }
+ }
+ }
+ }
+}
+
+
+//**************************************************************
+void XGUI_Workshop::setNormalView(bool toInvert)
+{
+ QList<ModuleBase_ViewerPrsPtr> aPrsList =
+ mySelector->selection()->getSelected(ModuleBase_ISelection::Viewer);
+ GeomShapePtr aPlanarFace;
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
+ GeomShapePtr aShape = aPrs->shape();
+ if (aShape.get() && aShape->isPlanar()) {
+ aPlanarFace = aShape;
+ break;
+ }
+ }
+ if (aPlanarFace.get()) {
+ GeomFacePtr aFace(new GeomAPI_Face(aPlanarFace));
+ GeomPlanePtr aPlane = aFace->getPlane();
+ GeomDirPtr aNormal = aPlane->direction();
+ if (toInvert)
+ aNormal->reverse();
+ GeomPointPtr aPos = aPlane->location();
+
+ double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+ aFace->computeSize(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+
+ Handle(V3d_View) aView = myViewerProxy->activeView();
+ double aScale = aView->Scale();
+ aView->SetAt(aPos->x(), aPos->y(), aPos->z());
+ aView->SetProj(aNormal->x(), aNormal->y(), aNormal->z());
+ Bnd_Box aBox;
+ aBox.Update(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+ aView->FitAll(aBox);
+ }