]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Fri, 8 Aug 2014 06:39:24 +0000 (10:39 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 8 Aug 2014 06:39:24 +0000 (10:39 +0400)
116 files changed:
CMakeCommon/FindSUIT.cmake [new file with mode: 0644]
CMakeCommon/FindSalome.cmake
CMakeLists.txt
msvc10_env.bat
src/Events/Events_LongOp.cpp
src/Events/Events_LongOp.h
src/GeomAPI/GeomAPI_Shape.h
src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp
src/Model/CMakeLists.txt
src/Model/Model_Document.cpp
src/Model/Model_ResultValidators.cpp [new file with mode: 0644]
src/Model/Model_ResultValidators.h [new file with mode: 0644]
src/Model/Model_Update.cpp
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeValidator.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_ResultValidator.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_Tools.cpp [new file with mode: 0644]
src/ModelAPI/ModelAPI_Tools.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_Validator.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IOperation.cpp
src/ModuleBase/ModuleBase_IOperation.h
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_ResultValidators.cpp
src/ModuleBase/ModuleBase_ResultValidators.h
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeature.h
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_WidgetSketchLabel.h
src/PyConsole/CMakeLists.txt [deleted file]
src/PyConsole/PyConsole.h [deleted file]
src/PyConsole/PyConsole_Console.cpp [deleted file]
src/PyConsole/PyConsole_Console.h [deleted file]
src/PyConsole/PyConsole_Editor.cpp [deleted file]
src/PyConsole/PyConsole_Editor.h [deleted file]
src/PyConsole/PyConsole_EnhEditor.cpp [deleted file]
src/PyConsole/PyConsole_EnhEditor.h [deleted file]
src/PyConsole/PyConsole_EnhInterp.cpp [deleted file]
src/PyConsole/PyConsole_EnhInterp.h [deleted file]
src/PyConsole/PyConsole_Event.cpp [deleted file]
src/PyConsole/PyConsole_Event.h [deleted file]
src/PyConsole/PyConsole_Interp.cpp [deleted file]
src/PyConsole/PyConsole_Interp.h [deleted file]
src/PyConsole/PyConsole_Request.cpp [deleted file]
src/PyConsole/PyConsole_Request.h [deleted file]
src/PyEvent/CMakeLists.txt [deleted file]
src/PyEvent/PyEvent.h [deleted file]
src/PyEvent/PyEvent_Event.cpp [deleted file]
src/PyEvent/PyEvent_Event.h [deleted file]
src/PyEvent/PyEvent_EventFilter.cpp [deleted file]
src/PyEvent/PyEvent_EventFilter.h [deleted file]
src/PyInterp/CMakeLists.txt [deleted file]
src/PyInterp/PyInterp.h [deleted file]
src/PyInterp/PyInterp_Dispatcher.cpp [deleted file]
src/PyInterp/PyInterp_Dispatcher.h [deleted file]
src/PyInterp/PyInterp_Event.cpp [deleted file]
src/PyInterp/PyInterp_Event.h [deleted file]
src/PyInterp/PyInterp_Interp.cpp [deleted file]
src/PyInterp/PyInterp_Interp.h [deleted file]
src/PyInterp/PyInterp_Request.cpp [deleted file]
src/PyInterp/PyInterp_Request.h [deleted file]
src/PyInterp/PyInterp_Watcher.h [deleted file]
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/SketchPlugin_Validators.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Validators.h [new file with mode: 0644]
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Solver.cpp
src/XGUI/CMakeLists.txt
src/XGUI/NewGeom.xml [new file with mode: 0644]
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_ViewPort.cpp
src/XGUI/XGUI_ViewPort.h
src/XGUI/XGUI_ViewWindow.cpp
src/XGUI/XGUI_ViewWindow.h
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

diff --git a/CMakeCommon/FindSUIT.cmake b/CMakeCommon/FindSUIT.cmake
new file mode 100644 (file)
index 0000000..54940d7
--- /dev/null
@@ -0,0 +1,14 @@
+
+SET(SUIT_DIR $ENV{SUIT_DIR} CACHE PATH "Path to the SUIT libraries")
+IF(EXISTS ${SUIT_DIR})
+       MESSAGE("-- SUIT found at " ${SUIT_DIR})
+
+       FIND_LIBRARY(Event Event ${SUIT_DIR}/lib)
+       FIND_LIBRARY(PyConsole PyConsole ${SUIT_DIR}/lib)
+       FIND_LIBRARY(PyInterp PyInterp ${SUIT_DIR}/lib)
+       FIND_LIBRARY(qtx qtx ${SUIT_DIR}/lib)
+       FIND_LIBRARY(suit suit ${SUIT_DIR}/lib)
+
+       SET(SUIT_INCLUDE ${SUIT_DIR}/include)
+       
+ENDIF(EXISTS ${SUIT_DIR})
index 5b4ba143f3f4c8f2a1d50a3b2c810d94b08aca84..114b1e745b711bb943f25d9ed3a7c6f5e60fac17 100644 (file)
@@ -2,6 +2,7 @@
 
 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL directory")
 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI directory")
+SET(HAVE_SALOME NO)
 IF(EXISTS ${GUI_ROOT_DIR})
        MESSAGE("-- SALOME found at " ${GUI_ROOT_DIR})
        SET(HAVE_SALOME YES)
index b4b8c4783a1dd76efa676f1c77feceb2adea0110..de2256284b03851b30e355ef5d298aba6f9b0981 100644 (file)
@@ -12,6 +12,10 @@ INCLUDE(FindSalome)
 INCLUDE(FindSolveSpace)
 INCLUDE(FindCAS)
 
+IF(NOT ${HAVE_SALOME})
+       INCLUDE(FindSUIT)
+ENDIF(NOT ${HAVE_SALOME})
+
 IF(UNIX)
   IF(CMAKE_COMPILER_IS_GNUCC)
     #C++11 is not supported on some platforms, disable it 
@@ -53,9 +57,6 @@ ADD_SUBDIRECTORY (src/SketchPlugin)
 ADD_SUBDIRECTORY (src/SketchSolver)
 ADD_SUBDIRECTORY (src/ModuleBase)
 ADD_SUBDIRECTORY (src/PartSet)
-ADD_SUBDIRECTORY (src/PyConsole)
-ADD_SUBDIRECTORY (src/PyEvent)
-ADD_SUBDIRECTORY (src/PyInterp)
 ADD_SUBDIRECTORY (src/XGUI)
 ADD_SUBDIRECTORY (src/GeomApp)
 
index ab394bec9c288d1645fb5525d5d5263a20495968..41f21666cf7153e110bd6cd26e77ee086758fe78 100644 (file)
@@ -135,6 +135,13 @@ set PATH=%CMAKEDIR%\bin;%PATH%
 @SET PATH=%ROOT_DIR%\install\plugins;%ROOT_DIR%\install\bin;%PATH%
 @SET PYTHONPATH=%ROOT_DIR%\install\swig;%PYTHONPATH%
 
+@REM -------------------------
+@REM SUIT
+@SET SUIT_DIR=%PDIR%\suit
+@SET PATH=%SUIT_DIR%\bin;%PATH%
+@REM -------------------------
+
+
 @REM -------------------------
 if "%GUI_ROOT_DIR%" == "" (
   @SET GUI_ROOT_DIR=%ROOT_DIR%\SALOME\GUI\DEBUG\GUI_INSTALL
@@ -142,6 +149,8 @@ if "%GUI_ROOT_DIR%" == "" (
 @REM -------------------------
 
 
+@SET NewGeomResources=%ROOT_DIR%\install\resources
+
 rem -------- Visual Studio --------------------
 rem Detect Visual Studio (either commercial or Express edition)
 if "%VS100COMNTOOLS%" == "" (
index ebfeb5677f764ef9826d85d8e4d68c6cfa639389..647d2bb4c545d576631a0420a42889e92f0eb661 100644 (file)
@@ -10,7 +10,7 @@
 std::map<void*, int> MY_SENDERS;
 
 Events_LongOp::Events_LongOp(void* theSender)
- : Events_Message(Events_LongOp::errorID(), theSender)
+ : Events_Message(Events_LongOp::eventID(), theSender)
 {
 }
 
@@ -18,7 +18,7 @@ Events_LongOp::~Events_LongOp()
 {
 }
 
-Events_ID Events_LongOp::errorID()
+Events_ID Events_LongOp::eventID()
 {
   Events_Loop* aLoop = Events_Loop::loop();
   return aLoop->eventByName("LongOperation");
@@ -26,14 +26,16 @@ Events_ID Events_LongOp::errorID()
 
 void Events_LongOp::start(void* theSender)
 {
-  if (MY_SENDERS.empty()) {
-    Events_LongOp anError(theSender);
-    Events_Loop::loop()->send(anError);
-  }
+  bool toSend = MY_SENDERS.empty();
   if (MY_SENDERS.find(theSender) == MY_SENDERS.end())
     MY_SENDERS[theSender] = 1;
   else 
     MY_SENDERS[theSender]++;
+
+  if (toSend) {
+    Events_LongOp anEvent(theSender);
+    Events_Loop::loop()->send(anEvent);
+  }
 }
 
 void Events_LongOp::end(void* theSender)
@@ -44,8 +46,8 @@ void Events_LongOp::end(void* theSender)
     else MY_SENDERS[theSender] = aCount - 1;
   }
   if (MY_SENDERS.empty()) {
-    Events_LongOp anError(theSender);
-    Events_Loop::loop()->send(anError);
+    Events_LongOp anEvent(theSender);
+    Events_Loop::loop()->send(anEvent);
   }
 }
 
index bc698ac502c32b05f680962dbc7ad34d3d8557fa..dfb06cae444ec8ad1dabc843851a421589ca72a2 100644 (file)
@@ -17,7 +17,7 @@ class EVENTS_EXPORT Events_LongOp: public Events_Message
 public:
   virtual ~Events_LongOp();
   /// Returns the identifier of this event
-  static Events_ID errorID();
+  static Events_ID eventID();
   /// Starts the long operation
   static void start(void* theSender = 0);
   /// Stops the long operation
index 7c058d5b31fe9243460f7ec5a0fc24e864caba3b..4b526589f22c85d9c032bfb06fa4e879c19d9b97 100644 (file)
@@ -28,6 +28,7 @@ public:
 
   /// Returns whether the shape is an edge
   virtual bool isEdge() const;
+
 };
 
 #endif
index c5c8588d401e552013b22a2fd761afdb11da84f7..4cd345b868b298f5fe861f6e962325c944a884b9 100644 (file)
@@ -157,6 +157,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
   gp_Dir aNextDir;
   while (aMapVE.Extent() > 0)
   {
+    if (aCurVertex.IsNull())
+      return;
     findNextVertex(aCurVertex, aMapVE, aCurDir, aCurNorm, aNextVertex, aBindingEdge, aNextDir);
     aCurNorm = aNorm;
 
@@ -210,7 +212,7 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
       if (!aPatch.IsNull())
       {
         boost::shared_ptr<GeomAPI_Shape> aFace(new GeomAPI_Shape);
-        aFace->setImpl(new TopoDS_Shape(aPatch));
+        aFace->setImpl(new TopoDS_Face(aPatch));
         theResultFaces.push_back(aFace);
       }
       // push the edges used in the loop to the map
@@ -344,6 +346,8 @@ void GeomAlgoAPI_SketchBuilder::fixIntersections(
     for (++anIter2; anIter2 != theFaces.end(); anIter2++)
     {
       const TopoDS_Face& aF1 = (*anIter1)->impl<TopoDS_Face>();
+      if (aF1.ShapeType() != TopAbs_FACE) // TODO: MPV - this workaround must be fixed later by AZV, now it just removes crash
+        continue;
       TopExp_Explorer aVert2((*anIter2)->impl<TopoDS_Shape>(), TopAbs_VERTEX);
       for ( ; aVert2.More(); aVert2.Next())
       {
@@ -355,6 +359,8 @@ void GeomAlgoAPI_SketchBuilder::fixIntersections(
       if (aVert2.More())
       { // second shape is not inside first, change the shapes order and repeat comparision
         const TopoDS_Face& aF2 = (*anIter2)->impl<TopoDS_Face>();
+        if (aF2.ShapeType() != TopAbs_FACE) // TODO: MPV - this workaround must be fixed later by AZV, now it just removes crash
+          continue;
         TopExp_Explorer aVert1((*anIter1)->impl<TopoDS_Shape>(), TopAbs_VERTEX);
         for ( ; aVert1.More(); aVert1.Next())
         {
index fdfb04ccf2ed7cc77bbac2f32f32d58fb3ea0dc5..45c3db89032839e88423b3c387d15ec3f321ad70 100644 (file)
@@ -18,6 +18,7 @@ SET(PROJECT_HEADERS
     Model_ResultBody.h
     Model_ResultConstruction.h
     Model_ResultPart.h
+       Model_ResultValidators.h
 )
 
 SET(PROJECT_SOURCES
@@ -37,6 +38,7 @@ SET(PROJECT_SOURCES
     Model_ResultBody.cpp
     Model_ResultConstruction.cpp
     Model_ResultPart.cpp
+       Model_ResultValidators.cpp
 )
 
 SET(PROJECT_LIBRARIES
index a4c9729ae4594613d8a745d1c6e0b14a42efc013..9d8cb9b8a6ff1f58c0c29a0afcbe47237f224944 100644 (file)
@@ -644,6 +644,11 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
       FeaturePtr aNewObj = ModelAPI_PluginManager::get()->createFeature(
         TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
         .ToCString());
+      if (!aNewObj) { // somethig is wrong, most probably, the opened document has invalid structure
+        Events_Error::send("Invalid type of object in the document");
+        aLabIter.Value()->Label().ForgetAllAttributes();
+        continue;
+      }
       // this must be before "setData" to redo the sketch line correctly
       myObjs.Bind(aFeatureLabel, aNewObj);
       aNewFeatures.insert(aNewObj);
diff --git a/src/Model/Model_ResultValidators.cpp b/src/Model/Model_ResultValidators.cpp
new file mode 100644 (file)
index 0000000..75b603f
--- /dev/null
@@ -0,0 +1,84 @@
+// File:        Model_ResultValidators.cpp
+// Created:     23 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "Model_ResultValidators.h"
+
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Tools.h>
+#include <GeomAPI_Shape.h>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+
+ResultPtr result(const ObjectPtr theObject)
+{
+  return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+}
+
+TopoDS_Shape shape(ResultPtr theResult)
+{
+  boost::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(theResult);
+  if (aShape)
+    return aShape->impl<TopoDS_Shape>();
+  return TopoDS_Shape();
+}
+
+
+bool Model_ResultPointValidator::isValid(const ObjectPtr theObject) const
+{
+  ResultPtr aResult = result(theObject);
+  if (!aResult)
+    return false;
+  TopoDS_Shape aShape = shape(aResult);
+  if (aShape.IsNull())
+    return false;
+
+  return aShape.ShapeType() == TopAbs_VERTEX;
+}
+
+
+bool Model_ResultLineValidator::isValid(const ObjectPtr theObject) const
+{
+  ResultPtr aResult = result(theObject);
+  if (!aResult)
+    return false;
+  TopoDS_Shape aShape = shape(aResult);
+  if (aShape.IsNull())
+    return false;
+
+  if (aShape.ShapeType() == TopAbs_EDGE) {
+    TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+    Standard_Real aStart, aEnd;
+    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+    GeomAdaptor_Curve aAdaptor(aCurve);
+    return aAdaptor.GetType() == GeomAbs_Line;
+  }
+  return false;
+}
+
+
+bool Model_ResultArcValidator::isValid(const ObjectPtr theObject) const
+{
+  ResultPtr aResult = result(theObject);
+  if (!aResult)
+    return false;
+  TopoDS_Shape aShape = shape(aResult);
+  if (aShape.IsNull())
+    return false;
+
+  TopAbs_ShapeEnum aa = aShape.ShapeType();
+  if (aShape.ShapeType() == TopAbs_EDGE) {
+    TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+    Standard_Real aStart, aEnd;
+    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+    GeomAdaptor_Curve aAdaptor(aCurve);
+    return aAdaptor.GetType() == GeomAbs_Circle;
+  }
+  return false;
+}
+
diff --git a/src/Model/Model_ResultValidators.h b/src/Model/Model_ResultValidators.h
new file mode 100644 (file)
index 0000000..c76cd30
--- /dev/null
@@ -0,0 +1,30 @@
+// File:        Model_ResultValidators.h
+// Created:     23 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef Model_ResultValidators_H
+#define Model_ResultValidators_H
+
+#include "Model.h"
+#include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_Object.h>
+
+class Model_ResultPointValidator: public ModelAPI_ResultValidator
+{
+public:
+  MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class Model_ResultLineValidator: public ModelAPI_ResultValidator
+{
+public:
+  MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class Model_ResultArcValidator: public ModelAPI_ResultValidator
+{
+public:
+  MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+#endif
\ No newline at end of file
index af5407cafedba7467c26761d5fc88277ca062f14..f728bb60e23a9861bbbd65daa9df0e37c6df15aa 100644 (file)
@@ -26,7 +26,7 @@ Model_Update::Model_Update()
 void Model_Update::processEvent(const Events_Message* theMessage)
 {
   if (isExecuted) return; // nothing to do: it is executed now
-  Events_LongOp::start(this);
+  //Events_LongOp::start(this);
   isExecuted = true;
   const ModelAPI_ObjectUpdatedMessage* aMsg = 
     dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
@@ -52,7 +52,7 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   // flush
   static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   Events_Loop::loop()->flush(EVENT_DISP);
-  Events_LongOp::end(this);
+  //Events_LongOp::end(this);
   isExecuted = false;
 }
 
@@ -100,6 +100,8 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
         myUpdated[aRes] = true;
         ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
       }
+      // to redisplay "presentable" feature (for ex. distance constraint)
+      ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
     } else { // returns also true is results were updated: for sketch that refers to sub-features but results of sub-features were changed
       const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
       std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
index 8ca1bf09f25be9dca2b659dff978f8cad556c58f..19e9f56dda46f684efb290f3237d36526944f6f7 100644 (file)
 // Author:      Mikhail PONIKAROV
 
 #include <Model_Validator.h>
+#include <Model_ResultValidators.h>
 #include <ModelAPI_Feature.h>
 #include <Events_Error.h>
 
-using namespace std;
-
 void Model_ValidatorsFactory::registerValidator(
-  const string& theID, ModelAPI_Validator* theValidator)
+  const std::string& theID, ModelAPI_Validator* theValidator)
 {
   if (myIDs.find(theID) != myIDs.end()) {
-    Events_Error::send(string("Validator ") + theID + " is already registered");
+    Events_Error::send(std::string("Validator ") + theID + " is already registered");
   } else {
     myIDs[theID] = theValidator;
   }
 }
 
-void Model_ValidatorsFactory::assignValidator(const string& theID, const string& theFeatureID)
+void Model_ValidatorsFactory::assignValidator(
+  const std::string& theID, const std::string& theFeatureID)
 {
-  bool isError = false;
-  map<string, ModelAPI_Validator*>::iterator aVal = myIDs.find(theID);
-  if (aVal == myIDs.end()) {
-    Events_Error::send(
-      string("Validator ") + theID + " for feature " + theFeatureID + " was not registered");
-    isError = true;
-  }
-  if (myFeatures.find(theFeatureID) != myFeatures.end()) {
-    // TODO: it is called many times now because of not-optimized XML reader
-      //Events_Error::send(
-      //  string("Validator for feature ") + theFeatureID + " is already registered");
-    isError = true;
+  if (myFeatures.find(theFeatureID) == myFeatures.end()) {
+    myFeatures[theFeatureID] = std::set<std::string>();
   }
-  if (!isError)
-    myFeatures[theFeatureID] = aVal->second;
+  myFeatures[theFeatureID].insert(theID);
 }
 
-void Model_ValidatorsFactory::assignValidator(const string& theID, 
-  const string& theFeatureID, const string& theAttrID, const list<string>& theArguments)
+void Model_ValidatorsFactory::assignValidator(const std::string& theID, 
+  const std::string& theFeatureID, const std::string& theAttrID, 
+  const std::list<std::string>& theArguments)
 {
-  bool isError = false;
-  map<string, ModelAPI_Validator*>::iterator aVal = myIDs.find(theID);
-  if (aVal == myIDs.end()) {
-    Events_Error::send(
-      string("Validator ") + theID + " for feature " + theFeatureID + " was not registered");
-    isError = true;
-  }
   // create feature-structures if not exist
-  map<string, map<string, pair<ModelAPI_Validator*, list<string> > > >::iterator
-    aFeature = myAttrs.find(theFeatureID);
+  std::map<std::string, std::map<std::string, AttrValidators> >::iterator aFeature = 
+    myAttrs.find(theFeatureID);
   if (aFeature == myAttrs.end()) {
-    myAttrs[theFeatureID] = map<string, pair<ModelAPI_Validator*, list<string> > >();
+    myAttrs[theFeatureID] = std::map<std::string, AttrValidators>();
     aFeature = myAttrs.find(theFeatureID);
   }
   // add attr-structure if not exist, or generate error if already exist
-  map<string, pair<ModelAPI_Validator*, list<string> > >::iterator 
-    anAttr = aFeature->second.find(theAttrID);
+  std::map<std::string, AttrValidators>::iterator anAttr = aFeature->second.find(theAttrID);
   if (anAttr == aFeature->second.end()) {
-    if (!isError) {
-      aFeature->second[theAttrID] = 
-        pair<ModelAPI_Validator*, list<string> >(aVal->second, theArguments);
-    }
-  } else {
-    // TODO: it is called many times now because of not-optimized XML reader
-    //Events_Error::send(
-    //  string("Validator ") + theID + " for feature " + theFeatureID +
-    //          "attribute " + theAttrID + " is already registered");
-    isError = true;
+    aFeature->second[theAttrID] = AttrValidators();
   }
+  aFeature->second[theAttrID].insert(
+    std::pair<std::string, std::list<std::string> >(theID, theArguments));
 }
 
-const ModelAPI_Validator* Model_ValidatorsFactory::validator(const string& theFeatureID) const
+void Model_ValidatorsFactory::validators(
+  const std::string& theFeatureID, std::list<ModelAPI_Validator*>& theResult ) const
 {
-  map<string, ModelAPI_Validator*>::const_iterator aFeature = myFeatures.find(theFeatureID);
-  if (aFeature != myFeatures.cend())
-    return aFeature->second;
-  return NULL; // not found
+  std::map<std::string, std::set<std::string> >::const_iterator aFeature =
+    myFeatures.find(theFeatureID);
+  if (aFeature != myFeatures.cend()) {
+    std::set<std::string>::const_iterator aValIter = aFeature->second.cbegin();
+    for(; aValIter != aFeature->second.cend(); aValIter++) {
+      std::map<std::string, ModelAPI_Validator*>::const_iterator aFound = myIDs.find(*aValIter);
+      if (aFound == myIDs.end()) {
+        Events_Error::send(std::string("Validator ") + *aValIter + " was not registered");
+      } else {
+        theResult.push_back(aFound->second);
+      }
+    }
+  }
 }
 
-const ModelAPI_Validator* Model_ValidatorsFactory::validator(
-  const std::string& theFeatureID, const std::string& theAttrID) const
+void Model_ValidatorsFactory::validators(const std::string& theFeatureID, 
+  const std::string& theAttrID, std::list<ModelAPI_Validator*>& theValidators, 
+  std::list<std::list<std::string> >& theArguments) const
 {
-  map<string, map<string, pair<ModelAPI_Validator*, list<string> > > >::const_iterator
-    aFeature = myAttrs.find(theFeatureID);
-  if (aFeature == myAttrs.cend()) return NULL; // feature is not found
-  map<string, pair<ModelAPI_Validator*, list<string> > >::const_iterator 
-    anAttr = aFeature->second.find(theAttrID);
-  if (anAttr == aFeature->second.cend()) return NULL; // attribute is not found
-  return anAttr->second.first;
+  std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeature =
+    myAttrs.find(theFeatureID);
+  if (aFeature != myAttrs.cend()) {
+    std::map<std::string, AttrValidators>::const_iterator anAttr =
+      aFeature->second.find(theAttrID);
+    if (anAttr != aFeature->second.end()) {
+      AttrValidators::const_iterator aValIter = anAttr->second.cbegin();
+      for(; aValIter != anAttr->second.cend(); aValIter++) {
+        std::map<std::string, ModelAPI_Validator*>::const_iterator aFound = 
+          myIDs.find(aValIter->first);
+        if (aFound == myIDs.end()) {
+          Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered");
+        } else {
+          theValidators.push_back(aFound->second);
+          theArguments.push_back(aValIter->second);
+        }
+      }
+    }
+  }
 }
 
-/*bool Model_ValidatorsFactory::validate(
-  const boost::shared_ptr<ModelAPI_Feature>& theFeature, const string& theAttrID ) const
-{
-  map<string, map<string, pair<ModelAPI_Validator*, list<string> > > >::const_iterator
-    aFeature = myAttrs.find(theFeature->getKind());
-  if (aFeature == myAttrs.cend()) return true; // feature is not found
-  map<string, pair<ModelAPI_Validator*, list<string> > >::const_iterator 
-    anAttr = aFeature->second.find(theAttrID);
-  if (anAttr == aFeature->second.cend()) return true; // attribute is not found
-  return anAttr->second.first->validate(theFeature, theAttrID, anAttr->second.second);
-}*/
-
 Model_ValidatorsFactory::Model_ValidatorsFactory() : ModelAPI_ValidatorsFactory()
 {
+  registerValidator("Model_ResultPointValidator", new Model_ResultPointValidator);
+  registerValidator("Model_ResultLineValidator", new Model_ResultLineValidator);
+  registerValidator("Model_ResultArcValidator", new Model_ResultArcValidator);
 }
+
+
+const ModelAPI_Validator* Model_ValidatorsFactory::validator(const std::string& theID) const
+{
+  std::map<std::string, ModelAPI_Validator*>::const_iterator aIt = myIDs.find(theID);
+  if (aIt != myIDs.end()) {
+    return aIt->second;
+  }
+  return NULL;
+}
\ No newline at end of file
index a93f450a414ed4d5b421f7038117c07a04ff22b2..f748c42ca7163560919e3899c79cc04b5149b1f0 100644 (file)
@@ -8,6 +8,7 @@
 #include <Model.h>
 #include <ModelAPI_Validator.h>
 #include <map>
+#include <set>
 
 /**\class Model_ValidatorsFactory
  * \ingroup DataModel
  */
 class Model_ValidatorsFactory: public ModelAPI_ValidatorsFactory
 {
+private:
   std::map<std::string, ModelAPI_Validator*> myIDs; ///< map from ID to registered validator
-  std::map<std::string, ModelAPI_Validator*> myFeatures; ///< validators by feature ID
-  std::map<std::string, std::map<std::string, std::pair<ModelAPI_Validator*, 
-    std::list<std::string> > > > myAttrs; ///< validators and arguments by feature and attribute IDs
+  /// validators IDs by feature ID
+  std::map<std::string, std::set<std::string> > myFeatures; 
+  /// set of pairs: validators IDs, list of arguments
+  typedef std::set<std::pair<std::string, std::list<std::string> > > AttrValidators;
+  /// validators IDs and arguments by feature and attribute IDs
+  std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
 public:
   /// Registers the instance of the validator by the ID
   MODEL_EXPORT virtual void registerValidator(
@@ -42,10 +47,16 @@ public:
     const std::list<std::string>& theArguments);
 
   /// Provides a validator for the feature, returns NULL if no validator
-  MODEL_EXPORT virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const;
+  MODEL_EXPORT virtual void validators(const std::string& theFeatureID, 
+    std::list<ModelAPI_Validator*>& theResult) const;
   /// Provides a validator for the attribute, returns NULL if no validator
-  MODEL_EXPORT virtual const ModelAPI_Validator* validator(
-    const std::string& theFeatureID, const std::string& theAttrID) const;
+  MODEL_EXPORT virtual void validators(
+    const std::string& theFeatureID, const std::string& theAttrID,
+    std::list<ModelAPI_Validator*>& theValidators, 
+    std::list<std::list<std::string> >& theArguments) const;
+
+  /// Returns registered validator by its Id
+  virtual const ModelAPI_Validator* validator(const std::string& theID) const;
 
   /// Returns the result of "validate" method for attribute of validator.
   /// If validator is not exists, returns true: everything is valid by default.
index 4d10c9ce172da4f4ba642c8bd539cc7948e124e8..cc1596c0fb89a4670c01bcbd69f917ccc0e45417 100644 (file)
@@ -26,11 +26,15 @@ SET(PROJECT_HEADERS
     ModelAPI_ResultConstruction.h
     ModelAPI_ResultPart.h
     ModelAPI_ResultParameters.h
+       ModelAPI_ResultValidator.h
+       ModelAPI_AttributeValidator.h
+       ModelAPI_Tools.h
 )
 
 SET(PROJECT_SOURCES
     ModelAPI_Feature.cpp
     ModelAPI_PluginManager.cpp
+       ModelAPI_Tools.cpp
 )
 
 SET(PROJECT_LIBRARIES
diff --git a/src/ModelAPI/ModelAPI_AttributeValidator.h b/src/ModelAPI/ModelAPI_AttributeValidator.h
new file mode 100644 (file)
index 0000000..b40c145
--- /dev/null
@@ -0,0 +1,21 @@
+// File:        ModelAPI_AttributeValidator.h
+// Created:     5 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModelAPI_AttributeValidator_H
+#define ModelAPI_AttributeValidator_H
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_Validator.h>
+
+
+class ModelAPI_AttributeValidator: public ModelAPI_Validator
+{
+public:
+  virtual bool isValid(const FeaturePtr& theFeature, 
+                       const std::list<std::string>& theArguments,
+                       const ObjectPtr& theObject) const = 0;
+};
+
+#endif
index 5617cedd9a9fffdb5747edd7b6269a688dd0309d..028f17385affbd04b928466274a9ee08cb5d904b 100644 (file)
@@ -5,6 +5,7 @@
 #include "ModelAPI_Feature.h"
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Result.h>
+#include <ModelAPI_Document.h>
 #include <Events_Loop.h>
 
 const std::list<boost::shared_ptr<ModelAPI_Result> >& ModelAPI_Feature::results() 
@@ -70,3 +71,16 @@ ModelAPI_Feature::~ModelAPI_Feature()
     ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());
   }
 }
+
+FeaturePtr ModelAPI_Feature::feature(ObjectPtr theObject)
+{
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (!aFeature) {
+    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult) {
+      DocumentPtr aDoc = aResult->document();
+      return aDoc->feature(aResult);
+    }
+  }
+  return aFeature;
+}
index bf3f233acce848bbce2a22d9f3d7e742a79b0049..9f989074b57cccc560b49814218b7ef6d51ee945 100644 (file)
@@ -62,6 +62,9 @@ public:
 
   /// To virtually destroy the fields of successors
   MODELAPI_EXPORT virtual ~ModelAPI_Feature();
+
+  MODELAPI_EXPORT static boost::shared_ptr<ModelAPI_Feature> feature(ObjectPtr theObject);
+
 };
 
 //! Pointer on feature object
diff --git a/src/ModelAPI/ModelAPI_ResultValidator.h b/src/ModelAPI/ModelAPI_ResultValidator.h
new file mode 100644 (file)
index 0000000..7484246
--- /dev/null
@@ -0,0 +1,18 @@
+// File:        ModelAPI_ResultValidators.h
+// Created:     23 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModelAPI_ResultValidators_H
+#define ModelAPI_ResultValidators_H
+
+#include "ModelAPI_Validator.h"
+#include "ModelAPI_Object.h"
+
+class ModelAPI_ResultValidator: public ModelAPI_Validator
+{
+public:
+  virtual bool isValid(const ObjectPtr theObject) const = 0;
+};
+
+
+#endif
\ No newline at end of file
diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp
new file mode 100644 (file)
index 0000000..1c49c67
--- /dev/null
@@ -0,0 +1,21 @@
+// File:        ModelAPI_Tools.cpp
+// Created:     06 Aug 2014
+// Author:      Vitaly Smetannikov
+
+#include "ModelAPI_Tools.h"
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+
+
+namespace ModelAPI_Tools {
+
+boost::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult)
+{
+  ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+  if (aBody) return aBody->shape();
+  ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
+  if (aConstruct) return aConstruct->shape();
+  return boost::shared_ptr<GeomAPI_Shape>();
+}
+
+}
\ No newline at end of file
diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h
new file mode 100644 (file)
index 0000000..f4fc0eb
--- /dev/null
@@ -0,0 +1,18 @@
+// File:        ModelAPI_Tools.h
+// Created:     06 Aug 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ModelAPI_Tools_HeaderFile
+#define ModelAPI_Tools_HeaderFile
+
+#include "ModelAPI.h"
+#include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
+
+namespace ModelAPI_Tools 
+{
+  /// Returns shape from the given Result object
+  MODELAPI_EXPORT boost::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
+};
+
+#endif
\ No newline at end of file
index 522945c3f1cfdbc661b7da7630385bab47b6b87e..bd53ecc24a349811a09755317f6d3821002fa115 100644 (file)
@@ -65,11 +65,16 @@ public:
     const std::list<std::string>& theArguments) = 0;
 
   /// Provides a validator for the feature, returns NULL if no validator
-  virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const = 0;
-
+  virtual void validators(const std::string& theFeatureID, 
+    std::list<ModelAPI_Validator*>& theResult) const = 0;
   /// Provides a validator for the attribute, returns NULL if no validator
-  virtual const ModelAPI_Validator* validator(
-    const std::string& theFeatureID, const std::string& theAttrID) const = 0;
+  virtual void validators(
+    const std::string& theFeatureID, const std::string& theAttrID,
+    std::list<ModelAPI_Validator*>& theValidators, 
+    std::list<std::list<std::string> >& theArguments) const = 0;
+
+  /// Returns registered validator by its Id
+  virtual const ModelAPI_Validator* validator(const std::string& theID) const = 0;
 
   /// Returns the result of "validate" method for attribute of validator.
   /// If validator is not exists, returns true: everything is valid by default.
index 1d8531d4d7b53455d9f8c9120a74c98dbf3717bb..b21756a5c39ff3dc9c72c13d5cbfd6696a9308cc 100644 (file)
@@ -25,8 +25,6 @@ SET(PROJECT_HEADERS
        ModuleBase_SelectionValidator.h
        ModuleBase_ISelection.h
        ModuleBase_ViewerPrs.h
-       ModuleBase_Tools.h
-       ModuleBase_ResultValidators.h
 )
 
 SET(PROJECT_SOURCES
@@ -46,8 +44,6 @@ SET(PROJECT_SOURCES
        ModuleBase_WidgetPoint2dDistance.cpp
        ModuleBase_WidgetValue.cpp
        ModuleBase_WidgetValueFeature.cpp
-       ModuleBase_Tools.cpp
-       ModuleBase_ResultValidators.cpp
 )
 
 SET(PROJECT_LIBRARIES
index cc398e5b03df0b227fb47b3b153740eb501fe097..cee8fbc2b1d531cc41fa5c3bab5d656d7f1481d2 100644 (file)
@@ -81,17 +81,21 @@ void ModuleBase_IOperation::abort()
   emit stopped();
 }
 
-void ModuleBase_IOperation::commit()
+bool ModuleBase_IOperation::commit()
 {
-  commitOperation();
-  emit committed();
+  if (canBeCommitted()) {
+    commitOperation();
+    emit committed();
 
-  stopOperation();
+    stopOperation();
 
-  document()->finishOperation();
-  emit stopped();
+    document()->finishOperation();
+    emit stopped();
   
-  afterCommitOperation();
+    afterCommitOperation();
+    return true;
+  }
+  return false;
 }
 
 void ModuleBase_IOperation::setRunning(bool theState)
index 0d304c0a2a7bebc1d684914ef6bba0b4bf48dc2b..c9510192f683b1e6cbfd719259ca28f6b0418669 100644 (file)
@@ -57,10 +57,6 @@ public:
   /// /returns the instance of the description class
   ModuleBase_OperationDescription* getDescription() const;
 
-  /// Verifies whether this operator can be commited.
-  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
-  virtual bool canBeCommitted() const;
-
   /// Verifies whether this operator can be always started above any already running one
   /// \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
   /// This method must be redefined in derived operation if operation of derived class
@@ -111,7 +107,7 @@ public slots:
   /// Commits operation
   /// Public slot. Commits operation. This slot is not virtual and cannot be redefined.
   /// Redefine commitOperation method to change behavior of operation instead
-  void commit();
+  bool commit();
 
   /// Alias for start/abort slots
   /// Public slot. Aborts operation if false, else does nothing.
@@ -127,16 +123,24 @@ protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
   virtual void startOperation() = 0;
+
   /// Virtual method called when operation stopped - committed or aborted.
   virtual void stopOperation() = 0;
+
   /// Virtual method called when operation aborted (see abort() method for more description)
   virtual void abortOperation() = 0;
+
   /// Virtual method called when operation committed (see commit() method for more description)
   virtual void commitOperation() = 0;
+
   /// Virtual method called after operation committed (see commit() method for more description)
   /// it is important that the method is called after the stop() signal is emitted
   virtual void afterCommitOperation() = 0;
 
+  /// Verifies whether this operator can be commited.
+  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
+  virtual bool canBeCommitted() const;
+
   /// Returns pointer to the root document.
   boost::shared_ptr<ModelAPI_Document> document() const;
 
index de0548b3d355b5ba765768d324f2015c4c32c548..c150d01b3c0fdb1c4dac49e21fcf510bf65724d7 100644 (file)
@@ -14,7 +14,6 @@
 #include <boost/shared_ptr.hpp>
 
 class Config_WidgetAPI;
-class ModelAPI_Feature;
 class ModuleBase_WidgetValue;
 class QKeyEvent;
 
@@ -49,9 +48,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theObject a model feature to be changed
-  virtual bool storeValue(ObjectPtr theObject) const = 0;
+  virtual bool storeValue() const = 0;
 
-  virtual bool restoreValue(ObjectPtr theObject) = 0;
+  virtual bool restoreValue() = 0;
 
   /// 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.
@@ -74,6 +73,9 @@ public:
   /// \returns the string value
   std::string parentID() const { return myParentId; }
 
+  FeaturePtr feature() const { return myFeature;}
+  void setFeature(const FeaturePtr& theFeature) { myFeature = theFeature; }
+
 signals:
   /// The signal about widget values changed
   void valuesChanged();
@@ -94,9 +96,10 @@ protected:
 
   bool myHasDefaultValue; /// the boolean state whether the control has a default value
 
-private:
+
   std::string myAttributeID; /// the attribute name of the model feature
   std::string myParentId;    /// name of parent
+  FeaturePtr myFeature;
 };
 
 #endif
index f3a657548a6fcf25bf613f9cb9b4662d02f2074b..4a980a1dc2b8b0dc534ca40968f0b57ca247bc57 100644 (file)
@@ -17,6 +17,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Result.h>
+#include <ModelAPI_Validator.h>
 
 #include <Events_Loop.h>
 
@@ -60,7 +61,7 @@ void ModuleBase_Operation::storeCustomValue()
 
   ModuleBase_ModelWidget* aCustom = dynamic_cast<ModuleBase_ModelWidget*>(sender());
   if (aCustom)
-    aCustom->storeValue(myFeature);
+    aCustom->storeValue();
 }
 
 void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
@@ -92,6 +93,30 @@ void ModuleBase_Operation::afterCommitOperation()
 {
 }
 
+bool ModuleBase_Operation::canBeCommitted() const
+{
+  if (ModuleBase_IOperation::canBeCommitted()) {
+/*    FeaturePtr aFeature = feature();
+    std::string aId = aFeature->getKind();
+
+    PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+    ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+    std::list<ModelAPI_Validator*> aValidators;
+    aFactory->validators(aId, aValidators);
+    std::list<ModelAPI_Validator*>::const_iterator aIt;
+    for (aIt = aValidators.cbegin(); aIt != aValidators.cend(); ++aIt) {
+      const ModuleBase_FeatureValidator* aFValidator = 
+        dynamic_cast<const ModuleBase_FeatureValidator*>(*aIt);
+      if (aFValidator) {
+        if (!aFValidator->isValid(aFeature))
+          return false;
+      }
+    }*/
+    return true;
+  }
+  return false;
+}
+
 void ModuleBase_Operation::flushUpdated()
 {
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
index ae2250624db9ad0c7fa94040b767abf69f65bfe8..c9693d3f60f120414451d29994dece2f69df4932 100644 (file)
@@ -112,6 +112,10 @@ protected:
   /// Sets the operation feature
   void setFeature(FeaturePtr theFeature);
 
+  /// Verifies whether this operator can be commited.
+  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
+  virtual bool canBeCommitted() const;
+
 protected:
   FeaturePtr myFeature; /// the operation feature to be handled
 };
index 548fc549cf307a3557b4cf2c4585c4c1c07c6d60..67a9ca5a992a8784ac82e673008449f34a388dab 100644 (file)
@@ -29,7 +29,7 @@ TopoDS_Shape shape(ResultPtr theResult)
 }
 
 
-bool ModuleBase_ResulPointValidator::isValid(const ObjectPtr theObject) const
+bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const
 {
   ResultPtr aResult = result(theObject);
   if (!aResult)
@@ -42,7 +42,7 @@ bool ModuleBase_ResulPointValidator::isValid(const ObjectPtr theObject) const
 }
 
 
-bool ModuleBase_ResulLineValidator::isValid(const ObjectPtr theObject) const
+bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const
 {
   ResultPtr aResult = result(theObject);
   if (!aResult)
@@ -62,7 +62,7 @@ bool ModuleBase_ResulLineValidator::isValid(const ObjectPtr theObject) const
 }
 
 
-bool ModuleBase_ResulArcValidator::isValid(const ObjectPtr theObject) const
+bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const
 {
   ResultPtr aResult = result(theObject);
   if (!aResult)
index 50cc2e7b1de8acecad5ba2f20b7ba0b4295eadc6..1b55460e0e7e6925484dfe70834754ceca449b39 100644 (file)
@@ -15,19 +15,19 @@ public:
   virtual bool isValid(const ObjectPtr theObject) const = 0;
 };
 
-class ModuleBase_ResulPointValidator: public ModuleBase_ResultValidator
+class ModuleBase_ResultPointValidator: public ModuleBase_ResultValidator
 {
 public:
   MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
 };
 
-class ModuleBase_ResulLineValidator: public ModuleBase_ResultValidator
+class ModuleBase_ResultLineValidator: public ModuleBase_ResultValidator
 {
 public:
   MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
 };
 
-class ModuleBase_ResulArcValidator: public ModuleBase_ResultValidator
+class ModuleBase_ResultArcValidator: public ModuleBase_ResultValidator
 {
 public:
   MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
index d3dd6f7ee16f288558d95a371f384d3100181d92..87f636360229b6e5d2d68ee3fa910042cb5d957d 100644 (file)
@@ -11,28 +11,6 @@ namespace ModuleBase_Tools
 {
 
 //******************************************************************
-boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
-{
-  ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
-  if (aBody) return aBody->shape();
-  ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
-  if (aConstruct) return aConstruct->shape();
-  return boost::shared_ptr<GeomAPI_Shape>();
-}
 
 //******************************************************************
-FeaturePtr feature(ObjectPtr theObject)
-{
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if (!aFeature) {
-    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    if (aResult) {
-      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-      DocumentPtr aDoc = aMgr->rootDocument();
-      return aDoc->feature(aResult);
-    }
-  }
-  return aFeature;
-}
-
 }
index c77ecad44d99958e7f43cefb0a60f55b9eeadf81..07a8eb000a427539c9211f89b706e448da4e4f7d 100644 (file)
@@ -42,21 +42,21 @@ QWidget* ModuleBase_WidgetBoolValue::getControl() const
   return myCheckBox; 
 }
 
-bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetBoolValue::storeValue() const
 {
-  DataPtr aData = theObject->data();
+  DataPtr aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
 
   if (aBool->value() != myCheckBox->isChecked()) {
     aBool->setValue(myCheckBox->isChecked());
-    updateObject(theObject);
+    updateObject(myFeature);
   }
   return true;
 }
 
-bool ModuleBase_WidgetBoolValue::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetBoolValue::restoreValue()
 {
-  DataPtr aData = theObject->data();
+  DataPtr aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
 
   bool isBlocked = myCheckBox->blockSignals(true);
index 17c5a68498b1bdec2e02b237216c4acb040a980c..7f6c822a87d3e1d943e0e178cd615130d3920597 100644 (file)
@@ -25,9 +25,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theObject a model feature to be changed
-  virtual bool storeValue(ObjectPtr theObject) const;
+  virtual bool storeValue() const;
 
-  virtual bool restoreValue(ObjectPtr theObject);
+  virtual bool restoreValue();
 
   /// Returns list of widget controls
   /// \return a control list
index 97782bf745f66a89bcdf735736456c33948d1c9f..beb384bcdfa5b7b21f8e45445a307c88a1cae49a 100644 (file)
@@ -90,20 +90,20 @@ ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
 {
 }
 
-bool ModuleBase_WidgetDoubleValue::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetDoubleValue::storeValue() const
 {
-  DataPtr aData = theObject->data();
+  DataPtr aData = myFeature->data();
   AttributeDoublePtr aReal = aData->real(attributeID());
   if (aReal->value() != mySpinBox->value()) {
     aReal->setValue(mySpinBox->value());
-    updateObject(theObject);
+    updateObject(myFeature);
   }
   return true;
 }
 
-bool ModuleBase_WidgetDoubleValue::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetDoubleValue::restoreValue()
 {
-  DataPtr aData = theObject->data();
+  DataPtr aData = myFeature->data();
   AttributeDoublePtr aRef = aData->real(attributeID());
 
   bool isBlocked = mySpinBox->blockSignals(true);
index a04a4e928fa804b2a349d1548b3280cd6a68df3c..15b9063b3552acb4dd135c44f61d93fa6dbf6268 100644 (file)
@@ -26,9 +26,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theObject a model feature to be changed
-  virtual bool storeValue(ObjectPtr theObject) const;
+  virtual bool storeValue() const;
 
-  virtual bool restoreValue(ObjectPtr theObject);
+  virtual bool restoreValue();
 
   /// Returns list of widget controls
   /// \return a control list
index b08058a604c24e3c68ecce8bd6a3f18730ae5c7a..983329b53ddf61b42dae50d72e1ad5bc23e0e2a2 100644 (file)
@@ -6,19 +6,20 @@
 
 #include <ModuleBase_WidgetValueFeature.h>
 #include <ModuleBase_WidgetValue.h>
-#include <ModuleBase_ResultValidators.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
 
 #include <Events_Loop.h>
-#include <ModelAPI_Events.h>
 
+#include <ModelAPI_Events.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_AttributeValidator.h>
 
 #include <QWidget>
 #include <QLineEdit>
@@ -30,10 +31,6 @@ ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent,
                                                    const std::string& theParentId)
 : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
-  //QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE));
-  //myObjectKinds = aKinds.split(" ");
-  //theData->
-
   myContainer = new QWidget(theParent);
   QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
   aControlLay->setContentsMargins(0, 0, 0, 0);
@@ -72,48 +69,74 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue)
   return isDone;
 }
 
-bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject)
+bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSendEvent)
 {
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  const ModelAPI_Validator* aValidator = aFactory->validator(parentID(), attributeID());
-  if (aValidator) {
-    const ModuleBase_ResultValidator* aResValidator = 
-      dynamic_cast<const ModuleBase_ResultValidator*>(aValidator);
+  std::list<ModelAPI_Validator*> aValidators;
+  std::list<std::list<std::string> > anArguments;
+  aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
+
+  // Check the type of selected object
+  std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+  bool isValid = true;
+  for(; aValidator != aValidators.end(); aValidator++) {
+    const ModelAPI_ResultValidator* aResValidator = 
+      dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
     if (aResValidator) {
-      if (!aResValidator->isValid(theObject))
+      isValid = false;
+      if (aResValidator->isValid(theObject)) {
+        isValid = true;
+        break;
+      }
+    }
+  }
+  if (!isValid)
+    return false;
+
+  // Check the acceptability of the object as attribute
+  aValidator = aValidators.begin();
+  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+  for(; aValidator != aValidators.end(); aValidator++, aArgs++) {
+    const ModelAPI_AttributeValidator* aAttrValidator = 
+      dynamic_cast<const ModelAPI_AttributeValidator*>(*aValidator);
+    if (aAttrValidator) {
+      if (!aAttrValidator->isValid(myFeature, *aArgs, theObject)) {
         return false;
+      }
     }
   }
 
   myObject = theObject;
   myEditor->setText(theObject ? theObject->data()->name().c_str() : "");
-  emit valuesChanged();
+  if (theSendEvent)
+    emit valuesChanged();
   return true;
 }
 
-bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetFeature::storeValue() const
 {
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if (!aFeature)
-    return false;
-  boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+  //FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  //if (!aFeature)
+  //  return false;
+  boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
   aRef->setObject(myObject);
-  aFeature->execute();
-  updateObject(theObject);
+  myFeature->execute();
+  updateObject(myFeature);
   return true;
 }
 
-bool ModuleBase_WidgetFeature::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetFeature::restoreValue()
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
+  boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
+  ObjectPtr aObj = aRef->object();
   FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
   if (aFeature) {
     myObject = aFeature;
index fbfc7e2e9a9a620a128dc7f69f81b6f232a20558..fee570d64f78553c08cbda9ab64b91ddc0150cf3 100644 (file)
@@ -40,9 +40,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(ObjectPtr theObject) const;
+  virtual bool storeValue() const;
 
-  virtual bool restoreValue(ObjectPtr theObject);
+  virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
@@ -56,7 +56,7 @@ protected:
   /// Fill the widget values by given point
   /// \param thePoint the point
   /// \return the boolean result of the feature set
-  bool setObject(const ObjectPtr& theObject);
+  bool setObject(const ObjectPtr& theObject, bool theSendEvent = true);
 
   /// Returns current widget feature
   /// \return the feature
@@ -70,7 +70,6 @@ protected:
   /// \return the list of kinds
   const QStringList& featureKinds() const { return myObjectKinds; }
 
-private:
   ObjectPtr myObject; ///< the current widget feature
   QStringList myObjectKinds; ///< the kinds of possible features
 
index 4b456e859a45c5d0541b785e129c2636ce0a6096..40fb3a52f7bae73bd9c2ce01e3de5dcbb4b2ed85 100644 (file)
@@ -17,6 +17,8 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Validator.h>
+
 #include <GeomAPI_Pnt2d.h>
 
 #include <GeomDataAPI_Point2D.h>
@@ -48,64 +50,73 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
       boost::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
-      ObjectPtr aValueFeature = aFeatureValue->object();
-      if (aValueFeature) {
-        isDone = setObject(aValueFeature);
+      ObjectPtr aObject = aFeatureValue->object();
+      if (aObject) {
+        isDone = setObject(aObject, false);
       }
-      if (!isDone && aValuePoint) {
-        // find the given point in the feature attributes
-        std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes =
-                                      aValueFeature->data()->attributes(GeomDataAPI_Point2D::type());
-        std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
-                                                                          aLast = anAttiributes.end();
-        boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
-        for (;anIt!=aLast && !aFPoint; anIt++) {
-          boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
-                                              boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
-          if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion())
-            aFPoint = aCurPoint;
+      if (aValuePoint) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
+        if (aFeature) {
+          // find the given point in the feature attributes
+          std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes =
+                                        aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+          std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
+                                                                            aLast = anAttiributes.end();
+          boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
+          for (;anIt!=aLast && !aFPoint; anIt++) {
+            boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
+                                                boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+            if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion())
+              aFPoint = aCurPoint;
+          }
+          if (aFPoint)
+            isDone = setAttribute(aFPoint, false);
         }
-        if (aFPoint)
-          isDone = setAttribute(aFPoint);
       }
+      if (isDone)
+        emit valuesChanged();
     }
   }
   return isDone;
 }
 
-bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetFeatureOrAttribute::storeValue() const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  //FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+  //if (!aFeature)
+  //  return false;
+
+  boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
-  ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this;
-  if (object())
-    aRef->setObject(object());
-  else if (myAttribute)
+  if (myObject)
+    aRef->setObject(myObject);
+  if (myAttribute)
     aRef->setAttr(myAttribute);
 
-  theFeature->execute();
-  updateObject(theFeature);
+  myFeature->execute();
+  updateObject(myFeature);
 
   return true;
 }
 
-bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetFeatureOrAttribute::restoreValue()
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+  ObjectPtr aObj = aRef->object();
+  FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
   if (aFeature) {
-    setObject(aFeature);
+    myObject = aFeature;
     myAttribute = aRef->attr();
 
     std::string aText = "";
     if (aFeature)
       aText = aFeature->data()->name().c_str();
-    else if (myAttribute)
+    if (myAttribute)
       aText = myAttribute->attributeType().c_str();
 
     editor()->setText(aText.c_str());
@@ -114,14 +125,17 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature)
   return false;
 }
 
-bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute)
+bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(
+                                    const boost::shared_ptr<ModelAPI_Attribute>& theAttribute,
+                                    bool theSendEvent)
 {
-  if (!theAttribute || !featureKinds().contains(theAttribute->attributeType().c_str()))
+  if (!theAttribute)// || !featureKinds().contains(theAttribute->attributeType().c_str()))
     return false;
 
   myAttribute = theAttribute;
   editor()->setText(theAttribute ? theAttribute->attributeType().c_str() : "");
-  emit valuesChanged();
+  if (theSendEvent)
+    emit valuesChanged();
   return true;
 }
 
index dc9bad6d8b4e249c5703795411a93fca11416d30..0518409bd1198d69545d8adedcdf0a27fe33d01a 100644 (file)
@@ -36,15 +36,16 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  virtual bool storeValue() const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue();
 
 protected:
   /// Set the attribute
   /// \param theAttribute value
   /// \return the boolean result of the attribute set
-  bool setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute);
+  bool setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute, 
+                    bool theSendEvent = true);
 
 protected:
   boost::shared_ptr<ModelAPI_Attribute> myAttribute; /// < the attribute
index c9c3dd9c77bd4076df0a037ffd4b3827dc648ca2..cd88c57b7d188e7f1ff5514b2437681db93b62f1 100644 (file)
@@ -102,24 +102,24 @@ void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>&
   emit valuesChanged();
 }
 
-bool ModuleBase_WidgetPoint2D::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetPoint2D::storeValue() const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
+  boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
 
   ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
   bool isBlocked = that->blockSignals(true);
   aPoint->setValue(myXSpin->value(), myYSpin->value());
-  updateObject(theObject);
+  updateObject(myFeature);
   that->blockSignals(isBlocked);
 
   return true;
 }
 
-bool ModuleBase_WidgetPoint2D::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetPoint2D::restoreValue()
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
+  boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
 
index ed249c4b76feae800cb8929fc53f99a2a6b7220c..77fbd74eee380035412274465eab65596b922668 100644 (file)
@@ -40,9 +40,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theObject a model feature to be changed
-  virtual bool storeValue(ObjectPtr theObject) const;
+  virtual bool storeValue() const;
 
-  virtual bool restoreValue(ObjectPtr theObject);
+  virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
index 9ad17625a7e4e1e346ac286cf97800c690caaa1d..c0933f566f361fd97bf3dd3ab1fdf277da4b0be1 100644 (file)
@@ -5,10 +5,10 @@
 
 #include "ModuleBase_WidgetSelector.h"
 #include "ModuleBase_IWorkshop.h"
-#include "ModuleBase_Tools.h"
 
 #include <Events_Loop.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_Tools.h>
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
@@ -102,24 +102,28 @@ ModuleBase_WidgetSelector::~ModuleBase_WidgetSelector()
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetSelector::storeValue() const
 {
-  DataPtr aData = theObject->data();
+  FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(mySelectedObject);
+  if (aSelectedFeature == myFeature) // In order to avoid selection of the same object
+    return false;
+
+  DataPtr aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeReference> aRef = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
 
   ObjectPtr aObject = aRef->value();
   if (!(aObject && aObject->isSame(mySelectedObject))) {
     aRef->setValue(mySelectedObject);
-    updateObject(theObject);
+    updateObject(myFeature);
   }
   return true;
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetSelector::restoreValue()
 {
-  DataPtr aData = theObject->data();
+  DataPtr aData = myFeature->data();
   boost::shared_ptr<ModelAPI_AttributeReference> aRef = aData->reference(attributeID());
 
   bool isBlocked = this->blockSignals(true);
@@ -157,7 +161,7 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
     mySelectedObject = aObject;
     if (mySelectedObject) {
       updateSelectionName();
-      activateSelection(false);
+      myActivateBtn->setChecked(false);
       raisePanel();
     } else {
       myTextLine->setText("");
@@ -170,7 +174,7 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
 bool ModuleBase_WidgetSelector::isAccepted(const ObjectPtr theResult) const
 {
   ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theResult);
-  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
   if (!aShapePtr) return false;
   TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
   if (aShape.IsNull()) return false;
@@ -207,7 +211,7 @@ bool ModuleBase_WidgetSelector::eventFilter(QObject* theObj, QEvent* theEvent)
 {
   if (theObj == myTextLine) {
     if (theEvent->type() == QEvent::Polish) {
-      activateSelection(myActivateOnStart);
+      myActivateBtn->setChecked(myActivateOnStart);
       onSelectionChanged();
     }
   }
index 1388bc77317fcc2addf1cad120bd7a155d46e719..9d71808489b8c119c753dddea333381ba0c3cda5 100644 (file)
@@ -34,9 +34,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theObject a model feature to be changed
-  virtual bool storeValue(ObjectPtr theObject) const;
+  virtual bool storeValue() const;
 
-  virtual bool restoreValue(ObjectPtr theObject);
+  virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
index 4d4de17e1af317af0f4167b2e3de867e87acd215..2786db20b755a74ca2504cbcdb0480b34c3a7c77 100644 (file)
@@ -77,6 +77,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/SketchPlugin
                     ${CMAKE_SOURCE_DIR}/src/GeomAPI
                     ${CAS_INCLUDE_DIRS}
+                                       ${SUIT_INCLUDE}
 )
 
 ADD_DEFINITIONS(-DPARTSET_EXPORTS ${CAS_DEFINITIONS})
index 0f60b0c80bd0077e0216ba291ebd458a0da48cdb..de53456660b728d22b1c3f213e8d4803aec1971b 100644 (file)
@@ -53,7 +53,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
     std::set<ObjectPtr > aFeatures = aUpdMsg->objects();
     std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
-      aDisplayer->deactivate(*anIt, false);
+      aDisplayer->deactivate(*anIt);
       FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
       if (aFeature)
         myModule->activateFeature(aFeature, false);
index 1391a0b2fff8eec3bc01716c31a0e37285316bca..ecace8c289d143877dfa5ecdb727440f69afaa8d 100644 (file)
@@ -13,7 +13,6 @@
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_Operation.h>
-#include <ModuleBase_Tools.h>
 
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
@@ -108,7 +107,7 @@ XGUI_Workshop* PartSet_Module::workshop() const
 
 void PartSet_Module::createFeatures()
 {
-  //!! Test registering of validators
+  //Registering of validators
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
@@ -188,6 +187,15 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
     //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
     //           this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
+  } else {
+    // Activate results of current feature for selection
+    FeaturePtr aFeature = theOperation->feature();
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    std::list<ResultPtr> aResults = aFeature->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+      aDisplayer->activate(*aIt);
+    }
   }
 }
 
@@ -205,13 +213,14 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp) {
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull())) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
 
-    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
+    aPreviewOp->mousePressed(theEvent, aView, aSelected, aHighlighted);
   }
 }
 
@@ -219,13 +228,14 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp) {
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull())) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
 
-    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
+    aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted);
   }
 }
 
@@ -233,8 +243,9 @@ void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp)
-    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull()))
+    aPreviewOp->mouseMoved(theEvent, aView);
 }
 
 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
@@ -250,14 +261,13 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp)
-  {
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull())) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
-    aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
-                                 aHighlighted);
+    aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted);
   }
 }
 
@@ -277,7 +287,7 @@ void PartSet_Module::onFitAllView()
 
 void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
 {
-  FeaturePtr aFeature = ModuleBase_Tools::feature(theObject);
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
   if (!aFeature) {
     qDebug("Warning! Restart operation without feature!");
     return;
@@ -285,8 +295,7 @@ void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
   ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
                                                       aFeature ? aFeature->getKind() : "");
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aPreviewOp)
-  {
+  if (aPreviewOp) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
@@ -295,6 +304,13 @@ void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
     aPreviewOp->initSelection(aSelected, aHighlighted);
   } else {
     anOperation->setEditingFeature(aFeature);
+    //Deactivate result of current feature in order to avoid its selection
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    std::list<ResultPtr> aResults = aFeature->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+      aDisplayer->deactivate(*aIt);
+    }
   }
   sendOperation(anOperation);
   myWorkshop->actionsMgr()->updateCheckState();
@@ -354,6 +370,8 @@ void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
         else
           aDisplayer->erase((*aIt), false);
       }
+      if (!isDisplay)
+        aDisplayer->erase((*aSFIt), false);
     }
   }
   if (isDisplay)
@@ -523,8 +541,14 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
   if (!aFeature || aFeature->getKind() != theCmdId)
     return;
 
-  std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  // Hide result of sketch
+  std::list<ResultPtr> aResults = aFeature->results();
+  std::list<ResultPtr>::const_iterator aIt;
+  for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
+    aDisplayer->erase(*aIt, false);
+
+  std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
   std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
 
   std::list<FeaturePtr>::const_iterator anIt = aList.begin(), 
@@ -541,6 +565,7 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
       aDisplayer->activateInLocalContext((*aRIt), aModes, false);
     }
     aDisplayer->display(aSPFeature, false);
+    aDisplayer->activateInLocalContext(aSPFeature, aModes, false);
   }
   aDisplayer->updateViewer();
 }
index 0b390fe761550717492b4a7ddab488e9f220f177..f8b2dddf12af432060c9eb262d62d0e52654ee36 100644 (file)
@@ -67,7 +67,9 @@ bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
 
 bool PartSet_OperationFeatureCreate::canBeCommitted() const
 {
-  return !myActiveWidget;
+  if (PartSet_OperationSketchBase::canBeCommitted())
+    return !myActiveWidget;
+  return false;
 }
 
 bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperation) const
