]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into SketchSolver
authorazv <azv@opencascade.com>
Tue, 24 Jun 2014 12:51:45 +0000 (16:51 +0400)
committerazv <azv@opencascade.com>
Tue, 24 Jun 2014 12:51:45 +0000 (16:51 +0400)
30 files changed:
src/Config/Config_Keywords.h
src/GeomData/GeomData_Dir.cpp
src/GeomData/GeomData_Point.cpp
src/GeomData/GeomData_Point2D.cpp
src/Model/Model_AttributeBoolean.cpp
src/Model/Model_AttributeDocRef.cpp
src/Model/Model_AttributeDouble.cpp
src/Model/Model_AttributeRefAttr.cpp
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeReference.cpp
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/ModelAPI/ModelAPI_Attribute.h
src/ModelAPI/ModelAPI_Data.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetEditor.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetEditor.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_PropertyPanel.cpp

index 0d16ad4321ad648738a79fc89a13046f39e7b1b3..69c2eea29883793bd168ab568cb56f05d5c11fcb 100644 (file)
@@ -31,8 +31,10 @@ const static char* WDG_SELECTOR = "selector";
 
 //Specific widget containers
 const static char* WDG_POINT_SELECTOR = "point_selector";
+const static char* WDG_POINT2D_DISTANCE = "point2ddistance";
 
 const static char* WDG_FEATURE_SELECTOR = "feature_selector";
+const static char* WDG_DOUBLEVALUE_EDITOR = "doublevalue_editor";
 
 const static char* _ID = "id";
 //const static char* WORKBENCH_ID = "id";
@@ -46,6 +48,7 @@ const static char* FEATURE_NESTED = "nested";
 const static char* FEATURE_INTERNAL = "internal";
 const static char* SOURCE_FILE = "path";
 
+const static char* PREVIOUS_FEATURE_PARAM = "previous_feature_param";
 
 // doublevalue properties:
 const static char* INFO_WDG_TEXT = FEATURE_TEXT;
index 44f04fe307900b6867a4bba70a6d7bd480b7c984..3800c938ce04ee810e1bca6d6ff858bd83114f28 100644 (file)
@@ -5,26 +5,26 @@
 #include "GeomData_Dir.h"
 #include "GeomAPI_Dir.h"
 #include <gp_Dir.hxx>
-#include "Model_Events.h"
-#include <Events_Loop.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
 
 using namespace std;
 
 void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
 {
-  if (myCoords->Value(0) != theX || myCoords->Value(1) != theY || myCoords->Value(2) != theZ) {
+  if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY || 
+       myCoords->Value(2) != theZ) {
     myCoords->SetValue(0, theX);
     myCoords->SetValue(1, theY);
     myCoords->SetValue(2, theZ);
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
 void GeomData_Dir::setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir)
 {
   setValue(theDir->x(), theDir->y(), theDir->z());
+  owner()->data()->sendAttributeUpdated(this);
 }
 
 double GeomData_Dir::x() const
@@ -50,8 +50,8 @@ boost::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
 
 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet, just zero
     myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
   }
index da6299703174b694c2d95b179b905a738c2dfc23..db942aff62389b2ff9f268787954b1ff15a3ed51 100644 (file)
@@ -3,27 +3,27 @@
 // Author:      Mikhail PONIKAROV
 
 #include "GeomData_Point.h"
