From 89971988290a755863b941ffe74628032a22682f Mon Sep 17 00:00:00 2001 From: dbv Date: Mon, 27 Mar 2017 16:32:15 +0300 Subject: [PATCH] Issue #2024: Redesign of circle and arc of circle Removed unused widget. --- src/PartSet/CMakeLists.txt | 3 - src/PartSet/PartSet_Module.cpp | 6 - src/PartSet/PartSet_WidgetPoint2dDistance.cpp | 209 ------------------ src/PartSet/PartSet_WidgetPoint2dDistance.h | 119 ---------- 4 files changed, 337 deletions(-) delete mode 100644 src/PartSet/PartSet_WidgetPoint2dDistance.cpp delete mode 100644 src/PartSet/PartSet_WidgetPoint2dDistance.h diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 3793d26af..8dee08d11 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -34,7 +34,6 @@ SET(PROJECT_HEADERS PartSet_WidgetFileSelector.h PartSet_WidgetMultiSelector.h PartSet_WidgetPoint2d.h - PartSet_WidgetPoint2dDistance.h PartSet_WidgetPoint2DFlyout.h PartSet_WidgetShapeSelector.h PartSet_WidgetSketchCreator.h @@ -54,7 +53,6 @@ SET(PROJECT_MOC_HEADERS PartSet_WidgetFileSelector.h PartSet_WidgetMultiSelector.h PartSet_WidgetPoint2d.h - PartSet_WidgetPoint2dDistance.h PartSet_WidgetPoint2DFlyout.h PartSet_WidgetShapeSelector.h PartSet_WidgetSketchCreator.h @@ -83,7 +81,6 @@ SET(PROJECT_SOURCES PartSet_WidgetFileSelector.cpp PartSet_WidgetMultiSelector.cpp PartSet_WidgetPoint2d.cpp - PartSet_WidgetPoint2dDistance.cpp PartSet_WidgetPoint2DFlyout.cpp PartSet_WidgetShapeSelector.cpp PartSet_WidgetSketchCreator.cpp diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 67b4adf85..e7e7e8fa4 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -6,7 +6,6 @@ #include "PartSet_Tools.h" #include "PartSet_PreviewPlanes.h" #include "PartSet_WidgetPoint2d.h" -#include "PartSet_WidgetPoint2dDistance.h" #include "PartSet_WidgetPoint2DFlyout.h" #include "PartSet_WidgetShapeSelector.h" #include "PartSet_WidgetMultiSelector.h" @@ -716,11 +715,6 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th aPointWgt->setSketch(mySketchMgr->activeSketch()); connect(aPointWgt, SIGNAL(vertexSelected()), sketchReentranceMgr(), SLOT(onVertexSelected())); aWgt = aPointWgt; - } else if (theType == "point2ddistance") { - PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, - aWorkshop, theWidgetApi); - aDistanceWgt->setSketch(mySketchMgr->activeSketch()); - aWgt = aDistanceWgt; } else if (theType == "sketch_shape_selector") { PartSet_WidgetShapeSelector* aShapeSelectorWgt = new PartSet_WidgetShapeSelector(theParent, aWorkshop, theWidgetApi); diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp deleted file mode 100644 index b87b470c0..000000000 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_WidgetPoint2dDistance.cpp -// Created: 23 June 2014 -// Author: Vitaly Smetannikov - -#include "PartSet_WidgetPoint2dDistance.h" -#include "PartSet_Tools.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent, - ModuleBase_IWorkshop* theWorkshop, - const Config_WidgetAPI* theData) -: ModuleBase_WidgetLabelValue(theParent, theData), myWorkshop(theWorkshop), - myValueIsCashed(false), myIsFeatureVisibleInCash(true), myValueInCash(0) -{ - myFirstPntName = theData->getProperty("first_point"); - myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop); -} - -PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance() -{ -} - -bool PartSet_WidgetPoint2dDistance::isValidSelectionCustom( - const std::shared_ptr& theValue) -{ - return false; -} - -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(); - emit objectUpdated(); - } - else { - bool isOk; - double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk); - // it is important to block the spin box control in order to do not through out the - // locking of the validating state. - myLabel->setValue(isOk ? aDefValue : 0.0); - storeValue(); - aDone = true; - } - } - return aDone; -} - -void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, - const std::shared_ptr& thePnt) -{ - std::shared_ptr aData = theFeature->data(); - std::shared_ptr aPoint = std::dynamic_pointer_cast( - aData->attribute(myFirstPntName)); - if (!aPoint) - return; - - double aValue = computeValue(aPoint->pnt(), thePnt); - AttributeDoublePtr aReal = aData->real(attributeID()); - if (aReal && (aReal->value() != aValue)) { - aReal->setValue(aValue); - - myLabel->setValue(aValue); - storeValue(); - } -} - -double PartSet_WidgetPoint2dDistance::computeValue( - const std::shared_ptr& theFirstPnt, - const std::shared_ptr& theCurrentPnt) -{ - return theCurrentPnt->distance(theFirstPnt); -} - -void PartSet_WidgetPoint2dDistance::mouseReleased(ModuleBase_IViewWindow* theWnd, - QMouseEvent* theEvent) -{ - // the contex menu release by the right button should not be processed by this widget - if (theEvent->button() != Qt::LeftButton) - return; - - //if (mySpinBox->hasVariable()) - // return; - - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); - - double aX, aY; - PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY); - - std::shared_ptr aPnt = std::shared_ptr(new GeomAPI_Pnt2d(aX, aY)); - setPoint(feature(), aPnt); - - // if the validator of the control returns false, focus should not be switched - if (getError(false).isEmpty()) - emit focusOutWidget(this); -} - -void PartSet_WidgetPoint2dDistance::mouseMoved(ModuleBase_IViewWindow* theWnd, - QMouseEvent* theEvent) -{ - if (isEditingMode()) - return; - - //if (mySpinBox->hasVariable()) - // return; - - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); - - double aX, aY; - PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY); - - std::shared_ptr aPnt = std::shared_ptr(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 = myLabel->value(); -} - -bool PartSet_WidgetPoint2dDistance::restoreCurentValue() -{ - bool aRestoredAndHidden = true; - - bool isVisible = myIsFeatureVisibleInCash; - // fill the control widgets by the cashed value - - myValueIsCashed = false; - myIsFeatureVisibleInCash = true; - myLabel->setValue(myValueInCash); - - // store value to the model - storeValueCustom(); - if (isVisible) { - setValueState(Stored); - aRestoredAndHidden = false; - } - else - aRestoredAndHidden = true; - - return aRestoredAndHidden; -} - -bool PartSet_WidgetPoint2dDistance::processEnter() -{ - return false; - /* - bool isModified = getValueState() == ModifiedInPP; - if (isModified) { - emit valuesChanged(); - //mySpinBox->selectAll(); - } - return isModified;*/ -} - -bool PartSet_WidgetPoint2dDistance::storeValueCustom() -{ - std::shared_ptr aData = myFeature->data(); - if (!aData) // can be on abort of sketcher element - return false; - AttributeDoublePtr anAttribute = myFeature->data()->real(attributeID()); - anAttribute->setValue(myLabel->value()); - - // after movement the solver will call the update event: optimization - updateObject(myFeature); - - return true; -} diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.h b/src/PartSet/PartSet_WidgetPoint2dDistance.h deleted file mode 100644 index 0ad39f03c..000000000 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.h +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_WidgetPoint2dDistance.h -// Created: 23 June 2014 -// Author: Vitaly Smetannikov - -#ifndef PartSet_WidgetPoint2dDistance_H -#define PartSet_WidgetPoint2dDistance_H - -#include "PartSet.h" -#include "PartSet_MouseProcessor.h" - -#include - -#include - -class GeomAPI_Pnt2d; -class ModuleBase_IWorkshop; -class ModuleBase_IViewWindow; -class QMouseEvent; - -/** -* \ingroup Modules -* Implementation of model widget for widget which provides input of a distance between two points -* In XML file can be defined as following: -* \code -* -* -* -* \endcode -*/ -class PARTSET_EXPORT PartSet_WidgetPoint2dDistance : public ModuleBase_WidgetLabelValue, - public PartSet_MouseProcessor -{ -Q_OBJECT - public: - /// Constructor - /// \param theParent the parent object - /// \param theWorkshop a current workshop - /// \param theData the widget configuation. The attribute of the model widget is obtained from - PartSet_WidgetPoint2dDistance(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, - const Config_WidgetAPI* theData); - - virtual ~PartSet_WidgetPoint2dDistance(); - - /// Checks if the selection presentation is valid in widget - /// \param theValue a selected presentation in the view - /// \return a boolean value - virtual bool isValidSelectionCustom(const std::shared_ptr& theValue); - - /// \returns the sketch instance - CompositeFeaturePtr sketch() const { return mySketch; } - - /// Set sketch instance - void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; } - - /// Returns true if the event is processed. - virtual bool processEnter(); - - /// Processing the mouse move event in the viewer - /// \param theWindow a view window - /// \param theEvent a mouse event - virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent); - - /// Processing the mouse release event in the viewer - /// \param theWindow a view window - /// \param theEvent a mouse event - virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, 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(); - - /// Set the second point which defines a value in the widget as - /// a distance with a first point defined by feature - void setPoint(FeaturePtr theFeature, const std::shared_ptr& thePnt); - - /// Compute the distance between points - /// \param theFirstPnt a point value of the out point attribute - /// \param theCurrentPnt a point of the current widget - /// \return a double value - virtual double computeValue(const std::shared_ptr& theFirstPnt, - const std::shared_ptr& theCurrentPnt); - - /// Saves the internal parameters to the given feature - /// \return True in success - virtual bool storeValueCustom(); - -protected: - /// A reference to workshop - ModuleBase_IWorkshop* myWorkshop; - - /// A name of the first point - std::string myFirstPntName; - - /// 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 -- 2.39.2