]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Wait cursor for solver operation
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 29 Jul 2014 12:01:04 +0000 (16:01 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 29 Jul 2014 12:01:04 +0000 (16:01 +0400)
src/Events/Events_LongOp.cpp
src/Events/Events_LongOp.h
src/Model/Model_Update.cpp
src/SketchSolver/SketchSolver_Solver.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 7cc46c3cda6ac9da4f7355eaabfbaa1667a1a12c..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");
@@ -33,8 +33,8 @@ void Events_LongOp::start(void* theSender)
     MY_SENDERS[theSender]++;
 
   if (toSend) {
-    Events_LongOp anError(theSender);
-    Events_Loop::loop()->send(anError);
+    Events_LongOp anEvent(theSender);
+    Events_Loop::loop()->send(anEvent);
   }
 }
 
@@ -46,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 af5407cafedba7467c26761d5fc88277ca062f14..d8ccc3dd9060950f6743e81a799328d90d74e995 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;
 }
 
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 5cf57b2aabedd86da81bea8d71135418680bfb3c..fe055eff44b0b246d1c2bc802299aa48d083eb60 100644 (file)
@@ -264,10 +264,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;
   }
@@ -294,6 +295,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)
 {
index 3fbe33e20dd1b69ff86442a7303b5ae988d04706..b857becb3abad33b6d6a375aedc1dbb7f9aac295 100644 (file)
@@ -179,6 +179,8 @@ protected slots:
 
   void onWidgetValuesChanged();
 
+  void onStartWaiting();
+
 private:
   void initMenu();