-#include "Model_Events.h"
-#include <Events_Loop.h>
 #include <GeomAPI_Pnt.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
 
 using namespace std;
 
 void GeomData_Point::setValue(const double theX, const double theY, const double theZ)
 {
-  if (myCoords->Value(0) != theX || myCoords->Value(1) != theY || myCoords->Value(2) != theZ) {
+  if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY || 
+       myCoords->Value(2) != theZ) {
     myCoords->SetValue(0, theX);
     myCoords->SetValue(1, theY);
     myCoords->SetValue(2, theZ);
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
 void GeomData_Point::setValue(const boost::shared_ptr<GeomAPI_Pnt>& thePoint)
 {
   setValue(thePoint->x(), thePoint->y(), thePoint->z());
+  owner()->data()->sendAttributeUpdated(this);
 }
 
 double GeomData_Point::x() const
@@ -50,8 +50,8 @@ boost::shared_ptr<GeomAPI_Pnt> GeomData_Point::pnt()
 
 GeomData_Point::GeomData_Point(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet, just zero
     myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
   }
index 334d2070a320b1c19d0f9cf73450d143eca4f868..7e6f889c41fb5698380bed1b4d2a99ee5da12fa5 100644 (file)
@@ -3,9 +3,9 @@
 // Author:      Mikhail PONIKAROV
 
 #include "GeomData_Point2D.h"
-#include "Model_Events.h"
-#include <Events_Loop.h>
 #include <GeomAPI_Pnt2d.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
 
 using namespace std;
 
@@ -14,15 +14,14 @@ void GeomData_Point2D::setValue(const double theX, const double theY)
   if (myCoords->Value(0) != theX || myCoords->Value(1) != theY) {
     myCoords->SetValue(0, theX);
     myCoords->SetValue(1, theY);
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
 void GeomData_Point2D::setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
 {
   setValue(thePoint->x(), thePoint->y());
+  owner()->data()->sendAttributeUpdated(this);
 }
 
 double GeomData_Point2D::x() const
@@ -44,8 +43,8 @@ boost::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
 
 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet, just zero
     myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);
   }
index 5472dadf255f13feac8b09704726979751f0d191..07c482b0741e5aa055866ff295f77a3cde81f79a 100644 (file)
@@ -3,19 +3,17 @@
 // Author:      Vitaly Smetannikov
 
 #include "Model_AttributeBoolean.h"
-#include "Model_Events.h"
-#include <Events_Loop.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
 
 using namespace std;
 
 void Model_AttributeBoolean::setValue(bool theValue)
 {
   Standard_Boolean aValue = theValue ? Standard_True : Standard_False;
-  if (myBool->Get() != aValue) {
+  if (!myIsInitialized || myBool->Get() != aValue) {
     myBool->Set(aValue);
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
@@ -27,7 +25,8 @@ bool Model_AttributeBoolean::value()
 Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
 {
   // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet, just zero
     myBool = TDataStd_Integer::Set(theLabel, 0);
   }
index dfb307f4dbfe0981cc8915fc838cea6a798540a4..83615e30ec458bd63417ebc210e95a03b4558ee4 100644 (file)
@@ -4,20 +4,17 @@
 
 #include "Model_AttributeDocRef.h"
 #include "Model_Application.h"
-#include "Model_Events.h"
-#include <Events_Loop.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
 
 using namespace std;
 
 void Model_AttributeDocRef::setValue(boost::shared_ptr<ModelAPI_Document> theDoc)
 {
   TCollection_ExtendedString aNewID(theDoc->id().c_str());
-  if (myComment->Get() != aNewID) {
+  if (!myIsInitialized || myComment->Get() != aNewID) {
     myComment->Set(TCollection_ExtendedString(theDoc->id().c_str()));
-
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
@@ -32,8 +29,8 @@ boost::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
 
 Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), myComment)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_Comment::GetID(), myComment) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet, just empty string
     myComment = TDataStd_Comment::Set(theLabel, "");
   } else { // document was already referenced: try to set it as loaded by demand
index 88b4352a56d288dd8b3b0c81a7acfdc28e5ce82f..13b976c2e1e57e74e19cd51a0168e4ddb6dbd611 100644 (file)
@@ -3,18 +3,16 @@
 // Author:      Mikhail PONIKAROV
 
 #include "Model_AttributeDouble.h"
-#include "Model_Events.h"
-#include <Events_Loop.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
 
 using namespace std;
 
 void Model_AttributeDouble::setValue(const double theValue)
 {
-  if (myReal->Get() != theValue) {
+  if (!myIsInitialized || myReal->Get() != theValue) {
     myReal->Set(theValue);
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
@@ -26,7 +24,8 @@ double Model_AttributeDouble::value()
 Model_AttributeDouble::Model_AttributeDouble(TDF_Label& theLabel)
 {
   // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_Real::GetID(), myReal)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_Real::GetID(), myReal) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet, just zero
     myReal = TDataStd_Real::Set(theLabel, 0.);
   }
index 39797722609130ae4fc3d7cf42ee4bcb5dcce231..24bcddec1a7e63378c7ed4e5fd3f24462f323295 100644 (file)
@@ -4,10 +4,8 @@
 
 #include "Model_AttributeRefAttr.h"
 #include "Model_Application.h"
-#include "Model_Events.h"
 #include "Model_Data.h"
 #include <ModelAPI_Feature.h>
-#include <Events_Loop.h>
 
 using namespace std;
 
@@ -21,15 +19,12 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAt
   boost::shared_ptr<Model_Data> aData = 
     boost::dynamic_pointer_cast<Model_Data>(theAttr->owner()->data());
   string anID = aData->id(theAttr);
-  if (feature() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
+  if (myIsInitialized && feature() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
     return; // nothing is changed
 
   myRef->Set(aData->label());
   myID->Set(aData->id(theAttr).c_str());
-
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-  Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-  Events_Loop::loop()->send(aMsg);
+  owner()->data()->sendAttributeUpdated(this);
 }
 
 boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
@@ -46,15 +41,12 @@ boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
 
 void Model_AttributeRefAttr::setFeature(FeaturePtr theFeature)
 {
-  if (myID->Get().Length() != 0 || feature() != theFeature) {
+  if (!myIsInitialized || myID->Get().Length() != 0 || feature() != theFeature) {
     boost::shared_ptr<Model_Data> aData = 
       boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
     myRef->Set(aData->label());
     myID->Set(""); // feature is identified by the empty ID
-
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
@@ -75,8 +67,8 @@ FeaturePtr Model_AttributeRefAttr::feature()
 
 Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), myID)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_Comment::GetID(), myID) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet
     myID = TDataStd_Comment::Set(theLabel, "");
     myRef = TDF_Reference::Set(theLabel, theLabel); // not initialized: reference to itself
index af4cbd3ea6246983a910f4bc3f177540ebe8d1e5..9e4dc839688cda9f7ec6d7f6326337220641eaa4 100644 (file)
@@ -4,10 +4,8 @@
 
 #include "Model_AttributeRefList.h"
 #include "Model_Application.h"
-#include "Model_Events.h"
 #include "Model_Data.h"
 #include <ModelAPI_Feature.h>
-#include <Events_Loop.h>
 #include <TDF_ListIteratorOfLabelList.hxx>
 
 using namespace std;
@@ -18,9 +16,7 @@ void Model_AttributeRefList::append(FeaturePtr theFeature)
     boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
   myRef->Append(aData->label());
 
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-  Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-  Events_Loop::loop()->send(aMsg);
+  owner()->data()->sendAttributeUpdated(this);
 }
 
 void Model_AttributeRefList::remove(FeaturePtr theFeature)
@@ -29,6 +25,7 @@ void Model_AttributeRefList::remove(FeaturePtr theFeature)
     boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
   myRef->Remove(aData->label());
 
+  owner()->data()->sendAttributeUpdated(this);
 }
 
 int Model_AttributeRefList::size()
@@ -52,8 +49,8 @@ list<FeaturePtr > Model_AttributeRefList::list()
 
 Model_AttributeRefList::Model_AttributeRefList(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True;
+  if (!myIsInitialized) {
     myRef = TDataStd_ReferenceList::Set(theLabel);
   }
 }
index adcfe4ab46e0b1d62d038f8408dd7568a029afe7..e2ff01ce7798975aa6e11d829c86281f6bfc99f5 100644 (file)
@@ -7,13 +7,12 @@
 #include "Model_Events.h"
 #include "Model_Data.h"
 #include <ModelAPI_Feature.h>
-#include <Events_Loop.h>
 
 using namespace std;
 
 void Model_AttributeReference::setValue(FeaturePtr theFeature)
 {
-  if (value() != theFeature) {
+  if (!myIsInitialized || value() != theFeature) {
     boost::shared_ptr<Model_Data> aData = 
       boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
     if (myRef.IsNull()) {
@@ -23,10 +22,7 @@ void Model_AttributeReference::setValue(FeaturePtr theFeature)
     } else {
       myRef->Set(aData->label());
     }
-
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
@@ -46,8 +42,6 @@ FeaturePtr Model_AttributeReference::value()
 
 Model_AttributeReference::Model_AttributeReference(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDF_Reference::GetID(), myRef)) {
-    // create attribute: not initialized by value yet: attribute is not set to the label!
-  }
+  // not initialized by value yet: attribute is not set to the label!
+  myIsInitialized = theLabel.FindAttribute(TDF_Reference::GetID(), myRef) == Standard_True;
 }
index 31f9f36a03eab9542a8410a4e753c2d83248fda6..60b7b540e7c4f554d12e3cab5924a5b2f89cf5f4 100644 (file)
@@ -207,6 +207,25 @@ bool Model_Data::isValid()
   return !myLab.IsNull() && myLab.HasAttribute();
 }
 
+list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string theType)
+{
+  list<boost::shared_ptr<ModelAPI_Attribute> > aResult;
+  map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = myAttrs.begin();
+  for(; anAttrsIter != myAttrs.end(); anAttrsIter++) {
+    if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
+    }
+  }
+  return aResult;
+}
+
+void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
+{
+  theAttr->setInitialized();
+  static const Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
+  Model_FeatureUpdatedMessage aMsg(myFeature, anEvent);
+  Events_Loop::loop()->send(aMsg);
+}
+
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TopoDS_Shape.hxx>
index 36f5f361463d7372cef018a00f687bebf9c23d65..eca52e960c44d99464996994eca977ac8d041634 100644 (file)
@@ -63,6 +63,11 @@ public:
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID);
+  /// Returns all attributes ofthe feature of the given type
+  /// or all attributes if "theType" is empty
+  MODEL_EXPORT virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
+    attributes(const std::string theType);
+
   /// Identifier by the id (not fast, iteration by map)
   /// \param theAttr attribute already created in this data
   MODEL_EXPORT virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute> theAttr);
@@ -82,6 +87,10 @@ public:
   /// \param theAttrType type of the created attribute (received from the type method)
   MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
 
+  /// Useful method for "set" methods of the attributes: sends an UPDATE event and
+  /// makes attribute initialized
+  MODEL_EXPORT virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr);
+
   /// Puts feature to the document data sub-structure
   MODEL_EXPORT void setLabel(TDF_Label& theLab);
 
index acea353df4d61d3be87566b1ea1da3232a3fe844..4a15abb88c718b680beeff2b45d323c3020426e2 100644 (file)
@@ -19,6 +19,8 @@ class ModelAPI_Attribute
 {
   ///< needed here to emit signal that feature changed on change of the attribute
   boost::shared_ptr<ModelAPI_Feature> myFeature;
+protected: // accessible from the attributes
+  bool myIsInitialized;
 public:
   
   /// Returns the type of this class of attributes, not static method
@@ -34,9 +36,16 @@ public:
   /// Returns the owner of this attribute
   MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Feature>& owner()
   {return myFeature;}
+
+  /// Returns true if attribute was  initialized by some value
+  MODELAPI_EXPORT bool isInitialized() {return myIsInitialized;}
+
+  /// Makes attribute initialized
+  MODELAPI_EXPORT void setInitialized() {myIsInitialized = true;}
+
 protected:
   /// Objects are created for features automatically
-  ModelAPI_Attribute(){}
+  ModelAPI_Attribute() {myIsInitialized = false;}
 
 };
 
index 76967d18143f6e50c00374755a0ad13fa5f6f110..5d6e36d5f8e7a9293b47180b3f84a85c3c76be23 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "ModelAPI.h"
 #include <string>
+#include <list>
 #include <boost/shared_ptr.hpp>
 
 class ModelAPI_AttributeDocRef;
@@ -51,6 +52,10 @@ public:
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
   virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID) = 0;
