]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 24 Jun 2014 08:48:36 +0000 (12:48 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 24 Jun 2014 08:48:36 +0000 (12:48 +0400)
Conflicts:
src/ModuleBase/ModuleBase_WidgetFactory.cpp

1  2 
src/Config/Config_Keywords.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/SketchPlugin/plugin-Sketch.xml

index 050a947fe275ad2068099dbfc55803f3169515c4,0d16ad4321ad648738a79fc89a13046f39e7b1b3..c9d705d551da19b2980e08176a27197f2ccce6cb
@@@ -31,8 -31,9 +31,10 @@@ const static char* WDG_SELECTOR = "sele
  
  //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* _ID = "id";
  //const static char* WORKBENCH_ID = "id";
  //const static char* GROUP_ID = "id";
Simple merge
index 89b82bef47bef6dc332a5c99967d79680a301d7e,1c372fd670b897986767d3b7caf24ce135fc50a9..4ce4f79aa40184b58b3acddbef5798f14d557017
@@@ -120,10 -120,11 +121,14 @@@ QWidget* ModuleBase_WidgetFactory::crea
    } else if (theType == WDG_POINT_SELECTOR) {
      result = pointSelectorControl(theParent);
  
-   } else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
+   } else if (theType == WDG_FEATURE_SELECTOR) {
+     result = featureSelectorControl(theParent);
 +  } else if (theType == WDG_POINT2D_DISTANCE) {
 +    result = point2dDistanceControl(theParent);
 +
+   }
+   else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
      result = createContainer(theType, theParent);
    }
  #ifdef _DEBUG
index 53ebdea46dc57df736fb19a5415f576b9c38579b,0000000000000000000000000000000000000000..7597fe126f3b86d447dfbb9ab18486cb5e46c751
mode 100644,000000..100644
--- /dev/null
@@@ -1,37 -1,0 +1,37 @@@
-   if (aReal && aReal->value() != mySpinBox->value()) {
 +// 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);
 +  }
 +}