@@ -104,11 +106,9 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
                                                 const std::list<ModuleBase_ViewerPrs>& theSelected,
                                                 const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
 {
-  if (canBeCommitted())
-  {
+  if (commit()) {
     // 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;
   }
@@ -161,8 +161,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
 
 void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
-  if (canBeCommitted()) {
-    commit();
+  if (commit()) {
     restartOperation(feature()->getKind(), feature());
   }
   else {
@@ -210,21 +209,14 @@ void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
 {
   switch (theKey) {
     case Qt::Key_Return: {
-      if (canBeCommitted())
-      {
-        commit();
+      if (commit()) {
         // it start a new line creation at a free point
         restartOperation(feature()->getKind(), FeaturePtr());
       }
     }
     break;
     case Qt::Key_Escape: {
-      if (canBeCommitted())
-      {
-        commit();
-      }
-      else
-      {
+      if (!commit()) {
         abort();
       }
     }
@@ -279,6 +271,8 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess
 
 bool PartSet_OperationFeatureCreate::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
 {
+  if (!myActiveWidget)
+    return false;
   ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
   aValue->setObject(theFeature);
   aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
index b0d9918875df89341a0c951229e6f666fa0d6fd9..5ba2e7428ee1d632159471e0a30db14a5d29a2f2 100644 (file)
@@ -40,10 +40,6 @@ public:
   /// Destructor
   virtual ~PartSet_OperationFeatureCreate();
 
-  /// Verifies whether this operator can be commited.
-  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
-  virtual bool canBeCommitted() const;
-
   /// Returns that this operator can be started above already running one.
    /// The runned operation should be the sketch feature modified operation
   /// \param theOperation the previous running operation
@@ -114,6 +110,10 @@ protected:
   /// \returns the created feature
   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 
+  /// Verifies whether this operator can be commited.
+  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
+  virtual bool canBeCommitted() const;
+
 protected:
   /// Set value to the active widget
   /// \param theFeature the feature
index 1a6fb55aaed07271807856e7702683e7aa41fa3b..887ec4f9ce8cf51a6afa43e3dfa1a214a9db16ab 100644 (file)
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_Tools.h>
 
 #include <ModelAPI_Events.h>
 
 #include <SketchPlugin_Feature.h>
 #include <GeomDataAPI_Point2D.h>
+
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
-
 #include <ModelAPI_Events.h>
 
 #include <Events_Loop.h>
@@ -80,27 +79,28 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
   if (!aObject && !theSelected.empty()) // changed for a constrain
     aObject = theSelected.front().object();
 
-  FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+  FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
   if (!aFeature || aFeature != feature()) {
-    commit();
-    emit featureConstructed(feature(), FM_Deactivation);
-
-    bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-    if(aHasShift && !theHighlighted.empty()) {
-      QList<ObjectPtr> aSelected;
-      std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
-      for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
-        aSelected.append((*aIt).object());
-      /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) {
-        if (!aSelected.contains((*aIt).object()))
+    if (commit()) {
+      emit featureConstructed(feature(), FM_Deactivation);
+
+      bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+      if(aHasShift && !theHighlighted.empty()) {
+        QList<ObjectPtr> aSelected;
+        std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
+        for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
           aSelected.append((*aIt).object());
-      }*/
-      //aSelected.push_back(feature());
-      //aSelected.push_back(theHighlighted.front().object());
-      emit setSelection(aSelected);
-    }
-    else if (aFeature) {
-      restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+        /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) {
+          if (!aSelected.contains((*aIt).object()))
+            aSelected.append((*aIt).object());
+        }*/
+        //aSelected.push_back(feature());
+        //aSelected.push_back(theHighlighted.front().object());
+        emit setSelection(aSelected);
+      }
+      else if (aFeature) {
+        restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+      }
     }
   }
 }
index 1768f0c94d82706699c8443b917d050919f0b793..83d2a04b5f6dc4d705b0956bc5423d9347fb1a43 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_Tools.h>
 
 #include <ModelAPI_Events.h>
 
@@ -60,7 +59,7 @@ void PartSet_OperationFeatureEditMulti::initSelection(const std::list<ModuleBase
     bool isSelected = false;
     std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
     for (; anIt != aLast && !isSelected; anIt++) {
-      isSelected = ModuleBase_Tools::feature((*anIt).object()) == feature();
+      isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature();
     }
     if (!isSelected)
       myFeatures = theHighlighted;
@@ -114,7 +113,7 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle
       ObjectPtr aObject = (*anIt).object();
       if (!aObject || aObject == feature())
         continue;
-      FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+      FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
       if (aFeature) {
         aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature)
@@ -131,14 +130,15 @@ void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Han
                                               const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
                                               const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
 {
-  std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
-  commit();
-  std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
-  for (; anIt != aLast; anIt++) {
-    ObjectPtr aFeature = (*anIt).object();
-    if (aFeature) {
-      emit featureConstructed(aFeature, FM_Deactivation);
-         }
+  if (commit()) {
+    std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
+    std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+    for (; anIt != aLast; anIt++) {
+      ObjectPtr aFeature = (*anIt).object();
+      if (aFeature) {
+        emit featureConstructed(aFeature, FM_Deactivation);
+           }
+    }
   }
 }
 
index 1d6250afe4c3245bffd2b1be651f7af52b089a3b..7a3d43fe7f17274dfd84289076a41a4f10802552 100644 (file)
@@ -99,3 +99,4 @@ bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection)
   }
   return (aCount > 0) && (aCount < 2);
 }
+
index 90487fe4f722de683f0cdee5caab1d4b69e4df83..94bab7756d5a7dc1b50a99dbb3fff9fbbde95a36 100644 (file)
 #include <ModuleBase_SelectionValidator.h>
 #include <ModuleBase_ISelection.h>
 
+/*
+* Selector validators
+*/
+
 //! A class to validate a selection for Distance constraint operation
 class PartSet_DistanceValidator: public ModuleBase_SelectionValidator
 {
@@ -45,4 +49,5 @@ public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
+
 #endif
index 558747b46864da25f2bb5eb7dec59e0ce730a964..98cae8a48fe9d50ec7a38244e88e6c00d3d2e272 100644 (file)
@@ -25,9 +25,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(ObjectPtr theFeature) const { return true;}
+  virtual bool storeValue() const { return true;}
 
-  virtual bool restoreValue(ObjectPtr theFeature) { return true;}
+  virtual bool restoreValue() { return true;}
 
   /// Returns list of widget controls
   /// \return a control list
diff --git a/src/PyConsole/CMakeLists.txt b/src/PyConsole/CMakeLists.txt
deleted file mode 100644 (file)
index aa79a1d..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-
-SET(CMAKE_AUTOMOC ON)
-
-# header files 
-SET(PROJECT_HEADERS
-  PyConsole.h
-  PyConsole_Console.h
-  PyConsole_Editor.h
-  PyConsole_EnhEditor.h
-  PyConsole_EnhInterp.h
-  PyConsole_Event.h
-  PyConsole_Interp.h
-  PyConsole_Request.h
-)
-
-SET(PROJECT_AUTOMOC 
-    ${CMAKE_CURRENT_BINARY_DIR}/PyConsole_automoc.cpp
-)
-
-# resource files / to be processed by lrelease
-SET(TEXT_RESOURCES
-  PyConsole_msg_fr.ts
-)
-
-# sources / static
-SET(PROJECT_SOURCES
-  PyConsole_Console.cpp
-  PyConsole_Editor.cpp
-  PyConsole_EnhEditor.cpp
-  PyConsole_EnhInterp.cpp
-  PyConsole_Event.cpp
-  PyConsole_Interp.cpp
-  PyConsole_Request.cpp
-)
-
-SET(PROJECT_LIBRARIES
-       PyInterp
-       ${QT_LIBRARIES}
-       ${PYTHON_LIBRARIES}
-)
-
-#QT4_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES})
-QT4_CREATE_TRANSLATION(QM_RESOURCES 
-                                          ${PROJECT_SOURCES}
-                                          ${TEXT_RESOURCES}
-                                          OPTIONS -extensions cpp -no-recursive
-                                          )
-
-SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${QM_RESOURCES})
-
-INCLUDE_DIRECTORIES(
-       ${PROJECT_SOURCE_DIR}/src/PyEvent
-       ${PROJECT_SOURCE_DIR}/src/PyInterp
-)
-
-ADD_DEFINITIONS(-DPYCONSOLE_EXPORTS -DHAVE_DEBUG_PYTHON)
-
-ADD_LIBRARY(PyConsole SHARED
-       ${PROJECT_HEADERS}
-       ${PROJECT_SOURCES}
-       ${TEXT_RESOURCES} 
-       ${QM_RESOURCES}
-)
-
-TARGET_LINK_LIBRARIES(PyConsole ${PROJECT_LIBRARIES})
-
-INSTALL(TARGETS PyConsole DESTINATION bin)
-INSTALL(FILES ${QM_RESOURCES} DESTINATION bin)
-
-
diff --git a/src/PyConsole/PyConsole.h b/src/PyConsole/PyConsole.h
deleted file mode 100644 (file)
index 1df9180..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-
-#if !defined ( PYCONSOLE_H )
-#define PYCONSOLE_H
-
-// ========================================================
-// set dllexport type for Win platform 
-#ifdef WIN32
-#  if defined PYCONSOLE_EXPORTS || defined PyConsole_EXPORTS
-#    define PYCONSOLE_EXPORT __declspec(dllexport)
-#  else
-#    define PYCONSOLE_EXPORT __declspec(dllimport)
-#  endif
-#else   // WIN32
-#  define PYCONSOLE_EXPORT
-#endif  // WIN32
-
-// ========================================================
-// avoid warning messages
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#pragma warning (disable : 4251)
-#endif
-
-#endif // PYCONSOLE_H
diff --git a/src/PyConsole/PyConsole_Console.cpp b/src/PyConsole/PyConsole_Console.cpp
deleted file mode 100644 (file)
index 79ae485..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-
-/*!
-  \class PyConsole_Console
-  \brief Python console widget.
-*/  
-
-#include "PyConsole_Interp.h"   /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
-#include "PyConsole_Console.h"
-#include "PyConsole_EnhEditor.h"
-#include "PyConsole_EnhInterp.h"
-
-//#include <Qtx.h>
-
-#include <QAction>
-#include <QApplication>
-#include <QClipboard>
-#include <QEvent>
-#include <QMenu>
-#include <QVBoxLayout>
-
-/*!
-  \brief Constructor.
-
-  Creates new python console widget.
-  \param parent parent widget
-  \param interp python interpreter
-*/
-PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp )
-: QWidget( parent )
-{
-  // create python interpreter
-  myInterp = interp;
-  if ( !myInterp )
-    myInterp = new PyConsole_Interp();
-  
-  // initialize Python interpretator
-  myInterp->initialize();
-  
-  // create editor console
-  QVBoxLayout* lay = new QVBoxLayout( this );
-  lay->setMargin( 0 );
-  myEditor = new PyConsole_Editor( myInterp, this );
-  char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
-  if (synchronous && atoi(synchronous))
-  {
-      myEditor->setIsSync(true);
-  }
-  myEditor->viewport()->installEventFilter( this );
-  lay->addWidget( myEditor );
-
-  createActions();
-}
-
-/**
- * Protected constructor.
- */
-PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* i,  PyConsole_Editor* e)
-  : QWidget (parent), myEditor(e), myInterp(i)
-{}
-
-/*!
-  \brief Destructor.
-
-  Does nothing for the moment.
-*/
-PyConsole_Console::~PyConsole_Console()
-{
-}
-
-/*!
-  \brief Execute python command in the interpreter.
-  \param command string with command and arguments
-*/
-void PyConsole_Console::exec( const QString& command )
-{
-  if ( myEditor )
-    myEditor->exec( command );
-}
-
-/*!
-  \brief Execute python command in the interpreter 
-         and wait until it is finished.
-  
-  Block execution of main application until the python command is executed.
-  \param command string with command and arguments
-*/
-void PyConsole_Console::execAndWait( const QString& command )
-{
-  if ( myEditor )
-    myEditor->execAndWait( command );
-}
-
-/*!
-  \brief Get synchronous mode flag value.
-  
-  \sa setIsSync()
-  \return True if python console works in synchronous mode
-*/
-bool PyConsole_Console::isSync() const
-{
-  return myEditor->isSync();
-}
-
-/*!
-  \brief Set synchronous mode flag value.
-
-  In synhronous mode the Python commands are executed in the GUI thread
-  and the GUI is blocked until the command is finished. In the asynchronous
-  mode each Python command is executed in the separate thread that does not
-  block the main GUI loop.
-
-  \param on synhronous mode flag
-*/
-void PyConsole_Console::setIsSync( const bool on )
-{
-  myEditor->setIsSync( on );
-}
-
-/*!
-  \brief Get suppress output flag value.
-  
-  \sa setIsSuppressOutput()
-  \return True if python console output is suppressed.
-*/
-bool PyConsole_Console::isSuppressOutput() const
-{
-  return myEditor->isSuppressOutput();
-}
-
-/*!
-  \brief Set suppress output flag value.
-
-  In case if suppress output flag is true, the python 
-  console output suppressed.
-
-  \param on suppress output flag
-*/
-void PyConsole_Console::setIsSuppressOutput( const bool on )
-{
-  myEditor->setIsSuppressOutput(on);
-}
-
-/*!
-  \brief Get 'show banner' flag value.
-  
-  \sa setIsShowBanner()
-  \return \c true if python console shows banner
-*/
-bool PyConsole_Console::isShowBanner() const
-{
-  return myEditor->isShowBanner();
-}
-
-/*!
-  \brief Set 'show banner' flag value.
-
-  The banner is shown in the top of the python console window.
-
-  \sa isShowBanner()
-  \param on 'show banner' flag
-*/
-void PyConsole_Console::setIsShowBanner( const bool on )
-{
-  myEditor->setIsShowBanner( on );
-}
-
-/*!
-  \brief Change the python console's font.
-  \param f new font
-*/
-void PyConsole_Console::setFont( const QFont& f )
-{
-  if( myEditor )
-    myEditor->setFont( f );
-}
-
-/*!
-  \brief Get python console font.
-  \return current python console's font
-*/
-QFont PyConsole_Console::font() const
-{
-  QFont res;
-  if( myEditor )
-    res = myEditor->font();
-  return res;
-}
-
-/*!
-  \brief Event handler.
-
-  Handles context menu request event.
-
-  \param o object
-  \param e event
-  \return True if the event is processed and further processing should be stopped
-*/
-bool PyConsole_Console::eventFilter( QObject* o, QEvent* e )
-{
-  if ( o == myEditor->viewport() && e->type() == QEvent::ContextMenu )
-  {
-    //contextMenuRequest( (QContextMenuEvent*)e );
-    return true;
-  }
-  return QWidget::eventFilter( o, e );
-}
-
-/*!
-  \brief Create the context popup menu.
-
-  Fill in the popup menu with the commands.
-
-  \param menu context popup menu
-*/
-void PyConsole_Console::contextMenuPopup( QMenu* menu )
-{
-  if ( myEditor->isReadOnly() )
-    return;
-
-  menu->addAction( myActions[CopyId] );
-  menu->addAction( myActions[PasteId] );
-  menu->addAction( myActions[ClearId] );
-  menu->addSeparator();
-  menu->addAction( myActions[SelectAllId] );
-  menu->addSeparator();
-  menu->addAction( myActions[DumpCommandsId] );
-
-  //Qtx::simplifySeparators( menu );
-
-  updateActions();
-}
-
-/*!
-  \brief Set actions to be visible in the context popup menu.
-  
-  Actions, which IDs are set in \a flags parameter, will be shown in the 
-  context popup menu. Other actions will not be shown.
-
-  \param flags ORed together actions flags
-*/
-void PyConsole_Console::setMenuActions( const int flags )
-{
-  myActions[CopyId]->setVisible( flags & CopyId );
-  myActions[PasteId]->setVisible( flags & PasteId );
-  myActions[ClearId]->setVisible( flags & ClearId );
-  myActions[SelectAllId]->setVisible( flags & SelectAllId );
-  myActions[DumpCommandsId]->setVisible( flags & DumpCommandsId );
-}
-
-/*!
-  \brief Get menu actions which are currently visible in the context popup menu.
-  \return ORed together actions flags
-  \sa setMenuActions()
-*/
-int PyConsole_Console::menuActions() const
-{
-  int ret = 0;
-  ret = ret | ( myActions[CopyId]->isVisible() ? CopyId : 0 );
-  ret = ret | ( myActions[PasteId]->isVisible() ? PasteId : 0 );
-  ret = ret | ( myActions[ClearId]->isVisible() ? ClearId : 0 );
-  ret = ret | ( myActions[SelectAllId]->isVisible() ? SelectAllId : 0 );
-  ret = ret | ( myActions[DumpCommandsId]->isVisible() ? DumpCommandsId : 0 );
-  return ret;
-}
-
-/*!
-  \brief Create menu actions.
-
-  Create context popup menu actions.
-*/
-void PyConsole_Console::createActions()
-{
-  QAction* a = new QAction( tr( "&Copy" ), this );
-  a->setStatusTip( tr( "Copy" ) );
-  connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( copy() ) );
-  myActions.insert( CopyId, a );
-
-  a = new QAction( tr( "&Paste" ), this );
-  a->setStatusTip( tr( "Paste" ) );
-  connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( paste() ) );
-  myActions.insert( PasteId, a );
-
-  a = new QAction( tr( "Clea&r" ), this );
-  a->setStatusTip( tr( "Clear" ) );
-  connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( clear() ) );
-  myActions.insert( ClearId, a );
-
-  a = new QAction( tr( "Select &All" ), this );
-  a->setStatusTip( tr( "Select all" ) );
-  connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( selectAll() ) );
-  myActions.insert( SelectAllId, a );
-  
-//  a = new QAction( tr( "EDIT_DUMPCOMMANDS_CMD" ), this );
-//  a->setStatusTip( tr( "EDIT_DUMPCOMMANDS_CMD" ) );
-//  connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( dump() ) );
-//  myActions.insert( DumpCommandsId, a );
-}
-
-/*!
-  \brief Update menu actions.
-
-  Update context popup menu action state.
-*/
-void PyConsole_Console::updateActions()
-{
-  myActions[CopyId]->setEnabled( myEditor->textCursor().hasSelection() );
-  myActions[PasteId]->setEnabled( !myEditor->isReadOnly() && !QApplication::clipboard()->text().isEmpty() );
-  myActions[SelectAllId]->setEnabled( !myEditor->document()->isEmpty() );
-}
-
-/**
- * Similar to constructor of the base class but using enhanced objects.
- * TODO: this should really be done in a factory to avoid code duplication.
- * @param parent
- * @param interp
- */
-PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp)
-  : PyConsole_Console(parent, interp, 0)
-{
-  // create python interpreter
-  myInterp = interp;
-  if ( !myInterp )
-    myInterp = new PyConsole_EnhInterp();
-
-  // initialize Python interpretator
-  myInterp->initialize();
-
-  // create editor console
-  QVBoxLayout* lay = new QVBoxLayout( this );
-  lay->setMargin( 0 );
-  myEditor = new PyConsole_EnhEditor( static_cast<PyConsole_EnhInterp*>(myInterp), this );
-  char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
-  if (synchronous && atoi(synchronous))
-  {
-      myEditor->setIsSync(true);
-  }
-  myEditor->viewport()->installEventFilter( this );
-  lay->addWidget( myEditor );
-
-  createActions();
-}
diff --git a/src/PyConsole/PyConsole_Console.h b/src/PyConsole/PyConsole_Console.h
deleted file mode 100644 (file)
index 7f109eb..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-
-#ifndef PYCONSOLE_CONSOLE_H
-#define PYCONSOLE_CONSOLE_H
-
-#include "PyConsole.h"
-
-//#include <SUIT_PopupClient.h>
-#include <QWidget>
-#include <QMap>
-
-class PyConsole_Interp;
-class PyConsole_Editor;
-class PyConsole_EnhInterp;
-class QMenu;
-
-class PYCONSOLE_EXPORT PyConsole_Console : public QWidget//, public SUIT_PopupClient
-{
-  Q_OBJECT
-
-public:
-  //! Context popup menu actions flags
-  enum
-  {
-    CopyId         = 0x01,                                           //!< "Copy" menu action
-    PasteId        = 0x02,                                           //!< "Paste" menu action
-    ClearId        = 0x04,                                           //!< "Clear" menu action
-    SelectAllId    = 0x08,                                           //!< "Select All" menu action
-    DumpCommandsId = 0x16,                                           //!< "DumpCommands" menu action
-    All = CopyId | PasteId | ClearId | SelectAllId | DumpCommandsId  //!< all menu actions
-  };
-
-public:
-  PyConsole_Console( QWidget* parent, PyConsole_Interp* interp = 0 );
-  virtual ~PyConsole_Console();
-
-  //! \brief Get python interperter
-  PyConsole_Interp*   getInterp() { return myInterp; } 
-  QFont               font() const;
-  virtual void        setFont( const QFont& );
-
-  bool                isSync() const;
-  void                setIsSync( const bool );
-
-  bool                isSuppressOutput() const;
-  void                setIsSuppressOutput( const bool );
-
-  bool                isShowBanner() const;
-  void                setIsShowBanner( const bool );
-
-  void                exec( const QString& );
-  void                execAndWait( const QString& );
-
-  virtual bool        eventFilter( QObject*, QEvent* );
-
-  //! \brief Get popup client symbolic name
-  virtual QString     popupClientType() const { return QString( "PyConsole" ); }
-  virtual void        contextMenuPopup( QMenu* );
-
-  void                setMenuActions( const int );
-  int                 menuActions() const;
-
-protected:
-  void                createActions();
-  void                updateActions();
-
-  PyConsole_Console( QWidget* parent, PyConsole_Interp*,  PyConsole_Editor*);
-
-
-  PyConsole_Interp*   myInterp;    //!< python interpreter
-  PyConsole_Editor*   myEditor;    //!< python console editor widget
-  QMap<int, QAction*> myActions;   //!< menu actions list
-};
-
-/**
- * Enhance console object providing auto-completion.
- * Similar to PyConsole_Console except that an enhanced interpreter and enhanced editor
- * are encapsulated.
- */
-//
-class PYCONSOLE_EXPORT PyConsole_EnhConsole: public PyConsole_Console
-{
-  Q_OBJECT
-
-public:
-  PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp = 0);
-  virtual ~PyConsole_EnhConsole() {}
-};
-
-#endif // PYCONSOLE_CONSOLE_H
diff --git a/src/PyConsole/PyConsole_Editor.cpp b/src/PyConsole/PyConsole_Editor.cpp
deleted file mode 100644 (file)
index 62ef9e8..0000000
+++ /dev/null
@@ -1,1105 +0,0 @@
-
-/*!
-  \class PyConsole_Editor
-  \brief Python command line interpreter front-end GUI widget.
-  
-  This class provides simple GUI interface to the Python interpreter, including basic 
-  navigation operations, executing commands (both interactively and programmatically), 
-  copy-paste operations, history of the commands and so on.
-
-  Here below is the shortcut keyboard boundings used for navigation and other operations:
-  - <Enter>              : execute current command
-  - <Ctrl><Break>        : clear current command
-  - <Escape>             : clear current command
-  - <Up>                 : previous command in the history
-  - <Shift><Up>          : move cursor one row up with selection
-  - <Ctrl><Up>           : move cursor one row up without selection
-  - <Ctrl><Shift><Up>    : move cursor one row up with selection
-  - <Down>               : next command in the history
-  - <Shift><Down>        : move cursor one row down with selection
-  - <Ctrl><Down>         : move cursor one row down without selection
-  - <Ctrl><Shift><Down>  : move cursor one row down with selection
-  - <Left>               : move one symbol left without selection
-  - <Shift><Left>        : move one symbol left with selection
-  - <Ctrl><Left>         : move one word left without selection
-  - <Ctrl><Shift><Left>  : move one word left with selection
-  - <Right>              : move one symbol right without selection
-  - <Shift><Right>       : move one symbol right with selection
-  - <Ctrl><Right>        : move one word right without selection
-  - <Ctrl><Shift><Right> : move one word right with selection
-  - <PgUp>               : first command in the history
-  - <Shift><PgUp>        : move one page up with selection
-  - <Ctrl><PgUp>         : move one page up without selection
-  - <Ctrl><Shift><PgUp>  : scroll one page up
-  - <PgDn>               : last command in the history
-  - <Shift><PgDn>        : move one page down with selection
-  - <Ctrl><PgDn>         : move one page down without selection
-  - <Ctrl><Shift><PgDn>  : scroll one page down
-  - <Home>               : move to the beginning of the line without selection
-  - <Shift><Home>        : move to the beginning of the line with selection
-  - <Ctrl><Home>         : move to the very first symbol without selection
-  - <Ctrl><Shift><Home>  : move to the very first symbol with selection
-  - <End>                : move to the end of the line without selection
-  - <Shift><End>         : move to the end of the line with selection
-  - <Ctrl><End>          : move to the very last symbol without selection
-  - <Ctrl><Shift><End>   : move to the very last symbol with selection
-  - <Backspace>          : delete symbol before the cursor
-                           / remove selected text and put it to the clipboard (cut)
-  - <Shift><Backspace>   : delete previous word
-                           / remove selected text and put it to the clipboard (cut)
-  - <Ctrl><Backspace>    : delete text from the cursor to the beginning of the line 
-                           / remove selected text and put it to the clipboard (cut)
-  - <Delete>             : delete symbol after the cursor 
-                           / remove selected text and put it to the clipboard (cut)
-  - <Shift><Delete>      : delete next word
-                           / remove selected text and put it to the clipboard (cut)
-  - <Ctrl><Delete>       : delete text from the cursor to the end of the line
-                           / remove selected text and put it to the clipboard (cut)
-  - <Ctrl><Insert>       : copy
-  - <Shift><Insert>      : paste
-  - <Ctrl><V>            : paste
-  - <Ctrl><C>            : copy
-  - <Ctrl><X>            : cut
-  - <Ctrl><V>            : paste
-*/
-
-#include "PyConsole_Interp.h"   // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
-#include "PyConsole_Editor.h"
-#include "PyConsole_Event.h"
-#include "PyInterp_Event.h"
-#include "PyInterp_Dispatcher.h"
-#include "PyConsole_Request.h"
-
-//#include <SUIT_Tools.h>
-//#include <SUIT_FileDlg.h>
-//#include <SUIT_MessageBox.h>
-//#include <SUIT_FileValidator.h>
-
-#include <QApplication>
-#include <QClipboard>
-#include <QDropEvent>
-#include <QEvent>
-#include <QKeyEvent>
-#include <QMouseEvent>
-#include <QScrollBar>
-#include <QTextBlock>
-#include <QTextCursor>
-#include <QTextDocument>
-#include <QTextStream>
-#include <QChar>
-
-static QString READY_PROMPT = ">>> ";
-static QString DOTS_PROMPT  = "... ";
-
-/*class DumpCommandsFileValidator : public SUIT_FileValidator
-{
- public:
-  DumpCommandsFileValidator( QWidget* parent = 0 ) : SUIT_FileValidator ( parent ) {};
-  virtual ~DumpCommandsFileValidator() {};
-  virtual bool canSave( const QString& file, bool permissions );
-};
-
-bool DumpCommandsFileValidator::canSave(const QString& file, bool permissions)
-{
-  QFileInfo fi( file );
-  if ( !QRegExp( "[A-Za-z_][A-Za-z0-9_]*" ).exactMatch( fi.completeBaseName() ) ) {
-    SUIT_MessageBox::critical( parent(),
-                               QObject::tr("WRN_WARNING"),
-                               QObject::tr("WRN_FILE_NAME_BAD") );
-    return false;
-  }
-  return SUIT_FileValidator::canSave( file, permissions);
-}
-*/
-void staticCallbackStdout( void* data, char* c )
-{
-  if(!((PyConsole_Editor*)data)->isSuppressOutput())
-    QApplication::postEvent( (PyConsole_Editor*)data, new PrintEvent( c, false ) );
-}
-
-void staticCallbackStderr( void* data, char* c )
-{
-  if(!((PyConsole_Editor*)data)->isSuppressOutput())
-    QApplication::postEvent( (PyConsole_Editor*)data, new PrintEvent( c, true ) );
-}
-
-
-/*!
-  \brief Constructor. 
-  
-  Creates python editor window.
-  \param theInterp python interper
-  \param theParent parent widget
-*/
-PyConsole_Editor::PyConsole_Editor( PyConsole_Interp* theInterp, 
-                                    QWidget*          theParent )
-: QTextEdit( theParent ),
-  myInterp( 0 ),
-  myCmdInHistory( -1 ),
-  myEventLoop( 0 ),
-  myShowBanner( true ),
-  myIsSync( false ),
-  myIsSuppressOutput( false )
-{
-  //QString fntSet( "" );
-  QFont aFont = QFont( "Courier", 11 );//SUIT_Tools::stringToFont( fntSet );
-  setFont( aFont );
-  setUndoRedoEnabled( false );
-
-  myPrompt = READY_PROMPT;
-  setLineWrapMode( QTextEdit::WidgetWidth );
-  setWordWrapMode( QTextOption::WrapAnywhere );
-  setAcceptRichText( false );
-
-  theInterp->setvoutcb( staticCallbackStdout, this );
-  theInterp->setverrcb( staticCallbackStderr, this );
-
-  // san - This is necessary for troubleless initialization
-  onPyInterpChanged( theInterp );
-}
-
-/*!
-  \brief Destructor.
-
-  Does nothing for the moment.
-*/
-PyConsole_Editor::~PyConsole_Editor()
-{
-}
-
-/*!
-  \brief Get synchronous mode flag value.
-  
-  \sa setIsSync()
-  \return True if python console works in synchronous mode
-*/
-bool PyConsole_Editor::isSync() const
-{
-  return myIsSync;
-}
-
-/*!
-  \brief Set synchronous mode flag value.
-
-  In synhronous mode the Python commands are executed in the GUI thread
-  and the GUI is blocked until the command is finished. In the asynchronous
-  mode each Python command is executed in the separate thread that does not
-  block the main GUI loop.
-
-  \param on synhronous mode flag
-*/
-void PyConsole_Editor::setIsSync( const bool on )
-{
-  myIsSync = on;
-}
-
-/*!
-  \brief Get suppress output flag value.
-  
-  \sa setIsSuppressOutput()
-  \return \c true if python console output is suppressed.
-*/
-bool PyConsole_Editor::isSuppressOutput() const
-{
-  return myIsSuppressOutput;
-}
-
-/*!
-  \brief Set suppress output flag value.
-
-  In case if suppress output flag is true, the python 
-  console output suppressed.
-
-  \param on suppress output flag
-*/
-void PyConsole_Editor::setIsSuppressOutput( const bool on )
-{
-  myIsSuppressOutput = on;
-}
-
-/*!
-  \brief Get 'show banner' flag value.
-  
-  \sa setIsShowBanner()
-  \return \c true if python console shows banner
-*/
-bool PyConsole_Editor::isShowBanner() const
-{
-  return myShowBanner;
-}
-
-/*!
-  \brief Set 'show banner' flag value.
-
-  The banner is shown in the top of the python console window.
-
-  \sa isShowBanner()
-  \param on 'show banner' flag
-*/
-void PyConsole_Editor::setIsShowBanner( const bool on )
-{
-  if ( myShowBanner != on ) {
-    myShowBanner = on;
-    clear();
-  }
-}
-
-/*!
-  \brief Get size hint for the Python console window
-  \return size hint value
-*/
-QSize PyConsole_Editor::sizeHint() const
-{
-  QFontMetrics fm( font() );
-  int nbLines = ( isShowBanner() ? myBanner.split("\n").count() : 0 ) + 1;
-  QSize s(100, fm.lineSpacing()*nbLines);
-  return s;
-}
-
-/*!
-  \brief Put the string \a str to the python editor.
-  \param str string to be put in the command line of the editor
-  \param newBlock if True, then the string is printed on a new line
-  \param isError if true, the text is printed in dark red
-*/
-void PyConsole_Editor::addText( const QString& str, 
-                                const bool     newBlock,
-                                const bool    isError)
-{
-  QTextCursor theCursor(textCursor());
-  QTextCharFormat cf;
-
-  moveCursor( QTextCursor::End );
-  if ( newBlock )
-    theCursor.insertBlock();
-  if (isError)
-      cf.setForeground(QBrush(Qt::red));
-  else
-      cf.setForeground(QBrush(Qt::black));
-  theCursor.insertText( str, cf);
-  moveCursor( QTextCursor::End );
-  ensureCursorVisible();
-}
-
-/*!
-  \brief Convenient method for executing a Python command,
-  as if the user typed it manually.
-  \param command python command to be executed
-
-  !!! WARNING: doesn't work properly with multi-line commands. !!!
-*/
-void PyConsole_Editor::exec( const QString& command )
-{
-  if ( isReadOnly() ) {
-    // some interactive command is being executed in this editor...
-    // shedule the command to the queue
-    myQueue.push_back( command );
-    return;
-  }
-  // remove last line
-  moveCursor( QTextCursor::End );
-  moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor );
-  textCursor().removeSelectedText();
-  // set "ready" prompt
-  myPrompt = READY_PROMPT;
-  // clear command buffer
-  myCommandBuffer.truncate( 0 );
-  // unset history browsing mode
-  myCmdInHistory = -1;
-  // print command line by line
-  QString cmd = command;
-  if ( !cmd.endsWith( "\n" ) ) cmd += "\n";
-  QStringList lines = command.split( "\n" );
-  for ( int i = 0; i < lines.size(); i++ ) {
-    if ( !lines[i].trimmed().isEmpty() )
-      myHistory.push_back( lines[i] );
-    addText( ( i == 0 ? READY_PROMPT : DOTS_PROMPT ) + lines[i], i != 0 );
-  }
-  // IPAL20182
-  addText( "", true );
-  // set read-only mode
-  setReadOnly( true );
-  // set busy cursor
-  setCursor( Qt::BusyCursor );
-  
-  // post a request to execute Python command;
-  // editor will be informed via a custom event that execution has been completed
-  PyInterp_Dispatcher::Get()->Exec( createRequest( cmd ) );
-}
-
-/*!
-  \brief Create request to the python dispatcher for the command execution.
-
-  \param command python command to be executed
- */
-PyInterp_Request* PyConsole_Editor::createRequest( const QString& command )
-{
-  return new ExecCommand( myInterp, command, this, isSync() );
-}
-
-/*!
-  \brief Execute command in the python interpreter
-  and wait until it is finished.
-
-  \param command python command to be executed
- */
-void PyConsole_Editor::execAndWait( const QString& command )
-{
-  // already running ?
-  if( myEventLoop )
-    return;
-
-  // create new event loop
-  myEventLoop = new QEventLoop( this );
-  // execute command
-  exec( command );
-  // run event loop
-  myEventLoop->exec();
-  // delete event loop after command is processed
-  delete myEventLoop;
-  myEventLoop = 0;
-}
-
-/*!
-  \brief Process "Enter" key press event. 
-  
-  Execute the command entered by the user.
-*/
-void PyConsole_Editor::handleReturn()
-{
-  // Position cursor at the end
-  QTextCursor curs(textCursor());
-  curs.movePosition(QTextCursor::End);
-  setTextCursor(curs);
-
-  // get last line
-  QTextBlock par = document()->end().previous();
-  if ( !par.isValid() ) return;
-
-  // get command
-  QString cmd = par.text().remove( 0, promptSize() );
-  // extend the command buffer with the current command 
-  myCommandBuffer.append( cmd );
-  // add command to the history
-  if ( !cmd.trimmed().isEmpty() )
-    myHistory.push_back( cmd );
-
-  // IPAL19397
-  addText( "", true ); 
-  
-  // set read-only mode
-  setReadOnly( true );
-  // set busy cursor
-  setCursor( Qt::BusyCursor );
-  
-  // post a request to execute Python command;
-  // editor will be informed via a custom event that execution has been completed
-  PyInterp_Dispatcher::Get()->Exec( createRequest( myCommandBuffer ) );
-}
-
-/*!
-  \brief Process drop event.
-
-  Paste dragged text.
-  \param event drop event
-*/
-void PyConsole_Editor::dropEvent( QDropEvent* event )
-{
-  // get the initial drop position
-  QPoint pos = event->pos();
-  QTextCursor cur = cursorForPosition( event->pos() );
-  // if the position is not in the last line move it to the end of the command line
-  if ( cur.position() < document()->end().previous().position() + promptSize() ) {
-    moveCursor( QTextCursor::End );
-    pos = cursorRect().center();
-  }
-  // create new drop event and use it instead of the original
-  QDropEvent de( pos,
-                 event->possibleActions(),
-                 event->mimeData(),
-                 event->mouseButtons(),
-                 event->keyboardModifiers(),
-                 event->type() );
-  QTextEdit::dropEvent( &de );
-  // accept the original event
-  event->acceptProposedAction();
-}
-
-/*!
-  \brief Process mouse button release event.
-
-  Left mouse button: copy selection to the clipboard.
-  Middle mouse button: paste clipboard's contents.
-  \param event mouse event
-*/
-void PyConsole_Editor::mouseReleaseEvent( QMouseEvent* event )
-{
-  if ( event->button() == Qt::LeftButton ) {
-    QTextEdit::mouseReleaseEvent( event );
-    //copy();
-  }
-  else if ( event->button() == Qt::MidButton ) {
-    QTextCursor cur = cursorForPosition( event->pos() );
-    // if the position is not in the last line move it to the end of the command line
-    if ( cur.position() < document()->end().previous().position() + promptSize() ) {
-      moveCursor( QTextCursor::End );
-    }
-    else {
-      setTextCursor( cur );
-    }
-    const QMimeData* md = QApplication::clipboard()->mimeData( QApplication::clipboard()->supportsSelection() ? 
-                                                              QClipboard::Selection : QClipboard::Clipboard );
-    if ( md )
-      insertFromMimeData( md );
-  }
-  else {
-    QTextEdit::mouseReleaseEvent( event );
-  }
-}
-
-/*!
-  \brief Check if the string is command.
-  
-  Return True if the string \a str is likely to be the command
-  (i.e. it is started from the '>>>' or '...').
-  \param str string to be checked
-*/
-bool PyConsole_Editor::isCommand( const QString& str ) const
-{
-  return str.startsWith( READY_PROMPT ) || str.startsWith( DOTS_PROMPT );
-}
-
-/*!
-  \brief Handle keyboard event.
-
-  Implement navigation, history browsing, copy/paste and other common
-  operations.
-  \param event keyboard event
-*/
-void PyConsole_Editor::keyPressEvent( QKeyEvent* event )
-{
-  // get cursor position
-  QTextCursor cur = textCursor();
-  int curLine = cur.blockNumber();
-  int curCol  = cur.columnNumber();
-
-  // get last edited line
-  int endLine = document()->blockCount()-1;
-
-  // get pressed key code
-  int aKey = event->key();
-
-  // check if <Ctrl> is pressed
-  bool ctrlPressed = event->modifiers() & Qt::ControlModifier;
-  // check if <Shift> is pressed
-  bool shftPressed = event->modifiers() & Qt::ShiftModifier;
-
-  if ( aKey == Qt::Key_Escape || ( ctrlPressed && aKey == -1 ) ) {
-    // process <Ctrl>+<Break> key-binding and <Escape> key: clear current command
-    myCommandBuffer.truncate( 0 );
-    myPrompt = READY_PROMPT;
-    addText( myPrompt, true );
-    horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() );
-    return;
-  }
-  else if ( ctrlPressed && aKey == Qt::Key_C ) {
-    // process <Ctrl>+<C> key-binding : copy
-    copy();
-    return;
-  }
-  else if ( ctrlPressed && aKey == Qt::Key_X ) {
-    // process <Ctrl>+<X> key-binding : cut
-    cut();
-    return;
-  }
-  else if ( ctrlPressed && aKey == Qt::Key_V ) {
-    // process <Ctrl>+<V> key-binding : paste
-    paste();
-    return;
-  }
-
-  // check for printed key
-  // #### aKey = ( aKey < Qt::Key_Space || aKey > Qt::Key_ydiaeresis ) ? aKey : 0;
-  // Better:
-  aKey = !(QChar(aKey).isPrint()) ? aKey : 0;
-
-  switch ( aKey ) {
-  case 0 :
-    // any printed key: just print it
-    {
-      if ( curLine < endLine || curCol < promptSize() ) {
-        moveCursor( QTextCursor::End );
-      }
-      QTextEdit::keyPressEvent( event );
-      break;
-    }
-  case Qt::Key_Return:
-  case Qt::Key_Enter:
-    // <Enter> key: process the current command
-    {
-      handleReturn();
-      break;
-    }
-  case Qt::Key_Up:
-    // <Up> arrow key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: previous command in history
-    // - with <Ctrl> modifier key pressed:  move cursor one row up without selection
-    // - with <Shift> modifier key pressed: move cursor one row up with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one row up
-    {
-      if ( ctrlPressed && shftPressed ) {
-        int value   = verticalScrollBar()->value();
-        int spacing = fontMetrics().lineSpacing();
-        verticalScrollBar()->setValue( value > spacing ? value-spacing : 0 );
-      }
-      else if ( shftPressed || ctrlPressed ) {
-        if ( curLine > 0 )
-          moveCursor( QTextCursor::Up, 
-                      shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor );
-      }
-      else { 
-        if ( myCmdInHistory < 0 && myHistory.count() > 0 ) {
-          // set history browsing mode
-          myCmdInHistory = myHistory.count();
-          // remember current command
-          QTextBlock par = document()->end().previous();
-          myCurrentCommand = par.text().remove( 0, promptSize() );
-        }
-        if ( myCmdInHistory > 0 ) {
-          myCmdInHistory--;
-          // get previous command in the history
-          QString previousCommand = myHistory.at( myCmdInHistory );
-          // print previous command
-          moveCursor( QTextCursor::End );
-          moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor );
-          textCursor().removeSelectedText();
-          addText( myPrompt + previousCommand ); 
-          // move cursor to the end
-          moveCursor( QTextCursor::End );
-        }
-      }
-      break;
-    }
-  case Qt::Key_Down:
-    // <Down> arrow key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: next command in history
-    // - with <Ctrl> modifier key pressed:  move cursor one row down without selection
-    // - with <Shift> modifier key pressed: move cursor one row down with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one row down
-    {
-      if ( ctrlPressed && shftPressed ) {
-        int value   = verticalScrollBar()->value();
-        int maxval  = verticalScrollBar()->maximum();
-        int spacing = fontMetrics().lineSpacing();
-        verticalScrollBar()->setValue( value+spacing < maxval ? value+spacing : maxval );
-      }
-      else if ( shftPressed || ctrlPressed) {
-        if ( curLine < endLine )
-          moveCursor( QTextCursor::Down, 
-                      shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor );
-      }
-      else { 
-        if ( myCmdInHistory >= 0 ) {
-          // get next command in the history
-          myCmdInHistory++;
-          QString nextCommand;
-          if ( myCmdInHistory < myHistory.count() ) {
-            // next command in history
-            nextCommand = myHistory.at( myCmdInHistory );
-          }
-          else {
-            // end of history is reached
-            // last printed command
-            nextCommand = myCurrentCommand;
-            // unset history browsing mode
-            myCmdInHistory = -1;
-          }
-          // print next or current command
-          moveCursor( QTextCursor::End );
-          moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor );
-          textCursor().removeSelectedText();
-          addText( myPrompt + nextCommand );
-          // move cursor to the end
-          moveCursor( QTextCursor::End );
-        }
-      }
-      break;
-    }
-  case Qt::Key_Left:
-    // <Left> arrow key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: move one symbol left (taking into account prompt)
-    // - with <Ctrl> modifier key pressed:  move one word left (taking into account prompt)
-    // - with <Shift> modifier key pressed: move one symbol left with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: move one word left with selection
-    {
-      QString txt = textCursor().block().text();
-      if ( !shftPressed && isCommand( txt ) && curCol <= promptSize() ) {
-        moveCursor( QTextCursor::Up );
-        moveCursor( QTextCursor::EndOfBlock );
-      }
-      else {
-        QTextEdit::keyPressEvent( event );
-      }
-      break;
-    }
-  case Qt::Key_Right:
-    // <Right> arrow key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: move one symbol right (taking into account prompt)
-    // - with <Ctrl> modifier key pressed:  move one word right (taking into account prompt)
-    // - with <Shift> modifier key pressed: move one symbol right with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: move one word right with selection
-    {
-      QString txt = textCursor().block().text();
-      if ( !shftPressed ) {
-        if ( curCol < txt.length() ) {
-          if ( isCommand( txt ) && curCol < promptSize() ) {
-            cur.setPosition( cur.block().position() + promptSize() );
-            setTextCursor( cur );
-            break;
-          }
-        }
-        else {
-          if ( curLine < endLine && isCommand( textCursor().block().next().text() ) ) {
-            cur.setPosition( cur.position() + promptSize()+1 );
-            setTextCursor( cur );
-            horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() );
-            break;
-          }
-        }
-      }
-      QTextEdit::keyPressEvent( event );
-      break;
-    }
-  case Qt::Key_PageUp:
-    // <PageUp> key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: first command in history
-    // - with <Ctrl> modifier key pressed:  move cursor one page up without selection
-    // - with <Shift> modifier key pressed: move cursor one page up with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one page up
-    {
-      if ( ctrlPressed && shftPressed ) {
-        verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
-      }
-      else if ( shftPressed || ctrlPressed ) {
-        bool moved = false;
-        qreal lastY = cursorRect( cur ).top();
-        qreal distance = 0;
-        // move using movePosition to keep the cursor's x
-        do {
-          qreal y = cursorRect( cur ).top();
-          distance += qAbs( y - lastY );
-          lastY = y;
-          moved = cur.movePosition( QTextCursor::Up, 
-                                    shftPressed ? QTextCursor::KeepAnchor : 
-                                                  QTextCursor::MoveAnchor );
-        } while ( moved && distance < viewport()->height() );
-        if ( moved ) {
-          cur.movePosition( QTextCursor::Down, 
-                            shftPressed ? QTextCursor::KeepAnchor : 
-                                          QTextCursor::MoveAnchor );
-          verticalScrollBar()->triggerAction( QAbstractSlider::SliderPageStepSub );
-        }
-        setTextCursor( cur );
-      }
-      else { 
-        if ( myCmdInHistory < 0 && myHistory.count() > 0 ) {
-          // set history browsing mode
-          myCmdInHistory = myHistory.count();
-          // remember current command
-          QTextBlock par = document()->end().previous();
-          myCurrentCommand = par.text().remove( 0, promptSize() );
-        }
-        if ( myCmdInHistory > 0 ) {
-          myCmdInHistory = 0;
-          // get very first command in the history
-          QString firstCommand = myHistory.at( myCmdInHistory );
-          // print first command
-          moveCursor( QTextCursor::End );
-          moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor );
-          textCursor().removeSelectedText();
-          addText( myPrompt + firstCommand ); 
-          // move cursor to the end
-          moveCursor( QTextCursor::End );
-        }
-      }
-      break;
-    }
-  case Qt::Key_PageDown:
-    // <PageDown> key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: last command in history
-    // - with <Ctrl> modifier key pressed:  move cursor one page down without selection
-    // - with <Shift> modifier key pressed: move cursor one page down with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one page down
-    {
-      if ( ctrlPressed && shftPressed ) {
-        verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
-      }
-      else if ( shftPressed || ctrlPressed ) {
-        bool moved = false;
-        qreal lastY = cursorRect( cur ).top();
-        qreal distance = 0;
-        // move using movePosition to keep the cursor's x
-        do {
-          qreal y = cursorRect( cur ).top();
-          distance += qAbs( y - lastY );
-          lastY = y;
-          moved = cur.movePosition( QTextCursor::Down, 
-                                    shftPressed ? QTextCursor::KeepAnchor : 
-                                                  QTextCursor::MoveAnchor );
-        } while ( moved && distance < viewport()->height() );
-        if ( moved ) {
-          cur.movePosition( QTextCursor::Up, 
-                            shftPressed ? QTextCursor::KeepAnchor : 
-                                          QTextCursor::MoveAnchor );
-          verticalScrollBar()->triggerAction( QAbstractSlider::SliderPageStepSub );
-        }
-        setTextCursor( cur );
-      }
-      else { 
-        if ( myCmdInHistory >= 0 ) {
-          // unset history browsing mode
-          myCmdInHistory = -1;
-          // print current command
-          moveCursor( QTextCursor::End );
-          moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor );
-          textCursor().removeSelectedText();
-          addText( myPrompt + myCurrentCommand ); 
-          // move cursor to the end
-          moveCursor( QTextCursor::End );
-        }
-      }
-      break;
-    }
-  case Qt::Key_Home: 
-    // <Home> key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: move cursor to the beginning of the current line without selection
-    // - with <Ctrl> modifier key pressed:  move cursor to the very first symbol without selection
-    // - with <Shift> modifier key pressed: move cursor to the beginning of the current line with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: move cursor to the very first symbol with selection
-    {
-      if ( ctrlPressed ) { 
-        moveCursor( QTextCursor::Start, 
-                    shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor );
-      }
-      else {
-        QString txt = textCursor().block().text();
-        if ( isCommand( txt ) ) {
-          if ( shftPressed ) {
-            if ( curCol > promptSize() ) {
-              cur.movePosition( QTextCursor::StartOfLine, QTextCursor::KeepAnchor );
-              cur.movePosition( QTextCursor::Right, QTextCursor::KeepAnchor, promptSize() );
-            }
-          }
-          else {
-            cur.movePosition( QTextCursor::StartOfLine );
-            cur.movePosition( QTextCursor::Right, QTextCursor::MoveAnchor, promptSize() );
-          }
-          setTextCursor( cur );
-        }
-        else {
-          moveCursor( QTextCursor::StartOfBlock, 
-                      shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor );
-        }
-        horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() );
-      }
-      break;
-    }
-  case Qt::Key_End:
-    // <End> key: process as follows:
-    // - without <Ctrl>, <Shift> modifiers: move cursor to the end of the current line without selection
-    // - with <Ctrl> modifier key pressed:  move cursor to the very last symbol without selection
-    // - with <Shift> modifier key pressed: move cursor to the end of the current line with selection
-    // - with <Ctrl>+<Shift> modifier keys pressed: move cursor to the very last symbol with selection
-    {
-      moveCursor( ctrlPressed ? QTextCursor::End : QTextCursor::EndOfBlock, 
-                  shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor );
-      break;
-    }  
-  case Qt::Key_Backspace :
-    // <Backspace> key: process as follows
-    // - without any modifiers : delete symbol before the cursor / selection (taking into account prompt)
-    // - with <Shift> modifier key pressed: delete previous word
-    // - with <Ctrl> modifier key pressed: delete text from the cursor to the line beginning
-    // works only for last (command) line
-    {
-      if ( cur.hasSelection() ) {
-        cut();
-      }
-      else if ( cur.position() > document()->end().previous().position() + promptSize() ) {
-        if ( shftPressed ) {
-          moveCursor( QTextCursor::PreviousWord, QTextCursor::KeepAnchor );
-          textCursor().removeSelectedText();
-        }
-        else if ( ctrlPressed ) {
-          cur.setPosition( document()->end().previous().position() + promptSize(),
-                           QTextCursor::KeepAnchor );
-          setTextCursor( cur );
-          textCursor().removeSelectedText();
-        }
-        else {
-          QTextEdit::keyPressEvent( event );
-        }
-      }
-      else {
-        cur.setPosition( document()->end().previous().position() + promptSize() );
-        setTextCursor( cur );
-        horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() );
-      }
-      break;
-    }
-  case Qt::Key_Delete :
-    // <Delete> key: process as follows
-    // - without any modifiers : delete symbol after the cursor / selection (taking into account prompt)
-    // - with <Shift> modifier key pressed: delete next word
-    // - with <Ctrl> modifier key pressed: delete text from the cursor to the end of line
-    // works only for last (command) line
-    {
-      if ( cur.hasSelection() ) {
-        cut();
-      }
-      else if ( cur.position() > document()->end().previous().position() + promptSize()-1 ) {
-        if ( shftPressed ) {
-          moveCursor( QTextCursor::NextWord, QTextCursor::KeepAnchor );
-          textCursor().removeSelectedText();
-        }
-        else if ( ctrlPressed ) {
-          moveCursor( QTextCursor::EndOfBlock, QTextCursor::KeepAnchor );
-          textCursor().removeSelectedText();
-        }
-        else {
-          QTextEdit::keyPressEvent( event );
-        }
-      }
-      else {
-        cur.setPosition( document()->end().previous().position() + promptSize() );
-        setTextCursor( cur );
-        horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() );
-      }
-      break;
-    }
-  case Qt::Key_Insert :
-    // <Insert> key: process as follows
-    // - with <Ctrl> modifier key pressed:  copy()
-    // - with <Shift> modifier key pressed: paste() to the command line
-    {
-      if ( ctrlPressed ) {
-        copy();
-      }
-      else if ( shftPressed ) {
-        paste();
-      }
-      else
-        QTextEdit::keyPressEvent( event );
-      break;
-    }
-  }
-}
-
-/*!
-  \brief Handle notification event coming from Python dispatcher.
-  \param event notification event
-*/
-void PyConsole_Editor::customEvent( QEvent* event )
-{
-  switch( event->type() )
-  {
-  case PrintEvent::EVENT_ID:
-    {
-      PrintEvent* pe=(PrintEvent*)event;
-      addText( pe->text(), false, pe->isError());
-      return;
-    }
-  case PyInterp_Event::ES_OK:
-  case PyInterp_Event::ES_ERROR:
-  {
-    // clear command buffer
-    myCommandBuffer.truncate( 0 );
-    // add caret return line if necessary
-    QTextBlock par = document()->end().previous();
-    QString txt = par.text();
-    txt.truncate( txt.length() - 1 );
-    // IPAL19397 : addText moved to handleReturn() method
-    //if ( !txt.isEmpty() )
-    //  addText( "", true );
-    // set "ready" prompt
-    myPrompt = READY_PROMPT;
-    addText( myPrompt );
-    // unset busy cursor
-    unsetCursor();
-    // stop event loop (if running)
-    if ( myEventLoop )
-      myEventLoop->exit();
-    break;
-  }
-  case PyInterp_Event::ES_INCOMPLETE:
-  {
-    // extend command buffer (multi-line command)
-    myCommandBuffer.append( "\n" );
-    // add caret return line if necessary
-    QTextBlock par = document()->end().previous();
-    QString txt = par.text();
-    txt.truncate( txt.length() - 1 );
-    // IPAL19397 : addText moved to handleReturn() method
-    //if ( !txt.isEmpty() )
-    //  addText( "", true );
-    // set "dot" prompt
-    myPrompt = DOTS_PROMPT;
-    addText( myPrompt/*, true*/ ); // IPAL19397
-    // unset busy cursor
-    unsetCursor();
-    // stop event loop (if running)
-    if ( myEventLoop )
-      myEventLoop->exit();
-    break;
-  }
-  default:
-    QTextEdit::customEvent( event );
-  }
-  
-  // unset read-only state
-  setReadOnly( false );
-  // unset history browsing mode
-  myCmdInHistory = -1;
-
-  if ( (int)event->type() == (int)PyInterp_Event::ES_OK && myQueue.count() > 0 )
-  {
-    // process the next sheduled command from the queue (if there is any)
-    QString nextcmd = myQueue[0];
-    myQueue.pop_front();
-    exec( nextcmd );
-  }
-}
-
-/*!
-  \brief Handle Python interpreter change.
-
-  Perform initialization actions if the interpreter is changed.
-  \param interp python interpreter is being set
-*/
-void PyConsole_Editor::onPyInterpChanged( PyConsole_Interp* interp )
-{
-  if ( myInterp != interp 
-       // Force read-only state and wait cursor when myInterp is NULL
-      || !myInterp ) {
-    myInterp = interp;
-    if ( myInterp ) {
-      // print banner
-      myBanner = myInterp->getbanner().c_str();
-      if ( isShowBanner() )
-       addText( myBanner );
-      // clear command buffer
-      myCommandBuffer.truncate(0);
-      // unset read-only state
-      setReadOnly( false );
-      // unset history browsing mode
-      myCmdInHistory = -1;
-      // add prompt
-      addText( myPrompt );
-      // unset busy cursor
-      viewport()->unsetCursor();
-      // stop event loop (if running)
-      if( myEventLoop)
-        myEventLoop->exit();
-    }
-    else {
-      // clear contents
-      clear();
-      // set read-only state
-      setReadOnly( true );
-      // set busy cursor
-      setCursor( Qt::WaitCursor );
-    }
-  }
-}
-
-/*!
-  \brief "Copy" operation.
-  
-  Reimplemented from Qt.
-  Warning! In Qt4 this method is not virtual.
- */
-void PyConsole_Editor::cut()
-{
-  QTextCursor cur = textCursor();
-  if ( cur.hasSelection() ) {
-    QApplication::clipboard()->setText( cur.selectedText() );
-    int startSelection = cur.selectionStart();
-    if ( startSelection < document()->end().previous().position() + promptSize() )
-      startSelection = document()->end().previous().position() + promptSize();
-    int endSelection = cur.selectionEnd();
-    if ( endSelection < document()->end().previous().position() + promptSize() )
-      endSelection = document()->end().previous().position() + promptSize();
-    cur.setPosition( startSelection );
-    cur.setPosition( endSelection, QTextCursor::KeepAnchor );
-    horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() );
-    setTextCursor( cur );
-    textCursor().removeSelectedText();
-  }
-}
-
-/*!
-  \brief "Paste" operation.
-
-  Reimplemented from Qt.
-  Warning! In Qt4 this method is not virtual.
- */
-void PyConsole_Editor::paste()
-{
-  QTextCursor cur = textCursor();
-  if ( cur.hasSelection() ) {
-    int startSelection = cur.selectionStart();
-    if ( startSelection < document()->end().previous().position() + promptSize() )
-      startSelection = document()->end().previous().position() + promptSize();
-    int endSelection = cur.selectionEnd();
-    if ( endSelection < document()->end().previous().position() + promptSize() )
-      endSelection = document()->end().previous().position() + promptSize();
-    cur.setPosition( startSelection );
-    cur.setPosition( endSelection, QTextCursor::KeepAnchor );
-    horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() );
-    setTextCursor( cur );
-    textCursor().removeSelectedText();
-  }
-  if ( textCursor().position() < document()->end().previous().position() + promptSize() )
-    moveCursor( QTextCursor::End );
-  QTextEdit::paste();
-}
-
-/*!
-  \brief "Clear" operation.
-
-  Reimplemented from Qt.
-  Warning! In Qt4 this method is not virtual.
- */
-void PyConsole_Editor::clear()
-{
-  QTextEdit::clear();
-  if ( isShowBanner() )
-    addText( myBanner );
-  myPrompt = READY_PROMPT;
-  addText( myPrompt );
-}
-
-/*!
-  \brief "Dump commands" operation.
- */
-/*void PyConsole_Editor::dump()
-{
-  QStringList aFilters;
-  aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
-  
-  QString fileName = SUIT_FileDlg::getFileName( this, QString(),
-                                    aFilters, tr( "TOT_DUMP_PYCOMMANDS" ),
-                                    false, true, new DumpCommandsFileValidator( this ) );
-  if ( fileName != "" ) {
-    QFile file( fileName ); 
-    if ( !file.open( QFile::WriteOnly ) )
-      return;
-
-    QTextStream out (&file);
-  
-    for( int i=0; i<myHistory.count(); i++ ) {
-         out<<myHistory[i]<<endl;
-    }
-    file.close();
-  }
-}*/
diff --git a/src/PyConsole/PyConsole_Editor.h b/src/PyConsole/PyConsole_Editor.h
deleted file mode 100644 (file)
index f3324dc..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-
-#ifndef PYCONSOLE_EDITOR_H
-#define PYCONSOLE_EDITOR_H
-
-#include "PyConsole.h"
-
-#include <QTextEdit>
-
-class PyConsole_Interp;
-class PyInterp_Request;
-class QEventLoop;
-
-class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit
-{
-  Q_OBJECT;
-
-public:
-  PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 );
-  ~PyConsole_Editor();
-  
-  virtual void   addText( const QString& str, const bool newBlock = false, const bool isError = false );
-  bool           isCommand( const QString& str ) const;
-
-  virtual void   exec( const QString& command );
-  void           execAndWait( const QString& command );
-
-  bool           isSync() const;
-  void           setIsSync( const bool );
-
-  bool           isSuppressOutput() const;
-  void           setIsSuppressOutput(const bool);
-
-  bool           isShowBanner() const;
-  void           setIsShowBanner( const bool );
-
-  virtual QSize  sizeHint() const;
-
-public slots:
-    void           cut();
-    void           paste();
-    void           clear();
-    void           handleReturn();
-    void           onPyInterpChanged( PyConsole_Interp* );
-    //.void           dump();
-
-protected:
-  virtual void   dropEvent( QDropEvent* event );
-  virtual void   mouseReleaseEvent( QMouseEvent* event );
-  virtual void   keyPressEvent ( QKeyEvent* event);
-  virtual void   customEvent( QEvent* event);
-
-  virtual PyInterp_Request* createRequest( const QString& );
-
-  /** Convenience function */
-  inline int promptSize() const { return myPrompt.size(); }
-
-  PyConsole_Interp* myInterp;           //!< python interpreter
-
-  QString           myCommandBuffer;    //!< python command buffer
-  QString           myCurrentCommand;   //!< currently being printed command
-  QString           myPrompt;           //!< current command line prompt
-  int               myCmdInHistory;     //!< current history command index
-  QStringList       myHistory;          //!< commands history buffer
-  QEventLoop*       myEventLoop;        //!< internal event loop
-  QString           myBanner;           //!< current banner
-  bool              myShowBanner;       //!< 'show banner' flag
-  QStringList       myQueue;            //!< python commands queue
-  bool              myIsSync;           //!< synchronous mode flag
-  bool              myIsSuppressOutput; //!< suppress output flag
-};
-
-#endif // PYCONSOLE_EDITOR_H
diff --git a/src/PyConsole/PyConsole_EnhEditor.cpp b/src/PyConsole/PyConsole_EnhEditor.cpp
deleted file mode 100644 (file)
index d5c47df..0000000
+++ /dev/null
@@ -1,464 +0,0 @@
-
-
-#include "PyConsole.h"
-#include <Python.h>
-
-#include <QKeyEvent>
-#include <QTextBlock>
-#include <QTextCursor>
-#include <QTextCharFormat>
-#include <QRegExp>
-#include <QMimeData>
-
-#include "PyConsole_EnhEditor.h"
-#include "PyConsole_EnhInterp.h"
-#include "PyConsole_Request.h"
-#include "PyInterp_Dispatcher.h"
-
-// Initialize list of valid separators
-static const char * tmp_a[] = {" ", "(", "[","+", "-", "*", "/", ";", "^", "="};
-const std::vector<QString> PyConsole_EnhEditor::SEPARATORS = \
-    std::vector<QString>(tmp_a, tmp_a + sizeof(tmp_a)/sizeof(tmp_a[0]));
-
-/**
- * Constructor.
- * @param interp the interpreter linked to the editor
- * @param parent parent widget
- */
-PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent) :
-     PyConsole_Editor(interp, parent),
-     _tab_mode(false),
-     _cursor_pos(-1),
-     _multi_line_paste(false),
-     _multi_line_content()
-{
-  document()->setUndoRedoEnabled(true);
-}
-
-/**
- * Overrides. Catches the TAB and Ctrl+TAB combinations.
- * @param event
- */
-void PyConsole_EnhEditor::keyPressEvent ( QKeyEvent* event)
-{
-  // check if <Ctrl> is pressed
-  bool ctrlPressed = event->modifiers() & Qt::ControlModifier;
-  // check if <Shift> is pressed
-  bool shftPressed = event->modifiers() & Qt::ShiftModifier;
-
-  if (event->key() == Qt::Key_Tab && !shftPressed)
-    {
-      if (!ctrlPressed)
-        handleTab();
-      else
-        {
-          clearCompletion();
-          handleBackTab();
-        }
-      PyConsole_Editor::keyPressEvent(event);
-    }
-  else
-    {
-      // If ctrl is not pressed (and sth else is pressed with it),
-      // or if ctrl is not pressed alone
-      if (!ctrlPressed || (ctrlPressed && event->key() != Qt::Key_Control))
-        {
-          clearCompletion();
-          _cursor_pos = -1;
-        }
-      // Discard ctrl pressed alone:
-      if (event->key() != Qt::Key_Control)
-        PyConsole_Editor::keyPressEvent(event);
-    }
-}
-
-/**
- * Whenever the mouse is clicked, clear the completion.
- * @param e
- */
-void PyConsole_EnhEditor::mousePressEvent(QMouseEvent* e)
-{
-  clearCompletion();
-  _cursor_pos = -1;
-  PyConsole_Editor::mousePressEvent(e);
-}
-
-/**
- * Clear in the editor the block of text displayed after having hit <TAB>.
- */
-void PyConsole_EnhEditor::clearCompletion()
-{
-  // Delete completion text if present
-  if (_tab_mode)
-    {
-      // Remove completion display
-      document()->undo();
-      // Remove trailing line return:
-      QTextCursor tc(textCursor());
-      tc.setPosition(document()->characterCount()-1);
-      setTextCursor(tc);
-      textCursor().deletePreviousChar();
-      // TODO: before wait for any TAB event to be completed
-      static_cast<PyConsole_EnhInterp *>(myInterp)->clearCompletion();
-    }
-  _tab_mode = false;
-}
-
-/**
- * Handle the sequence of events after having hit <TAB>
- */
-void PyConsole_EnhEditor::handleTab()
-{
-  if (_tab_mode)
-    {
-      // Already tab mode - nothing to do !
-      return;
-    }
-
-  QTextCursor cursor(textCursor());
-
-  // Cursor at end of input
-  cursor.movePosition(QTextCursor::End);
-  setTextCursor(cursor);
-
-  // Save cursor position if needed
-  if (_cursor_pos == -1)
-    _cursor_pos = textCursor().position();
-
-  // get last line
-  QTextBlock par = document()->end().previous();
-  if ( !par.isValid() ) return;
-
-  // Switch to completion mode
-  _tab_mode = true;
-
-  QString cmd = par.text().mid(promptSize());
-
-  // Post completion request
-  // Editor will be informed via a custom event that completion has been run
-  PyInterp_Request* req = createTabRequest(cmd);
-  PyInterp_Dispatcher::Get()->Exec(req);
-}
-
-/**
- * Handles what happens after hitting Ctrl-TAB
- */
-void PyConsole_EnhEditor::handleBackTab()
-{
-  QTextCursor cursor(textCursor());
-
-  if (_cursor_pos == -1)
-    {
-      // Invalid cursor position - we can't do anything:
-      return;
-    }
-  // Ensure cursor is at the end of command line
-  cursor.setPosition(_cursor_pos);
-  cursor.movePosition(QTextCursor::EndOfLine);
-  //setCursor(cursor);
-
-  // Delete last completed text
-  int i = cursor.position() - _cursor_pos;
-  cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor, i);
-  cursor.removeSelectedText();
-  _cursor_pos = -1;
-}
-
-/**
- * Create the Python requested that will be posted to the interpreter to
- * get the completions.
- * @param input line typed by the user at the time TAB was hit
- * @return a CompletionCommand
- * @sa CompletionCommand
- */
-PyInterp_Request* PyConsole_EnhEditor::createTabRequest( const QString& input )
-{
-  // Parse input to extract on what part the dir() has to be executed
-  QString input2(input);
-
-  // Split up to the last syntaxical separator
-  int lastSp = -1;
-  for (std::vector<QString>::const_iterator i = SEPARATORS.begin(); i != SEPARATORS.end(); i++)
-    {
-      int j = input2.lastIndexOf(*i);
-      if (j > lastSp)
-        lastSp = j;
-    }
-  if (lastSp >= 0)
-    input2 = input.mid(lastSp+1);
-
-  // Detect a qualified name (with a point)
-  int lastPt = input2.lastIndexOf(QString("."));
-
-  // Split the 2 surrounding parts of the qualified name
-  if (lastPt != -1)
-    {
-      _compl_before_point = input2.left(lastPt);
-      _compl_after_point = input2.mid(lastPt+1);
-    }
-  else
-    {
-      // No point found - do a global matching -
-      // (the following will call dir() with an empty string)
-      _compl_after_point = input2;
-      _compl_before_point = QString("");
-    }
-
-  return new CompletionCommand( static_cast<PyConsole_EnhInterp *>(myInterp), _compl_before_point,
-                               _compl_after_point, this, isSync() );
-}
-
-/**
- * Format completion results - this is where we should create 3 columns etc ...
- * @param matches list of possible completions
- * @param result return value
- */
-void PyConsole_EnhEditor::formatCompletion(const std::vector<QString> & matches, QString & result) const
-{
-  int sz = matches.size();
-
-  if (sz > MAX_COMPLETIONS)
-    {
-      sz = MAX_COMPLETIONS;
-      result.append("[Too many matches! Displaying first ones only ...]\n");
-    }
-
-  for (int i = 0; i < sz; ++i)
-    {
-      result.append(matches[i]);
-      result.append("\n");
-    }
-}
-
-/**
- * Override. Catches the events generated by the enhanced interpreter after the execution
- * of a completion request.
- * @param event
- */
-void PyConsole_EnhEditor::customEvent( QEvent* event )
-{
-  std::vector<QString> matches;
-  QString first_match, comple_text, doc, base;
-  QTextCursor cursor(textCursor());
-  QTextBlockFormat bf;
-  QTextCharFormat cf;
-  PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(myInterp);
-  int cursorPos;
-
-  switch( event->type() )
-  {
-    case PyInterp_Event::ES_TAB_COMPLETE_OK:
-      // Extract corresponding matches from the interpreter
-      matches = interp->getLastMatches();
-
-      if (matches.size() == 0)
-        {
-          // Completion successful but nothing returned.
-          _tab_mode = false;
-          _cursor_pos = -1;
-          return;
-        }
-
-      // Only one match - complete directly and update doc string window
-      doc = interp->getDocStr();
-      if (matches.size() == 1)
-        {
-          first_match = matches[0].mid(_compl_after_point.size());
-          cursor.insertText(first_match);
-          _tab_mode = false;
-          if (doc == QString(""))
-            emit updateDoc(formatDocHTML("(no documentation available)\n"));
-          else
-            emit updateDoc(formatDocHTML(doc));
-        }
-      else
-        {
-          // Detect if there is a common base to all available completion
-          // In this case append this base to the text already
-          extractCommon(matches, base);
-          first_match = base.mid(_compl_after_point.size());
-          cursor.insertText(first_match);
-
-          // If this happens to match exaclty the first completion
-          // also provide doc
-          if (base == matches[0])
-            {
-              doc = formatDocHTML(doc);
-              emit updateDoc(doc);
-            }
-
-          // Print all matching completion in a "undo-able" block
-          cursorPos = cursor.position();
-          cursor.insertBlock();
-          cursor.beginEditBlock();
-
-          // Insert all matches
-          QTextCharFormat cf;
-          cf.setForeground(QBrush(Qt::darkGreen));
-          cursor.setCharFormat(cf);
-          formatCompletion(matches, comple_text);
-          cursor.insertText(comple_text);
-          cursor.endEditBlock();
-
-          // Position cursor where it was before inserting the completion list:
-          cursor.setPosition(cursorPos);
-          setTextCursor(cursor);
-        }
-      break;
-    case PyInterp_Event::ES_TAB_COMPLETE_ERR:
-      // Tab completion was unsuccessful, switch off mode:
-      _tab_mode = false;
-      _cursor_pos = -1;
-      break;
-    case PyInterp_Event::ES_OK:
-    case PyInterp_Event::ES_ERROR:
-    case PyInterp_Event::ES_INCOMPLETE:
-      // Before everything else, call super()
-      PyConsole_Editor::customEvent(event);
-      // If we are in multi_paste_mode, process the next item:
-      multiLineProcessNextLine();
-      break;
-    default:
-      PyConsole_Editor::customEvent( event );
-      break;
-  }
-}
-
-/**
- * Extract the common leading part of all strings in matches.
- * @param matches
- * @param result
- */
-void PyConsole_EnhEditor::extractCommon(const std::vector<QString> & matches, QString & result) const
-{
-  result = "";
-  int charIdx = 0;
-
-  if (matches.size() < 2)
-    return;
-
-  while (true)
-    {
-      if (charIdx >= matches[0].size())
-        return;
-      QChar ch = matches[0][charIdx];
-      for (size_t j = 1; j < matches.size(); j++)
-        if (charIdx >= matches[j].size() || matches[j][charIdx] != ch)
-          return;
-      result += ch;
-      charIdx++;
-    }
-}
-
-/**
- * Format the doc string in HTML format with the first line in bold blue
- * @param doc initial doc string
- * @return HTML string
- */
-QString PyConsole_EnhEditor::formatDocHTML(const QString & doc) const
-{
-  QString templ = QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" ") +
-      QString(" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n ") +
-      QString("<html><head><meta name=\"qrichtext\" content=\"1\" /> ") +
-      QString("<style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style> ") +
-      QString("</head><body style=\" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;\">\n") +
-      QString("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">") +
-      QString("<span style=\" font-weight:600; color:#0000ff;\">%1</span></p>") +
-      QString("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">%2</p>") +
-      QString("</body></html>");
-
-  QString fst, rest("");
-
-  // Extract first line of doc
-  int idx = doc.indexOf("\n");
-  if (idx > 0)
-    {
-      fst = doc.left(idx);
-      rest = doc.mid(idx+1);
-    }
-  else
-    {
-      fst = doc;
-    }
-
-  fst = fst.replace("\n", " ");
-  rest = rest.replace("\n", " ");
-  return templ.arg(fst).arg(rest);
-}
-
-/**
- * Handle properly multi-line pasting. Qt4 doc recommends overriding this function.
- * If the pasted text doesn't contain a line return, no special treatment is done.
- * @param source
- */
-void PyConsole_EnhEditor::insertFromMimeData(const QMimeData * source)
-{
-  if (_multi_line_paste)
-    return;
-
-  if (source->hasText())
-    {
-      QString s = source->text();
-      if (s.contains("\n"))
-        multilinePaste(s);
-      else
-        PyConsole_Editor::insertFromMimeData(source);
-    }
-  else
-    {
-      PyConsole_Editor::insertFromMimeData(source);
-    }
-}
-
-
-void PyConsole_EnhEditor::multilinePaste(const QString & s)
-{
-  // Turn on multi line pasting mode
-  _multi_line_paste = true;
-
-  // Split the string:
-  QString s2 = s;
-  s2.replace("\r", ""); // Windows string format converted to Unix style
-
-  QStringList lst = s2.split(QChar('\n'), QString::KeepEmptyParts);
-
-  // Perform the proper paste operation for the first line to handle the case where
-  // sth was already there:
-  QMimeData source;
-  source.setText(lst[0]);
-  PyConsole_Editor::insertFromMimeData(&source);
-
-  // Prepare what will have to be executed after the first line:
-  _multi_line_content = std::queue<QString>();
-  for (int i = 1; i < lst.size(); ++i)
-    _multi_line_content.push(lst[i]);
-
-  // Trigger the execution of the first (mixed) line
-  handleReturn();
-
-  // See customEvent() and multiLineProcessNext() for the rest of the handling.
-}
-
-/**
- * Process the next line in the queue of a multiple copy/paste:
- */
-void PyConsole_EnhEditor::multiLineProcessNextLine()
-{
-  if (!_multi_line_paste)
-    return;
-
-  QString line(_multi_line_content.front());
-  _multi_line_content.pop();
-  if (!_multi_line_content.size())
-    {
-      // last line in the queue, just paste it
-      addText(line, false, false);
-      _multi_line_paste = false;
-    }
-  else
-    {
-      // paste the line and simulate a <RETURN> key stroke
-      addText(line, false, false);
-      handleReturn();
-    }
-}
diff --git a/src/PyConsole/PyConsole_EnhEditor.h b/src/PyConsole/PyConsole_EnhEditor.h
deleted file mode 100644 (file)
index 03b5e19..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-#ifndef PYCONSOLE_ENHEDITOR_H_
-#define PYCONSOLE_ENHEDITOR_H_
-
-#include "PyConsole.h"
-
-#include "PyConsole_Editor.h"
-#include <QObject>
-#include <queue>
-
-class PyConsole_EnhInterp;
-
-/**
- * Enhanced Python editor handling tab completion.
- */
-class PYCONSOLE_EXPORT PyConsole_EnhEditor: public PyConsole_Editor
-{
-  Q_OBJECT;
-
-public:
-  PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent=0);
-  virtual ~PyConsole_EnhEditor() {}
-
-signals:
-  /**
-   * Signal emitted by the editor widget when the doc string should be updated.
-   * @param doc a HTML block with the formatted doc string.
-   * TODO: for now this signal is left uncaught.
-   */
-  void updateDoc(QString doc);
-
-protected:
-  /** List of separators identifying the last parsable token for completion */
-  static const std::vector<QString> SEPARATORS;
-
-  /** Maximum number of completions shown at once */
-  static const int MAX_COMPLETIONS = 70;
-
-  /** Are we in completion mode */
-  bool _tab_mode;
-
-  /** String on which the dir() comamnd is executed */
-  QString _compl_before_point;
-  /** String on which the results of the dir() are matched */
-  QString _compl_after_point;
-
-  /** Cursor position when <TAB> is hit */
-  int _cursor_pos;
-
-  /** Are we currently pasting several lines */
-  bool _multi_line_paste;
-
-  /** Queue of lines being pasted */
-  std::queue<QString> _multi_line_content;
-
-  // Overrides:
-  virtual void   keyPressEvent ( QKeyEvent* event);
-  virtual void   customEvent( QEvent* event);
-  virtual void   mousePressEvent( QMouseEvent* event );
-  virtual void   insertFromMimeData(const QMimeData * source);
-
-  virtual PyInterp_Request* createTabRequest( const QString& input );
-  virtual void handleTab();
-  virtual void handleBackTab();
-  virtual void clearCompletion();
-  virtual void formatCompletion(const std::vector<QString> & matches, QString & result) const;
-  virtual QString formatDocHTML(const QString & doc) const;
-
-  virtual void multilinePaste(const QString & s);
-  virtual void multiLineProcessNextLine();
-
-private:
-  void extractCommon(const std::vector<QString> & matches, QString & result) const;
-
-};
-
-#endif /* PYCONSOLE_ENHEDITOR_H_ */
diff --git a/src/PyConsole/PyConsole_EnhInterp.cpp b/src/PyConsole/PyConsole_EnhInterp.cpp
deleted file mode 100644 (file)
index 4332f31..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
-#include "PyConsole.h"
-
-#include "PyConsole_EnhInterp.h"
-
-#include <pythonrun.h>
-#include <string>
-#include <QRegExp>
-
-static const char * tmp_k[] = {"and",  "as", "assert", "break",  "class",
-    "continue", "def",  "del",
-    "elif", "else", "except", "exec", "finally",  "for",  "from", "global", "if",
-    "import", "in", "is", "lambda", "not",  "or", "pass", "print",  "raise",
-    "return", "try",  "while",  "with", "yield"};
-
-const std::vector<QString> PyConsole_EnhInterp::PYTHON_KEYWORDS = \
-      std::vector<QString>(tmp_k, tmp_k+sizeof(tmp_k)/sizeof(tmp_k[0]));
-
-/*!
-  \brief Run Python dir() command and saves the result internally in _lastPy
-  \param dirArgument Python expression to pass to the dir command. The parsing of what the
-  user actually started typing is dedicated to the caller
-  \param startMatch string representing the begining of the patter to be completed. For example when
-  the user types "a_string_variable.rsp <TAB>", this is "rsp".
-  \return command exit status - 0 = success
-*/
-int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QString & startMatch)
-{
-  int ret;
-  std::vector<QString> v;
-
-  clearCompletion();
-  if ( (ret = runDirAndExtract(dirArgument, startMatch, _last_matches)) )
-      return ret;
-
-  // If dirArgument is empty, we append the __builtins__
-  if (dirArgument.isEmpty())
-    {
-      if ( (ret = runDirAndExtract(QString("__builtins__"), startMatch, _last_matches, false)) )
-            return ret;
-
-      // ... and we match on Python's keywords as well:
-      for (std::vector<QString>::const_iterator it = PYTHON_KEYWORDS.begin(); it != PYTHON_KEYWORDS.end(); it++)
-          if ((*it).startsWith(startMatch))
-            _last_matches.push_back(*it);
-    }
-
-  // Try to get doc string of the first match
-  if (_last_matches.size() > 0)
-    {
-      QString cmd("");
-      if (dirArgument.trimmed() != "")
-        cmd = dirArgument + ".";
-      cmd += _last_matches[0] + ".__doc__";
-      PyObject * str = PyRun_String(cmd.toStdString().c_str(), Py_eval_input, _g, _g);
-      if (!str || str == Py_None || !PyString_Check(str))
-        {
-          if (!str)
-            PyErr_Clear();
-          _doc_str = "";
-        }
-      else
-        _doc_str = QString(PyString_AsString(str));
-      Py_XDECREF(str);
-    }
-
-  // The command has been successfully executed
-  return 0;
-}
-
-/**
- * See runDirCommand().
- * @param dirArgument see runDirCommand()
- * @param startMatch  see runDirCommand()
- * @param[out] result the list of matches
- * @param discardSwig if true a regular expression is used to discard all static method generated
- * by SWIG. typically: MEDCouplingUMesh_Blabla
- * @return -1 if the call to dir() or the parsing of the result failed, 0 otherwise.
- */
-int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument,
-       const QString & startMatch, std::vector<QString> & result,
-       bool discardSwig) const
-{
-  QRegExp re("^[A-Z].+_[A-Z]+[a-z]+.+$");  // discard SWIG static method, e.g. MEDCouplingUMesh_Blabla
-  QString command("dir(" + dirArgument + ")");
-  PyObject * plst = PyRun_String(command.toStdString().c_str(), Py_eval_input, _g, _g);
-  if(!plst || plst == Py_None) {
-    if(!plst)
-      PyErr_Clear();
-
-    Py_XDECREF(plst);
-    return -1;
-  }
-
-  // Extract the returned list and convert it to a vector<>
-  if (!PySequence_Check(plst))
-    {
-      // Should never happen ...
-      //std::cerr << "not a list!" << std::endl;
-      Py_XDECREF(plst);
-      return -1;
-    }
-
-  // Convert plst to a vector of QString
-  int n = PySequence_Length(plst);
-  for (int i = 0; i < n; i++)
-    {
-      PyObject * it;
-      it = PySequence_GetItem(plst, i);
-      QString s(PyString_AsString(it));
-      // if the method is not from swig, not static (guessed from the reg exp) and matches
-      // what is already there
-      if (s.startsWith(startMatch))
-        if(!discardSwig || (!re.exactMatch(s) && !s.contains("swig")))
-          result.push_back(s);
-      Py_DECREF(it);
-    }
-  Py_DECREF(plst);
-
-  return 0;
-}
-
-/**
- * Clear internal members containing the last completion results.
- */
-void PyConsole_EnhInterp::clearCompletion()
-{
-  _last_matches.resize(0);
-  _doc_str = QString("");
-}
-
-
-
diff --git a/src/PyConsole/PyConsole_EnhInterp.h b/src/PyConsole/PyConsole_EnhInterp.h
deleted file mode 100644 (file)
index 1af977c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-#ifndef PYCONSOLE_ENHINTERP_H_
-#define PYCONSOLE_ENHINTERP_H_
-
-#include "PyConsole.h"
-
-#include <Python.h>
-#include "PyConsole_Interp.h"
-
-#include <vector>
-#include <QString>
-
-/**
- * Enhanced Python interpreter used for auto-completion.
- * This extends PyConsole_Interp with an API wrapping the Python dir() command nicely.
- */
-class PYCONSOLE_EXPORT PyConsole_EnhInterp: public PyConsole_Interp
-{
-public:
-  PyConsole_EnhInterp()
-    : PyConsole_Interp(), _last_matches(0), _doc_str("")
-    {}
-
-  virtual ~PyConsole_EnhInterp() {}
-
-  const std::vector<QString>& getLastMatches() const { return _last_matches; }
-  const QString & getDocStr() const                  { return _doc_str; }
-
-  virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
-  virtual void clearCompletion();
-
-protected:
-  /** Hard coded list of Python keywords */
-  static const std::vector<QString> PYTHON_KEYWORDS;
-
-  /** Last computed matches */
-  std::vector<QString> _last_matches;
-  /** Doc string of the first match - when only one match it will be displayed by the Editor*/
-  QString _doc_str;
-
-  virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch,
-      std::vector<QString> & result, bool discardSwig=true) const;
-
-};
-
-#endif /* PYCONSOLE_ENHINTERP_H_ */
diff --git a/src/PyConsole/PyConsole_Event.cpp b/src/PyConsole/PyConsole_Event.cpp
deleted file mode 100644 (file)
index a3e2b05..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-#include "PyConsole_Event.h"
diff --git a/src/PyConsole/PyConsole_Event.h b/src/PyConsole/PyConsole_Event.h
deleted file mode 100644 (file)
index 84771b8..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-#ifndef PYCONSOLE_EVENT_H
-#define PYCONSOLE_EVENT_H
-
-#include "PyConsole.h"
-
-#include <QEvent>
-#include <QString>
-
-/*!
-  \class PrintEvent
-  \brief Python command output backend event.
-  \internal
-*/
-class PrintEvent : public QEvent
-{
-public:
-  static const int EVENT_ID = 65432;
-
-  /*!
-    \brief Constructor
-    \param c message text (python trace)
-    \param isError default to false - if true indicates that an error is being printed.
-  */
-  PrintEvent( const char* c, bool isError = false) :
-    QEvent( (QEvent::Type)EVENT_ID ), myText( c ), errorFlag(isError)
-  {}
-
-  /*!
-    \brief Get message
-    \return message text (python trace)
-  */
-  QString text() const { return myText; }
-
-  /**
-   * @return true if this is an error message
-   */
-  bool isError() const { return errorFlag; }
-
-protected:
-  QString myText; //!< Event message (python trace)
-
-  /** Set to true if an error msg is to be displayed */
-  bool errorFlag;
-};
-
-#endif // PYCONSOLE_EVENT_H
diff --git a/src/PyConsole/PyConsole_Interp.cpp b/src/PyConsole/PyConsole_Interp.cpp
deleted file mode 100644 (file)
index 21af783..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-
-#include "PyConsole_Interp.h"
-
-/*!
-  \class PyConsole_Interp
-  \brief Python interpreter to be embedded to the SALOME study's GUI.
-
-  Python interpreter is created one per SALOME study.
-
-  Call initialize method defined in the base class PyInterp_Interp,
-  to intialize interpreter after instance creation.
-
-  The method initialize() calls virtuals methods
-  - initPython()  to initialize global Python interpreter
-  - initState()   to initialize embedded interpreter state
-  - initContext() to initialize interpreter internal context
-  - initRun()     to prepare interpreter for running commands
-
-  /EDF-CCAR/
-  When SALOME uses multi Python interpreter feature, 
-  every study has its own interpreter and thread state (_tstate = Py_NewInterpreter()).
-  This is fine because every study has its own modules (sys.modules) stdout and stderr.
-
-  <b>But</b> some Python modules must be imported only once. In multi interpreter 
-  context Python modules (*.py) are imported several times.
-  For example, the PyQt module must be imported only once because 
-  it registers classes in a C module.
-
-  It's quite the same with omniorb modules (internals and generated with omniidl).
-
-  This problem is handled with "shared modules" defined in salome_shared_modules.py.
-  These "shared modules" are imported only once and only copied in all 
-  the other interpreters.
-
-  <b>But</b> it's not the only problem. Every interpreter has its own 
-  __builtin__ module. That's fine but if we have copied some modules 
-  and imported others problems may arise with operations that are not allowed
-  in restricted execution environment. So we must impose that all interpreters
-  have identical __builtin__ module.
-*/
-
-/*!
-  \brief Constructor.
-
-  Creates new python interpreter.
-*/
-PyConsole_Interp::PyConsole_Interp(): PyInterp_Interp()
-{
-}
-
-/*!
-  \brief Destructor.
-
-  Does nothing for the moment.
-*/
-PyConsole_Interp::~PyConsole_Interp()
-{
-}
-/*!
-  \brief Initialize internal Python interpreter state.
-
-  When calling initState the GIL is not held
-  It must not be held on exit
-
-  \return \c true on success
-*/
-bool PyConsole_Interp::initState()
-{
-  PyEval_AcquireLock();
-  _tstate = Py_NewInterpreter(); // create an interpreter and save current state
-  PySys_SetArgv(PyInterp_Interp::_argc,PyInterp_Interp::_argv); // initialize sys.argv
-  
-  if(!builtinmodule) // PAL18041: deepcopy function don't work in Salome
-  {
-    //builtinmodule is static member of PyInterp class
-    //If it is not NULL (initialized to the builtin module of the main interpreter
-    //all the sub interpreters will have the same builtin
-    //_interp is a static member and is the main interpreter
-    //The first time we initialized it to the builtin of main interpreter
-    builtinmodule=PyDict_GetItemString(_interp->modules, "__builtin__");
-  }
-
-  //If builtinmodule has been initialized all the sub interpreters
-  // will have the same __builtin__ module
-  if(builtinmodule){ 
-    PyObject *m = PyImport_GetModuleDict();
-    PyDict_SetItemString(m, "__builtin__", builtinmodule);
-    _tstate->interp->builtins = PyModule_GetDict(builtinmodule);
-    Py_INCREF(_tstate->interp->builtins);
-  }
-  PyEval_ReleaseThread(_tstate);
-  return true;
-}
-
-/*!
-  \brief Initialize python interpeter context.
-
-  The GIL is assumed to be held.
-  It is the caller responsability to acquire the GIL.
-  It must still be held on initContext() exit.
-
-  \return \c true on success
-*/
-bool PyConsole_Interp::initContext()
-{
-  PyObject *m = PyImport_AddModule("__main__");  // interpreter main module (module context)
-  if(!m){
-    PyErr_Print();
-    return false;
-  }  
-  _g = PyModule_GetDict(m);          // get interpreter dictionnary context
-
-  if(builtinmodule){
-    PyDict_SetItemString(_g, "__builtins__", builtinmodule); // assign singleton __builtin__ module
-  }
-  return true;
-}
diff --git a/src/PyConsole/PyConsole_Interp.h b/src/PyConsole/PyConsole_Interp.h
deleted file mode 100644 (file)
index d65c9e6..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-
-#ifndef PYCONSOLE_INTERP_H
-#define PYCONSOLE_INTERP_H
-
-#include "PyConsole.h"
-
-#include <PyInterp_Interp.h>   /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
-
-class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_Interp
-{
-public:
-  PyConsole_Interp();
-  ~PyConsole_Interp();
-
-protected:
-  virtual bool initState();
-  virtual bool initContext();  
-};
-
-#endif // PYCONSOLE_INTERP_H
diff --git a/src/PyConsole/PyConsole_Request.cpp b/src/PyConsole/PyConsole_Request.cpp
deleted file mode 100644 (file)
index 3e31b90..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-#include "PyConsole_Request.h"
-
-#include "PyInterp_Event.h"
-#include "PyConsole_Event.h"
-#include "PyConsole_EnhInterp.h"
-#include "PyConsole_EnhEditor.h"
-
-#include <QCoreApplication>
-
-/**
- * Constructor.
- * @param theInterp interpreter that will execute the command
- * @param theCommand command text
- * @param theListener editor object that will receive the response events after execution
- * of the request
- * @param sync
- */
-ExecCommand::ExecCommand( PyInterp_Interp*        theInterp,
-               const QString&          theCommand,
-               PyConsole_Editor*       theListener,
-               bool                    sync )
-    : PyInterp_LockRequest( theInterp, theListener, sync ),
-      myCommand( theCommand ), myState( PyInterp_Event::ES_OK )
-  {}
-
-/**
- * Execute the command by calling the run() method of the embedded interpreter.
- */
-void ExecCommand::execute()
-{
-  if ( myCommand != "" )
-    {
-      int ret = getInterp()->run( myCommand.toUtf8().data() );
-      if ( ret < 0 )
-        myState = PyInterp_Event::ES_ERROR;
-      else if ( ret > 0 )
-        myState = PyInterp_Event::ES_INCOMPLETE;
-    }
-}
-
-/**
- * Create the event indicating the status of the request execution.
- * @return a QEvent
- */
-QEvent* ExecCommand::createEvent()
-{
-  if ( IsSync() )
-    QCoreApplication::sendPostedEvents( listener(), PrintEvent::EVENT_ID );
-  return new PyInterp_Event( myState, this );
-}
-
-
-/*!
-  Constructor.
-  Creates a new python completion request.
-  \param theInterp   python interpreter
-  \param input  string containing the dir() command to be executed
-  \param startMatch  part to be matched with the results of the dir() command
-  \param theListener widget to get the notification messages
-  \param sync        if True the request is processed synchronously
-*/
-CompletionCommand::CompletionCommand( PyConsole_EnhInterp*  theInterp,
-               const QString&          input,
-               const QString&         startMatch,
-               PyConsole_EnhEditor*           theListener,
-               bool                    sync)
-     : PyInterp_LockRequest( theInterp, theListener, sync ),
-       _tabSuccess(false), _dirArg(input), _startMatch(startMatch)
-{}
-
-/**
- * Execute the completion command by wrapping the runDirCommand() of the
- * embedded enhanced interpreter.
- */
-void CompletionCommand::execute()
-{
-  PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(getInterp());
-    int ret = interp->runDirCommand( _dirArg,  _startMatch);
-    if (ret == 0)
-      _tabSuccess = true;
-    else
-      _tabSuccess = false;
-}
-
-/**
- * Create the event indicating the return value of the completion command.
- * @return
- */
-QEvent* CompletionCommand::createEvent()
-{
-  int typ = _tabSuccess ? PyInterp_Event::ES_TAB_COMPLETE_OK : PyInterp_Event::ES_TAB_COMPLETE_ERR;
-
-  return new PyInterp_Event( typ, this);
-}
-
-
-
diff --git a/src/PyConsole/PyConsole_Request.h b/src/PyConsole/PyConsole_Request.h
deleted file mode 100644 (file)
index da5f94a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-#ifndef PYCONSOLE_REQUEST_H_
-#define PYCONSOLE_REQUEST_H_
-
-#include "PyConsole.h"
-#include "PyInterp_Request.h"
-
-#include <vector>
-#include <QString>
-#include <QEvent>
-
-class PyInterp_Interp;
-class PyConsole_Editor;
-
-/*!
-  \class ExecCommand
-  \brief Python command execution request.
-  \internal
-*/
-class ExecCommand : public PyInterp_LockRequest
-{
-public:
-  /*!
-    \brief Constructor.
-
-    Creates new python command execution request.
-    \param theInterp   python interpreter
-    \param theCommand  python command
-    \param theListener widget to get the notification messages
-    \param sync        if True the request is processed synchronously
-  */
-  ExecCommand( PyInterp_Interp*        theInterp,
-               const QString&          theCommand,
-               PyConsole_Editor*       theListener,
-               bool                    sync = false );
-
-protected:
-  /*!
-    \brief Execute the python command in the interpreter and
-           get its execution status.
-  */
-  virtual void execute();
-
-  /*!
-    \brief Create and return a notification event.
-    \return new notification event
-  */
-  virtual QEvent* createEvent();
-
-private:
-  QString myCommand;   //!< Python command
-  int     myState;     //!< Python command execution status
-};
-
-class PyConsole_EnhInterp;
-class PyConsole_EnhEditor;
-
-class CompletionCommand : public PyInterp_LockRequest
-{
-public:
-  CompletionCommand( PyConsole_EnhInterp*      theInterp,
-               const QString&          input,
-               const QString&          startMatch,
-               PyConsole_EnhEditor*    theListener,
-               bool                    sync = false );
-
-
-protected:
-  /** List of separators identifying the last parsable token for completion */
-  static const std::vector<QString> SEPARATORS;
-
-  /** String to be passed to the dir() command */
-  QString _dirArg;
-  /** Begining of the command (as typed by the user) */
-  QString _startMatch;
-  /** was the completion command successful */
-  bool _tabSuccess;
-
-  virtual void execute();
-  virtual QEvent* createEvent();
-
-};
-
-#endif /* PYCONSOLE_REQUEST_H_ */
diff --git a/src/PyEvent/CMakeLists.txt b/src/PyEvent/CMakeLists.txt
deleted file mode 100644 (file)
index 0b54ed9..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-
-SET(PROJECT_HEADERS 
-       PyEvent.h 
-       PyEvent_Event.h 
-       PyEvent_EventFilter.h
-)
-
-SET(PROJECT_SOURCES 
-       PyEvent_Event.cpp
-       PyEvent_EventFilter.cpp
-)
-
-#INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDES})
-
-ADD_DEFINITIONS(-DPYEVENT_EXPORTS)
-
-ADD_LIBRARY(PyEvent SHARED 
-       ${PROJECT_SOURCES} 
-       ${PROJECT_HEADERS} 
-)
-
-TARGET_LINK_LIBRARIES(PyEvent ${QT_LIBRARIES})
-
-INSTALL(TARGETS PyEvent DESTINATION bin)
diff --git a/src/PyEvent/PyEvent.h b/src/PyEvent/PyEvent.h
deleted file mode 100644 (file)
index 9c2f34f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-
-#if !defined ( PYEVENT_H )
-#define PYEVENT_H
-
-#ifdef WIN32
-#  if defined PYEVENT_EXPORTS || defined PyEvent_EXPORTS
-#    define PYEVENT_EXPORT __declspec(dllexport)
-#  else
-#    define PYEVENT_EXPORT __declspec(dllimport)
-#  endif
-#else               //WIN32
-#  define PYEVENT_EXPORT
-#endif              //WIN32
-
-#if defined WIN32
-#pragma warning ( disable: 4251 )
-#endif
-
-#endif // PYEVENT_H
diff --git a/src/PyEvent/PyEvent_Event.cpp b/src/PyEvent/PyEvent_Event.cpp
deleted file mode 100644 (file)
index fef847f..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-
-#include "PyEvent_Event.h"
-
-#include <QSemaphore>
-#include <QApplication>
-
-// asv 21.02.05 : introducing multi-platform approach of thread comparison
-// - on Unix using pthread_t type for storing ThreadId
-// - on Win32 using integer type for storing ThreadId
-// NOT using integer ThreadId on both Unix and Win32 because (from documentation):
-// "...Do not allow your program to rely on the internal structure or size of the pthread_t..."
-
-#ifdef WIN32
-#include <windows.h>
-static DWORD myThread;
-#else
-#include <pthread.h>
-static pthread_t myThread;
-#endif
-
-/*!
-  \class InitEvent
-  \brief Helper event class responsible for initializing PyEvent_Event
-  mechanism by the main thread ID
- */
-class InitEvent : public PyEvent_Event
-{
-public:
-  InitEvent();
-  virtual      ~InitEvent();
-  virtual void Execute();
-};
-
-/*!
-  \brief Constructor, initializes the event mechanism by the current thread ID.
-  It is asssumed to be the main thread ID, so be careful!
-*/
-InitEvent::InitEvent()
-{
-  GetSessionThread();
-}
-
-/*!
-  \brief Destructor, does nothing.
-*/
-InitEvent::~InitEvent()
-{
-}
-
-/*!
-  \brief Nothing to be executed for this kind of event.
-*/
-void InitEvent::Execute()
-{
-}
-
-// NOTE: Here the SALOME event mechanism is initalized by the 
-// current thread ID that is always assumed to be the main thread ID.
-// This should be revised as soon as the application library is no longer
-// linked against the Event library (i.e. this static object is not created or created 
-// outside the main thread).
-static InitEvent myInitEvent;
-
-/*!
-  \class PyEvent_CustomEvent
-  \brief Generic event class for user-defined events
-  
-  This class contains a generic void* data member that may be used
-  for transferring event-specific data to the receiver.
-
-  \warning The internal data is not destroyed by the class destructor.
-*/
-
-/*!
-  \brief Constructor.
-  \param type event type
-*/
-PyEvent_CustomEvent::PyEvent_CustomEvent( int type )
-: QEvent( (QEvent::Type)type ), d( 0 )
-{
-}
-
-/*!
-  \brief Constructor.
-  \param type event type
-  \param data custom data
-*/
-PyEvent_CustomEvent::PyEvent_CustomEvent( QEvent::Type type, void* data )
-: QEvent( type ), d( data )
-{
-}
-
-/*!
-  \brief Get custom data.
-  \return pointer to the internal data
-*/
-void* PyEvent_CustomEvent::data() const
-{
-  return d;
-}
-
-/*!
-  \brief Set custom data.
-  \param data pointer to the internal data
-*/
-void PyEvent_CustomEvent::setData( void* data )
-{
-  d = data;
-}
-
-/*!
-  \class PyEvent_Event
-  \brief The class which encapsulates data and functionality required for 
-         posting component-specific events to perform arbitrary operations 
-         in the main GUI thread. 
-
-  PyEvent_Event objects can be posted by any thread belonging to the GUI process.
-  
-  It is necessary to derive a custom event class from PyEvent_Event and 
-  re-implement virtual Execute() method. This method should actually perform 
-  the desirable operation. To pass all the required data to Execute() and 
-  store a return value, arbitrary data fields can be added to the custom 
-  event class. There is no need to protect such fields with a mutex, for only
-  one thread working with a PyEvent_Event object is active at any moment.
-  
-  Usage:
-  - Create PyEvent_Event. Components can derive their own event class from 
-  PyEvent_Event in order to pass custom data to the event handler.
-  - Call process() method to post the event. After process() execution
-  it is possible to examine fields of your custom event object.
-  - Perform delete operator on the event to wake up the desktop (you can also 
-  set <autoRelease>  parameter to \c true to automatically wake up desktop after 
-  process().
-  
-  The method processed() is used by the desktop to signal that event processing 
-  has been completed.
-
-  To make all this work, it is necessary to call static method GetSessionThread()
-  during the application initialization, i.e. from main() function.
-  It is important to call this method from the primary application thread.
-
-  Caveats: 
-  - there are no.
-*/
-
-//! Total number of semaphore resources
-const int NumberOfResources = 2;
-
-/*!
-  \brief Initialize event mechanism.
-
-  This function sets up the main application thread. It should be called
-  during the application initialization, i.e. main() function.
-*/
-void PyEvent_Event::GetSessionThread(){
-#ifdef WIN32
-  myThread = ::GetCurrentThreadId();
-#else
-  myThread = pthread_self();
-#endif
-}
-
-/*!
-  \brief Check if the processing is in the main application thread.
-  \return \c true if this method is called from the main application thread
-*/
-bool PyEvent_Event::IsSessionThread(){
-  bool aResult = false;
-#ifdef WIN32
-  aResult = myThread == ::GetCurrentThreadId();
-#else
-  aResult = myThread == pthread_self();
-#endif
-  return aResult;
-}
-
-/*!
-  \brief Constructor.
-*/
-PyEvent_Event::PyEvent_Event(){
-  // Prepare the semaphore 
-  mySemaphore = new QSemaphore( NumberOfResources );
-  mySemaphore->acquire( NumberOfResources );
-}
-
-/*!
-  \brief Destructor.
-*/
-PyEvent_Event::~PyEvent_Event(){
-  if ( mySemaphore->available() < NumberOfResources )
-    mySemaphore->release( NumberOfResources - mySemaphore->available() );
-  delete mySemaphore;
-}
-
-/*!
-  \brief This method should be called by the main GUI thread
-  in order to execute the code specific for this event and finally
-  to inform the calling thread that the event 
-  has been processed waking it up with help of the semaphore .
- */
-void PyEvent_Event::ExecutePostedEvent()
-{
-  // Diagnose incorrect usage of PyEvent_Event API
-  if ( !IsSessionThread() ){
-    qWarning( "PyEvent_Event::ExecutePostedEvent() is called from a secondary thread that might mean an error in application logic!" );
-  }
-  // Actual execution specific for particular kind of event
-  Execute();
-  // Signal the calling thread that the event has been processed
-  processed();
-}
-
-/*!
-  \brief Post the event and wait for its completion.
-  process() should be called from a secondary thread only. 
-  \sa processed()
-*/
-void PyEvent_Event::process()
-{
-  // Diagnose incorrect usage of PyEvent_Event API
-  if ( IsSessionThread() ){
-    qWarning( "PyEvent_Event::process() is called from the main GUI thread that might mean an error in application logic!" );
-  }
-
-  QApplication::postEvent( qApp, new PyEvent_CustomEvent( PyEvent_EVENT, (void*)this ) );
-  mySemaphore->acquire( 1 );
-}
-
-/*!
-  \brief Use this method to signal that this event has been processed.
-*/
-void PyEvent_Event::processed()
-{
-  mySemaphore->release( 1 );
-}
-
-/*!
-  \fn virtual void PyEvent_Event::Execute();
-  \brief This method should be redefined in the successor classes
-         to do real work.
-*/
-  
-/*!
-  \class TMemFunEvent
-  \brief Template class for event which calls the function
-  without arguments and returning result.
-*/
-
-/*!
-  \class TVoidMemFunEvent
-  \brief Template class for event which calls the function
-  without arguments and without return value.
-*/
-
-/*!
-  \class TMemFun1ArgEvent
-  \brief Template class for event which calls the function
-  with one argument and returning result.
-*/
-
-/*!
-  \class TVoidMemFun1ArgEvent
-  \brief Template class for event which calls the function
-  with one argument and without return value.
-*/
-
-/*!
-  \class TMemFun2ArgEvent
-  \brief Template class for event which calls the function
-  with two arguments and returning result.
-*/
-
-/*!
-  \class TVoidMemFun2ArgEvent
-  \brief Template class for event which calls the function
-  with two arguments and without return value.
-*/
-
-/*!
-  \fn ProcessEvent
-  \brief Template function for processing events with return value.
-*/
-
-/*!
-  \fn ProcessVoidEvent
-  \brief Template function for processing events without return value.
-*/
diff --git a/src/PyEvent/PyEvent_Event.h b/src/PyEvent/PyEvent_Event.h
deleted file mode 100644 (file)
index ed1ea7b..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-
-#ifndef PyEvent_PYEVENT_H
-#define PyEvent_PYEVENT_H
-
-#include "PyEvent.h"
-
-#include <QEvent>
-
-//! SALOME custom event type
-#define PyEvent_EVENT QEvent::Type( QEvent::User + 10000 )
-
-class PYEVENT_EXPORT PyEvent_CustomEvent : public QEvent
-{
-public:
-  PyEvent_CustomEvent( int type );
-  PyEvent_CustomEvent( QEvent::Type type, void* data );
-
-  void* data() const;
-  void  setData( void* data );
-
-private:
-  void *d;   //!< internal data
-};
-
-class QSemaphore;
-
-class PYEVENT_EXPORT PyEvent_Event
-{
-public:
-  PyEvent_Event();
-  virtual ~PyEvent_Event();
-
-  void            ExecutePostedEvent();
-  virtual void    Execute() = 0;
-
-  static bool     IsSessionThread();
-  void            process();
-
-protected:
-  void            processed();
-  static void     GetSessionThread();
-
-private:
-  QSemaphore*     mySemaphore;     //!< internal semaphore
-};
-
-template<class TObject, typename TRes> class TMemFunEvent : public PyEvent_Event
-{
-public:
-  typedef TRes TResult;
-  TResult myResult;
-  typedef TResult (TObject::* TAction)();
-  TMemFunEvent(TObject* theObject, TAction theAction, 
-               TResult theResult = TResult()):
-    myObject(theObject),
-    myAction(theAction),
-    myResult(theResult)
-  {}
-  virtual void Execute()
-  {
-    myResult = (myObject->*myAction)();
-  }
-private:
-  TObject* myObject;
-  TAction  myAction;
-};
-
-template<class TObject> class TVoidMemFunEvent : public PyEvent_Event
-{
-public:
-  typedef void (TObject::* TAction)();
-  TVoidMemFunEvent(TObject* theObject, TAction theAction):
-    myObject(theObject),
-    myAction(theAction)
-  {}
-  virtual void Execute()
-  {
-    (myObject->*myAction)();
-  }
-private:
-  TObject* myObject;
-  TAction myAction;
-};
-
-template<class TObject, typename TRes, typename TArg, typename TStoreArg = TArg> 
-class TMemFun1ArgEvent : public PyEvent_Event
-{
-public:
-  typedef TRes TResult;
-  TResult myResult;
-  typedef TResult (TObject::* TAction)(TArg);
-  TMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg, 
-                   TResult theResult = TResult()):
-    myObject(theObject),
-    myAction(theAction),
-    myResult(theResult),
-    myArg(theArg)
-  {}
-  virtual void Execute()
-  {
-    myResult = (myObject->*myAction)(myArg);
-  }
-private:
-  TObject* myObject;
-  TAction myAction;
-  TStoreArg myArg;
-};
-
-template<class TObject, typename TArg, typename TStoreArg = TArg> 
-class TVoidMemFun1ArgEvent : public PyEvent_Event
-{
-public:
-  typedef void (TObject::* TAction)(TArg);
-  TVoidMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg):
-    myObject(theObject),
-    myAction(theAction),
-    myArg(theArg)
-  {}
-  virtual void Execute()
-  {
-    (myObject->*myAction)(myArg);
-  }
-private:
-  TObject* myObject;
-  TAction myAction;
-  TStoreArg myArg;
-};
-
-template<class TObject, typename TRes, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1>
-class TMemFun2ArgEvent: public PyEvent_Event
-{
-public:
-  typedef TRes TResult;
-  TResult myResult;
-  typedef TResult (TObject::* TAction)(TArg,TArg1);
-  TMemFun2ArgEvent(TObject* theObject, TAction theAction, 
-                   TArg theArg, TArg1 theArg1,
-                   TResult theResult = TResult()):
-    myObject(theObject),
-    myAction(theAction),
-    myResult(theResult),
-    myArg(theArg),
-    myArg1(theArg1)
-  {}
-  virtual void Execute()
-  {
-    myResult = (myObject->*myAction)(myArg,myArg1);
-  }
-private:
-  TObject* myObject;
-  TAction myAction;
-  TStoreArg myArg;
-  TStoreArg1 myArg1;
-};
-
-template<class TObject, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1>
-class TVoidMemFun2ArgEvent : public PyEvent_Event
-{
-public:
-  typedef void (TObject::* TAction)(TArg,TArg1);
-  TVoidMemFun2ArgEvent(TObject* theObject, TAction theAction, TArg theArg, TArg1 theArg1):
-    myObject(theObject),
-    myAction(theAction),
-    myArg(theArg),
-    myArg1(theArg1)
-  {}
-  virtual void Execute()
-  {
-    (myObject->*myAction)(myArg,myArg1);
-  }
-private:
-  TObject* myObject;
-  TAction myAction;
-  TStoreArg myArg;
-  TStoreArg1 myArg1;
-};
-
-template<class TEvent> inline typename TEvent::TResult ProcessEvent(TEvent* theEvent)
-{
-  typename TEvent::TResult aResult;
-  if(PyEvent_Event::IsSessionThread()) {
-    theEvent->Execute();
-    aResult = theEvent->myResult;
-  }
-  else {
-    theEvent->process();
-    aResult = theEvent->myResult;
-  }
-  delete theEvent;
-  return aResult;
-}
-
-inline void ProcessVoidEvent(PyEvent_Event* theEvent)
-{
-  if(PyEvent_Event::IsSessionThread()) {
-    theEvent->Execute();
-  }
-  else {
-    theEvent->process();
-  }
-  delete theEvent;
-}
-
-#endif // PyEvent_PYEVENT_H
diff --git a/src/PyEvent/PyEvent_EventFilter.cpp b/src/PyEvent/PyEvent_EventFilter.cpp
deleted file mode 100644 (file)
index ac12e20..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-
-#include "PyEvent_EventFilter.h"
-#include "PyEvent_Event.h"
-
-#include <QApplication>
-
-PyEvent_EventFilter* PyEvent_EventFilter::myFilter = NULL;
-
-/*!Constructor.*/
-PyEvent_EventFilter::PyEvent_EventFilter()
-: QObject()
-{
-  /* VSR 13/01/03 : installing global event filter for the application */
-  qApp->installEventFilter( this );
-}
-
-/*!Destructor.*/
-PyEvent_EventFilter::~PyEvent_EventFilter()
-{
-  qApp->removeEventFilter( this );
-}
-
-/*!
-  Custom event filter
-*/
-bool PyEvent_EventFilter::eventFilter( QObject* o, QEvent* e )
-{
-  if ( e->type() == PyEvent_EVENT )
-  { 
-    PyEvent_Event* aSE = (PyEvent_Event*)((PyEvent_CustomEvent*)e)->data();
-    processEvent(aSE);
-    ((PyEvent_CustomEvent*)e)->setData( 0 );
-    return true;
-  }
-  return QObject::eventFilter( o, e );
-}
-
-/*!Process event.*/
-void PyEvent_EventFilter::processEvent( PyEvent_Event* theEvent )
-{
-  if(theEvent)
-    theEvent->ExecutePostedEvent();
-}
-
-/*!Create new instance of PyEvent_EventFilter*/
-void PyEvent_EventFilter::Init()
-{
-  if( myFilter==NULL )
-    myFilter = new PyEvent_EventFilter();
-}
-
-/*!Destroy filter.*/
-void PyEvent_EventFilter::Destroy()
-{
-  if( myFilter )
-  {
-    delete myFilter;
-    myFilter = NULL;
-  }
-}
diff --git a/src/PyEvent/PyEvent_EventFilter.h b/src/PyEvent/PyEvent_EventFilter.h
deleted file mode 100644 (file)
index 23132de..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-
-#ifndef PyEvent_EVENTFILTER_H
-#define PyEvent_EVENTFILTER_H
-
-#include "PyEvent.h"
-#include <QObject>
-
-#if defined WIN32
-#pragma warning( disable: 4251 )
-#endif
-
-class PyEvent_Event;
-
-/*!
-  Event filter class for QApplication object that handles custom events posted by PyEvent_Event objects.
-  It assumes that such custom events are alwys posted, not sent. 
-  This event filter can be installed by any application that intends to use PyEvent_Event mechanism asynchronously.
-  This class replaced SalomeApp_EventFilter.
-*/
-class PYEVENT_EXPORT PyEvent_EventFilter: public QObject 
-{
-public:
-  static void Init();
-  static void Destroy();
-
-protected:
-  PyEvent_EventFilter();
-  virtual ~PyEvent_EventFilter();
-
-private:
-  /*! global event filter for qapplication */
-  virtual bool eventFilter( QObject* o, QEvent* e );
-  void processEvent( PyEvent_Event* );
-
-private:
-  static PyEvent_EventFilter* myFilter;
-};
-
-#if defined WIN32
-#pragma warning( default: 4251 )
-#endif
-
-#endif
diff --git a/src/PyInterp/CMakeLists.txt b/src/PyInterp/CMakeLists.txt
deleted file mode 100644 (file)
index b540f09..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-
-SET(CMAKE_AUTOMOC ON)
-
-# header files 
-SET(PROJECT_HEADERS
-  PyInterp.h
-  PyInterp_Dispatcher.h
-  PyInterp_Event.h
-  PyInterp_Interp.h
-  PyInterp_Request.h
-  PyInterp_Watcher.h
-)
-
-SET(PROJECT_AUTOMOC 
-    ${CMAKE_CURRENT_BINARY_DIR}/PyInterp_automoc.cpp
-)
-
-# sources / static
-SET(PROJECT_SOURCES
-  PyInterp_Dispatcher.cpp
-  PyInterp_Event.cpp
-  PyInterp_Interp.cpp
-  PyInterp_Request.cpp
-)
-
-SET(PROJECT_LIBRARIES
-       PyEvent
-       ${QT_LIBRARIES}
-       ${PYTHON_LIBRARIES}
-)
-
-SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC})
-
-ADD_DEFINITIONS(-DPYINTERP_EXPORTS -DHAVE_DEBUG_PYTHON)
-
-INCLUDE_DIRECTORIES(
-       ${PROJECT_SOURCE_DIR}/src/PyEvent
-)
-
-ADD_LIBRARY(PyInterp SHARED    
-       ${PROJECT_SOURCES} 
-       ${PROJECT_HEADERS} 
-)
-
-TARGET_LINK_LIBRARIES(PyInterp ${PROJECT_LIBRARIES})
-
-INSTALL(TARGETS PyInterp DESTINATION bin)
diff --git a/src/PyInterp/PyInterp.h b/src/PyInterp/PyInterp.h
deleted file mode 100644 (file)
index 4977fce..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-
-#if !defined ( PYINTERP_H )
-#define PYINTERP_H
-
-// ========================================================
-// set dllexport type for Win platform 
-#ifdef WIN32
-# if defined PYINTERP_EXPORTS || defined PyInterp_EXPORTS
-#  define PYINTERP_EXPORT __declspec(dllexport)
-# else
-#  define PYINTERP_EXPORT __declspec(dllimport)
-# endif
-#else   // WIN32
-# define PYINTERP_EXPORT
-#endif  // WIN32
-
-// ========================================================
-// little trick - if we do not have debug python libraries
-#ifdef _DEBUG
- #ifndef HAVE_DEBUG_PYTHON
-  #undef _DEBUG
- #endif
-#endif
-
-#include <Python.h>
-
-#ifdef _DEBUG
- #ifndef HAVE_DEBUG_PYTHON
-  #define _DEBUG
- #endif
-#endif
-
-// ========================================================
-// avoid warning messages
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#pragma warning (disable : 4251)
-#endif
-
-#endif // PYINTERP_H
diff --git a/src/PyInterp/PyInterp_Dispatcher.cpp b/src/PyInterp/PyInterp_Dispatcher.cpp
deleted file mode 100644 (file)
index 1999e71..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-
-#include "PyInterp_Dispatcher.h"   // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
-#include "PyInterp_Interp.h"
-#include "PyInterp_Watcher.h"
-#include "PyInterp_Request.h"
-
-#include <QObject>
-#include <QCoreApplication>
-
-PyInterp_Dispatcher* PyInterp_Dispatcher::myInstance = 0;
-
-void PyInterp_Request::process()
-{
-  safeExecute();
-
-  bool isSync = IsSync();
-
-  if ( !isSync )
-    myMutex.lock();
-
-  if ( listener() )
-    processEvent( listener() );
-
-  if ( !isSync )
-    myMutex.unlock();
-}
-
-void PyInterp_Request::safeExecute()
-{
-  //ProcessVoidEvent( new PyInterp_ExecuteEvent( this ) );
-  execute();
-}
-
-void PyInterp_Request::Destroy( PyInterp_Request* request )
-{
-  // Lock and unlock the mutex to avoid errors on its deletion
-  request->myMutex.lock();
-  request->myMutex.unlock();
-  delete request;
-}
-
-QEvent* PyInterp_Request::createEvent()
-{
-  return new PyInterp_Event( PyInterp_Event::ES_NOTIFY, this );
-}
-
-void PyInterp_Request::processEvent( QObject* o )
-{
-  if ( !o )
-    return;
-
-  QEvent* e = createEvent();
-  if ( !e )
-    return;
-
-  if ( !IsSync() )
-    QCoreApplication::postEvent( o, e );
-  else
-  {
-    QCoreApplication::sendEvent( o, e );
-    delete e;
-  }
-}
-
-void PyInterp_Request::setListener( QObject* o )
-{
-  myMutex.lock();
-  myListener = o;
-  myMutex.unlock();
-}
-
-void PyInterp_LockRequest::safeExecute()
-{
-  if ( getInterp() ){
-    PyLockWrapper aLock = getInterp()->GetLockWrapper();
-    //ProcessVoidEvent( new PyInterp_ExecuteEvent( this ) );
-    execute();
-  }
-}
-
-PyInterp_Event::~PyInterp_Event()
-{
-  PyInterp_Request::Destroy( myRequest );
-  myRequest = 0;
-}
-
-PyInterp_Dispatcher* PyInterp_Dispatcher::Get()
-{
-  if ( !myInstance )
-    myInstance = new PyInterp_Dispatcher();
-  return myInstance;
-}
-
-PyInterp_Dispatcher::PyInterp_Dispatcher() 
-: QThread()
-{
-  myWatcher = new PyInterp_Watcher();
-}
-
-PyInterp_Dispatcher::~PyInterp_Dispatcher()
-{
-  // Clear the request queue
-  myQueueMutex.lock();
-
-  QListIterator<RequestPtr> it( myQueue );
-  while ( it.hasNext() )
-    PyInterp_Request::Destroy( it.next() );
-  myQueue.clear();
-
-  myQueueMutex.unlock();
-
-  // Wait for run() to finish
-  wait();
-
-  delete myWatcher;
-  myWatcher = 0;
-}
-
-bool PyInterp_Dispatcher::IsBusy() const
-{
-  return isRunning();
-}
-
-void PyInterp_Dispatcher::Exec( PyInterp_Request* theRequest )
-{
-  if ( !theRequest )
-    return;
-
-  //if ( theRequest->IsSync() && !IsBusy() ) // synchronous processing - nothing is done if dispatcher is busy!
-  if ( theRequest->IsSync() ) // synchronous processing
-    processRequest( theRequest );
-  else // asynchronous processing
-  {
-    myQueueMutex.lock();
-    myQueue.enqueue( theRequest );
-    if ( theRequest->listener() )
-      QObject::connect( theRequest->listener(), SIGNAL( destroyed( QObject* ) ), myWatcher, SLOT( onDestroyed( QObject* ) ) );
-    myQueueMutex.unlock();  
-
-    if ( !IsBusy() )
-      start();
-  }
-}
-
-void PyInterp_Dispatcher::run()
-{
-//  MESSAGE("*** PyInterp_Dispatcher::run(): STARTED")
-  PyInterp_Request* aRequest;
-
-  // prepare for queue size check
-  myQueueMutex.lock();
-
-  while( myQueue.size() ) {
-//    MESSAGE("*** PyInterp_Dispatcher::run(): next request taken from the queue")
-    aRequest = myQueue.head();
-
-    // let other threads append their requests to the end of the queue
-    myQueueMutex.unlock();
-
-    // processRequest() may delete a request, so this pointer must not be used
-    // after request is processed!
-    processRequest( aRequest );
-
-    // prepare for removal of the first request in the queue
-    myQueueMutex.lock();
-    // IMPORTANT: the first item could have been removed by objectDestroyed() --> we have to check it
-    if ( myQueue.head() == aRequest ) // It's still here --> remove it
-      myQueue.dequeue();
-
-//    MESSAGE("*** PyInterp_Dispatcher::run(): request processed")
-  }
-
-  myQueueMutex.unlock();
-//  MESSAGE("*** PyInterp_Dispatcher::run(): FINISHED")
-}
-
-void PyInterp_Dispatcher::processRequest( PyInterp_Request* theRequest )
-{
-  theRequest->process();
-}
-
-void PyInterp_Dispatcher::objectDestroyed( const QObject* o )
-{
-  // prepare for modification of the queue
-  myQueueMutex.lock();
-
-  QMutableListIterator<RequestPtr> it( myQueue );
-  while ( it.hasNext() )
-  {
-    RequestPtr r = it.next();
-    if ( o == r->listener() )
-    {
-      r->setListener( 0 ); // to prevent event posting
-      it.remove();
-    }
-  }
-
-  myQueueMutex.unlock();
-}
diff --git a/src/PyInterp/PyInterp_Dispatcher.h b/src/PyInterp/PyInterp_Dispatcher.h
deleted file mode 100644 (file)
index fa98d30..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-
-#ifndef PYINTERP_DISPATCHER_H
-#define PYINTERP_DISPATCHER_H
-
-#include "PyInterp.h"   // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
-
-#include "PyInterp_Request.h"   // full include instead of forward declaration
-                                // everyone inc'ing the Dispatcher will get the requests for free.
-
-#include <QMutex>
-#include <QThread>
-#include <QQueue>
-
-class QObject;
-class PyInterp_Watcher;
-
-class PYINTERP_EXPORT PyInterp_Dispatcher : protected QThread
-{
-  PyInterp_Dispatcher(); // private constructor
-
-public:
-  static PyInterp_Dispatcher* Get();
-
-  virtual                     ~PyInterp_Dispatcher();
-
-  bool                        IsBusy() const;  
-  void                        Exec( PyInterp_Request* );
-
-private:
-  virtual void                run();
-  void                        processRequest( PyInterp_Request* );
-  void                        objectDestroyed( const QObject* );
-
-private:
-  typedef PyInterp_Request*   RequestPtr;
-
-  QQueue<RequestPtr>          myQueue;
-  QMutex                      myQueueMutex;
-  PyInterp_Watcher*           myWatcher;
-
-  static PyInterp_Dispatcher* myInstance;
-
-  friend class PyInterp_Watcher;
-};
-
-#endif // PYINTERP_DISPATCHER_H
diff --git a/src/PyInterp/PyInterp_Event.cpp b/src/PyInterp/PyInterp_Event.cpp
deleted file mode 100644 (file)
index 524d06a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-#include "PyInterp_Event.h"
-#include "PyInterp_Request.h"
-
-void PyInterp_ExecuteEvent::Execute()
-{
-  myRequest->execute();
-}
diff --git a/src/PyInterp/PyInterp_Event.h b/src/PyInterp/PyInterp_Event.h
deleted file mode 100644 (file)
index 9fdc9eb..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-#ifndef PYINTERP_EVENT_H
-#define PYINTERP_EVENT_H
-
-#include "PyInterp.h"
-
-#include <PyEvent_Event.h>
-
-#include <QEvent>
-
-class PyInterp_Request;
-
-class PyInterp_ExecuteEvent: public PyEvent_Event
-{
-public:
-  PyInterp_ExecuteEvent( PyInterp_Request* r )
-    : myRequest( r ) {}
-
-  virtual void Execute();
-
-protected:
-  PyInterp_Request* myRequest;
-};
-
-/**
- * Events thrown by the interpreter having executed a command and indicating
- * the return status.
- */
-//
-class PYINTERP_EXPORT PyInterp_Event : public QEvent
-{
-  PyInterp_Event();
-  PyInterp_Event( const PyInterp_Event& );
-
-public:
-  //Execution state
-  enum { ES_NOTIFY = QEvent::User + 5000, ES_OK, ES_ERROR, ES_INCOMPLETE,
-         ES_TAB_COMPLETE_OK, ES_TAB_COMPLETE_ERR, ES_LAST };
-
-  PyInterp_Event( int type, PyInterp_Request* request )
-    : QEvent( (QEvent::Type)type ), myRequest( request ) {}
-
-  virtual ~PyInterp_Event();
-
-  PyInterp_Request* GetRequest() const { return myRequest; }
-  operator PyInterp_Request*() const { return myRequest; }
-
-private:
-  PyInterp_Request* myRequest;
-};
-
-#endif // PYINTERP_EVENT_H
diff --git a/src/PyInterp/PyInterp_Interp.cpp b/src/PyInterp/PyInterp_Interp.cpp
deleted file mode 100644 (file)
index 7e633b5..0000000
+++ /dev/null
@@ -1,533 +0,0 @@
-
-#include "PyInterp_Interp.h"  // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
-#include <pythread.h>
-
-#include <cStringIO.h>
-#include <structmember.h>
-
-#include <string>
-#include <vector>
-#include <map>
-#include <iostream>
-#include <algorithm>
-
-#define TOP_HISTORY_PY   "--- top of history ---"
-#define BEGIN_HISTORY_PY "--- begin of history ---"
-
-// a map to store python thread states that have been created for a given system thread (key=thread id,value=thread state)
-std::map<long,PyThreadState*> currentThreadMap;
-
-/*!
-  \class PyLockWrapper
-  \brief Python GIL wrapper.
-*/
-
-/*!
-  \brief Constructor. Automatically acquires GIL.
-  \param theThreadState python thread state
-*/
-PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState):
-  myThreadState(theThreadState),
-  mySaveThreadState(0)
-{
-  if (myThreadState->interp == PyInterp_Interp::_interp)
-    _savestate = PyGILState_Ensure();
-  else
-    PyEval_AcquireThread(myThreadState);
-}
-
-/*!
-  \brief Destructor. Automatically releases GIL.
-*/
-PyLockWrapper::~PyLockWrapper()
-{
-  if (myThreadState->interp == PyInterp_Interp::_interp)
-    PyGILState_Release(_savestate);
-  else
-    PyEval_ReleaseThread(myThreadState);
-}
-
-/*!
-  \brief Get Python GIL wrapper.
-  \return GIL lock wrapper (GIL is automatically acquired here)
-*/
-PyLockWrapper PyInterp_Interp::GetLockWrapper()
-{
-  if (_tstate->interp == PyInterp_Interp::_interp)
-    return _tstate;
-
-  // If we are here, we have a secondary python interpreter. Try to get a thread state synchronized with the system thread
-  long currentThreadid=PyThread_get_thread_ident(); // the system thread id
-  PyThreadState* theThreadState;
-  if(currentThreadMap.count(currentThreadid) != 0)
-    {
-      //a thread state exists for this thread id
-      PyThreadState* oldThreadState=currentThreadMap[currentThreadid];
-      if(_tstate->interp ==oldThreadState->interp)
-        {
-          //The old thread state has the same python interpreter as this one : reuse the threadstate
-          theThreadState=oldThreadState;
-        }
-      else
-        {
-          //The old thread state has not the same python interpreter as this one : delete the old threadstate and create a new one
-          PyEval_AcquireLock();
-          PyThreadState_Clear(oldThreadState);
-          PyThreadState_Delete(oldThreadState);
-          PyEval_ReleaseLock();
-          theThreadState=PyThreadState_New(_tstate->interp);
-          currentThreadMap[currentThreadid]=theThreadState;
-        }
-    }
-  else
-    {
-      // no old thread state for this thread id : create a new one
-      theThreadState=PyThreadState_New(_tstate->interp);
-      currentThreadMap[currentThreadid]=theThreadState;
-    }
-  return theThreadState;
-}
-
-/*
-  The following functions are used to hook the Python
-  interpreter output.
-*/
-
-static void
-PyStdOut_dealloc(PyStdOut *self)
-{
-  PyObject_Del(self);
-}
-
-static PyObject*
-PyStdOut_write(PyStdOut *self, PyObject *args)
-{
-  char *c;
-  int l;
-  if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
-    return NULL;
-  if(self->_cb==NULL) {
-    if ( self->_iscerr )
-      std::cerr << c ;
-    else
-      std::cout << c ;
-  }
-  else {
-    self->_cb(self->_data,c);
-  }
-  Py_INCREF(Py_None);
-  return Py_None;
-}
-
-static PyObject*
-PyStdOut_flush(PyStdOut *self)
-{
-  Py_INCREF(Py_None);
-  return Py_None;
-}
-
-static PyMethodDef PyStdOut_methods[] = {
-  {"write",  (PyCFunction)PyStdOut_write,  METH_VARARGS, PyDoc_STR("write(string) -> None")},
-  {"flush",  (PyCFunction)PyStdOut_flush,  METH_NOARGS,  PyDoc_STR("flush() -> None")},
-  {NULL,    NULL}   /* sentinel */
-};
-
-static PyMemberDef PyStdOut_memberlist[] = {
-  {(char*)"softspace", T_INT,  offsetof(PyStdOut, softspace), 0,
-   (char*)"flag indicating that a space needs to be printed; used by print"},
-  {NULL} /* Sentinel */
-};
-
-static PyTypeObject PyStdOut_Type = {
-  /* The ob_type field must be initialized in the module init function
-   * to be portable to Windows without using C++. */
-  PyObject_HEAD_INIT(NULL)
-  0,                            /*ob_size*/
-  "PyOut",                      /*tp_name*/
-  sizeof(PyStdOut),             /*tp_basicsize*/
-  0,                            /*tp_itemsize*/
-  /* methods */
-  (destructor)PyStdOut_dealloc, /*tp_dealloc*/
-  0,                            /*tp_print*/
-  0,                            /*tp_getattr*/
-  0,                            /*tp_setattr*/
-  0,                            /*tp_compare*/
-  0,                            /*tp_repr*/
-  0,                            /*tp_as_number*/
-  0,                            /*tp_as_sequence*/
-  0,                            /*tp_as_mapping*/
-  0,                            /*tp_hash*/
-  0,                            /*tp_call*/
-  0,                            /*tp_str*/
-  PyObject_GenericGetAttr,      /*tp_getattro*/
-  /* softspace is writable:  we must supply tp_setattro */
-  PyObject_GenericSetAttr,      /* tp_setattro */
-  0,                            /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT,           /*tp_flags*/
-  0,                            /*tp_doc*/
-  0,                            /*tp_traverse*/
-  0,                            /*tp_clear*/
-  0,                            /*tp_richcompare*/
-  0,                            /*tp_weaklistoffset*/
-  0,                            /*tp_iter*/
-  0,                            /*tp_iternext*/
-  PyStdOut_methods,             /*tp_methods*/
-  PyStdOut_memberlist,          /*tp_members*/
-  0,                            /*tp_getset*/
-  0,                            /*tp_base*/
-  0,                            /*tp_dict*/
-  0,                            /*tp_descr_get*/
-  0,                            /*tp_descr_set*/
-  0,                            /*tp_dictoffset*/
-  0,                            /*tp_init*/
-  0,                            /*tp_alloc*/
-  0,                            /*tp_new*/
-  0,                            /*tp_free*/
-  0,                            /*tp_is_gc*/
-};
-
-#define PyStdOut_Check(v)  ((v)->ob_type == &PyStdOut_Type)
-
-static PyStdOut* newPyStdOut( bool iscerr )
-{
-  PyStdOut *self;
-  self = PyObject_New(PyStdOut, &PyStdOut_Type);
-  if (self == NULL)
-    return NULL;
-  self->softspace = 0;
-  self->_cb = NULL;
-  self->_iscerr = iscerr;
-  return self;
-}
-
-/*!
-  \class PyInterp_Interp
-  \brief Generic embedded Python interpreter.
-*/
-
-int   PyInterp_Interp::_argc   = 1;
-char* PyInterp_Interp::_argv[] = {(char*)""};
-PyObject*           PyInterp_Interp::builtinmodule = NULL;
-PyThreadState*      PyInterp_Interp::_gtstate      = NULL;
-PyInterpreterState* PyInterp_Interp::_interp       = NULL;
-
-/*!
-  \brief Basic constructor.
-
-  After construction the interpreter instance successor classes
-  must call virtual method initalize().
-*/
-PyInterp_Interp::PyInterp_Interp():
-  _tstate(0), _vout(0), _verr(0), _g(0)
-{
-}
-
-/*!
-  \brief Destructor.
-*/
-PyInterp_Interp::~PyInterp_Interp()
-{
-}
-
-/*!
-  \brief Initialize embedded interpreter.
-
-  This method shoud be called after construction of the interpreter.
-  The method initialize() calls virtuals methods
-  - initPython()  to initialize global Python interpreter
-  - initState()   to initialize embedded interpreter state
-  - initContext() to initialize interpreter internal context
-  - initRun()     to prepare interpreter for running commands
-  which should be implemented in the successor classes, according to the
-  embedded Python interpreter policy (mono or multi interpreter, etc).
-*/
-void PyInterp_Interp::initialize()
-{
-  _history.clear();       // start a new list of user's commands
-  _ith = _history.begin();
-
-  initPython();
-  // Here the global lock is released
-
-  initState();
-
-  PyEval_AcquireThread(_tstate);
-
-  initContext();
-
-  // used to interpret & compile commands
-  PyObjWrapper m(PyImport_ImportModule("codeop"));
-  if(!m) {
-    PyErr_Print();
-    PyEval_ReleaseThread(_tstate);
-    return;
-  }
-
-  // Create python objects to capture stdout and stderr
-  _vout=(PyObject*)newPyStdOut( false ); // stdout
-  _verr=(PyObject*)newPyStdOut( true );  // stderr
-
-  // All the initRun outputs are redirected to the standard output (console)
-  initRun();
-  PyEval_ReleaseThread(_tstate);
-}
-
-/*!
-  \brief Initialize Python interpreter.
-
-  In case if Python is not initialized, it sets program name, initializes the interpreter, sets program arguments,
-  initializes threads.
-  Otherwise, it just obtains the global interpreter and thread states. This is important for light SALOME configuration,
-  as in full SALOME this is done at SalomeApp level.
-  \sa SalomeApp_PyInterp class
- */
-void PyInterp_Interp::initPython()
-{
-  if (!Py_IsInitialized()){
-    // Python is not initialized
-    Py_SetProgramName(_argv[0]);
-    Py_Initialize(); // Initialize the interpreter
-    PySys_SetArgv(_argc, _argv);
-    PyEval_InitThreads(); // Create (and acquire) the interpreter lock
-  }
-
-  if ( _interp == NULL )
-    _interp = PyThreadState_Get()->interp;
-  if (PyType_Ready(&PyStdOut_Type) < 0) {
-    PyErr_Print();
-  }
-  if ( _gtstate == NULL )
-    _gtstate = PyEval_SaveThread(); // Release global thread state
-}
-
-/*!
-  \brief Get embedded Python interpreter banner.
-  \return banner string
- */
-std::string PyInterp_Interp::getbanner()
-{
- // Should we take the lock ?
- // PyEval_RestoreThread(_tstate);
-  std::string aBanner("Python ");
-  aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ;
-  aBanner = aBanner + "\ntype help to get general information on environment\n";
-  //PyEval_SaveThread();
-  return aBanner;
-}
-
-/*!
-  \brief Initialize run command.
-
-  This method is used to prepare interpreter for running
-  Python commands.
-
-  \return \c true on success and \c false on error
-*/
-bool PyInterp_Interp::initRun()
-{
-  //
-  // probably all below code isn't required
-  //
-  /*
-  PySys_SetObject("stderr",_verr);
-  PySys_SetObject("stdout",_vout);
-
-  //PyObject *m = PyImport_GetModuleDict();
-
-  PySys_SetObject("stdout",PySys_GetObject("__stdout__"));
-  PySys_SetObject("stderr",PySys_GetObject("__stderr__"));
-  */
-  return true;
-}
-
-/*!
-  \brief Compile Python command and evaluate it in the
-         python dictionary context if possible.
-  \internal
-  \param command Python command string
-  \param context Python context (dictionary)
-  \return -1 on fatal error, 1 if command is incomplete and 0
-         if command is executed successfully
- */
-static int run_command(const char *command, PyObject *context)
-{
-  PyObject *m = PyImport_AddModule("codeop");
-  if(!m) { // Fatal error. No way to go on.
-    PyErr_Print();
-    return -1;
-  }
-  PyObjWrapper v(PyObject_CallMethod(m,(char*)"compile_command",(char*)"s",command));
-  if(!v) {
-    // Error encountered. It should be SyntaxError,
-    //so we don't write out traceback
-    PyObjWrapper exception, value, tb;
-    PyErr_Fetch(&exception, &value, &tb);
-    PyErr_NormalizeException(&exception, &value, &tb);
-    PyErr_Display(exception, value, NULL);
-    return -1;
-  }
-  else if (v == Py_None) {
-    // Incomplete text we return 1 : we need a complete text to execute
-    return 1;
-  }
-  else {
-    // Complete and correct text. We evaluate it.
-    //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0
-    //    PyObjWrapper r(PyEval_EvalCode(v,context,context));
-    //#else
-    PyObjWrapper r(PyEval_EvalCode((PyCodeObject *)(void *)v,context,context));
-    //#endif
-    if(!r) {
-      // Execution error. We return -1
-      PyErr_Print();
-      return -1;
-    }
-    // The command has been successfully executed. Return 0
-    return 0;
-  }
-}
-
-void replaceAll(std::string& str, const std::string& from, const std::string& to) {
-    if(from.empty())
-        return;
-    size_t start_pos = 0;
-    while((start_pos = str.find(from, start_pos)) != std::string::npos) {
-        str.replace(start_pos, from.length(), to);
-        start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
-    }
-}
-/*!
-  \brief Compile Python command and evaluate it in the
-         python dictionary context if possible. Command might correspond to
-         the execution of a script with optional arguments.
-         In this case, command is:
-         execfile(r"/absolute/path/to/script.py [args:arg1,...,argn]")
-  \internal
-  \param command Python command string
-  \param context Python context (dictionary)
-  \return -1 on fatal error, 1 if command is incomplete and 0
-         if command is executed successfully
- */
-static int compile_command(const char *command,PyObject *context)
-{
-  // First guess if command is execution of a script with args, or a simple Python command
-  std::string singleCommand = command;
-  std::string commandArgs = "";
-
-  std::size_t pos = std::string(command).find("args:");
-  if (pos != std::string::npos) {
-    commandArgs = singleCommand.substr(pos+5);
-    commandArgs = commandArgs.substr(0, commandArgs.length()-3);
-    singleCommand = singleCommand.substr(0, pos-1)+"\")";
-  }
-
-  if (commandArgs.empty()) {
-    // process command: expression
-    // process command: execfile(r"/absolute/path/to/script.py") (no args)
-    return run_command(singleCommand.c_str(), context);
-  }
-  else {
-    // process command: execfile(r"/absolute/path/to/script.py [args:arg1,...,argn]")
-    std::string script = singleCommand.substr(11); // remove leading execfile(r"
-    script = script.substr(0, script.length()-2); // remove trailing ")
-
-    std::string preCommandBegin = "import sys; save_argv = sys.argv; sys.argv=[";
-    std::string preCommandEnd = "];";
-    replaceAll(commandArgs, ",", "\",\"");
-    commandArgs = "\""+commandArgs+"\"";
-    std::string completeCommand = preCommandBegin+"\""+script+"\","+commandArgs+preCommandEnd+singleCommand+";sys.argv=save_argv";
-    return run_command(completeCommand.c_str(), context);
-  }
-}
-
-/*!
-  \brief Run Python command.
-  \param command Python command
-  \return command status
-*/
-int PyInterp_Interp::run(const char *command)
-{
-  beforeRun();
-  return simpleRun(command);
-}
-
-/*!
-  \brief Run Python command (used internally).
-  \param command Python command
-  \param addToHistory if \c true (default), the command is added to the commands history
-  \return command status
-*/
-int PyInterp_Interp::simpleRun(const char *command, const bool addToHistory)
-{
-  if( addToHistory && strcmp(command,"") != 0 ) {
-    _history.push_back(command);
-    _ith = _history.end();
-  }
-
-  // We come from C++ to enter Python world
-  // We need to acquire the Python global lock
-  //PyLockWrapper aLock(_tstate); // san - lock is centralized now
-
-  // Reset redirected outputs before treatment
-  PySys_SetObject((char*)"stderr",_verr);
-  PySys_SetObject((char*)"stdout",_vout);
-
-  int ier = compile_command(command,_g);
-
-  // Outputs are redirected on standards outputs (console)
-  PySys_SetObject((char*)"stdout",PySys_GetObject((char*)"__stdout__"));
-  PySys_SetObject((char*)"stderr",PySys_GetObject((char*)"__stderr__"));
-
-  return ier;
-}
-
-/*!
-  \brief Get previous command in the commands history.
-  \return previous command
-*/
-const char * PyInterp_Interp::getPrevious()
-{
-  if(_ith != _history.begin()){
-    _ith--;
-    return (*_ith).c_str();
-  }
-  else
-    return BEGIN_HISTORY_PY;
-}
-
-/*!
-  \brief Get next command in the commands history.
-  \return next command
-*/
-const char * PyInterp_Interp::getNext()
-{
-  if(_ith != _history.end()){
-    _ith++;
-  }
-  if (_ith == _history.end())
-    return TOP_HISTORY_PY;
-  else
-    return (*_ith).c_str();
-}
-
-/*!
-  \brief Set Python standard output device hook.
-  \param cb callback function
-  \param data callback function parameters
-*/
-void PyInterp_Interp::setvoutcb(PyOutChanged* cb, void* data)
-{
-  ((PyStdOut*)_vout)->_cb=cb;
-  ((PyStdOut*)_vout)->_data=data;
-}
-
-/*!
-  \brief Set Python standard error device hook.
-  \param cb callback function
-  \param data callback function parameters
-*/
-void PyInterp_Interp::setverrcb(PyOutChanged* cb, void* data)
-{
-  ((PyStdOut*)_verr)->_cb=cb;
-  ((PyStdOut*)_verr)->_data=data;
-}
diff --git a/src/PyInterp/PyInterp_Interp.h b/src/PyInterp/PyInterp_Interp.h
deleted file mode 100644 (file)
index d92bc4f..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-
-#ifndef PYINTERP_INTERP_H
-#define PYINTERP_INTERP_H
-
-#include "PyInterp.h"   // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
-
-#include <list>
-#include <string>
-
-class PYINTERP_EXPORT PyLockWrapper
-{
-  PyThreadState* myThreadState;
-  PyThreadState* mySaveThreadState;
-  PyGILState_STATE _savestate;
-public:
-  PyLockWrapper(PyThreadState* theThreadState);
-  ~PyLockWrapper();
-};
-
-typedef void PyOutChanged(void* data,char * c);
-
-class PYINTERP_EXPORT PyInterp_Interp
-{
-public:
-  static int _argc;
-  static char* _argv[];
-  static PyObject *builtinmodule;
-  static PyThreadState *_gtstate;
-  static PyInterpreterState *_interp;
-  
-  PyInterp_Interp();
-  virtual ~PyInterp_Interp();
-  
-  void initialize();
-
-  virtual int run(const char *command); 
-
-  PyLockWrapper GetLockWrapper();
-
-  std::string getbanner(); 
-  void setverrcb(PyOutChanged*,void*);
-  void setvoutcb(PyOutChanged*,void*);
-
-  const char * getPrevious();
-  const char * getNext();    
-
-protected:
-  PyThreadState * _tstate;
-  PyObject * _vout;
-  PyObject * _verr;
-  PyObject * _g;
-  PyObject * _codeop;
-  std::list<std::string> _history;
-  std::list<std::string>::iterator _ith;
-
-  virtual int beforeRun() { return 0; }
-  int simpleRun(const char* command, const bool addToHistory = true);
-
-  virtual bool initRun();
-  virtual void initPython();
-  virtual bool initState() = 0;
-  virtual bool initContext() = 0;  
-};
-
-class PYINTERP_EXPORT PyObjWrapper
-{
-  PyObject* myObject;
-public:
-  PyObjWrapper(PyObject* theObject) : myObject(theObject) {}
-  PyObjWrapper() : myObject(0) {}
-  virtual ~PyObjWrapper() { Py_XDECREF(myObject); }
-
-  operator PyObject*()    { return myObject;  }
-  PyObject* operator->()  { return myObject;  }
-  PyObject* get()         { return myObject;  }
-  bool operator!()        { return !myObject; }
-  bool operator==(PyObject* theObject) { return myObject == theObject; }
-  PyObject** operator&()  { return &myObject; }
-  PyObjWrapper& operator=(PyObjWrapper* theObjWrapper)
-  {
-    Py_XDECREF(myObject);
-    myObject = theObjWrapper->myObject;
-    return *this;
-  }
-};
-
-typedef struct {
-  PyObject_HEAD
-  int softspace;
-  PyOutChanged* _cb;
-  void* _data;
-  bool _iscerr;
-} PyStdOut;
-
-#endif // PYINTERP_INTERP_H
diff --git a/src/PyInterp/PyInterp_Request.cpp b/src/PyInterp/PyInterp_Request.cpp
deleted file mode 100644 (file)
index a4ce099..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-#include "PyInterp_Request.h"
-
diff --git a/src/PyInterp/PyInterp_Request.h b/src/PyInterp/PyInterp_Request.h
deleted file mode 100644 (file)
index 9cc3a68..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-#ifndef PYINTERP_REQUEST_H
-#define PYINTERP_REQUEST_H
-
-#include "PyInterp.h"
-#include "PyInterp_Event.h"
-
-#include <QMutex>
-#include <QObject>
-
-class PyInterp_Interp;
-class PyInterp_Watcher;
-class PyInterp_Dispatcher;
-class PyInterp_ExecuteEvent;
-class PyConsole_Editor;
-
-class PYINTERP_EXPORT PyInterp_Request
-{
-  friend class PyInterp_Dispatcher;
-  friend class PyInterp_ExecuteEvent;
-
-  PyInterp_Request();
-  PyInterp_Request( const PyInterp_Request& );
-
-protected:
-  virtual ~PyInterp_Request() {};
-  // protected destructor - to control deletion of requests
-
-public:
-  PyInterp_Request( QObject* listener, bool sync = false )
-    : myIsSync( sync ), myListener( listener ) {};
-
-  static void     Destroy( PyInterp_Request* );
-  // Deletes a request
-
-  bool            IsSync() const { return myIsSync; }
-  // Returns true if this request should be processed synchronously,
-  // without putting it to a queue
-
-protected:
-  virtual void    safeExecute();
-
-  virtual void    execute() = 0;
-  // Should be redefined in successors, contains actual request code
-
-  virtual QEvent* createEvent();
-  // This method can be overridden to customize notification event creation
-
-  virtual void    processEvent( QObject* );
-
-  QObject*        listener() const { return myListener; }
-  void            setListener( QObject* );
-
-private:
-  void            process();
-
-private:
-  QMutex          myMutex;
-  bool            myIsSync;
-  QObject*        myListener;
-};
-
-class PYINTERP_EXPORT PyInterp_LockRequest : public PyInterp_Request
-{
-public:
-
-  PyInterp_LockRequest( PyInterp_Interp* interp, QObject* listener = 0, bool sync = false )
-    : PyInterp_Request( listener, sync ), myInterp( interp )
-  {}
-
-protected:
-  PyInterp_Interp*  getInterp() const { return myInterp; }
-
-  virtual void      safeExecute();
-
-private:
-  PyInterp_Interp*  myInterp;
-};
-
-#endif // PYINTERP_REQUEST_H
diff --git a/src/PyInterp/PyInterp_Watcher.h b/src/PyInterp/PyInterp_Watcher.h
deleted file mode 100644 (file)
index 91126b7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-
-#ifndef PYINTERP_WATCHER_H
-#define PYINTERP_WATCHER_H
-
-#include "PyInterp.h"   // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
-
-#include "PyInterp_Dispatcher.h"
-
-#include <QObject>
-
-// Private class that keeps track of destructions of request listeners
-class PYINTERP_EXPORT PyInterp_Watcher : public QObject
-{                                           
-  Q_OBJECT
-
-public:
-  PyInterp_Watcher() : QObject( 0 ) {}
-  virtual ~PyInterp_Watcher() {}
-
-public slots:
-  void onDestroyed( QObject* o ) { PyInterp_Dispatcher::Get()->objectDestroyed( o ); }
-};
-
-#endif // PYINTERP_WATCHER_H
index 0b2870fa8530ac4afca51b5e5f4842ee49d1eb7b..d45087849ec89f9a252aea30cab8d64549fd5808 100644 (file)
@@ -17,6 +17,7 @@ SET(PROJECT_HEADERS
     SketchPlugin_ConstraintParallel.h
     SketchPlugin_ConstraintPerpendicular.h
     SketchPlugin_ConstraintRadius.h
+       SketchPlugin_Validators.h
 )
 
 SET(PROJECT_SOURCES
@@ -34,6 +35,7 @@ SET(PROJECT_SOURCES
     SketchPlugin_ConstraintParallel.cpp
     SketchPlugin_ConstraintPerpendicular.cpp
     SketchPlugin_ConstraintRadius.cpp
+       SketchPlugin_Validators.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -55,7 +57,6 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../GeomDataAPI
-  ../ModuleBase
 )
 
 INSTALL(TARGETS SketchPlugin DESTINATION plugins)
index b46cf90967b30b86bf225e4baa781bd40931bea3..de504f56ea4b1ca99cc88607c51d4dba6df46f09 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "SketchPlugin_ConstraintDistance.h"
 #include <SketchPlugin_Point.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Line.h>
 
 #include <GeomAPI_Lin2d.h>
 #include <GeomAPI_Pnt2d.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 
-/// Obtain the point object from specified constraint parameter
-static boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(
-            DataPtr             theData,
-            const std::string&  theAttribute);
-
 
 SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
 {
 }
 
+//*************************************************************************************
 void SketchPlugin_ConstraintDistance::initAttributes()
 {
   data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::type());
@@ -30,22 +28,39 @@ void SketchPlugin_ConstraintDistance::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
 }
 