+  /// Returns all attributes ofthe feature of the given type
+  /// or all attributes if "theType" is empty
+  virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
+    attributes(const std::string theType) = 0;
   /// Identifier by the id (not fast, iteration by map)
   /// \param theAttr attribute already created in this data
   virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute> theAttr) = 0;
@@ -70,6 +75,10 @@ public:
   /// \param theAttrType type of the created attribute (received from the type method)
   virtual void addAttribute(std::string theID, std::string theAttrType) = 0;
 
+  /// Useful method for "set" methods of the attributes: sends an UPDATE event and
+  /// makes attribute initialized
+  virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr) = 0;
+
   /// To virtually destroy the fields of successors
   virtual ~ModelAPI_Data() {}
 
index b617a50628ed4c310002de87182b9138a0d0f23c..7fa463bdc6b72aae0baa47c191d813209843259c 100644 (file)
@@ -9,12 +9,14 @@ SET(PROJECT_HEADERS
        ModuleBase_ModelWidget.h
        ModuleBase_WidgetBoolValue.h
        ModuleBase_WidgetDoubleValue.h
+       ModuleBase_WidgetEditor.h
        ModuleBase_WidgetFactory.h
        ModuleBase_WidgetFeature.h
        ModuleBase_WidgetPoint2D.h
        ModuleBase_WidgetSwitch.h
        ModuleBase_WidgetSelector.h
        ModuleBase_IWorkshop.h
+       ModuleBase_WidgetPoint2dDistance.h
 )
 
 SET(PROJECT_SOURCES
@@ -24,16 +26,19 @@ SET(PROJECT_SOURCES
        ModuleBase_ModelWidget.cpp
        ModuleBase_WidgetBoolValue.cpp
        ModuleBase_WidgetDoubleValue.cpp
+       ModuleBase_WidgetEditor.cpp
        ModuleBase_WidgetFactory.cpp
        ModuleBase_WidgetFeature.cpp
        ModuleBase_WidgetPoint2D.cpp
        ModuleBase_WidgetSwitch.cpp
        ModuleBase_WidgetSelector.cpp
+       ModuleBase_WidgetPoint2dDistance.cpp
 )
 
 SET(PROJECT_LIBRARIES
     Config
     ModelAPI
+       GeomAPI
     ${QT_LIBRARIES}
        ${CAS_VIEWER}
        ${CAS_KERNEL}
index b7b3de3b89d9e613abfc1070d8467a9f2badd95f..5a13b4cc08d4d7f8f506246adacd95f5b7b57aa1 100644 (file)
@@ -69,6 +69,9 @@ signals:
   /// \param theAttributeName a name of the attribute
   /// \param theEvent key release event
   void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent);
+  /// The signal about the widget is lost focus
+  /// \param theWidget the model base widget
+  void focusOutWidget(ModuleBase_ModelWidget* theWidget);
 
 protected:
   bool myHasDefaultValue; /// the boolean state whether the control has a default value
index 70f6de58ce510344ae127d927bd18313b9a0c578..2a5b6c2a1c28b63db3ccc283774c8a347f3b6f7f 100644 (file)
@@ -43,7 +43,7 @@ public:
   /// \param theEvent the processed event
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
-private:
+protected:
   QWidget*     myContainer;
   QLabel*      myLabel;
   QDoubleSpinBox* mySpinBox;
diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp
new file mode 100644 (file)
index 0000000..84b63cf
--- /dev/null
@@ -0,0 +1,93 @@
+// File:        ModuleBase_WidgetEditor.cpp
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <ModuleBase_WidgetEditor.h>
+
+#include <Config_Keywords.h>
+#include <Config_WidgetAPI.h>
+
+#include <Events_Loop.h>
+#include <Model_Events.h>
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <GeomDataAPI_Point2D.h>
+
+#include <QWidget>
+#include <QLineEdit>
+
+ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
+                                                 const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent, theData)
+{
+  myEditor = new QLineEdit(0);
+  myEditor->setWindowFlags(Qt::ToolTip);
+  myEditor->setFocusPolicy(Qt::StrongFocus);
+
+  connect(myEditor, SIGNAL(returnPressed()), this, SLOT(onStopEditing()));
+  connect(myEditor, SIGNAL(textChanged(const QString&)), this, SIGNAL(valuesChanged()));
+}
+
+ModuleBase_WidgetEditor::~ModuleBase_WidgetEditor()
+{
+  delete myEditor;
+}
+
+bool ModuleBase_WidgetEditor::storeValue(FeaturePtr theFeature) const
+{
+  DataPtr aData = theFeature->data();
+  AttributeDoublePtr aReal = aData->real(attributeID());
+  bool isOk;
+  double aValue = myEditor->text().toDouble(&isOk);
+  if (isOk && aReal->value() != aValue) {
+    //ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
+    //bool isBlocked = that->blockSignals(true);
+    aReal->setValue(aValue);
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+    //that->blockSignals(isBlocked);
+  }
+  return true;
+}
+
+bool ModuleBase_WidgetEditor::restoreValue(FeaturePtr theFeature)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  AttributeDoublePtr aRef = aData->real(attributeID());
+
+  //bool isBlocked = this->blockSignals(true);
+  myEditor->setText(QString::number(aRef->value()));
+  //this->blockSignals(isBlocked);
+  return true;
+}
+
+void ModuleBase_WidgetEditor::focusTo()
+{
+  QPoint aPoint = QCursor::pos();
+
+  myEditor->move(aPoint);
+  myEditor->show();
+
+  myEditor->selectAll();
+  myEditor->setFocus();
+}
+
+QWidget* ModuleBase_WidgetEditor::getControl() const
+{
+  return 0;
+}
+
+QList<QWidget*> ModuleBase_WidgetEditor::getControls() const
+{
+  QList<QWidget*> aControls;
+  return aControls;
+}
+
+void ModuleBase_WidgetEditor::onStopEditing()
+{
+  myEditor->hide();
+  emit focusOutWidget(this);
+}
diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.h b/src/ModuleBase/ModuleBase_WidgetEditor.h
new file mode 100644 (file)
index 0000000..e2f67a0
--- /dev/null
@@ -0,0 +1,61 @@
+// File:        ModuleBase_WidgetEditor.h
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_WidgetEditor_H
+#define ModuleBase_WidgetEditor_H
+
+#include <ModuleBase.h>
+#include "ModuleBase_ModelWidget.h"
+
+#include <QObject>
+#include <QStringList>
+
+class ModelAPI_Feature;
+class QLineEdit;
+
+/**\class ModuleBase_WidgetEditor
+ * \ingroup GUI
+ * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
+ */
+class MODULEBASE_EXPORT ModuleBase_WidgetEditor : public ModuleBase_ModelWidget
+{
+  Q_OBJECT
+public:
+  /// Constructor
+  /// \theParent the parent object
+  /// \theParent the parent object
+  /// \theData the widget configuation. The attribute of the model widget is obtained from
+  ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData);
+  /// Destructor
+  virtual ~ModuleBase_WidgetEditor();
+
+  /// Saves the internal parameters to the given feature
+  /// \param theFeature a model feature to be changed
+  virtual bool storeValue(FeaturePtr theFeature) const;
+
+  virtual bool restoreValue(FeaturePtr theFeature);
+
+  /// Set focus to the first control of the current widget. The focus policy of the control is checked.
+  /// If the widget has the NonFocus focus policy, it is skipped.
+  virtual void focusTo();
+
+  /// Returns the internal parent wiget control, that can be shown anywhere
+  /// \returns the widget
+  QWidget* getControl() const;
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+protected slots:
+  /// Slot to check the editing stop
+  void onStopEditing();
+
+private:
+  QLineEdit* myEditor;
+  FeaturePtr myFeature; ///< the current widget feature
+  QStringList myFeatureKinds; ///< the kinds of possible features
+};
+
+#endif
index 1c372fd670b897986767d3b7caf24ce135fc50a9..e122c52504b6633feb7e573e8ed2d885b91899ed 100644 (file)
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetPoint2D.h>
 #include <ModuleBase_WidgetFeature.h>
