} else {
// 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() == "Transparency" || theAttr->id() == "Deflection" ||
+ theAttr->id() == "Iso_lines")) {
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
}
data()->addAttribute(BASE_REF_ID(), ModelAPI_AttributeReference::typeId());
data()->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId());
if (aDocRef->isInitialized() && // initialized immediately means already exist and will be loaded
!Model_Application::getApplication()->hasDocument(aDocRef->docId()))
aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false);
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);
}
bool ModelAPI_Result::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
return MY_TRANSPARENCY_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& ISO_LINES_ID()
+ {
+ static const std::string MY_ISO_LINES_ID("Iso_lines");
+ return MY_ISO_LINES_ID;
+ }
+
/// Returns true if the result is concealed from the data tree (referenced by other objects)
MODELAPI_EXPORT virtual bool isConcealed();
}
}
+
+//**************************************************************
+void setDeflection(ResultPtr theResult, const double theDeflection)
+{
+ if (!theResult.get())
+ return;
+
+ AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
+ if (aDeflectionAttr.get() != NULL) {
+ aDeflectionAttr->setValue(theDeflection);
+ }
+}
+
// used by GUI only
// LCOV_EXCL_START
double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult)
return aDeflection;
}
+//******************************************************
+void setColor(ResultPtr theResult, const std::vector<int>& theColor)
+{
+ if (!theResult.get())
+ return;
+
+ AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ if (aColorAttr.get() != NULL) {
+ if (!aColorAttr->size()) {
+ aColorAttr->setSize(3);
+ }
+ aColorAttr->setValue(0, theColor[0]);
+ aColorAttr->setValue(1, theColor[1]);
+ aColorAttr->setValue(2, theColor[2]);
+ }
+}
void getColor(const std::shared_ptr<ModelAPI_Result>& theResult, std::vector<int>& theColor)
{
}
}
+//******************************************************
+void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult, std::vector<int>& theNbLines)
+{
+ theNbLines.clear();
+ // 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()) {
+ theNbLines.push_back(aAttr->value(0));
+ theNbLines.push_back(aAttr->value(1));
+ }
+ }
+}
+
+//******************************************************
+void setIsoLines(ResultPtr theResult, const std::vector<int>& theIso)
+{
+ if (!theResult.get())
+ return;
+
+ AttributeIntArrayPtr aAttr = theResult->data()->intArray(ModelAPI_Result::ISO_LINES_ID());
+ if (aAttr.get() != NULL) {
+ if (!aAttr->size()) {
+ aAttr->setSize(2);
+ }
+ aAttr->setValue(0, theIso[0]);
+ aAttr->setValue(1, theIso[1]);
+ }
+}
+
+//**************************************************************
+void setTransparency(ResultPtr theResult, double theTransparency)
+{
+ if (!theResult.get())
+ return;
+
+ AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
+ if (anAttribute.get() != NULL) {
+ anAttribute->setValue(theTransparency);
+ }
+}
+
double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult)
{
double aTransparency = -1;
aDestColor->setValue(a, aSourceColor->value(a));
}
}
+ // Iso-lines
+ AttributeIntArrayPtr aSource = theSource->data()->intArray(ModelAPI_Result::ISO_LINES_ID());
+ if (aSource.get() && aSource->isInitialized() && aSource->size()) {
+ AttributeIntArrayPtr aDest = theDest->data()->intArray(ModelAPI_Result::ISO_LINES_ID());
+ if (aDest.get()) {
+ aDest->setSize(aSource->size());
+ for(int a = 0; a < aSource->size(); a++)
+ aDest->setValue(a, aSource->value(a));
+ }
+ }
// deflection
AttributeDoublePtr aSourceDefl = theSource->data()->real(ModelAPI_Result::DEFLECTION_ID());
if (aSourceDefl.get() && aSourceDefl->isInitialized()) {
*/
MODELAPI_EXPORT double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult);
+/*! Sets the deflection value
+* \param theResult a result object
+* \param a deflection value
+*/
+MODELAPI_EXPORT void setDeflection(std::shared_ptr<ModelAPI_Result> theResult,
+ const double theDeflection);
+
/*! Returns current color of the current result
* \param[in] theResult a result object
* \param[out] theColor a color values if it is defined
MODELAPI_EXPORT void getColor(const std::shared_ptr<ModelAPI_Result>& theResult,
std::vector<int>& theColor);
+/*! Set color of the result
+* \param[in] theResult a result object
+* \param[in] theColor a color values
+*/
+MODELAPI_EXPORT void setColor(std::shared_ptr<ModelAPI_Result> theResult,
+ const std::vector<int>& theColor);
+
+/*! Returns number of iso-lines of the current result
+* \param[in] theResult a result object
+* \param[out] theNbLines values of iso-lines
+*/
+MODELAPI_EXPORT void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult,
+ std::vector<int>& theNbLines);
+
+/*! Set number of iso-lines of the result
+* \param[in] theResult a result object
+* \param[in] theIso nb iso-lines
+*/
+MODELAPI_EXPORT void setIsoLines(std::shared_ptr<ModelAPI_Result> theResult,
+ const std::vector<int>& theIso);
+
/*! Returns current transparency in the given result
* \param theResult a result object
* \return a transparency value or -1 if it was not defined
*/
MODELAPI_EXPORT double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult);
+/*! Set transparency for the given result
+* \param theResult a result object
+* \param a transparency value
+*/
+MODELAPI_EXPORT void setTransparency(std::shared_ptr<ModelAPI_Result> theResult,
+ double theTransparency);
+
+
/*! Copies all visualization attributes from one result to another.
* \param theSource a result that contains the copied attributes
* \param theDest a destination result that takes the visualization attributes
aDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1));
aDrawer->SetFaceBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1));
- aDrawer->VIsoAspect()->SetNumber(0);
- aDrawer->UIsoAspect()->SetNumber(0);
+ Quantity_Color aColor;
+ Color(aColor);
+
+ std::vector<int> aIsoValues;
+ ModelAPI_Tools::getIsoLines(myResult, aIsoValues);
+ if (aIsoValues.size() == 0) {
+ aIsoValues.push_back(1);
+ aIsoValues.push_back(1);
+ }
+ myUIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[0]);
+ myVIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[1]);
+ aDrawer->SetUIsoAspect(myUIsoAspect);
+ aDrawer->SetVIsoAspect(myVIsoAspect);
if (aDrawer->HasOwnPointAspect())
aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS);
if (aDrawer.IsNull()) {
if (!ModuleBase_IViewer::DefaultHighlightDrawer.IsNull()) {
aDrawer = new Prs3d_Drawer(*ModuleBase_IViewer::DefaultHighlightDrawer);
- aDrawer->VIsoAspect()->SetNumber(0);
- aDrawer->UIsoAspect()->SetNumber(0);
+ Handle(Prs3d_IsoAspect) aUIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, 0);
+ Handle(Prs3d_IsoAspect) aVIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, 0);
+ aDrawer->SetUIsoAspect(aUIsoAspect);
+ aDrawer->SetVIsoAspect(aVIsoAspect);
SetDynamicHilightAttributes(aDrawer);
}
} else {
ViewerData_AISShape::SetColor(theColor);
myHiddenSubShapesDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
setEdgesDefaultColor();
+ myUIsoAspect->SetColor(theColor);
+ myVIsoAspect->SetColor(theColor);
}
void ModuleBase_ResultPrs::setEdgesDefaultColor()
#include <ViewerData_AISShape.hxx>
#include <Standard_DefineHandle.hxx>
#include <TopoDS_Compound.hxx>
+#include <Prs3d_IsoAspect.hxx>
#include <QMap>
/// \return false if parameter is out of [0, 1]
Standard_EXPORT bool setHiddenSubShapeTransparency(double theTransparency);
+ /// Returns the original shape of the presentation
Standard_EXPORT TopoDS_Shape originalShape() const { return myOriginalShape; }
+ /// 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();
+ }
DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape)
/// selection priority that will be added to the standard
/// selection priority of the selection entity
int myAdditionalSelectionPriority;
+
+ Handle(Prs3d_IsoAspect) myUIsoAspect;
+ Handle(Prs3d_IsoAspect) myVIsoAspect;
};
aDesktop);
addAction("WIREFRAME_CMD", aAction);
+ aAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Iso-lines..."),
+ aDesktop);
+ addAction("ISOLINES_CMD", aAction);
+
mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
mySeparator1->setSeparator(true);
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);
}
}
if (!hasFeature) {
action("SHOW_ONLY_CMD")->setEnabled(true);
action("SHADING_CMD")->setEnabled(true);
action("WIREFRAME_CMD")->setEnabled(true);
+ action("ISOLINES_CMD")->setEnabled(true);
}
if (hasFeature && myWorkshop->canMoveFeature()) {
action("MOVE_CMD")->setEnabled(true);
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_ONLY_CMD")->setEnabled(true);
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
aList.append(action("TRANSPARENCY_CMD"));
+ aList.append(action("ISOLINES_CMD"));
aList.append(action("SHOW_FEATURE_CMD"));
aList.append(mySeparator3);
aList.append(action("DELETE_CMD"));
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
aList.append(action("TRANSPARENCY_CMD"));
+ aList.append(action("ISOLINES_CMD"));
aList.append(mySeparator3);
aList.append(action("SET_VIEW_NORMAL_CMD"));
aList.append(action("SET_VIEW_INVERTEDNORMAL_CMD"));
aActions.append(action("COLOR_CMD"));
aActions.append(action("DEFLECTION_CMD"));
aActions.append(action("TRANSPARENCY_CMD"));
+ aActions.append(action("ISOLINES_CMD"));
aActions.append(action("CLEAN_HISTORY_CMD"));
aActions.append(action("DELETE_CMD"));
}
double aTransparency = ModelAPI_Tools::getTransparency(aResult);
if ((aTransparency >= 0) && (aTransparency != aAISObj->getTransparency()))
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]);
+ }
}
myWorkshop->module()->storeSelection();
#include <QDesktopWidget>
#include <QProcess>
#include <QDesktopServices>
+#include <QFormLayout>
+#include <QSpinBox>
+#include <QDialogButtonBox>
#include <iterator>
moveObjects(theId == "MOVE_SPLIT_CMD");
else if (theId == "COLOR_CMD")
changeColor(aObjects);
+ else if (theId == "ISOLINES_CMD")
+ changeIsoLines(aObjects);
else if (theId == "DEFLECTION_CMD")
changeDeflection(aObjects);
else if (theId == "TRANSPARENCY_CMD")
return false;
}
-//******************************************************
-void setColor(ResultPtr theResult, const std::vector<int>& theColor)
-{
- if (!theResult.get())
- return;
-
- AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- if (aColorAttr.get() != NULL) {
- if (!aColorAttr->size()) {
- aColorAttr->setSize(3);
- }
- aColorAttr->setValue(0, theColor[0]);
- aColorAttr->setValue(1, theColor[1]);
- aColorAttr->setValue(2, theColor[2]);
- }
-}
//**************************************************************
void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(aBodyResult, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor());
+ ModelAPI_Tools::setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor());
}
}
- setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
+ ModelAPI_Tools::setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
myViewerProxy->update();
}
-//**************************************************************
-void setDeflection(ResultPtr theResult, const double theDeflection)
-{
- if (!theResult.get())
- return;
-
- AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
- if (aDeflectionAttr.get() != NULL) {
- aDeflectionAttr->setValue(theDeflection);
- }
-}
-
-//**************************************************************
-void setTransparency(ResultPtr theResult, double theTransparency)
-{
- if (!theResult.get())
- return;
-
- AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
- if (anAttribute.get() != NULL) {
- anAttribute->setValue(theTransparency);
- }
-}
-
//**************************************************************
void setTransparency(double theTransparency, const QObjectPtrList& theObjects)
{
ModelAPI_Tools::allSubs(aBodyResult, allRes);
std::list<ResultPtr>::iterator aRes;
for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- setTransparency(*aRes, theTransparency);
+ ModelAPI_Tools::setTransparency(*aRes, theTransparency);
}
}
- setTransparency(aResult, theTransparency);
+ ModelAPI_Tools::setTransparency(aResult, theTransparency);
}
}
}
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(aBodyResult, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- setDeflection(*aRes, aDeflection);
+ ModelAPI_Tools::setDeflection(*aRes, aDeflection);
}
}
- setDeflection(aResult, aDeflection);
+ ModelAPI_Tools::setDeflection(aResult, aDeflection);
}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
{
myActiveControlMgr->deactivateSelector(myActiveControlMgr->activeSelector());
}
+
+void XGUI_Workshop::changeIsoLines(const QObjectPtrList& theObjects)
+{
+ if (theObjects.isEmpty())
+ return;
+
+ std::vector<int> aValues;
+ if (theObjects.size() == 1) {
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObjects.first());
+ if (aRes.get())
+ ModelAPI_Tools::getIsoLines(aRes, aValues);
+ else
+ return;
+ }
+ if (aValues.size() == 0) {
+ aValues.push_back(1);
+ aValues.push_back(1);
+ }
+
+ if (!abortAllOperations())
+ return;
+
+ QDialog aDlg;
+ aDlg.setWindowTitle(tr("Number of Iso-lines"));
+ QFormLayout* aLayout = new QFormLayout(&aDlg);
+
+ QSpinBox* aUNb = new QSpinBox(&aDlg);
+ aUNb->setValue(aValues[0]);
+ aLayout->addRow("U:", aUNb);
+
+ QSpinBox* aVNb = new QSpinBox(&aDlg);
+ aVNb->setValue(aValues[1]);
+ aLayout->addRow("V:", aVNb);
+
+ QDialogButtonBox* aButtons =
+ new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &aDlg);
+ connect(aButtons, SIGNAL(accepted()), &aDlg, SLOT(accept()));
+ connect(aButtons, SIGNAL(rejected()), &aDlg, SLOT(reject()));
+ aLayout->addRow(aButtons);
+
+ if (aDlg.exec() == QDialog::Accepted) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ QString aDescription = contextMenuMgr()->action("ISOLINES_CMD")->text();
+ aMgr->startOperation(aDescription.toStdString());
+
+ aValues[0] = aUNb->value();
+ aValues[1] = aVNb->value();
+ ResultPtr aRes;
+ foreach(ObjectPtr aObj, theObjects) {
+ aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aRes.get()) {
+ ModelAPI_Tools::setIsoLines(aRes, aValues);
+ }
+ }
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aMgr->finishOperation();
+ updateCommandStatus();
+ }
+}
\ No newline at end of file
/// theObjects a list of selected objects
void changeTransparency(const QObjectPtrList& theObjects);
+ /// Change number of iso-lines for the given objects
+ /// theObjects a list of selected objects
+ void changeIsoLines(const QObjectPtrList& theObjects);
+
/// Show the given features in 3d Viewer
void showObjects(const QObjectPtrList& theList, bool isVisible);
<file>pictures/ArrowCursor.png</file>
<file>pictures/CrossCursor.png</file>
<file>pictures/HandCursor.png</file>
+ <file>pictures/iso_lines.png</file>
</qresource>
</RCC>