+ updateColorScaleVisibility();
+ displayer()->updateViewer();
+}
+
+
+//**************************************************************
+void XGUI_Workshop::updateColorScaleVisibility()
+{
+ QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
+ myViewerProxy->setColorScaleShown(false);
+ if (anObjects.size() == 1) {
+ FieldStepPtr aStep =
+ std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(anObjects.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(QString::fromStdWString(aStep->name()));
+ myViewerProxy->setColorScaleShown(true);
+ }
+ }
+ }
+ }
+}
+
+//**************************************************************
+void XGUI_Workshop::updateGroupsText()
+{
+ ModuleBase_IViewer::TextColor aText;
+
+ int aSize = 10;
+ SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
+ if (aResMgr->booleanValue("Viewer", "group_names_display")) {
+ // the first item in the TextColor list is font name -> text color
+ QColor aTextColor = aResMgr->colorValue("Viewer", "group_names_color");
+ std::vector<int> aTextCV;
+ aTextCV.push_back(aTextColor.red());
+ aTextCV.push_back(aTextColor.green());
+ aTextCV.push_back(aTextColor.blue());
+ QString aFontName = aResMgr->stringValue("Viewer", "group_names_font");
+ aText.push_back(std::pair<std::wstring, std::vector<int> >(aFontName.toStdWString(), aTextCV));
+ aSize = aResMgr->integerValue("Viewer", "group_names_size");
+
+ DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument();
+ int aNbGroups = aDoc->size(ModelAPI_ResultGroup::group());
+ for (int aGIndex = 0; aGIndex < aNbGroups; aGIndex++)
+ {
+ ResultGroupPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(
+ aDoc->object(ModelAPI_ResultGroup::group(), aGIndex));
+ if (aGroup.get() && !aGroup->isDisabled() && aGroup->isDisplayed())
+ {
+ std::vector<int> aColor;
+ ModelAPI_Tools::getColor(aGroup, aColor);
+ if (aColor.empty())
+ { // default groups colors
+ std::string aSection, aName, aDefault;
+ aGroup->colorConfigInfo(aSection, aName, aDefault);
+ if (!aSection.empty() && !aName.empty()) {
+ aColor = Config_PropManager::color(aSection, aName);
+ }
+ }
+ if (aColor.empty())
+ {
+ aColor.push_back(150.);
+ aColor.push_back(150.);
+ aColor.push_back(150.);
+ }
+ aText.push_back(std::pair<std::wstring, std::vector<int> >(aGroup->data()->name(), aColor));
+ }
+ }
+ }
+ myViewerProxy->setText(aText, aSize);
+}
+
+
+//**************************************************************
+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->isFace() && 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();
+ 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);
+ }