+#include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_WidgetSwitch.h>
 #include <ModuleBase_WidgetSelector.h>
 #include <ModuleBase_WidgetDoubleValue.h>
 #include <ModuleBase_WidgetBoolValue.h>
+#include <ModuleBase_WidgetPoint2dDistance.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -59,7 +61,11 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
     //Create a widget (doublevalue, groupbox, toolbox, etc.
     QWidget* aWidget = createWidgetByType(aWdgType, theParent);
     if (aWidget) {
-      aWidgetLay->addWidget(aWidget);
+      if (!isInternalWidget(aWdgType)) {
+        aWidgetLay->addWidget(aWidget);
+      }
+      else
+        aWidget->setVisible(false);
     }
     if (myWidgetApi->isContainerWidget()) {
       //if current widget is groupbox (container) process it's children recursively
@@ -123,6 +129,12 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
   } else if (theType == WDG_FEATURE_SELECTOR) {
     result = featureSelectorControl(theParent);
 
+  } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
+    result = doubleValueEditor(theParent);
+  
+  } else if (theType == WDG_POINT2D_DISTANCE) {
+    result = point2dDistanceControl(theParent);
+
   }
   else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
     result = createContainer(theType, theParent);
@@ -175,11 +187,28 @@ QWidget* ModuleBase_WidgetFactory::featureSelectorControl(QWidget* theParent)
   return aWidget->getControl();
 }
 
+QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
+{
+  ModuleBase_WidgetEditor* aWidget = new ModuleBase_WidgetEditor(theParent, myWidgetApi);
+  myModelWidgets.append(aWidget);
+  return 0;
+}
+
 QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
 {
   return QString::fromStdString(theStdString);
 }
 
+bool ModuleBase_WidgetFactory::isInternalWidget(const std::string& theType)
+{
+  std::string prop = myWidgetApi->getProperty(FEATURE_INTERNAL);
+
+  std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);
+  if(prop.empty() || prop == "false" || prop == "0") {
+    return false;
+  }
+  return true; 
+}
 
 QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
 {
@@ -195,4 +224,13 @@ QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
   myModelWidgets.append(aBoolWgt);
 
   return aBoolWgt->getControl();
+}
+
+
+QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent)
+{
+  ModuleBase_WidgetPoint2dDistance* aDistWgt = new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi);
+  myModelWidgets.append(aDistWgt);
+
+  return aDistWgt->getControl();
 }
\ No newline at end of file
index e2162872cdce5d040f655feff688a0e94aa03227..b29fba9eb6543470af9724e800c6dfb147410f09 100644 (file)
@@ -39,9 +39,16 @@ protected:
   QWidget* doubleSpinBoxControl(QWidget* theParent);
   QWidget* pointSelectorControl(QWidget* theParent);
   QWidget* featureSelectorControl(QWidget* theParent);
