-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectLoader.cpp
More file actions
89 lines (75 loc) · 2.29 KB
/
Copy pathSelectLoader.cpp
File metadata and controls
89 lines (75 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Created by user on 20.10.2020.
//
#include "SelectLoader.h"
INIT_PROPERTYS(TPropertyLoader)
void TSelectLoader::SetContainer(const TPtrContainer& value, const TString& path)
{
cont = value;
loadable = cont->Header()->LoadableData(path);
SetIsSelected(true);
beforeStep = cont->InfoDouble(iiStep);
if(beforeStep == 0)
cont->SetInfoDouble(iiStep, TUnits::Customs()->CurProfile()->DefaultStep());
}
TResult TSelectLoader::Select(const TPtrProgress& progress)
{//возвращаем список выбраных кривых
TVecData res;
for(const auto& it : loadable)
if(it->IsUsed()) res.push_back(it);
return cont->LoadData(res, progress);
}
TVecBool TSelectLoader::EditableVector()
{
TVecBool rez(loadable.size());
for(size_t i = 0; i < rez.size(); i++)
rez[i] = loadable[i]->IsUnitEditable();
return rez;
}
bool TSelectLoader::IsSelected() const
{//выбрана ли хоть одна кривая
for(const auto& v : loadable)
if(v->IsUsed()) return true;
return false;
}
void TSelectLoader::SetIsSelected(bool value)
{
for(const auto& v : loadable)
v->SetIsUsedNoCall(value);
}
bool TSelectLoader::IsStepChanged() const
{
return beforeStep != cont->InfoDouble(iiStep);
}
//----------------------------------------------------------------------------------------------------------------------
void TPropertyLoader::Init()
{
const TVecData& loadable = loader->loadable;
TPtrBaseContainer par = std::dynamic_pointer_cast<TBaseContainer>(shared_from_this());
for(size_t i = 0; i < loadable.size(); i++)
{
const TPtrData& l = loadable[i];
l->SetParent(par);
if(l->IsUnitEditable())
l->SetIndUnit(TUnits::Customs()->CurProfile()->FromCategory(l->Category()));//ставим значение по умолчанию
}
}
TPropertyLoader::TPropertyLoader(TSelectLoader *load):loader(load)
{
}
void TPropertyLoader::CallUsed(const TPtrData &value)
{
value->SetIsUsedNoCall(!value->IsUsed());
}
const TPtrData &TPropertyLoader::Loadable(int index) const
{
if(loader)
return loader->loadable[index];
return Single<TPtrData>();
}
size_t TPropertyLoader::CountLoadable() const
{
if(loader)
return loader->loadable.size();
return 0;
}