2 #include "graphwidget.h"
3 #include "BaseDriver.h"
5 #include <TFunction_Function.hxx>
6 #include <TFunction_IFunction.hxx>
7 #include <TFunction_Driver.hxx>
8 #include <TFunction_GraphNode.hxx>
10 #include <TDataStd_Tick.hxx>
11 #include <TDF_ListIteratorOfLabelList.hxx>
13 FThread::FThread(QObject* parent):QThread(parent),thread_index(0)
23 void FThread::setIterator(const TFunction_Iterator& theItr)
28 void FThread::setLogbook(const Handle(TFunction_Logbook)& theLog)
33 void FThread::setGraph(GraphWidget* theGraph)
35 this->graph = theGraph;
38 void FThread::setThreadIndex(const int theIndex)
40 this->thread_index = theIndex;
43 void FThread::setMutex(Standard_Mutex* pmutex)
45 this->pmutex = pmutex;
48 // Returns any free (not executed yet) function
49 TDF_Label FThread::getFreeFunction()
52 TDF_ListIteratorOfLabelList itrl(itr.Current());
53 for (; itrl.More(); itrl.Next())
55 if (itr.GetStatus(itrl.Value()) == TFunction_ES_NotExecuted)
58 itr.SetStatus(L, TFunction_ES_Executing);
69 // Take current function,
70 // choose one and set its status to "executing".
72 for (; itr.More(); itr.Next())
74 L = getFreeFunction();
85 // Nothing to compute? Finish.
92 // Check a Tick attribute - a marker of skipped for execution functions.
93 // It is used only for visual presentation of skipped (not modified) functions.
94 Handle(TDataStd_Tick) tick;
95 if (L.FindAttribute(TDataStd_Tick::GetID(), tick))
96 L.ForgetAttribute(tick);
98 // Execute the function
99 Handle(TFunction_Driver) D = TFunction_IFunction(L).GetDriver(thread_index);
100 const bool must = D->MustExecute(log);
103 // Usage of mutex for execution of Open CASCADE code.
104 // It makes the execution more reliable...
105 if (!Handle(BaseDriver)::DownCast(D).IsNull())
106 Handle(BaseDriver)::DownCast(D)->SetMutex(pmutex);
108 // Execute the driver.
109 const int ret = D->Execute(log);
112 // Successfuly executed!
113 itr.SetStatus(L, TFunction_ES_Succeeded);
117 TDF_ListIteratorOfLabelList itrr(res);
118 for (; itrr.More(); itrr.Next())
120 log->SetImpacted(itrr.Value());
126 itr.SetStatus(L, TFunction_ES_Failed);
127 graph->setFinished();
131 else if (itr.GetStatus(L) == TFunction_ES_Executing)
133 itr.SetStatus(L, TFunction_ES_Succeeded);
134 TDataStd_Tick::Set(L);
139 graph->setFinished();