+//*************************************************************************************
 void SketchPlugin_ConstraintDistance::execute()
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B());
-  if (aPoint_A && aPoint_B) {
-    AttributeDoublePtr anAttr_Value =
-      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
-
-    if (!anAttr_Value->isInitialized()) {
-      anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
+  AttributeDoublePtr anAttr_Value =
+    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+      aData->attribute(SketchPlugin_Constraint::VALUE()));
+
+  if (!anAttr_Value->isInitialized()) {
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = 
+      getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = 
+      getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B());
+  
+    if (aPoint_A && aPoint_B) { // both points
+        anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
+    } else {
+      if (!aPoint_A && aPoint_B) { //Line and point
+        boost::shared_ptr<SketchPlugin_Line> aLine = 
+          getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
+        if (aLine)
+          anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
+      } else if (aPoint_A && !aPoint_B) { // Point and line
+        boost::shared_ptr<SketchPlugin_Line> aLine = 
+          getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
+        if(aLine)
+          anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
+      }
     }
   }
 }
 
+//*************************************************************************************
 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObject(
                     boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
@@ -57,14 +72,36 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObje
   DataPtr aData = data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B());
-  if (!aPoint_A || !aPoint_B)
+
+  boost::shared_ptr<GeomAPI_Pnt2d> aPnt_A;
+  boost::shared_ptr<GeomAPI_Pnt2d> aPnt_B;
+
+  if (aPoint_A && aPoint_B) {
+    aPnt_A = aPoint_A->pnt();
+    aPnt_B = aPoint_B->pnt();
+  } else if (!aPoint_A && aPoint_B) {
+    boost::shared_ptr<SketchPlugin_Line> aLine = 
+      getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
+    if (aLine) {
+      aPnt_B = aPoint_B->pnt();
+      aPnt_A = getProjectionPoint(aLine, aPnt_B);
+    }
+  } else if (aPoint_A && !aPoint_B) {
+    boost::shared_ptr<SketchPlugin_Line> aLine = 
+      getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
+    if (aLine) {
+      aPnt_A = aPoint_A->pnt();
+      aPnt_B = getProjectionPoint(aLine, aPnt_A);
+    }
+  }
+  if (!aPnt_A || !aPnt_B)
     return thePrevious;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
 
