2 #include "graphwidget.h"
4 #include <TFunction_Function.hxx>
5 #include <TFunction_IFunction.hxx>
6 #include <TFunction_Driver.hxx>
7 #include <TFunction_GraphNode.hxx>
9 #include <TDataStd_Tick.hxx>
10 #include <TDF_ListIteratorOfLabelList.hxx>
12 FThread::FThread(QObject* parent):QThread(parent),thread_index(0)
22 void FThread::setIterator(const TFunction_Iterator& theItr)
27 void FThread::setLogbook(const Handle(TFunction_Logbook)& theLog)
32 void FThread::setGraph(GraphWidget* theGraph)
34 this->graph = theGraph;
37 void FThread::setThreadIndex(const int theIndex)
39 this->thread_index = theIndex;
42 // Returns any free (not executed yet) function
43 TDF_Label FThread::getFreeFunction()
46 TDF_ListIteratorOfLabelList itrl(itr.Current());
47 for (; itrl.More(); itrl.Next())
49 if (itr.GetStatus(itrl.Value()) == TFunction_ES_NotExecuted)
52 itr.SetStatus(L, TFunction_ES_Executing);
63 // Take current function,
64 // choose one and set its status to "executing".
66 for (; itr.More(); itr.Next())
68 L = getFreeFunction();
79 // Nothing to compute? Finish.
86 // Check a Tick attribute - a marker of skipped for execution functions.
87 // It is used only for visual presentation of skipped (not modified) functions.
88 Handle(TDataStd_Tick) tick;
89 if (L.FindAttribute(TDataStd_Tick::GetID(), tick))
90 L.ForgetAttribute(tick);
92 // Execute the function
93 Handle(TFunction_Driver) D = TFunction_IFunction(L).GetDriver(thread_index);
94 const bool must = D->MustExecute(log);
97 // Usage of mutex for execution of Open CASCADE code is the most stupid thing!!!
98 // But it makes the execution more reliable...
99 const int ret = D->Execute(log);
102 // Successfully executed!
103 itr.SetStatus(L, TFunction_ES_Succeeded);
107 TDF_ListIteratorOfLabelList itrr(res);
108 for (; itrr.More(); itrr.Next())
110 log->SetImpacted(itrr.Value());
116 itr.SetStatus(L, TFunction_ES_Failed);
117 graph->setFinished();
121 else if (itr.GetStatus(L) == TFunction_ES_Executing)
123 itr.SetStatus(L, TFunction_ES_Succeeded);
124 TDataStd_Tick::Set(L);
129 graph->setFinished();