index 0000000000000000000000000000000000000000,a318a128085fe285a719288dcd83c9d7edcb1e1a..afc823140cd60e077c05384086e463c865c87c34
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,319 +1,327 @@@
 -         theId == SKETCH_CONSTRAINT_DISTANCE_KIND/*|| theId == SKETCH_CIRCLE_KIND ||
+ // File:        PartSet_OperationFeatureCreate.h
+ // Created:     20 Apr 2014
+ // Author:      Natalia ERMOLAEVA
+ #include <PartSet_OperationFeatureCreate.h>
+ #include <PartSet_Tools.h>
+ #include <PartSet_OperationSketch.h>
+ #include <PartSet_FeaturePointPrs.h>
+ #include <PartSet_FeatureLinePrs.h>
+ #include <PartSet_FeatureCirclePrs.h>
+ #include <PartSet_FeatureArcPrs.h>
+ #include <SketchPlugin_Feature.h>
+ #include <SketchPlugin_Point.h>
+ #include <SketchPlugin_Line.h>
+ #include <SketchPlugin_Circle.h>
+ #include <SketchPlugin_Arc.h>
+ #include <SketchPlugin_ConstraintDistance.h>
+ #include <GeomAPI_Pnt2d.h>
+ #include <ModuleBase_OperationDescription.h>
+ #include <ModuleBase_WidgetPoint2D.h>
+ #include <ModuleBase_WidgetFeature.h>
++#include <ModuleBase_WidgetPoint2dDistance.h>
+ #include <XGUI_ViewerPrs.h>
+ #include <XGUI_Constants.h>
+ #include <V3d_View.hxx>
+ #include <TopoDS_Vertex.hxx>
+ #include <TopoDS.hxx>
+ #include <BRep_Tool.hxx>
+ #ifdef _DEBUG
+ #include <QDebug>
+ #endif
+ #include <QMouseEvent>
+ using namespace std;
+ PartSet_OperationFeatureCreate::PartSet_OperationFeatureCreate(const QString& theId,
+                                                                QObject* theParent,
+                                                                  FeaturePtr theFeature)
+ : PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myActiveWidget(0)
+ {
+ }
+ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
+ {
+ }
+ bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
+ {
+   return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND /*||
 -  if (!aWidget)
 -    return false;
 -
 -  aWidget->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
 -  return true;
++         theId == SKETCH_CONSTRAINT_DISTANCE_KIND*/ || theId == SKETCH_CIRCLE_KIND /*||
+          theId == SKETCH_ARC_KIND*/;
+ }
+ bool PartSet_OperationFeatureCreate::canBeCommitted() const
+ {
+   return !myActiveWidget;
+ }
+ bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperation) const
+ {
+   return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
+ }
+ std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theFeature) const
+ {
+   std::list<int> aModes;
+   if (theFeature != feature())
+     aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
+   return aModes;
+ }
+ void PartSet_OperationFeatureCreate::init(FeaturePtr theFeature,
+                                        const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                        const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+ {
+   if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+     return;
+   myInitFeature = theFeature;
+ }
+ FeaturePtr PartSet_OperationFeatureCreate::sketch() const
+ {
+   return mySketch;
+ }
+ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                 const std::list<XGUI_ViewerPrs>& theSelected,
+                                                 const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+ {
+   if (canBeCommitted())
+   {
+     // if the point creation is finished, the next mouse release should commit the modification
+     // the next release can happens by double click in the viewer
+     commit();
+     restartOperation(feature()->getKind(), feature());
+     return;
+   }
+   double aX, anY;
+   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+   if (theSelected.empty()) {
+     PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+   }
+   else {
+     XGUI_ViewerPrs aPrs = theSelected.front();
+     const TopoDS_Shape& aShape = aPrs.shape();
+     if (!aShape.IsNull()) // the point is selected
+     {
+       if (aShape.ShapeType() == TopAbs_VERTEX) {
+         const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+         if (!aVertex.IsNull()) {
+           aPoint = BRep_Tool::Pnt(aVertex);
+           PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+           PartSet_Tools::setConstraints(sketch(), feature(), myActiveWidget->attributeID(),
+                                         aX, anY);
+         }
+       }
+       else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
+       {
+         PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+         // move to selected line
+         if (feature()->getKind() == SKETCH_LINE_KIND) {
+           //boost::shared_ptr<PartSet_FeatureLinePrs> aLinePrs =
+           //                       boost::dynamic_pointer_cast<PartSet_FeatureLinePrs>(myFeaturePrs);
+           //if (aLinePrs) {
+           //  FeaturePtr aFeature = aPrs.feature();
+             //aLinePrs->projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
+           //}
+         }
+       }
+     }
+   }
+   /*if (feature()->getKind() == SKETCH_ARC_KIND) {
+     boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
+                               boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
+     if (anArcPrs) {
+       anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
+     }
+   }*/
+   bool isApplyed = false;
+   if (isPointWidget())
+     isApplyed = setWidgetPoint(aX, anY);
+   else {
+     if (!theSelected.empty()) {
+       XGUI_ViewerPrs aPrs = theSelected.front();
+       FeaturePtr aFeature = aPrs.feature();
+       if (aFeature)
+         isApplyed = setWidgetFeature(aFeature);
+     }
+   }
+   flushUpdated();
+   emit activateNextWidget(myActiveWidget);
+ }
+ void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+ {
+   if (canBeCommitted()) {
+     commit();
+     restartOperation(feature()->getKind(), feature());
+   }
+   else {
+     double aX, anY;
+     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+     PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+     /*if (myPointSelectionMode == SM_ThirdPoint) {
+       if (feature()->getKind() == SKETCH_ARC_KIND) {
+         boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
+                                 boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
+         if (anArcPrs) {
+           anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
+         }
+       }
+     }*/
+     setWidgetPoint(aX, anY);
+     flushUpdated();
+   }
+ }
+ void PartSet_OperationFeatureCreate::keyReleased(std::string theName, QKeyEvent* theEvent)
+ {
+   int aKeyType = theEvent->key();
+   // the second point should be activated by any modification in the property panel
+   if (!theName.empty())
+   {
+     //setPointSelectionMode(myFeaturePrs->getNextMode(theName), false);
+   }
+   keyReleased(theEvent->key());
+ }
+ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+ {
+   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);
+     myInitFeature = FeaturePtr();
+     emit activateNextWidget(myActiveWidget);
+   }
+ }
+ void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
+ {
+   switch (theKey) {
+     case Qt::Key_Return: {
+       if (canBeCommitted())
+       {
+         commit();
+         // it start a new line creation at a free point
+         restartOperation(feature()->getKind(), FeaturePtr());
+       }
+     }
+     break;
+     case Qt::Key_Escape: {
+       if (canBeCommitted())
+       {
+         commit();
+       }
+       else
+       {
+         abort();
+       }
+     }
+     default:
+     break;
+   }
+ }
+ void PartSet_OperationFeatureCreate::startOperation()
+ {
+   PartSet_OperationSketchBase::startOperation();
+   //setPointSelectionMode(!myInitFeature ? SM_FirstPoint : SM_SecondPoint);
+   emit multiSelectionEnabled(false);
+ }
+ void PartSet_OperationFeatureCreate::abortOperation()
+ {
+   emit featureConstructed(feature(), FM_Hide);
+   PartSet_OperationSketchBase::abortOperation();
+ }
+ void PartSet_OperationFeatureCreate::stopOperation()
+ {
+   PartSet_OperationSketchBase::stopOperation();
+   emit multiSelectionEnabled(true);
+ }
+ void PartSet_OperationFeatureCreate::afterCommitOperation()
+ {
+   PartSet_OperationSketchBase::afterCommitOperation();  
+   emit featureConstructed(feature(), FM_Deactivation);
+ }
+ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMessage)
+ {
+   FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false);
+   if (sketch()) {
+     boost::shared_ptr<SketchPlugin_Feature> aFeature = 
+                            boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
+     aFeature->addSub(aNewFeature);
+   }
+   //myFeaturePrs->init(aNewFeature);
+   //myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
+   emit featureConstructed(aNewFeature, FM_Activation);
+   if (theFlushMessage)
+     flushCreated();
+   return aNewFeature;
+ }
+ /*void PartSet_OperationFeatureCreate::setPointSelectionMode(const PartSet_SelectionMode& theMode,
+                                                            const bool isToEmitSignal)
+ {
+   myPointSelectionMode = theMode;
+   if (isToEmitSignal) {
+     std::string aName = myFeaturePrs->getAttribute(theMode);
+     if (aName.empty() && theMode == SM_DonePoint) {
+       aName = XGUI::PROP_PANEL_OK;
+     }
+     emit focusActivated(aName);
+   }
+ }*/
+ bool PartSet_OperationFeatureCreate::isPointWidget() const
+ {
+   return dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
+ }
+ 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) {
++    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)
+ {
+   ModuleBase_WidgetFeature* aWidget = dynamic_cast<ModuleBase_WidgetFeature*>(myActiveWidget);
+   if (!aWidget)
+     return false;
+   return aWidget->setFeature(theFeature);
+ }
Simple merge