// the presentation is not used in the selection
}
-bool PartSet_OperationPrs::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
-{
- bool aVisible = false;
- GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aPrs.get() || aResult.get()) {
- aVisible = theDisplayer->isVisible(theObject);
- // compsolid is not visualized in the viewer, but should have presentation when all sub solids are
- // visible. It is useful for highlight presentation where compsolid shape is selectable
- if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
- ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
- if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
- bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
- for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
- anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i));
- }
- aVisible = anAllSubsVisible;
- }
- }
- }
- else {
- // check if all results of the feature are visible
- FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- std::list<ResultPtr> aResults = aFeature->results();
- std::list<ResultPtr>::const_iterator aIt;
- aVisible = !aResults.empty();
- for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
- aVisible = aVisible && theDisplayer->isVisible(*aIt);
- }
- }
- return aVisible;
-}
-
bool isSubObject(const ObjectPtr& theObject, const FeaturePtr& theFeature)
{
bool isSub = false;
QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
{
XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
- if (isVisible(aDisplayer, theObject)) {
+ if (XGUI_Displayer::isVisible(aDisplayer, theObject)) {
if (theGeomShape.get()) {
if (theObjectShapes.contains(theObject))
theObjectShapes[theObject].append(theGeomShape);
QMap<ObjectPtr, QList<GeomShapePtr> >& featureShapes() { return myFeatureShapes; }
private:
- /// Return true if the object is visible. If the object is feature, it returns true
- /// if all results of the feature are shown
- /// \param theDisplayer a displayer
- /// \param theObject an object
- /// \return a boolean value
- static bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
-
/// Fills the map by the feature object and shapes, which should be visuaziled
/// Gets feature attributes, collect objects to whom the attributes refer
/// \param theFeature a current feature
#include <PartSet_Tools.h>
#include <PartSet_Module.h>
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
+
#include <ModuleBase_ParamSpinBox.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_IViewer.h>
const Config_WidgetAPI* theData,
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop),
- myValueIsCashed(false), myXValueInCash(0), myYValueInCash(0)
+ myValueIsCashed(false), myIsFeatureVisibleInCash(true),
+ myXValueInCash(0), myYValueInCash(0)
{
if (MyFeaturesForCoincedence.isEmpty()) {
MyFeaturesForCoincedence << SketchPlugin_Line::ID().c_str()
}
else {
if (myValueIsCashed) {
- // fill the control widgets by the cashed value
- restoreCurentValue();
- // store value to the model
- storeValueCustom();
- setValueState(Stored);
- aDone = false;
+ // if the restored value should be hidden, aDone = true to set
+ // reset state for the widget in the parent
+ aDone = restoreCurentValue();
}
else {
bool isOk;
return;
myValueIsCashed = true;
+ myIsFeatureVisibleInCash = XGUI_Displayer::isVisible(
+ XGUI_Tools::workshop(myWorkshop)->displayer(), myFeature);
myXValueInCash = myXSpin->value();
myYValueInCash = myYSpin->value();
}
-void PartSet_WidgetPoint2D::restoreCurentValue()
+bool PartSet_WidgetPoint2D::restoreCurentValue()
{
+ bool aRestoredAndHidden = true;
+
+ bool isVisible = myIsFeatureVisibleInCash;
+ // fill the control widgets by the cashed value
+
myValueIsCashed = false;
+ myIsFeatureVisibleInCash = true;
ModuleBase_Tools::setSpinValue(myXSpin, myXValueInCash);
ModuleBase_Tools::setSpinValue(myYSpin, myYValueInCash);
+
+ // store value to the model
+ storeValueCustom();
+ if (isVisible) {
+ setValueState(Stored);
+ aRestoredAndHidden = false;
+ }
+ else
+ aRestoredAndHidden = true;
+
+ return aRestoredAndHidden;
}
QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
void storeCurentValue();
/// Restore cashed value in the model attribute
- void restoreCurentValue();
+ /// \return boolean state if the restored feature shoud be hidden
+ bool restoreCurentValue();
/// Fills the widget with default values
/// \return true if the widget current value is reset
CompositeFeaturePtr mySketch;
bool myValueIsCashed; /// boolean state if the value is cashed during value state change
+ bool myIsFeatureVisibleInCash; /// boolean value if the feature was visible when cash if filled
double myXValueInCash; /// the cashed X value during value state change
double myYValueInCash; /// the cashed Y value during value state change
};
#include "PartSet_WidgetPoint2dDistance.h"
#include "PartSet_Tools.h"
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
+
#include <ModuleBase_ParamSpinBox.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IViewWindow.h>
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const std::string& theParentId)
- : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop)
+: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop),
+ myValueIsCashed(false), myIsFeatureVisibleInCash(true), myValueInCash(0)
{
myFirstPntName = theData->getProperty("first_point");
}
{
}
+bool PartSet_WidgetPoint2dDistance::resetCustom()
+{
+ bool aDone = false;
+ if (!isUseReset() || isComputedDefault() || mySpinBox->hasVariable()) {
+ aDone = false;
+ }
+ else {
+ if (myValueIsCashed) {
+ // if the restored value should be hidden, aDone = true to set
+ // reset state for the widget in the parent
+ aDone = restoreCurentValue();
+ }
+ else
+ aDone = ModuleBase_WidgetDoubleValue::resetCustom();
+ }
+ return aDone;
+}
+
void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
const std::shared_ptr<GeomAPI_Pnt2d>& thePnt)
{
PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY);
std::shared_ptr<GeomAPI_Pnt2d> aPnt = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
+ if (myState != ModifiedInViewer)
+ storeCurentValue();
+
bool isBlocked = blockValueState(true);
setPoint(feature(), aPnt);
blockValueState(isBlocked);
setValueState(ModifiedInViewer);
}
+void PartSet_WidgetPoint2dDistance::storeCurentValue()
+{
+ // do not use cash if a variable is used
+ if (mySpinBox->hasVariable())
+ return;
+
+ myValueIsCashed = true;
+ myIsFeatureVisibleInCash = XGUI_Displayer::isVisible(
+ XGUI_Tools::workshop(myWorkshop)->displayer(), myFeature);
+ myValueInCash = mySpinBox->value();
+}
+
+bool PartSet_WidgetPoint2dDistance::restoreCurentValue()
+{
+ bool aRestoredAndHidden = true;
+
+ bool isVisible = myIsFeatureVisibleInCash;
+ // fill the control widgets by the cashed value
+
+ myValueIsCashed = false;
+ myIsFeatureVisibleInCash = true;
+ ModuleBase_Tools::setSpinValue(mySpinBox, myValueInCash);
+
+ // store value to the model
+ storeValueCustom();
+ if (isVisible) {
+ setValueState(Stored);
+ aRestoredAndHidden = false;
+ }
+ else
+ aRestoredAndHidden = true;
+
+ return aRestoredAndHidden;
+}
+
bool PartSet_WidgetPoint2dDistance::processEnter()
{
bool isModified = getValueState() == ModifiedInPP;
void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
protected:
+ /// Store current value in cashed value
+ void storeCurentValue();
+
+ /// Restore cashed value in the model attribute
+ /// \return boolean state if the restored feature shoud be hidden
+ bool restoreCurentValue();
+
+ /// Fills the widget with default values
+ /// \return true if the widget current value is reset
+ virtual bool resetCustom();
+
/// The methiod called when widget is activated
virtual void activateCustom();
/// Reference to sketch
CompositeFeaturePtr mySketch;
+
+ bool myValueIsCashed; /// boolean state if the value is cashed during value state change
+ bool myIsFeatureVisibleInCash; /// boolean value if the feature was visible when cash if filled
+ double myValueInCash; /// the cashed X value during value state change
};
#endif
AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType);
}
+bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
+{
+ bool aVisible = false;
+ GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aPrs.get() || aResult.get()) {
+ aVisible = theDisplayer->isVisible(theObject);
+ // compsolid is not visualized in the viewer, but should have presentation when all sub solids are
+ // visible. It is useful for highlight presentation where compsolid shape is selectable
+ if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
+ ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+ if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
+ bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
+ for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
+ anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i));
+ }
+ aVisible = anAllSubsVisible;
+ }
+ }
+ }
+ else {
+ // check if all results of the feature are visible
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ aVisible = !aResults.empty();
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ aVisible = aVisible && theDisplayer->isVisible(*aIt);
+ }
+ }
+ return aVisible;
+}
+
+
void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
const bool theUpdateViewer)
{
/// \param theShapeType a shape type from TopAbs_ShapeEnum
static int getSelectionMode(int theShapeType);
+ /// Return true if the object is visible. If the object is feature, it returns true
+ /// if all results of the feature are shown
+ /// \param theDisplayer a displayer
+ /// \param theObject an object
+ /// \return a boolean value
+ static bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
+
signals:
/// Signal on object display
/// \param theObject a data object