+  QWidget* doubleValueEditor(QWidget* theParent);
   QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
   QWidget* selectorControl(QWidget* theParent);
   QWidget* booleanControl(QWidget* theParent);
+  QWidget* point2dDistanceControl(QWidget* theParent);
+
+  /// Check whether the XML definition for the given type contains internal property
+  /// \param theType the widget type
+  /// \return the boolean result
+  bool isInternalWidget(const std::string& theType);
 
   QString qs(const std::string& theStdString) const;
 
index dd33700f02b0fd927fa947c9721e77864fe4daae..37ed734c03bc32deea16ecb277ca1e31e696518f 100644 (file)
@@ -50,6 +50,7 @@ bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
   //bool isBlocked = that->blockSignals(true);
   aRef->setFeature(myFeature);
+  theFeature->execute();
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
   //that->blockSignals(isBlocked);
 
index 7903c829333acd1615e8db23da85477f6b0fec7a..c13fb2d31803a99baa1830d497cc498d8bff0698 100644 (file)
@@ -30,6 +30,7 @@ ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent,
                                                    const Config_WidgetAPI* theData)
 : ModuleBase_ModelWidget(theParent, theData)
 {
+  myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
   myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)),
                              theParent);
   QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
@@ -73,6 +74,7 @@ ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
 
 void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
 {
+
   bool isBlocked = this->blockSignals(true);
   myXSpin->setValue(thePoint->x());
   myYSpin->setValue(thePoint->y());
@@ -133,3 +135,18 @@ bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent)
   }
   return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
 }