-  boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPoint_A->x(), aPoint_A->y());
-  boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPoint_B->x(), aPoint_B->y());
+  boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y());
+  boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y());
   boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = aFlyOutAttr->isInitialized() ? 
                                               sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : 
                                               boost::shared_ptr<GeomAPI_Pnt>();
@@ -81,6 +118,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObje
   return anAIS;
 }
 
+//*************************************************************************************
 void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY)
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
@@ -92,6 +130,7 @@ void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY)
   aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
 }
 
+//*************************************************************************************
 boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
                                                        const std::string& theAttribute)
 {
@@ -104,14 +143,50 @@ boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
   if (anAttr)
-    aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
+    aFeature = ModelAPI_Feature::feature(anAttr->object());
 
   if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
     aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                            (aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
-  else {
-    if (anAttr->attr())
+  else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID())
+    aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                          (aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
+  else if (anAttr->attr()) {
       aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
   }
   return aPointAttr;
 }
+
+//*************************************************************************************
+boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute)
+{
+  boost::shared_ptr<SketchPlugin_Line> aLine;
+  if (!theData)
+    return aLine;
+
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
+  if (anAttr) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
+    if (aFeature && aFeature->getKind() == SketchPlugin_Line::ID()) {
+      aLine = boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+    }
+  }
+  return aLine;
+}
+
+//*************************************************************************************
+boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine, 
+                                                          const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = theLine->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+        aData->attribute(SketchPlugin_Line::START_ID()));
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+        aData->attribute(SketchPlugin_Line::END_ID()));
+
+  GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y());
+  return aLin2d.project(thePoint);
+}
\ No newline at end of file
index 2294ac6ef2be8483ab3d3c1339bbf0ce982223c7..afb687d09c49f1caa24932f4b821b6e9a38f556d 100644 (file)
@@ -8,9 +8,13 @@
 #include "SketchPlugin.h"
 #include "SketchPlugin_Constraint.h"
 #include "SketchPlugin_Sketch.h"
