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& itr)
27 void FThread::setLogbook(const Handle(TFunction_Logbook)& log)
32 void FThread::setGraph(GraphWidget* graph)
37 void FThread::setThreadIndex(const int thread_index)
39 this->thread_index = thread_index;
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();
75 // Nothing to compute? Finish.
82 // Check a Tick attribute - a marker of skipped for execution functions.
83 // It is used only for visual presentation of skipped (not modified) functions.
84 Handle(TDataStd_Tick) tick;
85 if (L.FindAttribute(TDataStd_Tick::GetID(), tick))
86 L.ForgetAttribute(tick);
88 // Execute the function
89 Handle(TFunction_Driver) D = TFunction_IFunction(L).GetDriver(thread_index);
90 const bool must = D->MustExecute(log);
93 // Usage of mutex for execution of Open CASCADE code is the most stupid thing!!!
94 // But it makes the execution more reliable...
95 const int ret = D->Execute(log);
98 // Successfuly executed!
99 itr.SetStatus(L, TFunction_ES_Succeeded);
103 TDF_ListIteratorOfLabelList itrr(res);
104 for (; itrr.More(); itrr.Next())
106 log->SetImpacted(itrr.Value());
112 itr.SetStatus(L, TFunction_ES_Failed);
113 graph->setFinished();
117 else if (itr.GetStatus(L) == TFunction_ES_Executing)
119 itr.SetStatus(L, TFunction_ES_Succeeded);
120 TDataStd_Tick::Set(L);
125 graph->setFinished();