git-svn-id: svn://db.shs.com.ru/libs@357 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2018-02-13 13:59:11 +00:00
parent a9a05517a9
commit 540b358a08
26 changed files with 218 additions and 260 deletions

View File

@@ -1,15 +1,15 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
if (POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()
if (POLICY CMP0011) if (POLICY CMP0011)
cmake_policy(SET CMP0011 OLD) cmake_policy(SET CMP0011 NEW)
endif()
if (POLICY CMP0017)
cmake_policy(SET CMP0017 OLD)
endif() endif()
#if (POLICY CMP0017)
#cmake_policy(SET CMP0017 OLD)
#endif()
if (POLICY CMP0053) if (POLICY CMP0053)
cmake_policy(SET CMP0053 OLD) cmake_policy(SET CMP0053 NEW)
endif()
if(POLICY CMP0020)
cmake_policy(SET CMP0020 OLD)
endif() endif()
project(libs) project(libs)
include(SDKMacros.cmake) include(SDKMacros.cmake)

View File

@@ -1,6 +1,8 @@
project(cd_utils) project(cd_utils)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0017 OLD) if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif()
if (NOT LIBPROJECT) if (NOT LIBPROJECT)
find_package(PIP REQUIRED) find_package(PIP REQUIRED)
option(LIB "System install" 1) option(LIB "System install" 1)

View File