+#include "ModelAPI_Data.h"
 
 #include <list>
 
+class SketchPlugin_Line;
+class GeomDataAPI_Point2D;
+
 /** \class SketchPlugin_ConstraintDistance
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines a distance
@@ -52,4 +56,15 @@ public:
   SketchPlugin_ConstraintDistance();
 };
 
+
+/// Obtain the point object from specified constraint parameter
+boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
+                                                       const std::string&  theAttribute);
+
+boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute);
+
+boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine, 
+                                                    const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
+
+
 #endif
index 3c2b146b82be40b3e5b6e7552e4295381bcb980a..28d2cf7d35b2b63dac6e836e0520cbb945efef88 100644 (file)
@@ -36,7 +36,7 @@ void SketchPlugin_ConstraintLength::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
+    FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
     if (aFeature) {
       // set length value
       boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
@@ -65,7 +65,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
     return thePrevious;
-  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
+  FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
   if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
     return thePrevious;
 
index 4a971e8c7e3c27ab72870d3dfef5d49b6a863d55..e2cd9c53dd2d52ab8b5ee548dd945362999502ac 100644 (file)
@@ -45,13 +45,13 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
       !anAttr2 || !anAttr2->isObject())
     return thePrevious;
 
-  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+  FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object());
   if (!aFeature)
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
     boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
 
-  aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+  aFeature = ModelAPI_Feature::feature(anAttr2->object());
   if (!aFeature)
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
index 8985eb061bb3f6ef15164d7b61e0d4801b296b3c..4f6a0b77136a4e5ef3794a065b23e310233689ef 100644 (file)
@@ -45,13 +45,13 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
       !anAttr2 || !anAttr2->isObject())
     return thePrevious;
 
-  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+  FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object());
   if (!aFeature)
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
     boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
 
-  aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+  aFeature = ModelAPI_Feature::feature(anAttr2->object());
   if (!aFeature)
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
index 11071843f283cd2801d576cdc3c61d45f3a31ea6..b771035423ffbe373fbf492317700b4f997323e0 100644 (file)
@@ -37,7 +37,7 @@ void SketchPlugin_ConstraintRadius::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
+    FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
     if (aFeature) {
       double aRadius = 0;
       boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
@@ -73,7 +73,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
     return thePrevious;
-  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
+  FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
   std::string aKind = aFeature ? aFeature->getKind() : "";
   if (aKind != SketchPlugin_Circle::ID() && aKind != SketchPlugin_Arc::ID())
     return thePrevious;
@@ -130,7 +130,7 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
+  FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
   if (!aFeature)
     return;
   std::string aCenterAttrName;
index 9c0da3f592d8e5b530c74bf82dc45f1acdd841c1..2a05d45641cd3c9e5dca8516904eec7bd6e224cd 100644 (file)
 #include "SketchPlugin_ConstraintParallel.h"
 #include "SketchPlugin_ConstraintPerpendicular.h"
 #include "SketchPlugin_ConstraintRadius.h"
+#include "SketchPlugin_Validators.h"
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Validator.h>
 
 using namespace std;
 
@@ -20,6 +22,10 @@ static SketchPlugin_Plugin* MY_INSTANCE = new SketchPlugin_Plugin();
 
 SketchPlugin_Plugin::SketchPlugin_Plugin() 
 {
+  PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  aFactory->registerValidator("SketchPlugin_DistanceAttrValidator", new SketchPlugin_DistanceAttrValidator);
+
   // register this plugin
   ModelAPI_PluginManager::get()->registerPlugin(this);
 }
index 288e4e5297b308d8c5aab90a98be643ed3405bf9..b3cacc6ae777b297067e9935282790f6116cff84 100644 (file)
@@ -41,7 +41,8 @@ void SketchPlugin_Sketch::execute()
   if (!data()->isValid())
     return ;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+    data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
 
   boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
@@ -166,17 +167,3 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::
   }
   return boost::shared_ptr<GeomAPI_AISObject>();
 }
-
-FeaturePtr SketchPlugin_Sketch::getFeature(ObjectPtr theObject)
-{
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if (!aFeature) {
-    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    if (aResult) {
-      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-      DocumentPtr aDoc = aMgr->rootDocument();
-      return aDoc->feature(aResult);
-    }
-  }
-  return aFeature;
-}
\ No newline at end of file
index 9a2e31ee6ed0dca75d46c387f6cd42451ccf5914..3c71a6505c29a65eb616adc9a7791d6a97888eb3 100644 (file)
@@ -96,8 +96,6 @@ public:
   virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                             boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
-  static FeaturePtr getFeature(ObjectPtr theObject);
-
 protected:
   /// Creates a plane and append it to the list
   /// \param theX the X normal value
diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp
new file mode 100644 (file)
index 0000000..862a303
--- /dev/null
@@ -0,0 +1,35 @@
+// File:        SketchPlugin_Validators.cpp
+// Created:     01 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketchPlugin_Validators.h"
+#include "SketchPlugin_ConstraintDistance.h"
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultValidator.h>
+#include <GeomDataAPI_Point2D.h>
+
+
+bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, 
+                                                 const std::list<std::string>& theArguments,
+                                                 const ObjectPtr& theObject) const
+{
+  std::string aParamA = theArguments.front();
+  PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
+  // If the object is not a line then it is accepted
+  const ModelAPI_ResultValidator* aLineValidator = dynamic_cast<const ModelAPI_ResultValidator*>(
+                                              aFactory->validator("Model_ResultLineValidator"));
+  if (!aLineValidator->isValid(theObject))
+    return true;
+
+  // If it is a line then we have to check that first attribute id not a line
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint = getFeaturePoint(theFeature->data(), aParamA);
+  if (aPoint)
+    return true;
+  return false;
+}
+
+
+
diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h
new file mode 100644 (file)
index 0000000..74357d1
--- /dev/null
@@ -0,0 +1,22 @@
+// File:        SketchPlugin_Validators.h
+// Created:     01 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketchPlugin_Validators_H
+#define SketchPlugin_Validators_H
+
+#include "SketchPlugin.h"
+//#include <ModuleBase_FeatureValidator.h>
+#include <ModelAPI_AttributeValidator.h>
+
+
+class SketchPlugin_DistanceAttrValidator: public ModelAPI_AttributeValidator
+{
+public:
+  virtual bool isValid(const FeaturePtr& theFeature, 
+                       const std::list<std::string>& theArguments,
+                       const ObjectPtr& theObject) const;
+
+};
+
+#endif
\ No newline at end of file
index e6d71aa232f7b64251fbce45bc64916a45764b58..804f1bb32609a9d858b818f13d125e28a5a2cf43 100644 (file)
 
       <feature id="SketchConstraintDistance" title="Distance" 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_or_attribute_selector id="ConstraintEntityA" label="First point" tooltip="Select an point in the viewer">
-          <validator id="ModuleBase_ResulPointValidator"/>
+        <feature_or_attribute_selector id="ConstraintEntityA" label="First object" tooltip="Select an point in the viewer">
+          <validator id="Model_ResultPointValidator"/>
+          <validator id="Model_ResultLineValidator"/>
         </feature_or_attribute_selector>
-        <feature_or_attribute_selector id="ConstraintEntityB" label="Last point" tooltip="Select an point in the viewer">
-          <validator id="ModuleBase_ResulPointValidator"/>
+        <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select an point in the viewer">
+          <validator id="Model_ResultPointValidator"/>
+          <validator id="Model_ResultLineValidator"/>
+          <validator id="SketchPlugin_DistanceAttrValidator" parameters="ConstraintEntityA"/>
         </feature_or_attribute_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
-        <validator id="PartSet_DistanceValidator"/> 
+        <validator id="PartSet_DistanceValidator"/>
       </feature>
       
       <feature id="SketchConstraintLength" title="Length" tooltip="Create constraint for the given length of a line segment">
         <label title="Select a line on which to calculate lenght" tooltip="Select a line on which to calculate lenght"/>
         <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer">
-          <validator id="ModuleBase_ResulLineValidator"/>
+          <validator id="Model_ResultLineValidator"/>
         </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
@@ -52,7 +55,7 @@
       <feature id="SketchConstraintRadius" title="Radius" tooltip="Create constraint for the given radius of a circle or an arc">
         <label title="Select a circle or an arc on which to calculate radius" tooltip="Select a circle or an arc on which to calculate radius"/>
         <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer">
-          <validator id="ModuleBase_ResulArcValidator"/>
+          <validator id="Model_ResultArcValidator"/>
         </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
       
       <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines">
         <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
-          <validator id="ModuleBase_ResulLineValidator"/>
+          <validator id="Model_ResultLineValidator"/>
         </feature_selector>
         <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
-          <validator id="ModuleBase_ResulLineValidator"/>
+          <validator id="Model_ResultLineValidator"/>
         </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <validator id="PartSet_ParallelValidator"/>
       
       <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines">
         <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
-          <validator id="ModuleBase_ResulLineValidator"/>
+          <validator id="Model_ResultLineValidator"/>
         </feature_selector>
         <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
-          <validator id="ModuleBase_ResulLineValidator"/>
+          <validator id="Model_ResultLineValidator"/>
         </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <validator id="PartSet_PerpendicularValidator"/>
index 40c76d1a772b5a863d13af4c711a1fe65ee8f6a3..b91d267f61b4625b1402b314787a0253a0850d66 100644 (file)
@@ -3,6 +3,7 @@
 // Author:  Artem ZHIDKOV
 
 #include "SketchSolver_Solver.h"
+#include <Events_LongOp.h>
 
 SketchSolver_Solver::SketchSolver_Solver()
 {
@@ -111,7 +112,9 @@ int SketchSolver_Solver::solve()
   if (myEquationsSystem.constraints <= 0)
     return SLVS_RESULT_EMPTY_SET;
 
+  Events_LongOp::start(this);
   Slvs_Solve(&myEquationsSystem, myGroupID);
+  Events_LongOp::end(this);
 
   return myEquationsSystem.result;
 }
index 67ba7629dcd28365ffb75f99e84791f2d7db21b2..a5a31330139a65f38fd5fbf4b66b6fd33b3fd5d4 100644 (file)
@@ -16,7 +16,6 @@ SET(PROJECT_HEADERS
     XGUI_Viewer.h
        XGUI_RubberBand.h
        XGUI_Constants.h
-       XGUI_ViewBackground.h
        XGUI_DocumentDataModel.h
        XGUI_PartDataModel.h
        XGUI_ObjectsBrowser.h
@@ -51,7 +50,6 @@ SET(PROJECT_SOURCES
     XGUI_ViewPort.cpp
     XGUI_Viewer.cpp
        XGUI_RubberBand.cpp
-       XGUI_ViewBackground.cpp
        XGUI_DocumentDataModel.cpp
        XGUI_PartDataModel.cpp
        XGUI_ObjectsBrowser.cpp
@@ -70,6 +68,10 @@ SET(PROJECT_RESOURCES
     XGUI_pictures.qrc
 )
 
+SET(PREFERENCES_XML
+       NewGeom.xml
+)
+
 SET(TEXT_RESOURCES
        XGUI_msg_fr.ts
 )
@@ -80,9 +82,10 @@ SET(PROJECT_LIBRARIES
        ${QT_LIBRARIES}
        ${CAS_VIEWER}
        ${CAS_KERNEL}
-       PyConsole
-       PyInterp
-       PyEvent
+       ${PyConsole}
+       ${PyInterp}
+       ${suit}
+       ${qtx}
        ModelAPI
        ModuleBase
 )
@@ -105,19 +108,18 @@ QT4_CREATE_TRANSLATION(QM_RESOURCES
 
 SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES})
 #SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES})
-SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES} ${PREFERENCES_XML})
 
 ADD_DEFINITIONS( -DXGUI_EXPORTS ${CAS_DEFINITIONS} )
 
 INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
                                         ${PROJECT_SOURCE_DIR}/src/Config
-                                        ${PROJECT_SOURCE_DIR}/src/PyInterp
-                                        ${PROJECT_SOURCE_DIR}/src/PyConsole
                                         ${PROJECT_SOURCE_DIR}/src/ModelAPI
                                         ${PROJECT_SOURCE_DIR}/src/GeomAPI
                                         ${PROJECT_SOURCE_DIR}/src/ModuleBase
                                         ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
-                                        ${CAS_INCLUDE_DIRS})
+                                        ${CAS_INCLUDE_DIRS}
+                                        ${SUIT_INCLUDE})
 
 LINK_DIRECTORIES($ENV{PYTHON_LIB_DIR})
 
@@ -127,6 +129,7 @@ ADD_LIBRARY(XGUI SHARED
        ${PROJECT_COMPILED_RESOURCES} 
        ${TEXT_RESOURCES}
        ${QM_RESOURCES}
+       ${PREFERENCES_XML}
 )
 
 ADD_DEPENDENCIES(XGUI ModelAPI)
@@ -136,3 +139,4 @@ TARGET_LINK_LIBRARIES(XGUI ${PROJECT_LIBRARIES})
 
 INSTALL(TARGETS XGUI DESTINATION bin)
 INSTALL(FILES ${QM_RESOURCES} DESTINATION bin)
+INSTALL(FILES ${PREFERENCES_XML} DESTINATION resources)
diff --git a/src/XGUI/NewGeom.xml b/src/XGUI/NewGeom.xml
new file mode 100644 (file)
index 0000000..0f76d83
--- /dev/null
@@ -0,0 +1,8 @@
+<!--
+-->
+<document>
+  <section name="Viewer" >
+    <!-- OCC viewer preferences -->
+    <parameter name="background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
+ </section>
+</document>
index 6891d57daa7601a43f28fd242982263a9ef8943f..e699b4a2aca094101a7c11485f88c4a3b1f745a6 100644 (file)
@@ -101,40 +101,50 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
   QMenu* aMenu = new QMenu();
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
   QList<ObjectPtr> aObjects = aSelMgr->selection()->selectedObjects();
-  if (aObjects.size() == 1) {
+  int aSelected = aObjects.size();
+  if (aSelected > 0) {
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-    ObjectPtr aObject = aObjects.first();
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
     //Process Feature
-    if (aObject) {
-      ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
-      if (aPart) {
-        if (aMgr->currentDocument() == aPart->partDoc())
-          aMenu->addAction(action("DEACTIVATE_PART_CMD"));
-        else 
-          aMenu->addAction(action("ACTIVATE_PART_CMD"));
-      } else {
-        ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
-        if (aResult) {
-          XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-          if (aDisplayer->isVisible(aResult))
+    if (aSelected == 1) {
+      ObjectPtr aObject = aObjects.first();
+      if (aObject) {
+        ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+        FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+        if (aPart) {
+          if (aMgr->currentDocument() == aPart->partDoc())
+            aMenu->addAction(action("DEACTIVATE_PART_CMD"));
+          else 
+            aMenu->addAction(action("ACTIVATE_PART_CMD"));
+        } else if (aFeature) {
+          aMenu->addAction(action("EDIT_CMD"));
+        } else {
+          if (aDisplayer->isVisible(aObject))
             aMenu->addAction(action("HIDE_CMD"));
           else
             aMenu->addAction(action("SHOW_CMD"));
-        } else {
-          FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
-          if (aFeature) {
-            aMenu->addAction(action("EDIT_CMD"));
-            aMenu->addAction(action("DELETE_CMD"));
-          }
         }
+      } else { // If feature is 0 the it means that selected root object (document)
+        if (aMgr->currentDocument() != aMgr->rootDocument()) 
+          aMenu->addAction(action("ACTIVATE_PART_CMD"));
       }
-      aMenu->addSeparator();
-
-    // Process Root object (document)
-    } else { // If feature is 0 the it means that selected root object (document)
-      if (aMgr->currentDocument() != aMgr->rootDocument()) {
-        aMenu->addAction(action("ACTIVATE_PART_CMD"));
+    } else if (aSelected >= 1) {
+      bool hasResult = false;
+      bool hasFeature = false;
+      foreach(ObjectPtr aObj, aObjects) {
+        FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+        ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+        if (aResult) hasResult = true;
+        if (aFeature) hasFeature = true;
+        if (hasFeature && hasResult)
+          break;
+      }
+      if (hasResult) {
+        aMenu->addAction(action("SHOW_CMD"));
+        aMenu->addAction(action("HIDE_CMD"));
       }
+      if (hasFeature)
+        aMenu->addAction(action("DELETE_CMD"));
     }
   }
   aMenu->addActions(myWorkshop->objectBrowser()->actions());
index f51afd3a9f7d435710212174467574bdc2d1a13f..62c735ce71e89d1e546a6d5802831bd602a071c3 100644 (file)
@@ -6,11 +6,11 @@
 #include "XGUI_Viewer.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_ViewerProxy.h"
-#include "ModuleBase_Tools.h"
 
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_IPresentable.h>
@@ -54,7 +54,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
     } else {
       ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
       if (aResult) {
-        boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+        boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
         if (aShapePtr) {
           anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
           anAIS->createShape(aShapePtr);
@@ -144,7 +144,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
   } else {
     ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
     if (aResult) {
-      boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+      boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
       if (aShapePtr) {
         Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
         if (!aAISShape.IsNull()) {
@@ -197,7 +197,7 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult,
     updateViewer();
 }
 
-void XGUI_Displayer::deactivate(ObjectPtr theObject, bool toUpdate)
+void XGUI_Displayer::deactivate(ObjectPtr theObject)
 {
   if (isVisible(theObject)) {
     Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -208,6 +208,17 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject, bool toUpdate)
   }
 }
 
+void XGUI_Displayer::activate(ObjectPtr theObject)
+{
+  if (isVisible(theObject)) {
+    Handle(AIS_InteractiveContext) aContext = AISContext();
+
+     boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+     aContext->Activate(anAIS);
+  }
+}
+
 void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const bool isStop,
                                    const bool isUpdateViewer)
 {
index af80496e1911dad066b078c9f2568db786e9b4af..ebbfad740e3d8af48abea97a51b512ed638236f8 100644 (file)
@@ -120,7 +120,9 @@ public:
   /// \return feature the feature or NULL if it not visualized
   ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const;
 
-  void deactivate(ObjectPtr theFeature, bool toUpdate);
+  void deactivate(ObjectPtr theFeature);
+
+  void activate(ObjectPtr theFeature);
 
 protected:
   /// Deactivate local selection
index 6e61fef19bb19e453c7b639dcfff76a50b73d550..45d287465f3e87b761670c99239021ce63ea29ae 100644 (file)
@@ -23,6 +23,8 @@ XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
   setHeaderHidden(true);
   setModel(new XGUI_DocumentDataModel(this));
   setEditTriggers(QAbstractItemView::NoEditTriggers);
+  setSelectionBehavior(QAbstractItemView::SelectRows);
+  setSelectionMode(QAbstractItemView::ExtendedSelection);
 
   connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), 
           this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
index 99f8b066da82feb19b8ebb00cb198f87658d4ca4..5b26e4e6a8f62b7937613382b6bfcceb36a598b0 100644 (file)
@@ -144,7 +144,8 @@ QWidget* XGUI_PropertyPanel::contentWidget()
 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
 {
   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
-    eachWidget->restoreValue(theFeature);
+    eachWidget->setFeature(theFeature);
+    eachWidget->restoreValue();
   }
   // the repaint is used here to immediatelly react in GUI to the values change.
   repaint();
index 6ec2c0c65f51c35f6c852dd8e76721ca28ba4bb2..609db462fa7eb2248208512245eaeb10d3fc1344 100644 (file)
@@ -492,7 +492,7 @@ void XGUI_ViewPort::zoom(int x0, int y0, int x, int y)
 /*!
  Sets the background data
  */
