]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
AIS presentation for result is created
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 22 Oct 2014 08:05:22 +0000 (12:05 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 22 Oct 2014 08:05:22 +0000 (12:05 +0400)
src/FeaturesPlugin/extrusion_widget.xml
src/GeomAPI/GeomAPI_Wire.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_ResultPrs.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_ResultPrs.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/XGUI/XGUI_Displayer.cpp

index fee9e00dfb54a701d10cba2ef05713e189c03842..c7c5f4bdd90bebae461edbd3873fae7ace5471a5 100644 (file)
@@ -4,10 +4,10 @@
     icon=":icons/sketch.png" 
     tooltip="Select a face for extrusion"
     activate="true"
-    shape_types="face wire edge"
+    shape_types="face"
     use_subshapes="true"
   />
-  <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="0" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
+  <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="1" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
     <validator id="GeomValidators_Positive"/>
   </doublevalue>
   <boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
index de849ef9391376b870c22321976f9c6d7e783d1c..4bc0e0cd9060ee1eb577f51c6d9505514adcffb7 100644 (file)
@@ -5,8 +5,10 @@
 #ifndef GEOMAPI_WIRE_H_
 #define GEOMAPI_WIRE_H_
 
-#include <GeomAPI.h>
-#include <GeomAPI_Edge.h>
+#include "GeomAPI.h"
+#include "GeomAPI_Edge.h"
+#include "GeomAPI_Pnt.h"
+#include "GeomAPI_Dir.h"
 
 #include <boost/smart_ptr/shared_ptr.hpp>
 
@@ -37,6 +39,30 @@ class GEOMAPI_EXPORT GeomAPI_Wire : public GeomAPI_Shape
   void addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge);
   std::list<boost::shared_ptr<GeomAPI_Shape> > getEdges();
 
+  /// Returns True if the wire is defined in a plane
+  bool hasPlane() const { return myOrigin && myNorm && myDirX && myDirY; }
+
+  /// Set/Get origin point
+  void setOrigin(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin) { myOrigin = theOrigin; }
+  boost::shared_ptr<GeomAPI_Pnt> origin() const { return myOrigin; }
+
+  /// Set/Get X direction vector
+  void setDirX(const boost::shared_ptr<GeomAPI_Dir>& theDirX) { myDirX = theDirX; }
+  boost::shared_ptr<GeomAPI_Dir> dirX() const { return myDirX; }
+
+  /// Set/Get Y direction vector
+  void setDirY(const boost::shared_ptr<GeomAPI_Dir>& theDirY) { myDirY = theDirY; }
+  boost::shared_ptr<GeomAPI_Dir> dirY() const { return myDirY; }
+
+  /// Set/Get Normal direction vector
+  void setNorm(const boost::shared_ptr<GeomAPI_Dir>& theNorm) { myNorm = theNorm; }
+  boost::shared_ptr<GeomAPI_Dir> norm() const { return myNorm; }
+
+private:
+  boost::shared_ptr<GeomAPI_Pnt> myOrigin;
+  boost::shared_ptr<GeomAPI_Dir> myDirX;
+  boost::shared_ptr<GeomAPI_Dir> myDirY;
+  boost::shared_ptr<GeomAPI_Dir> myNorm;
 };
 
 #endif