@@ -91,13 +91,13 @@ CDCore::~CDCore() {
void CDCore::k_write(PIIODevice * d) { void CDCore::k_write(PIIODevice * d) {
k_.write(d, PIString()); k_.write(d, CDType::cdK, PIString());
} }
void CDCore::k_read(PIIODevice * d) { void CDCore::k_read(PIIODevice * d) {
PIConfig conf(d, PIIODevice::ReadOnly); PIConfig conf(d, PIIODevice::ReadOnly);
k_.read(&(conf.rootEntry())); k_.read(&(conf.rootEntry()), CDType::cdK);
initRoot(k_); initRoot(k_);
K_ChangedGlobal(); K_ChangedGlobal();
/*PIVector<PIIODevice * > ds = connection.allDevices(); /*PIVector<PIIODevice * > ds = connection.allDevices();

View File

@@ -8,6 +8,8 @@ using namespace CDUtils;
//int cdtype_debug_cnt = 1; //int cdtype_debug_cnt = 1;
const int cd_x_history_max_size = 4000;
CDType::CDType() { CDType::CDType() {
index_ = -1; index_ = -1;
value_d = 0.; 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 { PIString CDType::type() const {
if (type_.trimmed().isEmpty()) return "f"; if (type_.trimmed().isEmpty()) return "f";
// piCout << "type =" << type_.trimmed() << ";" << type_ << "#"; // piCout << "type =" << type_.trimmed() << ";" << type_ << "#";
return type_; return type_;
} }
@@ -206,7 +227,7 @@ PIVariantTypes::Enum CDType::parseEnumComment(PIString c) {
int CDSection::count(bool recursive) const { int CDSection::count(bool recursive) const {
int ret = k.size_s(); int ret = cd.size_s();
if (recursive) { if (recursive) {
PIMap<int, CDSection>::const_iterator i; PIMap<int, CDSection>::const_iterator i;
for (i = s.begin(); i != s.end(); ++i) for (i = s.begin(); i != s.end(); ++i)
@@ -224,7 +245,7 @@ int CDSection::sectionsCount() const {
PIStringList CDSection::index_names() const { PIStringList CDSection::index_names() const {
PIStringList ret; PIStringList ret;
PIMap<int, CDType>::const_iterator i; 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(); ret << i->second.name();
return ret; return ret;
} }
@@ -275,13 +296,13 @@ CDType & CDSection::getByName(const PIString & name_) {
int dv = 0; int dv = 0;
if (isd) dv = np.back().toInt(); if (isd) dv = np.back().toInt();
//piCout << np.back() << isd << dv; //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; bool f = false;
if (isd) f = (dv == it.key()); if (isd) f = (dv == it.key());
else f = (np.back() == it.value().name()); else f = (np.back() == it.value().name());
//piCout << "k..." << it.key() << it.value().name() << f; //piCout << "k..." << it.key() << it.value().name() << f;
if (f) if (f)
return cs->k[it.key()]; return cs->cd[it.key()];
} }
return null; 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 (!d) return;
if (k.isEmpty() && s.isEmpty()) return; if (cd.isEmpty() && s.isEmpty()) return;
// piCout << "[CDSection] write start"; // piCout << "[CDSection] write start";
PIString l; PIString l;
if (prefix.isEmpty()) l = "[k]"; PIStringList cdtl;
else l = "[" + prefix + ".k]"; cdtl << "null" << "k" << "x" << "c";
if (prefix.isEmpty()) l = "[" + cdtl[cdt] + "]";
else l = "[" + prefix + "." + cdtl[cdt] + "]";
l += "\n"; l += "\n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l = "name = " + name + " \n"; l = "name = " + name + " \n";
@@ -311,8 +334,12 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
l = "alias = " + alias + " \n"; l = "alias = " + alias + " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
PIMap<int, CDType>::iterator i; 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()); CDType & ck(i.value());
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"; l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n"; l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
@@ -326,13 +353,27 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
l << "} \n"; l << "} \n";
d->write(l.toUTF8()); 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()) { if (!s.isEmpty()) {
if (prefix.isEmpty()) l = "s"; if (prefix.isEmpty()) l = "s";
else l = prefix + ".s"; else l = prefix + ".s";
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++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()) { 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"; // piCout << "[CDSection] read start";
k.clear(); PIStringList cdtl;
cdtl << "null" << "k" << "x" << "c";
cd.clear();
s.clear(); s.clear();
PIConfig::Entry & e(*(PIConfig::Entry*)ep); PIConfig::Entry & e(*(PIConfig::Entry*)ep);
name = e.getValue("k.name").value(); name = e.getValue(cdtl[cdt] + ".name").value();
alias = e.getValue("k.alias").value(); alias = e.getValue(cdtl[cdt] + ".alias").value();
PIConfig::Entry & kl = e.getValue("k"); PIConfig::Entry & kl = e.getValue(cdtl[cdt]);
for (int i = 0; i < kl.childCount(); ++i) { 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; bool ok = false;
int kid = ke->name().toInt(-1, &ok); int id = e->name().toInt(-1, &ok);
// piCout << "[read]" << ke->name() << ke->value() << ok; // piCout << "[read]" << ke->name() << ke->value() << ok;
// PIString n = ke->getValue("v").comment(); // PIString n = ke->getValue("v").comment();
// PIString t = n.takeLeft(1); // PIString t = n.takeLeft(1);
if (ok) { 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); CDType c;
PIString ev = ke->getValue("ev", ""); 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()) if (!ev.isEmpty())
ck.enum_values = ck.parseEnumComment(ev); c.enum_values = c.parseEnumComment(ev);
k[kid] = ck; 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"); PIConfig::Entry & sl = e.getValue("s");
for (int i = 0; i < sl.childCount(); ++i) { for (int i = 0; i < sl.childCount(); ++i) {
const PIConfig::Entry * se(sl.child(i)); const PIConfig::Entry * se(sl.child(i));
int sid = se->name().toInt(); int sid = se->name().toInt();
s[sid].read(se); s[sid].read(se, cdt);
} }
// piCout << "[CDSection] read end"; // piCout << "[CDSection] read end";
} }
@@ -388,26 +446,26 @@ void CDSection::update(CDSection & v, UpdateModeFlags mode) {
PIMap<PIString, PIString> prev_k_f_bn; PIMap<PIString, PIString> prev_k_f_bn;
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
if (mode[SaveByIndex]) { 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(); prev_k_f_bi[i.key()] = i.value().formula();
} }
if (mode[SaveByName]) { 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(); prev_k_f_bn[i.value().name_] = i.value().formula();
} }
if (!mode[Merge]) if (!mode[Merge])
k.clear(); cd.clear();
for (i = v.k.begin(); i != v.k.end(); ++i) { for (i = v.cd.begin(); i != v.cd.end(); ++i) {
int id = i.key(); int id = i.key();
PIString n = i.value().name(); PIString n = i.value().name();
k[id] = i.value(); cd[id] = i.value();
if (mode[SaveByIndex]) { if (mode[SaveByIndex]) {
if (prev_k_f_bi.contains(id)) 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 (mode[SaveByName]) {
if (prev_k_f_bn.contains(n)) 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) { bool CDSection::isSameStructure(CDSection & v) {
PIMap<PIString, int> k_ids; PIMap<PIString, int> k_ids;
PIMap<int, CDType>::iterator i; 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(); 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; if (!k_ids.contains(i.value().name())) continue;
//piCout << i.key() << k[i.key()].name() << i.value().name(); //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; return false;
} }
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
@@ -499,7 +557,7 @@ bool CDSection::isSameStructure(CDSection & v) {
void CDSection::prepareCalculate() { void CDSection::prepareCalculate() {
PIMap<int, CDType>::iterator i; 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().parent = this;
i.value().calculated = false; i.value().calculated = false;
} }
@@ -511,7 +569,7 @@ void CDSection::prepareCalculate() {
void CDSection::calculateRecursive(PIEvaluator * e) { void CDSection::calculateRecursive(PIEvaluator * e) {
PIMap<int, CDType>::iterator i; 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); i.value().calculate(e);
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++j) for (j = s.begin(); j != s.end(); ++j)
@@ -522,7 +580,7 @@ void CDSection::calculateRecursive(PIEvaluator * e) {
void CDSection::makePath(PIDeque<int> p) { void CDSection::makePath(PIDeque<int> p) {
PIDeque<int> tp; PIDeque<int> tp;
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
for (i = k.begin(); i != k.end(); ++i) { for (i = cd.begin(); i != cd.end(); ++i) {
tp = p; tp = p;
tp << i.key(); tp << i.key();
i.value().path_ = tp; i.value().path_ = tp;
@@ -540,7 +598,7 @@ void CDSection::makePath(PIDeque<int> p) {
PIVector<CDType * > CDSection::children(bool recursive) const { PIVector<CDType * > CDSection::children(bool recursive) const {
PIVector<CDType * > ret; PIVector<CDType * > ret;
PIMap<int, CDType>::const_iterator i; 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())); ret << const_cast<CDType * >(&(i.value()));
if (!recursive) return ret; if (!recursive) return ret;
PIMap<int, CDSection>::const_iterator j; PIMap<int, CDSection>::const_iterator j;
@@ -553,14 +611,9 @@ PIVector<CDType * > CDSection::children(bool recursive) const {
PIVariantTypes::Enum CDSection::enumValues() const { PIVariantTypes::Enum CDSection::enumValues() const {
PIVariantTypes::Enum ret; PIVariantTypes::Enum ret;
PIMap<int, CDType>::const_iterator i; 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()); ret << PIVariantTypes::Enumerator(i.key(), i.value().name());
return ret; return ret;
} }
XType::XType(const CDType & cdt) {
}

View File

@@ -27,8 +27,12 @@ class CDType {
friend class CDSection; friend class CDSection;
public: public:
enum cdT {cdNull, cdK, cdX, cdC}; enum cdT {cdNull, cdK, cdX, cdC};
enum XMode {X_Current, X_All_Avg};
CDType(); CDType();
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t); 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_;} int index() const {return index_;}
PIString name() const {return name_;} PIString name() const {return name_;}
PIString type() const; PIString type() const;
@@ -47,6 +51,10 @@ public:
void setEnumValues(const PIVariantTypes::Enum & ev) {enum_values = ev;} void setEnumValues(const PIVariantTypes::Enum & ev) {enum_values = ev;}
const PIString & errorString() const {return error_;} const PIString & errorString() const {return error_;}
PIDeque<int> path() const {return path_;} 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: protected:
bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >()); bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >());
@@ -61,23 +69,8 @@ protected:
double value_d; double value_d;
int value_i; int value_i;
bool value_b, calculated; 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; PIVector<double> history;
double last_val; PIVector <double> avg_h;
int avg_size; int avg_size;
XMode mode_; XMode mode_;
}; };
@@ -92,10 +85,10 @@ public:
CDSection() {} 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) {if (!k.contains(v)) k[v].index_ = v; return k[v];}
CDType & operator [](int v) {return k[v];} CDType & operator [](int v) {return cd[v];}
const CDType operator [](int v) const {return k[v];} const CDType operator [](int v) const {return cd[v];}
CDType & operator [](const PIString & name_) {return getByName(name_);} CDType & operator [](const PIString & name_) {return getByName(name_);}
const CDType operator [](const PIString & name_) const {return const_cast<CDSection*>(this)->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_);} CDType & operator [](const PIDeque<int> & path_) {return getByPath(path_);}
@@ -103,10 +96,10 @@ public:
CDSection & section(int v) {return s[v];} CDSection & section(int v) {return s[v];}
const CDSection section(int v) const {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 count(bool recursive = true) const;
int sectionsCount() const; int sectionsCount() const;
PIVector<int> indexes() const {return k.keys();} PIVector<int> indexes() const {return cd.keys();}
PIStringList index_names() const; PIStringList index_names() const;
void calculate(); void calculate();
void makePath(PIDeque<int> p = PIDeque<int>()); void makePath(PIDeque<int> p = PIDeque<int>());
@@ -118,26 +111,26 @@ public:
protected: protected:
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) { CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) {
k = k_; cd = k_;
s = s_; s = s_;
} }
CDType & getByName(const PIString & name_); CDType & getByName(const PIString & name_);
CDType & getByPath(const PIDeque<int> & path_); CDType & getByPath(const PIDeque<int> & path_);
void write(PIIODevice * d, const PIString & prefix = PIString()); void write(PIIODevice * d, CDType::cdT cdt, const PIString & prefix = PIString());
void read(const void * ep); void read(const void * ep, CDType::cdT cdt);
void update(CDSection & v, UpdateModeFlags mode = SaveByName); void update(CDSection & v, UpdateModeFlags mode = SaveByName);
bool isSameStructure(CDSection & v); bool isSameStructure(CDSection & v);
void prepareCalculate(); void prepareCalculate();
void calculateRecursive(PIEvaluator * e); void calculateRecursive(PIEvaluator * e);
PIMap<int, CDType> k; PIMap<int, CDType> cd;
PIMap<int, CDSection> s; PIMap<int, CDSection> s;
CDType null; CDType null;
}; };
} }
inline PICout operator <<(PICout s, const CDUtils::CDType & v) { inline PICout operator <<(PICout s, const CDUtils::CDType & v) {
s.space(); s.space();
s.setControl(0, true); 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 #endif // CDUTILS_TYPES_H

View File

@@ -1,5 +1,8 @@
project(kx_utils) project(kx_utils)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif()
if (NOT LIBPROJECT) if (NOT LIBPROJECT)
find_package(PIP REQUIRED) find_package(PIP REQUIRED)
endif () endif ()

View File

@@ -3,4 +3,4 @@ set ARCH=%~1
set PATH=%SDK_MINGW_DIR%%ARCH%\bin;%SDK_QT4_DIR%%ARCH%\bin;%SDK_CMAKE_DIR%\bin 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% if defined SDK_QT5_DIR set Qt5_DIR=%SDK_QT5_DIR%%ARCH%
mkdir ..\libs_build_win%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

View File

@@ -1,6 +1,8 @@
project(piqt) project(piqt)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0017 OLD) if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif()
if(NOT LIBPROJECT) if(NOT LIBPROJECT)
find_package(PIP REQUIRED) find_package(PIP REQUIRED)
option(LIB "System install" 0) option(LIB "System install" 0)

View File

@@ -1,6 +1,8 @@
project(piqt_utils) project(piqt_utils)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0017 OLD) if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif()
if(LIBPROJECT) if(LIBPROJECT)
include(PIPMacros) include(PIPMacros)
include(SDKMacros) include(SDKMacros)

View File

@@ -1,7 +1,8 @@
project(qad) project(qad)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
#cmake_policy(SET CMP0017 OLD) if (POLICY CMP0017)
#find_package(Qt4 REQUIRED) cmake_policy(SET CMP0017 NEW)
endif()
if (NOT LIBPROJECT) if (NOT LIBPROJECT)
option(LIB "System install" 1) option(LIB "System install" 1)
option(DEBUG "Build with -g3" 0) option(DEBUG "Build with -g3" 0)

View File

@@ -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) if(NOT LIBPROJECT)
include(QtWraps) include(QtWraps)
endif() endif()

View File

@@ -80,7 +80,6 @@ macro(find_qt)
find_package(Qt5 COMPONENTS LinguistTools UiPlugin Widgets ${_QCOMP} ${_QUIET}) find_package(Qt5 COMPONENTS LinguistTools UiPlugin Widgets ${_QCOMP} ${_QUIET})
if (Qt5_FOUND) if (Qt5_FOUND)
set(LOCAL_FOUND5 1) set(LOCAL_FOUND5 1)
#cmake_policy(SET CMP0020 NEW)
set(_Qt5Modules) set(_Qt5Modules)
foreach(m ${_QCOMP}) foreach(m ${_QCOMP})
if (${Qt5${m}_FOUND}) if (${Qt5${m}_FOUND})
@@ -357,7 +356,6 @@ macro(qt_add_executable _NAME)
_qt_split_add_args(_PREF _ARGS ${ARGN}) _qt_split_add_args(_PREF _ARGS ${ARGN})
#message("${_PREF}") #message("${_PREF}")
#message("${_ARGS}") #message("${_ARGS}")
#cmake_policy(SET CMP0020 NEW)
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}}) set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
add_executable(${_TARGET} ${_PREF} ${_ARGS}) add_executable(${_TARGET} ${_PREF} ${_ARGS})
set(_${_NAME}_is_qt 1) set(_${_NAME}_is_qt 1)
@@ -419,7 +417,6 @@ macro(qt_target_link_libraries _NAME)
list(APPEND _ARGS ${_i}) list(APPEND _ARGS ${_i})
endif() endif()
endforeach() endforeach()
cmake_policy(SET CMP0020 OLD)
target_link_libraries(${_TARGET} ${Qt${_v}_LIBRARIES} ${_ARGS}) target_link_libraries(${_TARGET} ${Qt${_v}_LIBRARIES} ${_ARGS})
#message("link ${_TARGET}: ${Qt${_v}_LIBRARIES} ${_ARGS}") #message("link ${_TARGET}: ${Qt${_v}_LIBRARIES} ${_ARGS}")
endif() endif()

View File

@@ -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 "emainwindow.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>

View File

@@ -88,6 +88,8 @@ public:
BlockBusItem * connectionBus(BlockItem * b0, BlockItem * b1) const; BlockBusItem * connectionBus(BlockItem * b0, BlockItem * b1) const;
QList<BlockBusItem * > connectionBuses(BlockItem * b0, BlockItem * b1) const; QList<BlockBusItem * > connectionBuses(BlockItem * b0, BlockItem * b1) const;
bool connectPins(BlockItemPin * p0, BlockItemPin * p1); bool connectPins(BlockItemPin * p0, BlockItemPin * p1);
QList<BlockItem * > selectedBlocks() const;
QList<QGraphicsItem * > selectedDecors() const;
void setTransform(const QTransform & matrix, bool combine = false); void setTransform(const QTransform & matrix, bool combine = false);
void centerOn(const QPointF & pos); void centerOn(const QPointF & pos);
@@ -136,8 +138,6 @@ protected:
void simplifyBuses(); void simplifyBuses();
void moveBuses(const QList<QGraphicsItem * > & items, QPointF dp); void moveBuses(const QList<QGraphicsItem * > & items, QPointF dp);
QList<BlockBusItem * > internalBuses(const QList<BlockItem * > & items); QList<BlockBusItem * > internalBuses(const QList<BlockItem * > & items);
QList<BlockItem * > selectedBlocks() const;
QList<QGraphicsItem * > selectedDecors() const;
double _thumb() const {return _talpha;} double _thumb() const {return _talpha;}
QRectF _nav() const; QRectF _nav() const;
void animateNav(QRectF d); void animateNav(QRectF d);

View File

@@ -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" #include "qpievaluator.h"

View File

@@ -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 #ifndef QPIEVALUATOR_H
#define QPIEVALUATOR_H #define QPIEVALUATOR_H

View File

@@ -25,8 +25,23 @@ public:
bool isClearButtonVisible() const {return cw_visible;} bool isClearButtonVisible() const {return cw_visible;}
bool isCleared() const; 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: protected:
QString text() const {return QAbstractSpinBox::text();}
virtual StepEnabled stepEnabled() const;
virtual void focusInEvent(QFocusEvent *event);
virtual void focusOutEvent(QFocusEvent *event);
QWidget * status; QWidget * status;
QWidget * cw; QWidget * cw;
QPIEvaluator eval; QPIEvaluator eval;
@@ -52,26 +67,10 @@ private slots:
void textChanged_(const QString & text); void textChanged_(const QString & text);
void setExpression_(); 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: signals:
void valueChanged(double val); void valueChanged(double val);
void cleared(); void cleared();
}; };
#endif // EVALSPINBOX_H #endif // EVALSPINBOX_H

View File

@@ -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" #include "session_manager.h"

View File

@@ -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 #ifndef SESSION_MANAGER_H
#define SESSION_MANAGER_H #define SESSION_MANAGER_H

View File

@@ -1,6 +1,8 @@
project(qcd_utils) project(qcd_utils)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0017 OLD) if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif()
if (NOT LIBPROJECT) if (NOT LIBPROJECT)
find_package(PIP REQUIRED) find_package(PIP REQUIRED)
option(LIB "System install" 0) 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) qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets cd_utils piqt)
message(STATUS "Building ${PROJECT_NAME}") message(STATUS "Building ${PROJECT_NAME}")
add_subdirectory(pult)
if(LIBPROJECT) if(LIBPROJECT)
#sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}") sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
else() else()
if(LIB) if(LIB)
if(WIN32) if(WIN32)
@@ -49,3 +49,5 @@ else()
endif() endif()
endif() endif()
add_subdirectory(pult)

View File

@@ -1,6 +1,6 @@
project(cd_pult) project(cd_pult)
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts") 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_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
qt_add_executable(${PROJECT_NAME} WIN32 out_CPP) qt_add_executable(${PROJECT_NAME} WIN32 out_CPP)
qt_target_link_libraries(${PROJECT_NAME} qad_utils qad_widgets qad_graphic qcd_utils qad_application) qt_target_link_libraries(${PROJECT_NAME} qad_utils qad_widgets qad_graphic qcd_utils qad_application)

View File

@@ -24,10 +24,10 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), ui(new Ui::CD
session.addEntry(ribbon->tabWidget()); session.addEntry(ribbon->tabWidget());
session.load(); session.load();
reset(); reset();
CONNECTU(&K, sended, this, KSended); connect(ui->viewK, SIGNAL(KSendSucceed()), this, SLOT(KSended()));
CONNECTU(&K, received, this, KReceived); connect(ui->viewK, SIGNAL(KReceiveSucceed()), this, SLOT(KReceived()));
CONNECTU(&K, sendFailed, this, KSendFailed); connect(ui->viewK, SIGNAL(KSendFailed()), this, SLOT(KSendFailed()));
CONNECTU(&K, receiveFailed, this, KReceiveFailed); connect(ui->viewK, SIGNAL(KReceiveFailed()), this, SLOT(KReceiveFailed()));
if (windowState() == Qt::WindowMinimized) if (windowState() == Qt::WindowMinimized)
setWindowState(Qt::WindowNoState); setWindowState(Qt::WindowNoState);
} }
@@ -44,23 +44,22 @@ void CDPultWindow::loadFile(const QString & fp) {
void CDPultWindow::KReceived() { 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() { 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() { 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() { 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) { void CDPultWindow::reset(bool full) {
setWindowTitle(QString("CD Pult")); setWindowTitle(QString("CD Pult"));
ui->viewK->setKFile(""); ui->viewK->setKFile("");
ui->viewK->clearK(); // ui->viewK->clearK();
file_name.clear(); file_name.clear();
ui->viewK->refresh(); ui->viewK->refresh();
setChanged(false); setChanged(false);

View File

@@ -10,11 +10,10 @@ namespace Ui {
class CDPultWindow; class CDPultWindow;
} }
class CDPultWindow : public EMainWindow, public PIObject class CDPultWindow : public EMainWindow
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(LogIcon) Q_ENUMS(LogIcon)
PIOBJECT(CDPultWindow)
public: public:
enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon}; enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon};
@@ -24,12 +23,7 @@ public:
private: private:
EVENT_HANDLER(void, KSended); void closeEvent(QCloseEvent *);
EVENT_HANDLER(void, KReceived);
EVENT_HANDLER(void, KSendFailed);
EVENT_HANDLER(void, KReceiveFailed);
void closeEvent(QCloseEvent * );
void reset(bool full = false); void reset(bool full = false);
bool load(const QString & path); bool load(const QString & path);
bool save(const QString & path); bool save(const QString & path);
@@ -41,6 +35,10 @@ private:
QMap<LogIcon, QIcon> log_icons; QMap<LogIcon, QIcon> log_icons;
private slots: private slots:
void KSended();
void KReceived();
void KSendFailed();
void KReceiveFailed();
void addToLog(LogIcon icon, const QString & msg); void addToLog(LogIcon icon, const QString & msg);
void on_actionSend_K_triggered(); void on_actionSend_K_triggered();
void on_actionReceive_K_triggered(); void on_actionReceive_K_triggered();

View File

@@ -124,7 +124,7 @@ void CDKItemModel::rebuildModel() {
void CDKItemModel::buildItem(CDKItem *it, CDSection & r) { void CDKItemModel::buildItem(CDKItem *it, CDSection & r) {
//piCout << "build item" << r.name << r.alias; //piCout << "build item" << r.name << r.alias;
PIMap<int, CDType>::iterator i; 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); it->childs << new CDKItem(i.key(), CDKItem::ItemCDType, it);
} }
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;

View File

@@ -29,7 +29,6 @@ CDKView::~CDKView() {
void CDKView::refresh() { void CDKView::refresh() {
if (!kmodel) { if (!kmodel) {
//K.reinitConnection(K.pultConfig());
kmodel = new CDKItemModel(); kmodel = new CDKItemModel();
setModel(kmodel); setModel(kmodel);
setItemDelegateForColumn(4, new CDKDelegate()); setItemDelegateForColumn(4, new CDKDelegate());
@@ -75,6 +74,7 @@ void CDKView::loadK() {
void CDKView::clearK() { void CDKView::clearK() {
//piCout << "clearK";
K.root() = CDSection(); K.root() = CDSection();
refresh(); refresh();
} }

View File

@@ -1,6 +1,8 @@
project(qglview) project(qglview)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0017 OLD) if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif()
if (IBPROJECT) if (IBPROJECT)
include(SDKMacros) include(SDKMacros)
else() else()