-void XGUI_ViewPort::setBackground(const XGUI_ViewBackground& bgData)
+void XGUI_ViewPort::setBackground(const Qtx::BackgroundData& bgData)
 {
   if (bgData.isValid()) {
     myBackground = bgData;
index a0f9be0db84e93569d12157641528f1e399f725e..2988e8fed69494726b90a7480fe725a7e605656d 100644 (file)
@@ -2,7 +2,8 @@
 #define XGUI_ViewPort_H
 
 #include "XGUI.h"
-#include "XGUI_ViewBackground.h"
+
+#include <Qtx.h>
 
 #include <QWidget>
 #include <V3d_Viewer.hxx>
@@ -52,17 +53,17 @@ public:
     return myIsAdvancedZoomingEnabled;
   }
 
-  XGUI_ViewBackground background() const
+  Qtx::BackgroundData background() const
   {
     return myBackground;
   }
 
-  void setBackground(const XGUI_ViewBackground& bgData);
+  void setBackground(const Qtx::BackgroundData& bgData);
 
   void syncronizeWith( const XGUI_ViewPort* ref );
 
 signals:
-  void vpChangeBackground(const XGUI_ViewBackground&);
+  void vpChangeBackground(const Qtx::BackgroundData&);
   void vpClosed();
   void vpMapped();
   void vpTransformed();
@@ -94,7 +95,7 @@ private:
 
   double myScale;
 
-  XGUI_ViewBackground myBackground;
+  Qtx::BackgroundData myBackground;
   int myBgImgHeight;
   int myBgImgWidth;
 };
