Salome HOME
Minor updates.
[modules/shaper.git] / src / Events / Events_Loop.cpp
index 013e0a02d6e9e0952e76a42db5da0c165b2046f9..fda4aadca27f471169fd4bcdc7d1453074826fbc 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:       Events_Loop.hxx
-// Created:    Thu Mar 13 2014
-// Author:     Mikhail PONIKAROV
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include <Events_Loop.h>
 #include <Events_MessageGroup.h>
@@ -171,6 +185,7 @@ void Events_Loop::flush(const Events_ID& theID)
 {
   if (!myFlushActive)
     return;
+  bool hasEventsToFlush = !myGroups.empty();
   std::map<char*, std::shared_ptr<Events_Message> >::iterator aMyGroup;
   for(aMyGroup = myGroups.find(theID.eventText());
     aMyGroup != myGroups.end(); aMyGroup = myGroups.find(theID.eventText()))
@@ -206,6 +221,12 @@ void Events_Loop::flush(const Events_ID& theID)
       }
     }
   }
+  if (hasEventsToFlush && myGroups.empty() && myFlushed.empty()) {
+    // no more messages left in the queue, so, finalize the sketch processing
+    static Events_ID anID = Events_Loop::eventByName("SketchPrepared");
+    std::shared_ptr<Events_Message> aMsg(new Events_Message(anID, this));
+    Events_Loop::loop()->send(aMsg, false);
+  }
 }
 
 void Events_Loop::eraseMessages(const Events_ID& theID)
@@ -234,14 +255,6 @@ void Events_Loop::clear(const Events_ID& theID)
   }
 }
 
-void Events_Loop::autoFlush(const Events_ID& theID, const bool theAuto)
-{
-  if (theAuto)
-    myFlushed.insert(theID.myID);
-  else
-    myFlushed.erase(myFlushed.find(theID.myID));
-}
-
 bool Events_Loop::isFlushed(const Events_ID& theID)
 {
   return myFlushed.find(theID.myID) != myFlushed.end();
@@ -254,3 +267,8 @@ void Events_Loop::setFlushed(const Events_ID& theID, const bool theValue)
   else
     myFlushed.erase(myFlushed.find(theID.myID));
 }
+
+bool Events_Loop::hasGrouppedEvent(const Events_ID& theID)
+{
+  return myGroups.find(theID.myID) != myGroups.end();
+}
\ No newline at end of file