+
+void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+{
+  if (myOptionParam.length() == 0)
+    return;
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
+  if (aPoint) {
+    bool isBlocked = this->blockSignals(true);
+    myXSpin->setValue(aPoint->x());
+    this->blockSignals(isBlocked);
+    myYSpin->setValue(aPoint->y());
+  }
+}
index cf92afd3a020d43749965c6d497521599519ae97..255a3950c43bee860c65d9b6eee023d4d6fc8b70 100644 (file)
@@ -55,10 +55,14 @@ public:
   /// \param theEvent the processed event
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
+  void initFromPrevious(FeaturePtr theFeature);
+
 private:
   QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
   QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
   QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
+
+  std::string myOptionParam; /// Parameter name which has to be taken from previous feature
 };
 
 #endif
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp
new file mode 100644 (file)
index 0000000..7597fe1
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        ModuleBase_WidgetPoint2dDistance.h
+// Created:     23 June 2014
+// Author:      Vitaly Smetannikov
+
+#include "ModuleBase_WidgetPoint2dDistance.h"
+
+#include <GeomAPI_Pnt2d.h>
+#include <Config_WidgetAPI.h>
+#include <GeomDataAPI_Point2D.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <QDoubleSpinBox>
+
+ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData)
+  : ModuleBase_WidgetDoubleValue(theParent, theData)
+{
+  myFirstPntName = theData->getProperty("first_point");
+}
+
+ModuleBase_WidgetPoint2dDistance::~ModuleBase_WidgetPoint2dDistance()
+{
+}
+
+void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boost::shared_ptr<GeomAPI_Pnt2d>& thePnt)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                                              (aData->attribute(myFirstPntName));
+  double aRadius = thePnt->distance(aPoint->pnt());
+  AttributeDoublePtr aReal = aData->real(attributeID());
+  if (aReal && (aReal->value() != aRadius)) {
+    aReal->setValue(aRadius);
+    mySpinBox->setValue(aRadius);
+  }
+}
\ No newline at end of file
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h
new file mode 100644 (file)
index 0000000..a078b9b
--- /dev/null
@@ -0,0 +1,33 @@
+// File:        ModuleBase_WidgetPoint2dDistance.h
+// Created:     23 June 2014
+// Author:      Vitaly Smetannikov
+
+
+#ifndef ModuleBase_WidgetPoint2dDistance_H
+#define ModuleBase_WidgetPoint2dDistance_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_WidgetDoubleValue.h"
+
+class GeomAPI_Pnt2d;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetPoint2dDistance: public ModuleBase_WidgetDoubleValue
+{
+  Q_OBJECT
+public:
+  /// Constructor
+  /// \theParent the parent object
+  /// \theData the widget configuation. The attribute of the model widget is obtained from
+  ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData);
+
+  virtual ~ModuleBase_WidgetPoint2dDistance();
+
+  /// 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 boost::shared_ptr<GeomAPI_Pnt2d>& thePnt);
+
+private:
+  std::string myFirstPntName;
+};
+
+
+#endif
\ No newline at end of file
index a318a128085fe285a719288dcd83c9d7edcb1e1a..27c0e068903862ffdb2c2de754ff04e55ca0d09f 100644 (file)
@@ -23,6 +23,7 @@
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetPoint2D.h>
 #include <ModuleBase_WidgetFeature.h>
+#include <ModuleBase_WidgetPoint2dDistance.h>
 
 #include <XGUI_ViewerPrs.h>
 #include <XGUI_Constants.h>
@@ -53,8 +54,8 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
 
 bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
 {
-  return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND /*||
-         theId == SKETCH_CONSTRAINT_DISTANCE_KIND/*|| theId == SKETCH_CIRCLE_KIND ||
+  return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND ||
+         theId == SKETCH_CONSTRAINT_DISTANCE_KIND || theId == SKETCH_CIRCLE_KIND /*||
          theId == SKETCH_ARC_KIND*/;
 }
 
@@ -201,10 +202,9 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t
   myActiveWidget = theWidget;
 
   if (myInitFeature && myActiveWidget) {
-    // TODO: to be realized in the custom point selector. The last point values of the init feature
-    // should be to to the start point of a new feature
-    //myActiveWidget->init(myInitFeature);
-    //PartSet_FeatureLinePrs::setFeature(myInitFeature, SM_FirstPoint);
+    ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
+    if (aWgt)
+      aWgt->initFromPrevious(myInitFeature);
     myInitFeature = FeaturePtr();
     emit activateNextWidget(myActiveWidget);
   }