index 7c0bc5d9ac14c8c9e225178db90b52ae4344bf63..c62a266524ab56dbe29c05f6a2c27b16d874c0b6 100644 (file)
@@ -1004,12 +1004,12 @@ void XGUI_ViewWindow::resetState()
   setTransformRequested(NOTHING);
 }
 
-XGUI_ViewBackground XGUI_ViewWindow::background() const
+Qtx::BackgroundData XGUI_ViewWindow::background() const
 {
-  return myViewPort ? myViewPort->background() : XGUI_ViewBackground();
+  return myViewPort ? myViewPort->background() : Qtx::BackgroundData();
 }
 
-void XGUI_ViewWindow::setBackground(const XGUI_ViewBackground& theBackground)
+void XGUI_ViewWindow::setBackground(const Qtx::BackgroundData& theBackground)
 {
   if (myViewPort) 
        myViewPort->setBackground( theBackground );
index 65c2ae273cc87b9c50a25f7636d97de8515aff75..016c261d969f0402b77113db4edd06379d2d2ca8 100644 (file)
@@ -3,7 +3,8 @@
 
 #include "XGUI.h"
 #include "XGUI_Constants.h"
-#include "XGUI_ViewBackground.h"
+
+#include <Qtx.h>
 
 #include <QFrame>
 #include <QIcon>
@@ -76,10 +77,10 @@ public:
   bool transformEnabled(const OperationType) const;
 
   //! Returns View background object
-  XGUI_ViewBackground background() const;
+  Qtx::BackgroundData background() const;
 
   //! Sets View background object
-  void setBackground(const XGUI_ViewBackground& theBackground);
+  void setBackground(const Qtx::BackgroundData& theBackground);
 
   //! Returns true if the current view window can be closed
   bool closable() const { return myClosable; }
index ff33f60eb7b4c9a48e0539c9890f1d6b8b1a51b5..c0048f2fad54430451e33e24e6f1c95d0862f5c8 100644 (file)
@@ -2,6 +2,9 @@
 #include "XGUI_MainWindow.h"
 #include "XGUI_ViewWindow.h"
 #include "XGUI_ViewPort.h"
+#include "XGUI_Workshop.h"
+
+#include <SUIT_ResourceMgr.h>
 
 #include <QMdiArea>
 #include <QMdiSubWindow>
@@ -181,8 +184,8 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
   if (myViews.size() == 0) 
     setTrihedronShown(true);
 
-  view->setBackground(XGUI_ViewBackground(XGUI::VerticalGradient, Qt::white, QColor(Qt::blue).lighter()));
-  //view->setBackground(XGUI_ViewBackground(Qt::black));
+  Qtx::BackgroundData aBk = XGUI_Workshop::resourceMgr()->backgroundValue("Viewer", "background");
+  view->setBackground(aBk);
   view->updateEnabledDrawMode();
 
   QMdiArea* aMDI = myMainWindow->mdiArea();
@@ -197,7 +200,9 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
 
 XGUI_ViewWindow* XGUI_Viewer::activeViewWindow() const
 {
-  return dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+  if (myActiveView)
+    return dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+  return 0;
 }
 
 void XGUI_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
index 19453efdb3a4719691ba02a5952c86c9a4cf14fe..65c21fc5853e4efd9e6bfbc7ddc30040a1109f69 100644 (file)
@@ -37,7 +37,9 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const
     return myWorkshop->salomeConnector()->viewer()->activeView();
   } else {
     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-    return aViewer->activeViewWindow()->viewPort()->getView();
+    return (aViewer->activeViewWindow())?
+      aViewer->activeViewWindow()->viewPort()->getView():
+      Handle(V3d_View)();
   }
 }
  
@@ -58,7 +60,8 @@ void XGUI_ViewerProxy::fitAll()
   }
   else {
     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-    aViewer->activeViewWindow()->viewPort()->fitAll();
+    if (aViewer->activeViewWindow())
+      aViewer->activeViewWindow()->viewPort()->fitAll();
   }
 }
 
index db0ab95fd7765e0d98f4b981f9b9aa9eec03e189..49a1eade12b048118d17db0621a6fbd2dafe426b 100644 (file)
@@ -50,6 +50,8 @@
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
 
+#include <SUIT_ResourceMgr.h>
+
 #include <QApplication>
 #include <QFileDialog>
 #include <QMessageBox>
@@ -69,6 +71,7 @@
 #include <dlfcn.h>
 #endif
 
+SUIT_ResourceMgr* XGUI_Workshop::myResourceMgr = 0;
 
 QMap<QString, QString> XGUI_Workshop::myIcons;
 
@@ -89,6 +92,10 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   myObjectBrowser(0),
   myDisplayer(0)
 {
+  if (!myResourceMgr) {
+    myResourceMgr = new SUIT_ResourceMgr("NewGeom");
+    myResourceMgr->setCurrentFormat("xml");
+  }
   myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
 
   myDisplayer = new XGUI_Displayer(this);
@@ -262,10 +269,11 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
     return;
   }
 
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName("LongOperation")) {
+  if (theMessage->eventID() == Events_LongOp::eventID()) {
     if (Events_LongOp::isPerformed())
       QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-    else
+      //QTimer::singleShot(10, this, SLOT(onStartWaiting()));
+    else 
       QApplication::restoreOverrideCursor();
     return;
   }
@@ -279,8 +287,8 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
     if (myOperationMgr->startOperation(anOperation)) {
       myPropertyPanel->updateContentWidget(anOperation->feature());
       if (!anOperation->getDescription()->hasXmlRepresentation()) {
-        anOperation->commit();
-        updateCommandStatus();
+        if (anOperation->commit())
+          updateCommandStatus();
       }
     }
     return;
@@ -292,6 +300,14 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   }
 }
 
+//******************************************************
+void XGUI_Workshop::onStartWaiting()
+{
+  if (Events_LongOp::isPerformed()) {
+    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  }
+}
+
 //******************************************************
 void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
 {
@@ -392,12 +408,15 @@ void XGUI_Workshop::onOperationStarted()
     ModuleBase_ModelWidget* aWidget;
     for (; anIt != aLast; anIt++) {
       aWidget = *anIt;
+      aWidget->setFeature(aOperation->feature());
       //QObject::connect(aWidget, SIGNAL(valuesChanged()),  aOperation, SLOT(storeCustomValue()));
       QObject::connect(aWidget, SIGNAL(valuesChanged()),
                        this, SLOT(onWidgetValuesChanged()));
       // Init default values
       if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) {
-        aWidget->storeValue(aOperation->feature());
+        //aWidget->storeValue(aOperation->feature());
+        
+        aWidget->storeValue();
       }
     }
 
@@ -930,7 +949,8 @@ void XGUI_Workshop::onWidgetValuesChanged()
   for (; anIt != aLast; anIt++) {
     ModuleBase_ModelWidget* aCustom = *anIt;
     if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/ aCustom == aSenderWidget)) {
-      aCustom->storeValue(aFeature);
+      //aCustom->storeValue(aFeature);
+      aCustom->storeValue();
     }
   }
 }
@@ -1012,12 +1032,16 @@ void XGUI_Workshop::updateCommandsOnViewSelection()
   QList<QAction*> aActions = getModuleCommands();
   foreach(QAction* aAction, aActions) {
     QString aId = aAction->data().toString();
-    const ModelAPI_Validator* aValidator = aFactory->validator(aId.toStdString());
-    if (aValidator) {
-      const ModuleBase_SelectionValidator* aSelValidator = 
-        dynamic_cast<const ModuleBase_SelectionValidator*>(aValidator);
-      if (aSelValidator) {
-        aAction->setEnabled(aSelValidator->isValid(aSelection));
+    std::list<ModelAPI_Validator*> aValidators;
+    aFactory->validators(aId.toStdString(), aValidators);
+    std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+    for(; aValidator != aValidators.end(); aValidator++) {
+      if (*aValidator) {
+        const ModuleBase_SelectionValidator* aSelValidator = 
+          dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
+        if (aSelValidator) {
+          aAction->setEnabled(aSelValidator->isValid(aSelection));
+        }
       }
     }
   }
@@ -1029,10 +1053,6 @@ void XGUI_Workshop::registerValidators() const
 {
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-
-  aFactory->registerValidator("ModuleBase_ResulPointValidator", new ModuleBase_ResulPointValidator);
-  aFactory->registerValidator("ModuleBase_ResulLineValidator", new ModuleBase_ResulLineValidator);
-  aFactory->registerValidator("ModuleBase_ResulArcValidator", new ModuleBase_ResulArcValidator);
 }
 
 
index 3fbe33e20dd1b69ff86442a7303b5ae988d04706..c83583cc0f8094bbcf973eaeb5d381776d156a41 100644 (file)
@@ -43,6 +43,8 @@ class ModelAPI_ObjectUpdatedMessage;
 class ModelAPI_ObjectDeletedMessage;
 class QAction;
 
+class SUIT_ResourceMgr;
+
 /**\class XGUI_Workshop
  * \ingroup GUI
  * \brief Class which defines a configuration of the application (Workshop) and launches it.
@@ -111,6 +113,8 @@ public:
   //! Returns icon name according to feature Id
   static QString featureIcon(const std::string& theId);
 
+  static SUIT_ResourceMgr* resourceMgr() { return myResourceMgr; }
+
   //! Activates or deactivates a part
   //! If PartPtr is Null pointer then PartSet will be activated
   void activatePart(ResultPartPtr theFeature);
@@ -179,6 +183,8 @@ protected slots:
 
   void onWidgetValuesChanged();
 
+  void onStartWaiting();
+
 private:
   void initMenu();
 
@@ -211,6 +217,8 @@ private:
   QString myCurrentDir;
   static QMap<QString, QString> myIcons;
 
+  static SUIT_ResourceMgr* myResourceMgr;
+
 };
 
 #endif