index 7641722e4312b0bad49b53cc8c32ce30f3cc9454..ddf454e2c6a816cf620a27716dd3c64492265ca2 100644 (file)
@@ -33,6 +33,7 @@ SET(PROJECT_HEADERS
        ModuleBase_WidgetLineEdit.h
        ModuleBase_WidgetMultiSelector.h
        ModuleBase_ViewerFilters.h
+       ModuleBase_ResultPrs.h
 )
 
 SET(PROJECT_SOURCES
@@ -59,12 +60,14 @@ SET(PROJECT_SOURCES
     ModuleBase_WidgetLineEdit.cpp
        ModuleBase_WidgetMultiSelector.cpp
        ModuleBase_ViewerFilters.cpp
+       ModuleBase_ResultPrs.cpp
 )
 
 SET(PROJECT_LIBRARIES
     Config
     ModelAPI
        GeomAPI
+       GeomAlgoAPI
     ${QT_LIBRARIES}
        ${CAS_VIEWER}
        ${CAS_KERNEL}
@@ -89,6 +92,7 @@ INCLUDE_DIRECTORIES(
     ${CMAKE_SOURCE_DIR}/src/ModelAPI
     ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
     ${CMAKE_SOURCE_DIR}/src/GeomAPI
+    ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI
 )
 
 ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${CAS_DEFINITIONS})
diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp
new file mode 100644 (file)
index 0000000..a1ca0bd
--- /dev/null
@@ -0,0 +1,74 @@
+// File:        ModuleBase_ResultPrs.cpp
+// Created:     21 October 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "ModuleBase_ResultPrs.h"
+
+#include <ModelAPI_Tools.h>
+#include <GeomAPI_Wire.h>
+#include <GeomAlgoAPI_SketchBuilder.h>
+
+#include <BRep_Builder.hxx>
+#include <AIS_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_ResultPrs, AIS_Shape);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, AIS_Shape);
+
+ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
+  : AIS_Shape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
+{
+  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
+  boost::shared_ptr<GeomAPI_Wire> aWirePtr = 
+    boost::dynamic_pointer_cast<GeomAPI_Wire>(aShapePtr);
+  if (aWirePtr) {
+    if (aWirePtr->hasPlane() ) {
+      // If this is a wire with plane defined thin it is a sketch-like object
+      // It must have invisible faces
+      std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+      GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
+        aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, aFaces);
+
+      BRep_Builder aBuilder;
+      TopoDS_Shape aShape = aWirePtr->impl<TopoDS_Shape>();
+      std::list<boost::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
+      for (aIt = aFaces.cbegin(); aIt != aFaces.cend(); ++aIt) {
+        TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
+        aBuilder.Add(aShape, aFace);
+      }
+      Set(aShape);
+      myIsSketchMode = true;
+      // Define number of ISO lines
+      //Handle(AIS_Drawer) aDrawer = Attributes();
+      //Attributes()->SetIsoOnPlane(Standard_False);
+      //SetAttributes(aDrawer);
+    } else {
+      Set(aWirePtr->impl<TopoDS_Shape>());
+    }
+  } else {
+    Set(aShapePtr->impl<TopoDS_Shape>());
+  }
+}
+
+
+Standard_Boolean ModuleBase_ResultPrs::AcceptDisplayMode(const Standard_Integer theMode) const
+{
+  if (myIsSketchMode) {
+    return theMode == 0;
+  }
+  return AIS_Shape::AcceptDisplayMode(theMode);
+}
+
+void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                   const Handle(Prs3d_Presentation)& thePresentation, 
+                                   const Standard_Integer theMode)
+{
+  if (myIsSketchMode) {
+    Handle(AIS_Drawer) aDrawer = Attributes();
+    aDrawer->SetIsoOnPlane(Standard_False);
+    aDrawer->UIsoAspect()->SetNumber(0);
+    aDrawer->VIsoAspect()->SetNumber(0);
+    SetAttributes(aDrawer);
+  }
+  AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+}
diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h
new file mode 100644 (file)
index 0000000..068cffe
--- /dev/null
@@ -0,0 +1,38 @@
+// File:        ModuleBase_ResultPrs.h
+// Created:     21 October 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_ResultPrs_H
+#define ModuleBase_ResultPrs_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Result.h>
+
+#include <AIS_Shape.hxx>
+#include <Standard_DefineHandle.hxx>
+
+DEFINE_STANDARD_HANDLE(ModuleBase_ResultPrs, AIS_Shape)
+
+class ModuleBase_ResultPrs: public AIS_Shape
+{
+public:
+  Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
+
+  Standard_EXPORT ResultPtr getResult() const { return myResult; }
+
+  Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const;
+
+  DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs)
+protected:
+  void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+    const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+
+private:
+  ResultPtr myResult;
+
+  bool myIsSketchMode;
+};
+
+
+#endif
\ No newline at end of file
index a8fef3263d7e4a5b3c3922a851e92dff80db7c0b..19715af301878f9e0bc47cb25cebcef8a7071d07 100644 (file)
@@ -93,6 +93,11 @@ void SketchPlugin_Sketch::execute()
   for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) {
     aBigWire->addEdge(*aShapeIt);
   }
+  aBigWire->setOrigin(anOrigin->pnt());
+  aBigWire->setDirX(aDirX->dir());
+  aBigWire->setDirY(aDirY->dir());
+  aBigWire->setNorm(aNorm->dir());
+
 //  GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
 //                                         aFeaturesPreview, aLoops, aWires);
   boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
index 8e0f38400d48cf1f6ece06010e3138a16ad6b881..d281f86f08a1578ecea62c8aab33b82ee14ff660 100644 (file)
@@ -12,6 +12,8 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Tools.h>
 
+#include <ModuleBase_ResultPrs.h>
+
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_IPresentable.h>
 
@@ -59,7 +61,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
         boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
         if (aShapePtr) {
           anAIS = AISObjectPtr(new GeomAPI_AISObject());
-          anAIS->createShape(aShapePtr);
+          anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult)));
+          //anAIS->createShape(aShapePtr);
           isShading = true;
         }
       }