// trim: need to redisplay or set color in the python script
if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color" ||
theAttr->id() == "Transparency" || theAttr->id() == "Deflection" ||
- theAttr->id() == "Iso_lines")) {
+ theAttr->id() == "Iso_lines" || theAttr->id() == "Show_Iso_lines")) {
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
}
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeBoolean.h>
#include <Events_Loop.h>
aData->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false);
aData->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false);
aData->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false);
+ aData->addAttribute(SHOW_ISO_LINES_ID(), ModelAPI_AttributeBoolean::typeId())->setIsArgument(false);
}
bool ModelAPI_Result::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
return MY_ISO_LINES_ID;
}
+ /// Reference to the transparency of the result.
+ /// The double value is used. The value is in [0, 1] range
+ inline static const std::string& SHOW_ISO_LINES_ID()
+ {
+ static const std::string MY_SHOW_ISO_LINES_ID("Show_Iso_lines");
+ return MY_SHOW_ISO_LINES_ID;
+ }
+
/// Returns true if the result is concealed from the data tree (referenced by other objects)
MODELAPI_EXPORT virtual bool isConcealed();
#include <ModelAPI_Validator.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeBoolean.h>
#include <list>
#include <map>
#include <iostream>
}
//******************************************************
-void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult, std::vector<int>& theNbLines)
+void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult,
+ bool& isVisible, std::vector<int>& theNbLines)
{
theNbLines.clear();
+ isVisible = false;
+ if (!theResult.get())
+ return;
if (theResult->groupName() == ModelAPI_ResultConstruction::group()) {
theNbLines.push_back(0);
theNbLines.push_back(0);
}
else {
// get color from the attribute of the result
- if (theResult.get() != NULL &&
- theResult->data()->attribute(ModelAPI_Result::ISO_LINES_ID()).get() != NULL) {
- AttributeIntArrayPtr aAttr = theResult->data()->intArray(ModelAPI_Result::ISO_LINES_ID());
- if (aAttr.get() && aAttr->size()) {
+ AttributeIntArrayPtr aAttr = theResult->data()->intArray(ModelAPI_Result::ISO_LINES_ID());
+ if (aAttr.get()) {
+ if (aAttr->size()) {
theNbLines.push_back(aAttr->value(0));
theNbLines.push_back(aAttr->value(1));
}
}
+ AttributeBooleanPtr aBoolAttr =
+ theResult->data()->boolean(ModelAPI_Result::SHOW_ISO_LINES_ID());
+ if (aBoolAttr.get()) {
+ isVisible = aBoolAttr->value();
+ }
}
}
}
}
+//******************************************************
+void showIsoLines(std::shared_ptr<ModelAPI_Result> theResult, bool theShow)
+{
+ if (!theResult.get())
+ return;
+
+ AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::SHOW_ISO_LINES_ID());
+ if (aAttr.get() != NULL) {
+ aAttr->setValue(theShow);
+ }
+}
+
+//******************************************************
+bool isShownIsoLines(std::shared_ptr<ModelAPI_Result> theResult)
+{
+ if (!theResult.get())
+ return false;
+
+ AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::SHOW_ISO_LINES_ID());
+ if (aAttr.get() != NULL) {
+ return aAttr->value();
+ }
+ return false;
+}
+
//**************************************************************
void setTransparency(ResultPtr theResult, double theTransparency)
{
* \param[out] theNbLines values of iso-lines
*/
MODELAPI_EXPORT void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult,
- std::vector<int>& theNbLines);
+ bool& isVisible, std::vector<int>& theNbLines);
/*! Set number of iso-lines of the result
* \param[in] theResult a result object
MODELAPI_EXPORT void setIsoLines(std::shared_ptr<ModelAPI_Result> theResult,
const std::vector<int>& theIso);
+/*! Set visibility of Iso lines
+* \param[in] theResult a result object
+* \param[in] theShow is a visibility flag
+*/
+MODELAPI_EXPORT void showIsoLines(std::shared_ptr<ModelAPI_Result> theResult, bool theShow);
+
+MODELAPI_EXPORT bool isShownIsoLines(std::shared_ptr<ModelAPI_Result> theResult);
+
/*! Returns current transparency in the given result
* \param theResult a result object
* \return a transparency value or -1 if it was not defined
Color(aColor);
std::vector<int> aIsoValues;
- ModelAPI_Tools::getIsoLines(myResult, aIsoValues);
- if (aIsoValues.size() == 0) {
- aIsoValues.push_back(1);
- aIsoValues.push_back(1);
+ bool isIsoVisible;
+ ModelAPI_Tools::getIsoLines(myResult, isIsoVisible, aIsoValues);
+ if (isIsoVisible) {
+ if (aIsoValues.size() == 0) {
+ aIsoValues.push_back(1);
+ aIsoValues.push_back(1);
+ }
+ }
+ else {
+ aIsoValues.push_back(0);
+ aIsoValues.push_back(0);
}
myUIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[0]);
myVIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[1]);
thePM->AddToImmediateList(aHilightPrs);
}
}
+
+
+//********************************************************************
+void ModuleBase_ResultPrs::updateIsoLines()
+{
+ std::vector<int> aIsoValues;
+ bool isIsoVisible;
+ ModelAPI_Tools::getIsoLines(myResult, isIsoVisible, aIsoValues);
+ if (isIsoVisible) {
+ if (aIsoValues.size() == 0) {
+ aIsoValues.push_back(1);
+ aIsoValues.push_back(1);
+ }
+ }
+ else {
+ if (aIsoValues.size() == 0) {
+ aIsoValues.push_back(0);
+ aIsoValues.push_back(0);
+ }
+ else {
+ aIsoValues[0] = 0;
+ aIsoValues[1] = 0;
+ }
+ }
+ myUIsoAspect->SetNumber(aIsoValues[0]);
+ myVIsoAspect->SetNumber(aIsoValues[1]);
+}
/// Returns True if the original shape is substituted by a corresponded shell
Standard_EXPORT bool isSubstituted() const { return myIsSubstituted; }
- /// Set number of Iso-lines
- /// \param theU a number of U Iso-lines
- /// \param theV a number of V Iso-lines
- Standard_EXPORT void setIsolinesNumber(int theU, int theV) {
- myUIsoAspect->SetNumber(theU); myVIsoAspect->SetNumber(theV);
- }
-
- /// Returns number of U Iso-lines
- Standard_EXPORT int UIsoLines() const {
- return myUIsoAspect->Number();
- }
-
- /// Returns number of V Iso-lines
- Standard_EXPORT int VIsoLines() const {
- return myVIsoAspect->Number();
- }
+ Standard_EXPORT void updateIsoLines();
DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape)
aDesktop);
addAction("WIREFRAME_CMD", aAction);
- aAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Iso-lines..."),
+ aAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Define Isos..."),
aDesktop);
addAction("ISOLINES_CMD", aAction);
+ aAction = ModuleBase_Tools::createAction(QIcon(), tr("Show Isos..."), aDesktop);
+ aAction->setCheckable(true);
+ addAction("SHOW_ISOLINES_CMD", aAction);
+
mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
mySeparator1->setSeparator(true);
//Process Feature
if (aSelected == 1) { // single selection
ObjectPtr aObject = aObjects.first();
+ ResultPtr aResult;
+ if (hasResult)
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
if (aObject) {
if (hasResult && myWorkshop->canBeShaded(aObject)) {
XGUI_Displayer::DisplayMode aMode = aDisplayer->displayMode(aObject);
if (aMode != XGUI_Displayer::NoMode) {
action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading);
action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe);
- action("ISOLINES_CMD")->setEnabled(true);
} else {
action("WIREFRAME_CMD")->setEnabled(true);
action("SHADING_CMD")->setEnabled(true);
- action("ISOLINES_CMD")->setEnabled(true);
}
+ action("SHOW_ISOLINES_CMD")->setEnabled(true);
+ action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult));
+ action("ISOLINES_CMD")->setEnabled(true);
}
if (!hasFeature) {
- bool aHasSubResults = ModelAPI_Tools::hasSubResults(
- std::dynamic_pointer_cast<ModelAPI_Result>(aObject));
+ bool aHasSubResults = ModelAPI_Tools::hasSubResults(aResult);
if (aHasSubResults) {
action("HIDE_CMD")->setEnabled(true);
action("SHOW_CMD")->setEnabled(true);
action("SHOW_ONLY_CMD")->setEnabled(true);
action("SHADING_CMD")->setEnabled(true);
action("WIREFRAME_CMD")->setEnabled(true);
+ action("SHOW_ISOLINES_CMD")->setEnabled(false);
action("ISOLINES_CMD")->setEnabled(true);
}
if (hasFeature && myWorkshop->canMoveFeature()) {
if (aMode != XGUI_Displayer::NoMode) {
action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading);
action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe);
- action("ISOLINES_CMD")->setEnabled(true);
} else {
action("WIREFRAME_CMD")->setEnabled(true);
action("SHADING_CMD")->setEnabled(true);
- action("ISOLINES_CMD")->setEnabled(true);
+ }
+ action("ISOLINES_CMD")->setEnabled(true);
+
+ if (aPrsList.size() == 1) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+ if (aResult.get()) {
+ action("SHOW_ISOLINES_CMD")->setEnabled(true);
+ action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult));
+ }
}
}
action("SHOW_ONLY_CMD")->setEnabled(true);
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
aList.append(action("TRANSPARENCY_CMD"));
+ aList.append(action("SHOW_ISOLINES_CMD"));
aList.append(action("ISOLINES_CMD"));
aList.append(action("SHOW_FEATURE_CMD"));
aList.append(mySeparator3);
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
aList.append(action("TRANSPARENCY_CMD"));
+ aList.append(action("SHOW_ISOLINES_CMD"));
aList.append(action("ISOLINES_CMD"));
aList.append(mySeparator3);
aList.append(action("SET_VIEW_NORMAL_CMD"));
aActions.append(action("COLOR_CMD"));
aActions.append(action("DEFLECTION_CMD"));
aActions.append(action("TRANSPARENCY_CMD"));
+ aActions.append(action("SHOW_ISOLINES_CMD"));
aActions.append(action("ISOLINES_CMD"));
aActions.append(action("CLEAN_HISTORY_CMD"));
aActions.append(action("DELETE_CMD"));
aAISObj->setTransparency(aTransparency);
// Set Iso-Lines
- std::vector<int> aIsoValues;
- ModelAPI_Tools::getIsoLines(aResult, aIsoValues);
- if (aIsoValues.size() > 0) {
- Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO);
- if (!aResPrs.IsNull())
- aResPrs->setIsolinesNumber(aIsoValues[0], aIsoValues[1]);
- }
+ Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO);
+ if (!aResPrs.IsNull())
+ aResPrs->updateIsoLines();
}
myWorkshop->module()->storeSelection();
changeColor(aObjects);
else if (theId == "ISOLINES_CMD")
changeIsoLines(aObjects);
+ else if (theId == "SHOW_ISOLINES_CMD") {
+ foreach(ObjectPtr aObj, aObjects) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aResult.get())
+ ModelAPI_Tools::showIsoLines(aResult, !ModelAPI_Tools::isShownIsoLines(aResult));
+ }
+ mySelector->clearSelection();
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ }
else if (theId == "DEFLECTION_CMD")
changeDeflection(aObjects);
else if (theId == "TRANSPARENCY_CMD")
return;
std::vector<int> aValues;
+ bool isVisible;
if (theObjects.size() == 1) {
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObjects.first());
if (aRes.get())
- ModelAPI_Tools::getIsoLines(aRes, aValues);
+ ModelAPI_Tools::getIsoLines(aRes, isVisible, aValues);
else
return;
}
ModelAPI_Tools::setIsoLines(aRes, aValues);
}
}
+ mySelector->clearSelection();
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
aMgr->finishOperation();
updateCommandStatus();
</message>
<message>
<source>Iso-lines...</source>
- <translation>Iso-lines...</translation>
+ <translation type="vanished">Iso-lines...</translation>
+ </message>
+ <message>
+ <source>Define Isos...</source>
+ <translation>Définir l'Isos...</translation>
+ </message>
+ <message>
+ <source>Show Isos...</source>
+ <translation>Show Isos...</translation>
</message>
</context>
<context>