git-svn-id: svn://db.shs.com.ru/libs@357 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
if (POLICY CMP0020)
|
||||
cmake_policy(SET CMP0020 NEW)
|
||||
endif()
|
||||
if (POLICY CMP0011)
|
||||
cmake_policy(SET CMP0011 OLD)
|
||||
endif()
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 OLD)
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
endif()
|
||||
#if (POLICY CMP0017)
|
||||
#cmake_policy(SET CMP0017 OLD)
|
||||
#endif()
|
||||
if (POLICY CMP0053)
|
||||
cmake_policy(SET CMP0053 OLD)
|
||||
endif()
|
||||
if(POLICY CMP0020)
|
||||
cmake_policy(SET CMP0020 OLD)
|
||||
cmake_policy(SET CMP0053 NEW)
|
||||
endif()
|
||||
project(libs)
|
||||
include(SDKMacros.cmake)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(cd_utils)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(SET CMP0017 OLD)
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if (NOT LIBPROJECT)
|
||||
find_package(PIP REQUIRED)
|
||||
option(LIB "System install" 1)
|
||||
|
||||
@@ -91,13 +91,13 @@ CDCore::~CDCore() {
|
||||
|
||||
|
||||
void CDCore::k_write(PIIODevice * d) {
|
||||
k_.write(d, PIString());
|
||||
k_.write(d, CDType::cdK, PIString());
|
||||
}
|
||||
|
||||
|
||||
void CDCore::k_read(PIIODevice * d) {
|
||||
PIConfig conf(d, PIIODevice::ReadOnly);
|
||||
k_.read(&(conf.rootEntry()));
|
||||
k_.read(&(conf.rootEntry()), CDType::cdK);
|
||||
initRoot(k_);
|
||||
K_ChangedGlobal();
|
||||
/*PIVector<PIIODevice * > ds = connection.allDevices();
|
||||
|
||||
@@ -8,6 +8,8 @@ using namespace CDUtils;
|
||||
|
||||
//int cdtype_debug_cnt = 1;
|
||||
|
||||
const int cd_x_history_max_size = 4000;
|
||||
|
||||
CDType::CDType() {
|
||||
index_ = -1;
|
||||
value_d = 0.;
|
||||
@@ -49,9 +51,28 @@ CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v
|
||||
}
|
||||
|
||||
|
||||
CDType &CDType::operator =(double x) {
|
||||
value_d = x;
|
||||
if (mode_ == X_All_Avg) {
|
||||
avg_h << x;
|
||||
double val = 0;
|
||||
if (avg_h.size_s() >= avg_size) {
|
||||
for (int i=0; i<avg_h.size_s(); i++) {
|
||||
val += avg_h[i];
|
||||
}
|
||||
val /= avg_h.size();
|
||||
avg_h.pop_front();
|
||||
}
|
||||
if (history.size() < cd_x_history_max_size)
|
||||
history << val;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
PIString CDType::type() const {
|
||||
if (type_.trimmed().isEmpty()) return "f";
|
||||
// piCout << "type =" << type_.trimmed() << ";" << type_ << "#";
|
||||
// piCout << "type =" << type_.trimmed() << ";" << type_ << "#";
|
||||
return type_;
|
||||
}
|
||||
|
||||
@@ -206,7 +227,7 @@ PIVariantTypes::Enum CDType::parseEnumComment(PIString c) {
|
||||
|
||||
|
||||
int CDSection::count(bool recursive) const {
|
||||
int ret = k.size_s();
|
||||
int ret = cd.size_s();
|
||||
if (recursive) {
|
||||
PIMap<int, CDSection>::const_iterator i;
|
||||
for (i = s.begin(); i != s.end(); ++i)
|
||||
@@ -224,7 +245,7 @@ int CDSection::sectionsCount() const {
|
||||
PIStringList CDSection::index_names() const {
|
||||
PIStringList ret;
|
||||
PIMap<int, CDType>::const_iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
for (i = cd.begin(); i != cd.end(); ++i)
|
||||
ret << i->second.name();
|
||||
return ret;
|
||||
}
|
||||
@@ -275,13 +296,13 @@ CDType & CDSection::getByName(const PIString & name_) {
|
||||
int dv = 0;
|
||||
if (isd) dv = np.back().toInt();
|
||||
//piCout << np.back() << isd << dv;
|
||||
for (it = cs->k.begin(); it != cs->k.end(); ++it) {
|
||||
for (it = cs->cd.begin(); it != cs->cd.end(); ++it) {
|
||||
bool f = false;
|
||||
if (isd) f = (dv == it.key());
|
||||
else f = (np.back() == it.value().name());
|
||||
//piCout << "k..." << it.key() << it.value().name() << f;
|
||||
if (f)
|
||||
return cs->k[it.key()];
|
||||
return cs->cd[it.key()];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -297,13 +318,15 @@ CDType & CDSection::getByPath(const PIDeque<int> & path_) {
|
||||
}
|
||||
|
||||
|
||||
void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
void CDSection::write(PIIODevice * d, CDType::cdT cdt, const PIString & prefix) {
|
||||
if (!d) return;
|
||||
if (k.isEmpty() && s.isEmpty()) return;
|
||||
if (cd.isEmpty() && s.isEmpty()) return;
|
||||
// piCout << "[CDSection] write start";
|
||||
PIString l;
|
||||
if (prefix.isEmpty()) l = "[k]";
|
||||
else l = "[" + prefix + ".k]";
|
||||
PIStringList cdtl;
|
||||
cdtl << "null" << "k" << "x" << "c";
|
||||
if (prefix.isEmpty()) l = "[" + cdtl[cdt] + "]";
|
||||
else l = "[" + prefix + "." + cdtl[cdt] + "]";
|
||||
l += "\n";
|
||||
d->write(l.toUTF8());
|
||||
l = "name = " + name + " \n";
|
||||
@@ -311,20 +334,38 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
l = "alias = " + alias + " \n";
|
||||
d->write(l.toUTF8());
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i) {
|
||||
for (i = cd.begin(); i != cd.end(); ++i) {
|
||||
CDType & ck(i.value());
|
||||
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
if (!ck.enumValues().enum_list.isEmpty()) {
|
||||
l.clear(); l << ck.index() << ".ev = {";
|
||||
//PIVector<CDType::Enumerator> el = ck.enumValues();
|
||||
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
|
||||
l << e.value << " - " << e.name << ", ";
|
||||
l.cutRight(2);
|
||||
l << "} \n";
|
||||
if (ck.cd_type() != cdt) continue;
|
||||
switch (cdt) {
|
||||
case CDType::cdNull: break;
|
||||
case CDType::cdK:
|
||||
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
if (!ck.enumValues().enum_list.isEmpty()) {
|
||||
l.clear(); l << ck.index() << ".ev = {";
|
||||
//PIVector<CDType::Enumerator> el = ck.enumValues();
|
||||
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
|
||||
l << e.value << " - " << e.name << ", ";
|
||||
l.cutRight(2);
|
||||
l << "} \n";
|
||||
d->write(l.toUTF8());
|
||||
}
|
||||
break;
|
||||
case CDType::cdX:
|
||||
l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
l.clear(); l << ck.index() << ".mode = " << ck.xmode() << " #e (0 - cur, 1 - all_avg) " << "\n";
|
||||
d->write(l.toUTF8());
|
||||
l.clear(); l << ck.index() << ".avg = " << ck.avg() << " #n " << "\n";
|
||||
d->write(l.toUTF8());
|
||||
break;
|
||||
case CDType::cdC:
|
||||
l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!s.isEmpty()) {
|
||||
@@ -332,7 +373,7 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
else l = prefix + ".s";
|
||||
PIMap<int, CDSection>::iterator j;
|
||||
for (j = s.begin(); j != s.end(); ++j) {
|
||||
j.value().write(d, l + "." + PIString::fromNumber(j.key()));
|
||||
j.value().write(d, cdt, l + "." + PIString::fromNumber(j.key()));
|
||||
}
|
||||
}
|
||||
if (prefix.isEmpty()) {
|
||||
@@ -343,34 +384,51 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
}
|
||||
|
||||
|
||||
void CDSection::read(const void * ep) {
|
||||
void CDSection::read(const void * ep, CDType::cdT cdt) {
|
||||
// piCout << "[CDSection] read start";
|
||||
k.clear();
|
||||
PIStringList cdtl;
|
||||
cdtl << "null" << "k" << "x" << "c";
|
||||
cd.clear();
|
||||
s.clear();
|
||||
PIConfig::Entry & e(*(PIConfig::Entry*)ep);
|
||||
name = e.getValue("k.name").value();
|
||||
alias = e.getValue("k.alias").value();
|
||||
PIConfig::Entry & kl = e.getValue("k");
|
||||
name = e.getValue(cdtl[cdt] + ".name").value();
|
||||
alias = e.getValue(cdtl[cdt] + ".alias").value();
|
||||
PIConfig::Entry & kl = e.getValue(cdtl[cdt]);
|
||||
for (int i = 0; i < kl.childCount(); ++i) {
|
||||
const PIConfig::Entry * ke(kl.child(i));
|
||||
const PIConfig::Entry * e(kl.child(i));
|
||||
bool ok = false;
|
||||
int kid = ke->name().toInt(-1, &ok);
|
||||
int id = e->name().toInt(-1, &ok);
|
||||
// piCout << "[read]" << ke->name() << ke->value() << ok;
|
||||
// PIString n = ke->getValue("v").comment();
|
||||
// PIString t = n.takeLeft(1);
|
||||
if (ok) {
|
||||
CDType ck = CDType(kid, ke->getValue("v").comment(), ke->getValue("v").type(), ke->getValue("v").value(), ke->getValue("f").value(), ke->getValue("f").comment(), CDType::cdK);
|
||||
PIString ev = ke->getValue("ev", "");
|
||||
if (!ev.isEmpty())
|
||||
ck.enum_values = ck.parseEnumComment(ev);
|
||||
k[kid] = ck;
|
||||
CDType c;
|
||||
PIString ev;
|
||||
switch (cdt) {
|
||||
case CDType::cdNull: break;
|
||||
case CDType::cdK:
|
||||
c = CDType(id, e->getValue("v").comment(), e->getValue("v").type(), e->getValue("v").value(), e->getValue("f").value(), e->getValue("f").comment(), cdt);
|
||||
ev = e->getValue("ev", "");
|
||||
if (!ev.isEmpty())
|
||||
c.enum_values = c.parseEnumComment(ev);
|
||||
break;
|
||||
case CDType::cdX:
|
||||
c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cdt);
|
||||
c.setXMode((CDType::XMode)e->getValue("mode").value().toInt());
|
||||
c.setAvg((CDType::XMode)e->getValue("avg").value().toInt());
|
||||
break;
|
||||
case CDType::cdC:
|
||||
c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cdt);
|
||||
break;
|
||||
}
|
||||
cd[id] = c;
|
||||
}
|
||||
}
|
||||
PIConfig::Entry & sl = e.getValue("s");
|
||||
for (int i = 0; i < sl.childCount(); ++i) {
|
||||
const PIConfig::Entry * se(sl.child(i));
|
||||
int sid = se->name().toInt();
|
||||
s[sid].read(se);
|
||||
s[sid].read(se, cdt);
|
||||
}
|
||||
// piCout << "[CDSection] read end";
|
||||
}
|
||||
@@ -388,26 +446,26 @@ void CDSection::update(CDSection & v, UpdateModeFlags mode) {
|
||||
PIMap<PIString, PIString> prev_k_f_bn;
|
||||
PIMap<int, CDType>::iterator i;
|
||||
if (mode[SaveByIndex]) {
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
for (i = cd.begin(); i != cd.end(); ++i)
|
||||
prev_k_f_bi[i.key()] = i.value().formula();
|
||||
}
|
||||
if (mode[SaveByName]) {
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
for (i = cd.begin(); i != cd.end(); ++i)
|
||||
prev_k_f_bn[i.value().name_] = i.value().formula();
|
||||
}
|
||||
if (!mode[Merge])
|
||||
k.clear();
|
||||
for (i = v.k.begin(); i != v.k.end(); ++i) {
|
||||
cd.clear();
|
||||
for (i = v.cd.begin(); i != v.cd.end(); ++i) {
|
||||
int id = i.key();
|
||||
PIString n = i.value().name();
|
||||
k[id] = i.value();
|
||||
cd[id] = i.value();
|
||||
if (mode[SaveByIndex]) {
|
||||
if (prev_k_f_bi.contains(id))
|
||||
k[id].setFormula(prev_k_f_bi[id]);
|
||||
cd[id].setFormula(prev_k_f_bi[id]);
|
||||
}
|
||||
if (mode[SaveByName]) {
|
||||
if (prev_k_f_bn.contains(n))
|
||||
k[id].setFormula(prev_k_f_bn[n]);
|
||||
cd[id].setFormula(prev_k_f_bn[n]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,12 +537,12 @@ void CDSection::update(CDSection & v, UpdateModeFlags mode) {
|
||||
bool CDSection::isSameStructure(CDSection & v) {
|
||||
PIMap<PIString, int> k_ids;
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
for (i = cd.begin(); i != cd.end(); ++i)
|
||||
k_ids[i.value().name()] = i.key();
|
||||
for (i = v.k.begin(); i != v.k.end(); ++i) {
|
||||
for (i = v.cd.begin(); i != v.cd.end(); ++i) {
|
||||
if (!k_ids.contains(i.value().name())) continue;
|
||||
//piCout << i.key() << k[i.key()].name() << i.value().name();
|
||||
if (k[k_ids[i.value().name()]].index() != i.key())
|
||||
if (cd[k_ids[i.value().name()]].index() != i.key())
|
||||
return false;
|
||||
}
|
||||
PIMap<int, CDSection>::iterator j;
|
||||
@@ -499,7 +557,7 @@ bool CDSection::isSameStructure(CDSection & v) {
|
||||
|
||||
void CDSection::prepareCalculate() {
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i) {
|
||||
for (i = cd.begin(); i != cd.end(); ++i) {
|
||||
i.value().parent = this;
|
||||
i.value().calculated = false;
|
||||
}
|
||||
@@ -511,7 +569,7 @@ void CDSection::prepareCalculate() {
|
||||
|
||||
void CDSection::calculateRecursive(PIEvaluator * e) {
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
for (i = cd.begin(); i != cd.end(); ++i)
|
||||
i.value().calculate(e);
|
||||
PIMap<int, CDSection>::iterator j;
|
||||
for (j = s.begin(); j != s.end(); ++j)
|
||||
@@ -522,7 +580,7 @@ void CDSection::calculateRecursive(PIEvaluator * e) {
|
||||
void CDSection::makePath(PIDeque<int> p) {
|
||||
PIDeque<int> tp;
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i) {
|
||||
for (i = cd.begin(); i != cd.end(); ++i) {
|
||||
tp = p;
|
||||
tp << i.key();
|
||||
i.value().path_ = tp;
|
||||
@@ -540,7 +598,7 @@ void CDSection::makePath(PIDeque<int> p) {
|
||||
PIVector<CDType * > CDSection::children(bool recursive) const {
|
||||
PIVector<CDType * > ret;
|
||||
PIMap<int, CDType>::const_iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
for (i = cd.begin(); i != cd.end(); ++i)
|
||||
ret << const_cast<CDType * >(&(i.value()));
|
||||
if (!recursive) return ret;
|
||||
PIMap<int, CDSection>::const_iterator j;
|
||||
@@ -553,14 +611,9 @@ PIVector<CDType * > CDSection::children(bool recursive) const {
|
||||
PIVariantTypes::Enum CDSection::enumValues() const {
|
||||
PIVariantTypes::Enum ret;
|
||||
PIMap<int, CDType>::const_iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
for (i = cd.begin(); i != cd.end(); ++i)
|
||||
ret << PIVariantTypes::Enumerator(i.key(), i.value().name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
XType::XType(const CDType & cdt) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,12 @@ class CDType {
|
||||
friend class CDSection;
|
||||
public:
|
||||
enum cdT {cdNull, cdK, cdX, cdC};
|
||||
enum XMode {X_Current, X_All_Avg};
|
||||
|
||||
CDType();
|
||||
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
|
||||
|
||||
CDType & operator =(double x);
|
||||
int index() const {return index_;}
|
||||
PIString name() const {return name_;}
|
||||
PIString type() const;
|
||||
@@ -47,6 +51,10 @@ public:
|
||||
void setEnumValues(const PIVariantTypes::Enum & ev) {enum_values = ev;}
|
||||
const PIString & errorString() const {return error_;}
|
||||
PIDeque<int> path() const {return path_;}
|
||||
void setXMode(XMode mode) {mode_ = mode;}
|
||||
void setAvg(int avg) {avg_size = avg;}
|
||||
XMode xmode() const {return mode_;}
|
||||
int avg() const {return avg_size;}
|
||||
|
||||
protected:
|
||||
bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >());
|
||||
@@ -61,23 +69,8 @@ protected:
|
||||
double value_d;
|
||||
int value_i;
|
||||
bool value_b, calculated;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class XType : public CDType {
|
||||
friend class XSection;
|
||||
public:
|
||||
enum XMode {X_Current, X_All_Avg};
|
||||
|
||||
XType(const CDType & cdt = CDType());
|
||||
void setXMode(XMode mode) {mode_ = mode;}
|
||||
void setAvg(int avg) {avg_size = avg;}
|
||||
double currentValue() const {return last_val;}
|
||||
|
||||
private:
|
||||
PIVector<double> history;
|
||||
double last_val;
|
||||
PIVector <double> avg_h;
|
||||
int avg_size;
|
||||
XMode mode_;
|
||||
};
|
||||
@@ -92,10 +85,10 @@ public:
|
||||
|
||||
CDSection() {}
|
||||
|
||||
bool test(int v) {return k.value(v).toBool();}
|
||||
bool test(int v) {return cd.value(v).toBool();}
|
||||
// CDType & operator [](int v) {if (!k.contains(v)) k[v].index_ = v; return k[v];}
|
||||
CDType & operator [](int v) {return k[v];}
|
||||
const CDType operator [](int v) const {return k[v];}
|
||||
CDType & operator [](int v) {return cd[v];}
|
||||
const CDType operator [](int v) const {return cd[v];}
|
||||
CDType & operator [](const PIString & name_) {return getByName(name_);}
|
||||
const CDType operator [](const PIString & name_) const {return const_cast<CDSection*>(this)->getByName(name_);}
|
||||
CDType & operator [](const PIDeque<int> & path_) {return getByPath(path_);}
|
||||
@@ -103,10 +96,10 @@ public:
|
||||
CDSection & section(int v) {return s[v];}
|
||||
const CDSection section(int v) const {return s[v];}
|
||||
|
||||
bool isEmpty() const {return k.isEmpty() && s.isEmpty();}
|
||||
bool isEmpty() const {return cd.isEmpty() && s.isEmpty();}
|
||||
int count(bool recursive = true) const;
|
||||
int sectionsCount() const;
|
||||
PIVector<int> indexes() const {return k.keys();}
|
||||
PIVector<int> indexes() const {return cd.keys();}
|
||||
PIStringList index_names() const;
|
||||
void calculate();
|
||||
void makePath(PIDeque<int> p = PIDeque<int>());
|
||||
@@ -118,26 +111,26 @@ public:
|
||||
|
||||
protected:
|
||||
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) {
|
||||
k = k_;
|
||||
cd = k_;
|
||||
s = s_;
|
||||
}
|
||||
CDType & getByName(const PIString & name_);
|
||||
CDType & getByPath(const PIDeque<int> & path_);
|
||||
void write(PIIODevice * d, const PIString & prefix = PIString());
|
||||
void read(const void * ep);
|
||||
void write(PIIODevice * d, CDType::cdT cdt, const PIString & prefix = PIString());
|
||||
void read(const void * ep, CDType::cdT cdt);
|
||||
void update(CDSection & v, UpdateModeFlags mode = SaveByName);
|
||||
bool isSameStructure(CDSection & v);
|
||||
void prepareCalculate();
|
||||
void calculateRecursive(PIEvaluator * e);
|
||||
|
||||
PIMap<int, CDType> k;
|
||||
PIMap<int, CDType> cd;
|
||||
PIMap<int, CDSection> s;
|
||||
CDType null;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline PICout operator <<(PICout s, const CDUtils::CDType & v) {
|
||||
s.space();
|
||||
s.setControl(0, true);
|
||||
@@ -153,15 +146,4 @@ inline PICout operator <<(PICout s, const CDUtils::CDType & v) {
|
||||
}
|
||||
|
||||
|
||||
inline PICout operator <<(PICout s, const CDUtils::XType & v) {
|
||||
s.space();
|
||||
s.setControl(0, true);
|
||||
switch (v.cd_type()) {
|
||||
case CDUtils::CDType::cdX : s << "X["; break;
|
||||
default : s << "Null["; break;
|
||||
}
|
||||
s << v.name() << "(" << v.index() << ")] = " << v.currentValue();
|
||||
s.restoreControl();
|
||||
return s;
|
||||
}
|
||||
#endif // CDUTILS_TYPES_H
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
project(kx_utils)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if (NOT LIBPROJECT)
|
||||
find_package(PIP REQUIRED)
|
||||
endif ()
|
||||
|
||||
@@ -3,4 +3,4 @@ set ARCH=%~1
|
||||
set PATH=%SDK_MINGW_DIR%%ARCH%\bin;%SDK_QT4_DIR%%ARCH%\bin;%SDK_CMAKE_DIR%\bin
|
||||
if defined SDK_QT5_DIR set Qt5_DIR=%SDK_QT5_DIR%%ARCH%
|
||||
mkdir ..\libs_build_win%ARCH%
|
||||
cd ../libs_build_win%ARCH% && cmake_mgw -Wno-dev -DQGLVIEW=1 ../libs && make install -j8 && cd ../libs && pause
|
||||
cd ../libs_build_win%ARCH% && cmake_mgw -Wno-dev -DQGLVIEW=1 ../libs && make install -j4 && cd ../libs && pause
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(piqt)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(SET CMP0017 OLD)
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if(NOT LIBPROJECT)
|
||||
find_package(PIP REQUIRED)
|
||||
option(LIB "System install" 0)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(piqt_utils)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(SET CMP0017 OLD)
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if(LIBPROJECT)
|
||||
include(PIPMacros)
|
||||
include(SDKMacros)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
project(qad)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
#cmake_policy(SET CMP0017 OLD)
|
||||
#find_package(Qt4 REQUIRED)
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if (NOT LIBPROJECT)
|
||||
option(LIB "System install" 1)
|
||||
option(DEBUG "Build with -g3" 0)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if (POLICY CMP0011)
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
endif()
|
||||
if(NOT LIBPROJECT)
|
||||
include(QtWraps)
|
||||
endif()
|
||||
|
||||
@@ -80,7 +80,6 @@ macro(find_qt)
|
||||
find_package(Qt5 COMPONENTS LinguistTools UiPlugin Widgets ${_QCOMP} ${_QUIET})
|
||||
if (Qt5_FOUND)
|
||||
set(LOCAL_FOUND5 1)
|
||||
#cmake_policy(SET CMP0020 NEW)
|
||||
set(_Qt5Modules)
|
||||
foreach(m ${_QCOMP})
|
||||
if (${Qt5${m}_FOUND})
|
||||
@@ -357,7 +356,6 @@ macro(qt_add_executable _NAME)
|
||||
_qt_split_add_args(_PREF _ARGS ${ARGN})
|
||||
#message("${_PREF}")
|
||||
#message("${_ARGS}")
|
||||
#cmake_policy(SET CMP0020 NEW)
|
||||
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
||||
add_executable(${_TARGET} ${_PREF} ${_ARGS})
|
||||
set(_${_NAME}_is_qt 1)
|
||||
@@ -419,7 +417,6 @@ macro(qt_target_link_libraries _NAME)
|
||||
list(APPEND _ARGS ${_i})
|
||||
endif()
|
||||
endforeach()
|
||||
cmake_policy(SET CMP0020 OLD)
|
||||
target_link_libraries(${_TARGET} ${Qt${_v}_LIBRARIES} ${_ARGS})
|
||||
#message("link ${_TARGET}: ${Qt${_v}_LIBRARIES} ${_ARGS}")
|
||||
endif()
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Peri4 Paint
|
||||
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "emainwindow.h"
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
BlockBusItem * connectionBus(BlockItem * b0, BlockItem * b1) const;
|
||||
QList<BlockBusItem * > connectionBuses(BlockItem * b0, BlockItem * b1) const;
|
||||
bool connectPins(BlockItemPin * p0, BlockItemPin * p1);
|
||||
QList<BlockItem * > selectedBlocks() const;
|
||||
QList<QGraphicsItem * > selectedDecors() const;
|
||||
|
||||
void setTransform(const QTransform & matrix, bool combine = false);
|
||||
void centerOn(const QPointF & pos);
|
||||
@@ -136,8 +138,6 @@ protected:
|
||||
void simplifyBuses();
|
||||
void moveBuses(const QList<QGraphicsItem * > & items, QPointF dp);
|
||||
QList<BlockBusItem * > internalBuses(const QList<BlockItem * > & items);
|
||||
QList<BlockItem * > selectedBlocks() const;
|
||||
QList<QGraphicsItem * > selectedDecors() const;
|
||||
double _thumb() const {return _talpha;}
|
||||
QRectF _nav() const;
|
||||
void animateNav(QRectF d);
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Peri4 Paint
|
||||
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "qpievaluator.h"
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Peri4 Paint
|
||||
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QPIEVALUATOR_H
|
||||
#define QPIEVALUATOR_H
|
||||
|
||||
|
||||
@@ -25,8 +25,23 @@ public:
|
||||
bool isClearButtonVisible() const {return cw_visible;}
|
||||
bool isCleared() const;
|
||||
|
||||
virtual void stepBy(int steps);
|
||||
virtual void clear();
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
void setExpression(const QString & expr);
|
||||
void setValue(double val);
|
||||
void setDefaultText(const QString & t);
|
||||
void setClearButtonVisible(bool visible);
|
||||
|
||||
protected:
|
||||
QString text() const {return QAbstractSpinBox::text();}
|
||||
|
||||
virtual StepEnabled stepEnabled() const;
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void focusOutEvent(QFocusEvent *event);
|
||||
|
||||
QWidget * status;
|
||||
QWidget * cw;
|
||||
QPIEvaluator eval;
|
||||
@@ -52,26 +67,10 @@ private slots:
|
||||
void textChanged_(const QString & text);
|
||||
void setExpression_();
|
||||
|
||||
public slots:
|
||||
void setExpression(const QString & expr);
|
||||
void setValue(double val);
|
||||
void setDefaultText(const QString & t);
|
||||
void setClearButtonVisible(bool visible);
|
||||
|
||||
public:
|
||||
virtual void stepBy(int steps);
|
||||
virtual void clear();
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
protected:
|
||||
virtual StepEnabled stepEnabled() const;
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void focusOutEvent(QFocusEvent *event);
|
||||
|
||||
|
||||
signals:
|
||||
void valueChanged(double val);
|
||||
void cleared();
|
||||
|
||||
};
|
||||
|
||||
#endif // EVALSPINBOX_H
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Peri4 Paint
|
||||
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "session_manager.h"
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Peri4 Paint
|
||||
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SESSION_MANAGER_H
|
||||
#define SESSION_MANAGER_H
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(qcd_utils)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(SET CMP0017 OLD)
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if (NOT LIBPROJECT)
|
||||
find_package(PIP REQUIRED)
|
||||
option(LIB "System install" 0)
|
||||
@@ -21,10 +23,8 @@ qt_add_library(${PROJECT_NAME} SHARED out_CPP)
|
||||
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets cd_utils piqt)
|
||||
message(STATUS "Building ${PROJECT_NAME}")
|
||||
|
||||
add_subdirectory(pult)
|
||||
|
||||
if(LIBPROJECT)
|
||||
#sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
||||
sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
||||
else()
|
||||
if(LIB)
|
||||
if(WIN32)
|
||||
@@ -49,3 +49,5 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(pult)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
project(cd_pult)
|
||||
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts")
|
||||
find_qt(${QtVersions} Core Gui)
|
||||
find_qt(${QtVersions} Core Gui OpenGL)
|
||||
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
|
||||
qt_add_executable(${PROJECT_NAME} WIN32 out_CPP)
|
||||
qt_target_link_libraries(${PROJECT_NAME} qad_utils qad_widgets qad_graphic qcd_utils qad_application)
|
||||
|
||||
@@ -24,10 +24,10 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), ui(new Ui::CD
|
||||
session.addEntry(ribbon->tabWidget());
|
||||
session.load();
|
||||
reset();
|
||||
CONNECTU(&K, sended, this, KSended);
|
||||
CONNECTU(&K, received, this, KReceived);
|
||||
CONNECTU(&K, sendFailed, this, KSendFailed);
|
||||
CONNECTU(&K, receiveFailed, this, KReceiveFailed);
|
||||
connect(ui->viewK, SIGNAL(KSendSucceed()), this, SLOT(KSended()));
|
||||
connect(ui->viewK, SIGNAL(KReceiveSucceed()), this, SLOT(KReceived()));
|
||||
connect(ui->viewK, SIGNAL(KSendFailed()), this, SLOT(KSendFailed()));
|
||||
connect(ui->viewK, SIGNAL(KReceiveFailed()), this, SLOT(KReceiveFailed()));
|
||||
if (windowState() == Qt::WindowMinimized)
|
||||
setWindowState(Qt::WindowNoState);
|
||||
}
|
||||
@@ -44,23 +44,22 @@ void CDPultWindow::loadFile(const QString & fp) {
|
||||
|
||||
|
||||
void CDPultWindow::KReceived() {
|
||||
QMetaObject::invokeMethod(this, "addToLog", Qt::QueuedConnection, Q_ARG(LogIcon, OKIcon), Q_ARG(QString, "K received succesfull"));
|
||||
addToLog(OKIcon, "K received succesfull");
|
||||
}
|
||||
|
||||
|
||||
void CDPultWindow::KSended() {
|
||||
QMetaObject::invokeMethod(this, "addToLog", Qt::QueuedConnection, Q_ARG(LogIcon, OKIcon), Q_ARG(QString, "K sended succesfull"));
|
||||
addToLog(OKIcon, "K sended succesfull");
|
||||
}
|
||||
|
||||
|
||||
void CDPultWindow::KSendFailed() {
|
||||
QMetaObject::invokeMethod(this, "addToLog", Qt::QueuedConnection, Q_ARG(LogIcon, FailIcon), Q_ARG(QString, "K NOT sended"));
|
||||
addToLog(FailIcon, "K NOT sended");
|
||||
}
|
||||
|
||||
|
||||
void CDPultWindow::KReceiveFailed() {
|
||||
QMetaObject::invokeMethod(this, "addToLog", Qt::QueuedConnection, Q_ARG(LogIcon, FailIcon), Q_ARG(QString, "K NOT received"));
|
||||
//addToLog(FailIcon, "K NOT received");
|
||||
addToLog(FailIcon, "K NOT received");
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +76,7 @@ void CDPultWindow::closeEvent(QCloseEvent *e) {
|
||||
void CDPultWindow::reset(bool full) {
|
||||
setWindowTitle(QString("CD Pult"));
|
||||
ui->viewK->setKFile("");
|
||||
ui->viewK->clearK();
|
||||
// ui->viewK->clearK();
|
||||
file_name.clear();
|
||||
ui->viewK->refresh();
|
||||
setChanged(false);
|
||||
|
||||
@@ -10,11 +10,10 @@ namespace Ui {
|
||||
class CDPultWindow;
|
||||
}
|
||||
|
||||
class CDPultWindow : public EMainWindow, public PIObject
|
||||
class CDPultWindow : public EMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(LogIcon)
|
||||
PIOBJECT(CDPultWindow)
|
||||
public:
|
||||
enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon};
|
||||
|
||||
@@ -24,12 +23,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
EVENT_HANDLER(void, KSended);
|
||||
EVENT_HANDLER(void, KReceived);
|
||||
EVENT_HANDLER(void, KSendFailed);
|
||||
EVENT_HANDLER(void, KReceiveFailed);
|
||||
|
||||
void closeEvent(QCloseEvent * );
|
||||
void closeEvent(QCloseEvent *);
|
||||
void reset(bool full = false);
|
||||
bool load(const QString & path);
|
||||
bool save(const QString & path);
|
||||
@@ -41,6 +35,10 @@ private:
|
||||
QMap<LogIcon, QIcon> log_icons;
|
||||
|
||||
private slots:
|
||||
void KSended();
|
||||
void KReceived();
|
||||
void KSendFailed();
|
||||
void KReceiveFailed();
|
||||
void addToLog(LogIcon icon, const QString & msg);
|
||||
void on_actionSend_K_triggered();
|
||||
void on_actionReceive_K_triggered();
|
||||
|
||||
@@ -124,7 +124,7 @@ void CDKItemModel::rebuildModel() {
|
||||
void CDKItemModel::buildItem(CDKItem *it, CDSection & r) {
|
||||
//piCout << "build item" << r.name << r.alias;
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = r.k.begin(); i != r.k.end(); ++i) {
|
||||
for (i = r.cd.begin(); i != r.cd.end(); ++i) {
|
||||
it->childs << new CDKItem(i.key(), CDKItem::ItemCDType, it);
|
||||
}
|
||||
PIMap<int, CDSection>::iterator j;
|
||||
|
||||
@@ -29,7 +29,6 @@ CDKView::~CDKView() {
|
||||
|
||||
void CDKView::refresh() {
|
||||
if (!kmodel) {
|
||||
//K.reinitConnection(K.pultConfig());
|
||||
kmodel = new CDKItemModel();
|
||||
setModel(kmodel);
|
||||
setItemDelegateForColumn(4, new CDKDelegate());
|
||||
@@ -75,6 +74,7 @@ void CDKView::loadK() {
|
||||
|
||||
|
||||
void CDKView::clearK() {
|
||||
//piCout << "clearK";
|
||||
K.root() = CDSection();
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(qglview)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(SET CMP0017 OLD)
|
||||
if (POLICY CMP0017)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
if (IBPROJECT)
|
||||
include(SDKMacros)
|
||||
else()
|
||||
|
||||
Reference in New Issue
Block a user