@@ -301,12 +301,19 @@ bool PartSet_OperationFeatureCreate::isPointWidget() const
 
 bool PartSet_OperationFeatureCreate::setWidgetPoint(double theX, double theY)
 {
+  boost::shared_ptr<GeomAPI_Pnt2d> aPoint(new GeomAPI_Pnt2d(theX, theY));
   ModuleBase_WidgetPoint2D* aWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
-  if (!aWidget)
-    return false;
-
-  aWidget->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
-  return true;
+  if (aWidget) {
+    aWidget->setPoint(aPoint);
+    return true;
+  } else {
+    ModuleBase_WidgetPoint2dDistance* aWgt = dynamic_cast<ModuleBase_WidgetPoint2dDistance*>(myActiveWidget);
+    if (aWgt) {
+      aWgt->setPoint(feature(), aPoint);
+      return true;
+    }
+  }
+  return false;
 }
 
 bool PartSet_OperationFeatureCreate::setWidgetFeature(const FeaturePtr& theFeature)
index b6ddb808aa950a4fa3b3a4d95fff1f15d2aad57f..599cb72e954d034d58537f0eb8dabf97ea51b4b2 100644 (file)
@@ -36,6 +36,24 @@ void SketchPlugin_ConstraintDistance::initAttributes()
 
 void SketchPlugin_ConstraintDistance::execute()
 {
+  boost::shared_ptr<ModelAPI_Data> aData = data();
+
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr_A = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr_B = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+
+  AttributeDoublePtr anAttribute =
+      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+
+  if (anAttr_A && anAttr_B && anAttribute->value() == 0)
+  {
+    FeaturePtr aFeature_A = anAttr_A->feature();
+    FeaturePtr aFeature_B = anAttr_B->feature();
+
+    double aValue = 40; // TODO
+    anAttribute->setValue(aValue);
+  }
 }
 
 Handle(AIS_InteractiveObject) SketchPlugin_ConstraintDistance::getAISShape(
index f1d354e4601378786820f5584759b0e6318e1ed6..dc6b959aa2f0eb423a1ddce9fdba71e1152d1f33 100644 (file)
@@ -9,12 +9,12 @@
         <point_selector id="PointCoordindates" title="Point" tooltip="Point"/>
       </feature>
       <feature id="SketchLine" title="Line" tooltip="Create a new line" icon=":icons/line.png">
-        <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
+        <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line" previous_feature_param="EndPoint"/>
         <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
       </feature>
       <feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon="">
         <point_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>
-        <doublevalue id="CircleRadius" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set Radius"/>
+        <point2ddistance id="CircleRadius" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set Radius"/>
       </feature>
       <feature id="SketchArc" title="Arc" tooltip="Create a new arc of a circle" icon="">
         <point_selector id="ArcCenter" title="Center" tooltip="Center of the arc"/>
       <feature id="SketchConstraintCoincidence" title="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
       <feature id="SketchConstraintDistance" title="Distance between objects" tooltip="Create constraint for the distance from a point to an object">
         <label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
-        <feature_selector id="ConstraintEntityA" keysequence="SketchPoint"/>
-        <feature_selector id="ConstraintEntityB" keysequence="SketchPoint"/>
-        <point_selector id="ConstraintFlyoutValuePnt" title="Flyout point" tooltip="Flyout"/>
-        <doublevalue id="ConstraintValue" label="Value:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Constraint value"/>
+        <feature_selector id="ConstraintEntityA" keysequence="SketchPoint" internal="1"/>
+        <feature_selector id="ConstraintEntityB" keysequence="SketchPoint" internal="1"/>
+        <point_selector id="ConstraintFlyoutValuePnt" title="Flyout point" tooltip="Flyout" internal="1"/>
+        <doublevalue_editor id="ConstraintValue" min="0" step="1.0" tooltip="Constraint value"/>
       </feature>
       <feature id="SketchConstraintLength" title="Length of a line" tooltip="Create constraint for the given length of a line segment">
         <label title="Select a line entity on which to calculate lenght" tooltip="Select a line entity on which to calculate lenght"/>
index d82244211d37b9134bcd0fe8da212552e87ac5b8..83de5b27d792671585cfa538f5340433a05686be 100644 (file)
@@ -92,6 +92,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
     for (; anIt != aLast; anIt++) {
       connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)),
               this, SIGNAL(keyReleased(const std::string&, QKeyEvent*)));
+
+      connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
+              this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
     }
     ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
     if (aLastWidget) {