From 540b358a08c315c9f6e4f61e53bd50f844af8db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Tue, 13 Feb 2018 13:59:11 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@357 a8b55f48-bf90-11e4-a774-851b48703e85 --- CMakeLists.txt | 16 ++-- cd_utils/CMakeLists.txt | 4 +- cd_utils/cdutils_core.cpp | 4 +- cd_utils/cdutils_types.cpp | 163 +++++++++++++++++++++----------- cd_utils/cdutils_types.h | 56 ++++------- kx_utils/CMakeLists.txt | 3 + make_libs.bat | 2 +- piqt/CMakeLists.txt | 4 +- piqt_utils/CMakeLists.txt | 4 +- qad/CMakeLists.txt | 5 +- qad/FindQAD.cmake | 6 ++ qad/QtWraps.cmake | 3 - qad/application/emainwindow.cpp | 26 +---- qad/blockview/blockview.h | 14 +-- qad/utils/qpievaluator.cpp | 18 ---- qad/utils/qpievaluator.h | 18 ---- qad/widgets/evalspinbox.h | 39 ++++---- qad/widgets/session_manager.cpp | 18 ---- qad/widgets/session_manager.h | 22 +---- qcd_utils/CMakeLists.txt | 10 +- qcd_utils/pult/CMakeLists.txt | 2 +- qcd_utils/pult/cdpultwindow.cpp | 19 ++-- qcd_utils/pult/cdpultwindow.h | 14 ++- qcd_utils/qcd_kmodel.cpp | 2 +- qcd_utils/qcd_kview.cpp | 2 +- qglview/CMakeLists.txt | 4 +- 26 files changed, 218 insertions(+), 260 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ca707c..df75eb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cd_utils/CMakeLists.txt b/cd_utils/CMakeLists.txt index 7c0240a..9104848 100644 --- a/cd_utils/CMakeLists.txt +++ b/cd_utils/CMakeLists.txt @@ -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) diff --git a/cd_utils/cdutils_core.cpp b/cd_utils/cdutils_core.cpp index 13db1bd..2d0f299 100644 --- a/cd_utils/cdutils_core.cpp +++ b/cd_utils/cdutils_core.cpp @@ -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 ds = connection.allDevices(); diff --git a/cd_utils/cdutils_types.cpp b/cd_utils/cdutils_types.cpp index 76f1dfe..c7a3e10 100644 --- a/cd_utils/cdutils_types.cpp +++ b/cd_utils/cdutils_types.cpp @@ -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::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::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 & 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::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 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 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::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 prev_k_f_bn; PIMap::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 k_ids; PIMap::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::iterator j; @@ -499,7 +557,7 @@ bool CDSection::isSameStructure(CDSection & v) { void CDSection::prepareCalculate() { PIMap::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::iterator i; - for (i = k.begin(); i != k.end(); ++i) + for (i = cd.begin(); i != cd.end(); ++i) i.value().calculate(e); PIMap::iterator j; for (j = s.begin(); j != s.end(); ++j) @@ -522,7 +580,7 @@ void CDSection::calculateRecursive(PIEvaluator * e) { void CDSection::makePath(PIDeque p) { PIDeque tp; PIMap::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 p) { PIVector CDSection::children(bool recursive) const { PIVector ret; PIMap::const_iterator i; - for (i = k.begin(); i != k.end(); ++i) + for (i = cd.begin(); i != cd.end(); ++i) ret << const_cast(&(i.value())); if (!recursive) return ret; PIMap::const_iterator j; @@ -553,14 +611,9 @@ PIVector CDSection::children(bool recursive) const { PIVariantTypes::Enum CDSection::enumValues() const { PIVariantTypes::Enum ret; PIMap::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) { - -} - diff --git a/cd_utils/cdutils_types.h b/cd_utils/cdutils_types.h index 7c31a5a..aeb720d 100644 --- a/cd_utils/cdutils_types.h +++ b/cd_utils/cdutils_types.h @@ -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 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 stack = PIVector()); @@ -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 history; - double last_val; + PIVector 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(this)->getByName(name_);} CDType & operator [](const PIDeque & 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 indexes() const {return k.keys();} + PIVector indexes() const {return cd.keys();} PIStringList index_names() const; void calculate(); void makePath(PIDeque p = PIDeque()); @@ -118,26 +111,26 @@ public: protected: CDSection(PIMap k_, PIMap s_) { - k = k_; + cd = k_; s = s_; } CDType & getByName(const PIString & name_); CDType & getByPath(const PIDeque & 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 k; + PIMap cd; PIMap 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 diff --git a/kx_utils/CMakeLists.txt b/kx_utils/CMakeLists.txt index a796b39..96bb27e 100644 --- a/kx_utils/CMakeLists.txt +++ b/kx_utils/CMakeLists.txt @@ -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 () diff --git a/make_libs.bat b/make_libs.bat index 3880234..dd57e1a 100644 --- a/make_libs.bat +++ b/make_libs.bat @@ -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 diff --git a/piqt/CMakeLists.txt b/piqt/CMakeLists.txt index 58c4c55..cef8d8a 100644 --- a/piqt/CMakeLists.txt +++ b/piqt/CMakeLists.txt @@ -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) diff --git a/piqt_utils/CMakeLists.txt b/piqt_utils/CMakeLists.txt index 49c58d4..5983043 100644 --- a/piqt_utils/CMakeLists.txt +++ b/piqt_utils/CMakeLists.txt @@ -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) diff --git a/qad/CMakeLists.txt b/qad/CMakeLists.txt index 86924d4..32685fb 100644 --- a/qad/CMakeLists.txt +++ b/qad/CMakeLists.txt @@ -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) diff --git a/qad/FindQAD.cmake b/qad/FindQAD.cmake index 32afe8c..86b646e 100644 --- a/qad/FindQAD.cmake +++ b/qad/FindQAD.cmake @@ -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() diff --git a/qad/QtWraps.cmake b/qad/QtWraps.cmake index 8e749a8..dc94d22 100644 --- a/qad/QtWraps.cmake +++ b/qad/QtWraps.cmake @@ -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() diff --git a/qad/application/emainwindow.cpp b/qad/application/emainwindow.cpp index 79dd409..76eb206 100644 --- a/qad/application/emainwindow.cpp +++ b/qad/application/emainwindow.cpp @@ -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 . -*/ - #include "emainwindow.h" #include #include @@ -239,7 +221,7 @@ void EMainWindow::initMenus() { action_hide_all_tools.disconnect(); action_show_all_docks.disconnect(); action_hide_all_docks.disconnect(); - + QList tools = findChildren(); foreach (QToolBar * i, tools) { if (i->property("ribbon").toBool()) continue; @@ -247,7 +229,7 @@ void EMainWindow::initMenus() { connect(&action_show_all_tools, SIGNAL(triggered(bool)), i, SLOT(show())); connect(&action_hide_all_tools, SIGNAL(triggered(bool)), i, SLOT(hide())); } - + QList docks = findChildren(); foreach (QDockWidget * i, docks) { if (i->property("ribbon").toBool()) continue; @@ -255,7 +237,7 @@ void EMainWindow::initMenus() { connect(&action_show_all_docks, SIGNAL(triggered(bool)), i, SLOT(show())); connect(&action_hide_all_docks, SIGNAL(triggered(bool)), i, SLOT(hide())); } - + QList actions = findChildren(); foreach (QAction * i, actions) i->setIconVisibleInMenu(true); @@ -311,7 +293,7 @@ void EMainWindow::changedDock() { docks_tabs << dock; } } - + foreach (QDockWidget * d, docks) { if (d->titleBarWidget() == 0) continue; QWidget * ctb = d->titleBarWidget(); diff --git a/qad/blockview/blockview.h b/qad/blockview/blockview.h index a3cbeaf..c14a602 100644 --- a/qad/blockview/blockview.h +++ b/qad/blockview/blockview.h @@ -49,7 +49,7 @@ class BlockView: public QGraphicsView Q_PROPERTY(bool traceConsiderBuses READ isTraceConsiderBuses WRITE setTraceConsiderBuses) Q_PROPERTY(bool pinMulticonnect READ isPinMulticonnectEnabled WRITE setPinMulticonnectEnabled) Q_PROPERTY(bool miniMap READ isMiniMapEnabled WRITE setMiniMapEnabled) - + Q_PROPERTY(double _thumb READ _thumb WRITE _setThumb DESIGNABLE false SCRIPTABLE false) Q_PROPERTY(QRectF _nav READ _nav WRITE _setNav DESIGNABLE false SCRIPTABLE false) @@ -63,7 +63,7 @@ public: SingleSelection, MultiSelection }; - + QPen gridPen() const {return grid_pen;} bool isGridVisible() const {return grid_visible;} bool isSnapToGrid() const {return grid_snap;} @@ -79,7 +79,7 @@ public: double gridPointsWidth() const {return grid_points;} SelectionMode selectionMode() const {return smode;} void setSelectionMode(SelectionMode mode) {smode = mode;} - + void addItems(QList items) {foreach (QGraphicsItem * i, items) addItem(i);} QList buses() const; QList wrongConnectedBuses() const; @@ -88,6 +88,8 @@ public: BlockBusItem * connectionBus(BlockItem * b0, BlockItem * b1) const; QList connectionBuses(BlockItem * b0, BlockItem * b1) const; bool connectPins(BlockItemPin * p0, BlockItemPin * p1); + QList selectedBlocks() const; + QList selectedDecors() const; void setTransform(const QTransform & matrix, bool combine = false); void centerOn(const QPointF & pos); @@ -136,15 +138,13 @@ protected: void simplifyBuses(); void moveBuses(const QList & items, QPointF dp); QList internalBuses(const QList & items); - QList selectedBlocks() const; - QList selectedDecors() const; double _thumb() const {return _talpha;} QRectF _nav() const; void animateNav(QRectF d); void scrollFromThumb(); void deleteCopyTemp(); void emitActionEvent(BlockItemBase::Action action, QList items); - + virtual void loadBus(BlockBusItem * bus) {} virtual void copyBlocks(QList items, QPointF offset) {} virtual void copyBuses(QList items, QPointF offset) {} @@ -207,7 +207,7 @@ public slots: void setTraceConsiderBuses(bool on) {m_trace_with_buses = on;} void setPinMulticonnectEnabled(bool on) {m_pin_mc = on;} void setMiniMapEnabled(bool on) {minimap = on;} - + void zoom(double factor); void zoomIn() {zoom(1.2);} void zoomOut() {zoom(1. / 1.2);} diff --git a/qad/utils/qpievaluator.cpp b/qad/utils/qpievaluator.cpp index a3dbead..d03fd77 100644 --- a/qad/utils/qpievaluator.cpp +++ b/qad/utils/qpievaluator.cpp @@ -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 . -*/ - #include "qpievaluator.h" diff --git a/qad/utils/qpievaluator.h b/qad/utils/qpievaluator.h index b38c32f..d8213ad 100644 --- a/qad/utils/qpievaluator.h +++ b/qad/utils/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 . -*/ - #ifndef QPIEVALUATOR_H #define QPIEVALUATOR_H diff --git a/qad/widgets/evalspinbox.h b/qad/widgets/evalspinbox.h index a78b092..c6b856f 100644 --- a/qad/widgets/evalspinbox.h +++ b/qad/widgets/evalspinbox.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; @@ -38,7 +53,7 @@ protected: QImage clear_im; QString dt; bool cw_visible; - + private: bool eventFilter(QObject * o, QEvent * e); void resizeEvent(QResizeEvent * ); @@ -46,32 +61,16 @@ private: void statusPaintEvent(); void cwPaintEvent(); void resizeIcons(); - + private slots: void clearMouseRelease(QMouseEvent * e); 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 diff --git a/qad/widgets/session_manager.cpp b/qad/widgets/session_manager.cpp index 2ecf047..e165421 100644 --- a/qad/widgets/session_manager.cpp +++ b/qad/widgets/session_manager.cpp @@ -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 . -*/ - #include "session_manager.h" diff --git a/qad/widgets/session_manager.h b/qad/widgets/session_manager.h index 3dccbff..7d8a15c 100644 --- a/qad/widgets/session_manager.h +++ b/qad/widgets/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 . -*/ - #ifndef SESSION_MANAGER_H #define SESSION_MANAGER_H @@ -39,7 +21,7 @@ public: ~SessionManager() {;} inline void setFile(const QString & file) {file_ = file;} - + inline void addEntry(QMainWindow * e) {mwindows.push_back(QPair(e->objectName(), e));} inline void addEntry(QCheckBox * e) {checks.push_back(QPair(e->objectName(), e));} inline void addEntry(QLineEdit * e) {lines.push_back(QPair(e->objectName(), e));} @@ -50,7 +32,7 @@ public: inline void addEntry(QTabWidget * e) {tabs.push_back(QPair(e->objectName(), e));} inline void addEntry(QAction * e) {actions.push_back(QPair(e->objectName(), e));} inline void addMainWidget(QWidget * e) {widgets.push_back(QPair(e->objectName(), e));} - + inline void addEntry(const QString & name, QMainWindow * e) {mwindows.push_back(QPair(name, e));} inline void addEntry(const QString & name, QCheckBox * e) {checks.push_back(QPair(name, e));} inline void addEntry(const QString & name, QLineEdit * e) {lines.push_back(QPair(name, e));} diff --git a/qcd_utils/CMakeLists.txt b/qcd_utils/CMakeLists.txt index 93a43ac..a1ed0d0 100644 --- a/qcd_utils/CMakeLists.txt +++ b/qcd_utils/CMakeLists.txt @@ -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) + diff --git a/qcd_utils/pult/CMakeLists.txt b/qcd_utils/pult/CMakeLists.txt index b753d46..ce88833 100644 --- a/qcd_utils/pult/CMakeLists.txt +++ b/qcd_utils/pult/CMakeLists.txt @@ -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) diff --git a/qcd_utils/pult/cdpultwindow.cpp b/qcd_utils/pult/cdpultwindow.cpp index 6574dd5..46539c2 100644 --- a/qcd_utils/pult/cdpultwindow.cpp +++ b/qcd_utils/pult/cdpultwindow.cpp @@ -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); diff --git a/qcd_utils/pult/cdpultwindow.h b/qcd_utils/pult/cdpultwindow.h index 2887d15..7a6c248 100644 --- a/qcd_utils/pult/cdpultwindow.h +++ b/qcd_utils/pult/cdpultwindow.h @@ -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 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(); diff --git a/qcd_utils/qcd_kmodel.cpp b/qcd_utils/qcd_kmodel.cpp index 4af3ec4..36e8c75 100644 --- a/qcd_utils/qcd_kmodel.cpp +++ b/qcd_utils/qcd_kmodel.cpp @@ -124,7 +124,7 @@ void CDKItemModel::rebuildModel() { void CDKItemModel::buildItem(CDKItem *it, CDSection & r) { //piCout << "build item" << r.name << r.alias; PIMap::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::iterator j; diff --git a/qcd_utils/qcd_kview.cpp b/qcd_utils/qcd_kview.cpp index df9ad9a..38a2fd9 100644 --- a/qcd_utils/qcd_kview.cpp +++ b/qcd_utils/qcd_kview.cpp @@ -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(); } diff --git a/qglview/CMakeLists.txt b/qglview/CMakeLists.txt index b213d6c..5c70cbd 100644 --- a/qglview/CMakeLists.txt +++ b/qglview/CMakeLists.txt @@ -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()