git-svn-id: svn://db.shs.com.ru/libs@159 a8b55f48-bf90-11e4-a774-851b48703e85
@@ -21,7 +21,7 @@ if (WIN32)
|
|||||||
set(PIP_DLL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pip")
|
set(PIP_DLL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pip")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIST_LIBS pip qad_widgets qad_utils qad_application qad_blockview qad_graphic qad_sql_table piqt cd_utils kx_utils piqt_utils touch_widgets qglview)
|
set(LIST_LIBS pip qad_widgets qad_utils qad_application qad_blockview qad_graphic qad_sql_table piqt cd_utils qcd_utils kx_utils piqt_utils touch_widgets qglview)
|
||||||
foreach(L ${LIST_LIBS})
|
foreach(L ${LIST_LIBS})
|
||||||
add_subdirectory(${L})
|
add_subdirectory(${L})
|
||||||
include_directories(${L})
|
include_directories(${L})
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ if (MINGW)
|
|||||||
endif()
|
endif()
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
|
||||||
set(PULT_NAME "cd_pult")
|
set(PULT_NAME "cd_pult")
|
||||||
option(PULT "Build ${PULT_NAME}" 1)
|
|
||||||
option(LIB "System install" 1)
|
option(LIB "System install" 1)
|
||||||
option(DEBUG "Build with -g3" 0)
|
option(DEBUG "Build with -g3" 0)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
|
||||||
@@ -29,24 +28,6 @@ target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
|
|||||||
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
|
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
|
||||||
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
|
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
|
||||||
|
|
||||||
if (NOT DEFINED ENV{QNX_HOST})
|
|
||||||
if (PULT)
|
|
||||||
add_subdirectory(pult)
|
|
||||||
# find_package(Qt4 REQUIRED)
|
|
||||||
# find_package(OpenGL REQUIRED)
|
|
||||||
# include_directories(${QT_INCLUDES})
|
|
||||||
# set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp")
|
|
||||||
# set(MOCS "kx_pult.h")
|
|
||||||
# file(GLOB UIS "*.ui")
|
|
||||||
# file(GLOB RES "*.qrc")
|
|
||||||
# qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
|
||||||
# qt4_wrap_ui(CUIS ${UIS})
|
|
||||||
# qt4_add_resources(RESS ${RES})
|
|
||||||
# add_executable(${KX_PULT_NAME} WIN32 ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS})
|
|
||||||
# set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic qad_utils qad_widgets)
|
|
||||||
# target_link_libraries(${KX_PULT_NAME} ${LIBS} ${PROJECT_NAME})
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
if (LIB)
|
if (LIB)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||||
@@ -63,8 +44,3 @@ else ()
|
|||||||
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||||
message(STATUS "Install to local \"bin\"")
|
message(STATUS "Install to local \"bin\"")
|
||||||
endif ()
|
endif ()
|
||||||
#if (NOT DEFINED ENV{QNX_HOST})
|
|
||||||
# if (KX_PULT)
|
|
||||||
# install(TARGETS ${KX_PULT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
|
||||||
# endif ()
|
|
||||||
#endif ()
|
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ __Core_Initializer__::~__Core_Initializer__() {
|
|||||||
|
|
||||||
CDCore::CDCore() {
|
CDCore::CDCore() {
|
||||||
setName("CDCore");
|
setName("CDCore");
|
||||||
CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
|
|
||||||
PIString s(app_config);
|
|
||||||
connection.configureFromString(&s);
|
|
||||||
datatr.setPacketSize(960);
|
datatr.setPacketSize(960);
|
||||||
connection.start();
|
CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
|
||||||
|
/*PIString s(app_config);
|
||||||
|
connection.configureFromString(&s);
|
||||||
|
connection.start();*/
|
||||||
k_.name = "__root__";
|
k_.name = "__root__";
|
||||||
k_.alias = "root";
|
k_.alias = "root";
|
||||||
|
|
||||||
@@ -99,6 +99,8 @@ void CDCore::k_write(PIIODevice * d) {
|
|||||||
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()));
|
||||||
|
k_.makePath();
|
||||||
|
K_ChangedGlobal();
|
||||||
PIVector<PIIODevice * > ds = connection.allDevices();
|
PIVector<PIIODevice * > ds = connection.allDevices();
|
||||||
// piForeach(PIIODevice * d, ds) {
|
// piForeach(PIIODevice * d, ds) {
|
||||||
// if (d)
|
// if (d)
|
||||||
@@ -109,6 +111,8 @@ void CDCore::k_read(PIIODevice * d) {
|
|||||||
|
|
||||||
void CDCore::k_parse(PIIODevice * d) {
|
void CDCore::k_parse(PIIODevice * d) {
|
||||||
k_ = CDParser::parse(d, CDType::cdK);
|
k_ = CDParser::parse(d, CDType::cdK);
|
||||||
|
k_.makePath();
|
||||||
|
K_ChangedGlobal();
|
||||||
k_.name = "__root__";
|
k_.name = "__root__";
|
||||||
k_.alias = "root";
|
k_.alias = "root";
|
||||||
}
|
}
|
||||||
@@ -126,15 +130,28 @@ void CDCore::k_update(PIIODevice * d) {
|
|||||||
uk.update(k_, kn);
|
uk.update(k_, kn);
|
||||||
//piCout << k_.count() << uk.count();
|
//piCout << k_.count() << uk.count();
|
||||||
k_ = uk;
|
k_ = uk;
|
||||||
|
k_.makePath();
|
||||||
|
K_ChangedGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDCore::k_calculate() {
|
void CDCore::k_calculate() {
|
||||||
k_.calculate();
|
k_.calculate();
|
||||||
|
K_ChangedGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDCore::reinitConnection(const PIString & configuration) {
|
void CDCore::initApp() {
|
||||||
|
init(appConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDCore::initPult() {
|
||||||
|
init(pultConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDCore::init(const PIString & configuration) {
|
||||||
PIString c = configuration;
|
PIString c = configuration;
|
||||||
connection.stop();
|
connection.stop();
|
||||||
connection.removeAllDevices();
|
connection.removeAllDevices();
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class CDCore: public PIObject
|
|||||||
{
|
{
|
||||||
PIOBJECT(CDUtils::CDCore)
|
PIOBJECT(CDUtils::CDCore)
|
||||||
friend class __Core_Initializer__;
|
friend class __Core_Initializer__;
|
||||||
|
friend class CDSection;
|
||||||
|
friend class KInterface;
|
||||||
public:
|
public:
|
||||||
static CDCore * instance() {return __Core_Initializer__::__instance__;}
|
static CDCore * instance() {return __Core_Initializer__::__instance__;}
|
||||||
|
|
||||||
@@ -32,23 +34,27 @@ public:
|
|||||||
EVENT(K_SendFail)
|
EVENT(K_SendFail)
|
||||||
EVENT(K_Received)
|
EVENT(K_Received)
|
||||||
EVENT(K_ReceiveFail)
|
EVENT(K_ReceiveFail)
|
||||||
|
EVENT(K_ChangedGlobal)
|
||||||
EVENT1(K_KeepNamesRequest, bool*, kn)
|
EVENT1(K_KeepNamesRequest, bool*, kn)
|
||||||
EVENT_HANDLER(void, K_Send);
|
EVENT_HANDLER(void, K_Send);
|
||||||
EVENT_HANDLER(void, K_Request);
|
EVENT_HANDLER(void, K_Request);
|
||||||
|
|
||||||
CDSection k_;
|
|
||||||
|
|
||||||
void k_write(PIIODevice * d);
|
void k_write(PIIODevice * d);
|
||||||
void k_read(PIIODevice * d);
|
void k_read(PIIODevice * d);
|
||||||
void k_parse(PIIODevice * d);
|
void k_parse(PIIODevice * d);
|
||||||
void k_update(PIIODevice * d);
|
void k_update(PIIODevice * d);
|
||||||
void k_calculate();
|
void k_calculate();
|
||||||
PIString pultConfig() {return PIString(pult_config);}
|
void initApp();
|
||||||
PIString appConfig() {return PIString(app_config);}
|
void initPult();
|
||||||
void reinitConnection(const PIString & configuration);
|
void init(const PIString & configuration);
|
||||||
void startPing();
|
void startPing();
|
||||||
bool inProgress() {return sendt.isRunning();}
|
bool inProgress() {return sendt.isRunning();}
|
||||||
|
|
||||||
|
CDSection & k() {return k_;}
|
||||||
|
|
||||||
|
static PIString pultConfig() {return PIString(pult_config);}
|
||||||
|
static PIString appConfig() {return PIString(app_config);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CDCore();
|
CDCore();
|
||||||
~CDCore();
|
~CDCore();
|
||||||
@@ -65,6 +71,7 @@ private:
|
|||||||
PIByteArray send_data;
|
PIByteArray send_data;
|
||||||
PIThread sendt;
|
PIThread sendt;
|
||||||
PITimer x_timer;
|
PITimer x_timer;
|
||||||
|
CDSection k_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ bool KInterface::configure(const PIString & config, const PIString & sect) {
|
|||||||
|
|
||||||
|
|
||||||
void KInterface::reinitConnection(const PIString &configuration) {
|
void KInterface::reinitConnection(const PIString &configuration) {
|
||||||
core->reinitConnection(configuration);
|
core->init(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -231,6 +231,14 @@ CDType & CDSection::operator [](const PIString & name_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDType & CDSection::operator [](const PIDeque<int> & path_) {
|
||||||
|
if (path_.isEmpty()) return null;
|
||||||
|
CDSection & s(*this);
|
||||||
|
for (int i = 0; i < path_.size_s() - 1; ++i)
|
||||||
|
s = s.section(path_[i]);
|
||||||
|
return s[path_.back()];
|
||||||
|
}
|
||||||
|
|
||||||
int CDSection::count(bool recursive) const {
|
int CDSection::count(bool recursive) const {
|
||||||
int ret = k.size_s();
|
int ret = k.size_s();
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
@@ -333,18 +341,14 @@ void CDSection::read(const void * ep) {
|
|||||||
|
|
||||||
void CDSection::update(CDSection & v, bool keep_names) {
|
void CDSection::update(CDSection & v, bool keep_names) {
|
||||||
// piCout << "[CDSection] update start";
|
// piCout << "[CDSection] update start";
|
||||||
PIMap<PIString, int> vk_ids;
|
PIMap<PIString, PIString> prev_k_f;
|
||||||
PISet<int> used;
|
PISet<int> used;
|
||||||
PIMap<int, CDType>::iterator i;
|
PIMap<int, CDType>::iterator i;
|
||||||
for (i = v.k.begin(); i != v.k.end(); ++i)
|
|
||||||
vk_ids[i.value().name_] = i.value().index_;
|
|
||||||
for (i = k.begin(); i != k.end(); ++i) {
|
|
||||||
if (keep_names) {
|
if (keep_names) {
|
||||||
if (vk_ids.contains(i.value().name_)) {
|
for (i = k.begin(); i != k.end(); ++i)
|
||||||
k[i.key()] = v.k[vk_ids[i.value().name_]];
|
prev_k_f[i.value().name_] = i.value().formula();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (i = k.begin(); i != k.end(); ++i) {
|
||||||
if (v.k.contains(i.key())) {
|
if (v.k.contains(i.key())) {
|
||||||
PIString f = k[i.key()].formula_;
|
PIString f = k[i.key()].formula_;
|
||||||
CDType & cdt = v.k[i.key()];
|
CDType & cdt = v.k[i.key()];
|
||||||
@@ -352,10 +356,17 @@ void CDSection::update(CDSection & v, bool keep_names) {
|
|||||||
k[i.key()] = cdt;
|
k[i.key()] = cdt;
|
||||||
used << i.key();
|
used << i.key();
|
||||||
}
|
}
|
||||||
|
if (keep_names) {
|
||||||
|
CDType & ck(k[i.key()]);
|
||||||
|
if (prev_k_f.contains(ck.name_))
|
||||||
|
ck.setFormula(prev_k_f[ck.name_]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (i = v.k.begin(); i != v.k.end(); ++i) {
|
for (i = v.k.begin(); i != v.k.end(); ++i) {
|
||||||
if (!used.contains(i.key()))
|
if (!used.contains(i.key()))
|
||||||
k[i.key()] = i.value();
|
k[i.key()] = i.value();
|
||||||
|
CDType & ck(k[i.key()]);
|
||||||
|
ck.setFormula(prev_k_f.value(ck.name_));
|
||||||
}
|
}
|
||||||
used.clear();
|
used.clear();
|
||||||
PIMap<int, CDSection>::iterator j;
|
PIMap<int, CDSection>::iterator j;
|
||||||
@@ -415,3 +426,33 @@ 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) {
|
||||||
|
tp = p;
|
||||||
|
tp << i.key();
|
||||||
|
i.value().path_ = tp;
|
||||||
|
}
|
||||||
|
PIMap<int, CDSection>::iterator j;
|
||||||
|
for (j = s.begin(); j != s.end(); ++j) {
|
||||||
|
tp = p;
|
||||||
|
tp << j.key();
|
||||||
|
j.value().makePath(tp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVector<CDType * > CDSection::children(bool recursive) const {
|
||||||
|
PIVector<CDType * > ret;
|
||||||
|
PIMap<int, CDType>::const_iterator i;
|
||||||
|
for (i = k.begin(); i != k.end(); ++i)
|
||||||
|
ret << const_cast<CDType * >(&(i.value()));
|
||||||
|
if (!recursive) return ret;
|
||||||
|
PIMap<int, CDSection>::const_iterator j;
|
||||||
|
for (j = s.begin(); j != s.end(); ++j)
|
||||||
|
ret << j.value().children(true);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public:
|
|||||||
operator double() const {return value_d;}
|
operator double() const {return value_d;}
|
||||||
const PIStringList & enumValues() const {return enum_values;}
|
const PIStringList & enumValues() const {return enum_values;}
|
||||||
const PIString & errorString() const {return error_;}
|
const PIString & errorString() const {return error_;}
|
||||||
|
PIDeque<int> path() const {return path_;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >());
|
bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >());
|
||||||
@@ -44,6 +45,7 @@ protected:
|
|||||||
PIString value_s, formula_, comment_, error_;
|
PIString value_s, formula_, comment_, error_;
|
||||||
PIStringList enum_values;
|
PIStringList enum_values;
|
||||||
CDSection * parent;
|
CDSection * parent;
|
||||||
|
PIDeque<int> path_;
|
||||||
double value_d;
|
double value_d;
|
||||||
int value_i;
|
int value_i;
|
||||||
bool value_b, calculated;
|
bool value_b, calculated;
|
||||||
@@ -66,6 +68,8 @@ public:
|
|||||||
const CDType operator [](int v) const {return k[v];}
|
const CDType operator [](int v) const {return k[v];}
|
||||||
CDType & operator [](const PIString & name_);
|
CDType & operator [](const PIString & name_);
|
||||||
const CDType operator [](const PIString & name_) const {return (*this)[name_];}
|
const CDType operator [](const PIString & name_) const {return (*this)[name_];}
|
||||||
|
CDType & operator [](const PIDeque<int> & path_);
|
||||||
|
const CDType operator [](const PIDeque<int> & path_) const {return (*this)[path_];}
|
||||||
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];}
|
||||||
|
|
||||||
@@ -75,6 +79,8 @@ public:
|
|||||||
PIVector<int> indexes() const {return k.keys();}
|
PIVector<int> indexes() const {return k.keys();}
|
||||||
PIStringList index_names() const;
|
PIStringList index_names() const;
|
||||||
void calculate();
|
void calculate();
|
||||||
|
void makePath(PIDeque<int> p = PIDeque<int>());
|
||||||
|
PIVector<CDType * > children(bool recursive = true) const;
|
||||||
|
|
||||||
PIString name;
|
PIString name;
|
||||||
PIString alias;
|
PIString alias;
|
||||||
@@ -110,7 +116,7 @@ inline PICout operator <<(PICout s, const CDUtils::CDType & v) {
|
|||||||
}
|
}
|
||||||
s << v.name() << "(" << v.index() << ")] = " << v.value();
|
s << v.name() << "(" << v.index() << ")] = " << v.value();
|
||||||
s.restoreControl();
|
s.restoreControl();
|
||||||
return s;\
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CDUTILS_TYPES_H
|
#endif // CDUTILS_TYPES_H
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
project(cd_pult)
|
|
||||||
cmake_minimum_required(VERSION 2.6)
|
|
||||||
if (NOT LIBPROJECT)
|
|
||||||
find_package(PIP REQUIRED)
|
|
||||||
endif ()
|
|
||||||
if (MINGW)
|
|
||||||
find_package(MinGW REQUIRED)
|
|
||||||
endif()
|
|
||||||
find_package(Qt4 REQUIRED)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/../)
|
|
||||||
file(GLOB CPPS "*.cpp")
|
|
||||||
file(GLOB MOCS "*.h")
|
|
||||||
file(GLOB UIS "*.ui")
|
|
||||||
file(GLOB RES "*.qrc")
|
|
||||||
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
|
||||||
qt4_wrap_ui(CUIS ${UIS})
|
|
||||||
qt4_add_resources(RESS ${RES})
|
|
||||||
add_executable(${PROJECT_NAME} ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS})
|
|
||||||
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic qad_utils qad_widgets)
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${LIBS} cd_utils)
|
|
||||||
|
|
||||||
# if (NOT DEFINED ENV{QNX_HOST})
|
|
||||||
# if (PULT)
|
|
||||||
# find_package(Qt4 REQUIRED)
|
|
||||||
# find_package(OpenGL REQUIRED)
|
|
||||||
# include_directories(${QT_INCLUDES})
|
|
||||||
# set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp")
|
|
||||||
# set(MOCS "kx_pult.h")
|
|
||||||
# file(GLOB UIS "*.ui")
|
|
||||||
# file(GLOB RES "*.qrc")
|
|
||||||
# qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
|
||||||
# qt4_wrap_ui(CUIS ${UIS})
|
|
||||||
# qt4_add_resources(RESS ${RES})
|
|
||||||
# add_executable(${KX_PULT_NAME} WIN32 ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS})
|
|
||||||
# set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic qad_utils qad_widgets)
|
|
||||||
# target_link_libraries(${KX_PULT_NAME} ${LIBS} ${PROJECT_NAME})
|
|
||||||
# endif ()
|
|
||||||
# endif ()
|
|
||||||
# if (LIB)
|
|
||||||
# if (WIN32)
|
|
||||||
# set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
|
||||||
# install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
|
|
||||||
# install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB})
|
|
||||||
# install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_BIN})
|
|
||||||
# else ()
|
|
||||||
# set(CMAKE_INSTALL_PREFIX /usr)
|
|
||||||
# install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
|
||||||
# install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
|
||||||
# endif ()
|
|
||||||
# message(STATUS "Install to system \"${CMAKE_INSTALL_PREFIX}\"")
|
|
||||||
# else ()
|
|
||||||
# install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
|
||||||
# message(STATUS "Install to local \"bin\"")
|
|
||||||
# endif ()
|
|
||||||
# if (NOT DEFINED ENV{QNX_HOST})
|
|
||||||
# if (KX_PULT)
|
|
||||||
# install(TARGETS ${KX_PULT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
|
||||||
# endif ()
|
|
||||||
# endif ()
|
|
||||||
52
qcd_utils/CMakeLists.txt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
project(qcd_utils)
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
if (NOT LIBPROJECT)
|
||||||
|
find_package(PIP REQUIRED)
|
||||||
|
endif ()
|
||||||
|
if (MINGW)
|
||||||
|
find_package(MinGW REQUIRED)
|
||||||
|
endif()
|
||||||
|
find_package(Qt4 REQUIRED)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES} ${QT_INCLUDES})
|
||||||
|
set(PULT_NAME "cd_pult")
|
||||||
|
option(PULT "Build ${PULT_NAME}" 1)
|
||||||
|
option(LIB "System install" 1)
|
||||||
|
option(DEBUG "Build with -g3" 0)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
|
||||||
|
if (DEBUG)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||||
|
endif ()
|
||||||
|
file(GLOB CPPS "*.cpp")
|
||||||
|
file(GLOB MOCS "*.h")
|
||||||
|
file(GLOB UIS "*.ui")
|
||||||
|
file(GLOB RES "*.qrc")
|
||||||
|
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
||||||
|
qt4_wrap_ui(CUIS ${UIS})
|
||||||
|
qt4_add_resources(RESS ${RES})
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS})
|
||||||
|
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PIP_LIBRARY} qad_widgets cd_utils piqt)
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||||
|
|
||||||
|
if (NOT DEFINED ENV{QNX_HOST})
|
||||||
|
if (PULT)
|
||||||
|
add_subdirectory(pult)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
if (LIB)
|
||||||
|
if (WIN32)
|
||||||
|
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||||
|
install(FILES ${MOCS} DESTINATION ${MINGW_INCLUDE})
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB})
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_BIN})
|
||||||
|
get_filename_component(QTDIR ${QT_QMAKE_EXECUTABLE} PATH)
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION ${QTDIR})
|
||||||
|
else ()
|
||||||
|
set(CMAKE_INSTALL_PREFIX /usr)
|
||||||
|
install(FILES ${MOCS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
|
endif ()
|
||||||
|
message(STATUS "Install to system \"${CMAKE_INSTALL_PREFIX}\"")
|
||||||
|
else ()
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||||
|
message(STATUS "Install to local \"bin\"")
|
||||||
|
endif ()
|
||||||
4
qcd_utils/clean.bat
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#make clean
|
||||||
|
del /q /f /s CMakeFiles
|
||||||
|
rmdir /q /s CMakeFiles
|
||||||
|
del /q /f CMakeCache.txt Makefile cmake_install.cmake install_manifest.txt *.user* *~ *cxx moc_* ui_* qrc_* *.o *.exe *.a *.dll *.lib core *.qrc.depends
|
||||||
1
qcd_utils/make_lib.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmake -G "MinGW Makefiles" -DLIB=1 && make install . %*
|
||||||
21
qcd_utils/pult/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
project(cd_pult)
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
if (NOT LIBPROJECT)
|
||||||
|
find_package(PIP REQUIRED)
|
||||||
|
endif ()
|
||||||
|
if (MINGW)
|
||||||
|
find_package(MinGW REQUIRED)
|
||||||
|
endif()
|
||||||
|
find_package(Qt4 REQUIRED)
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/../)
|
||||||
|
file(GLOB PULT_CPPS "*.cpp")
|
||||||
|
file(GLOB PULT_MOCS "*.h")
|
||||||
|
file(GLOB PULT_UIS "*.ui")
|
||||||
|
file(GLOB PULT_RES "*.qrc")
|
||||||
|
qt4_wrap_cpp(PULT_CMOCS ${PULT_MOCS} OPTIONS -nw)
|
||||||
|
qt4_wrap_ui(PULT_CUIS ${PULT_UIS})
|
||||||
|
qt4_add_resources(PULT_RESS ${PULT_RES})
|
||||||
|
add_executable(${PROJECT_NAME} ${PULT_CPPS} ${PULT_CMOCS} ${PULT_CUIS} ${PULT_RESS} ${PULT_MOCS})
|
||||||
|
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic qad_utils qad_widgets qcd_utils)
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${LIBS} cd_utils)
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "qpievaluator.h"
|
#include "qpievaluator.h"
|
||||||
#include "cdutils_core.h"
|
#include "cdutils_core.h"
|
||||||
#include "cdutils_k.h"
|
#include "cdutils_k.h"
|
||||||
#include "cd_kmodel.h"
|
#include "qcd_kmodel.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
#include "form.h"
|
#include "form.h"
|
||||||
#include "ui_form.h"
|
#include "ui_form.h"
|
||||||
#include "QFileDialog"
|
#include <QFileDialog>
|
||||||
|
#include <QDebug>
|
||||||
#include "cdutils_k.h"
|
#include "cdutils_k.h"
|
||||||
|
#include "cdutils_core.h"
|
||||||
|
#include "qcd_core.h"
|
||||||
|
|
||||||
using namespace CDUtils;
|
using namespace CDUtils;
|
||||||
|
|
||||||
|
|
||||||
Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::Form) {
|
Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::Form) {
|
||||||
|
CDCore::instance()->initPult();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->treeView->setKFile("");
|
ui->treeView->setKFile("");
|
||||||
ui->treeView->refresh();
|
ui->treeView->refresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -28,6 +33,7 @@ void Form::on_pushButton_4_clicked() {
|
|||||||
ui->treeView->setKFile(QFileDialog::getOpenFileName(this, "Open"));
|
ui->treeView->setKFile(QFileDialog::getOpenFileName(this, "Open"));
|
||||||
ui->treeView->loadK();
|
ui->treeView->loadK();
|
||||||
ui->treeView->setKFile("");
|
ui->treeView->setKFile("");
|
||||||
|
qDebug() << QCDCore::instance()->bindWindow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -6,21 +6,18 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>581</width>
|
<width>731</width>
|
||||||
<height>432</height>
|
<height>508</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="3" column="1">
|
||||||
<widget class="CDKView" name="treeView"/>
|
<widget class="QPushButton" name="buttonRefresh">
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QPushButton" name="pushButton_3">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>Refresh</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -31,10 +28,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="pushButton_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Receive</string>
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<widget class="CDKView" name="treeView"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QPushButton" name="buttonCalc">
|
||||||
|
<property name="text">
|
||||||
|
<string>Calculate</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -59,20 +66,66 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="1" column="1">
|
||||||
<widget class="QPushButton" name="buttonCalc">
|
<widget class="QPushButton" name="pushButton_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Calculate</string>
|
<string>Receive</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="2" rowspan="5">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>GroupBox</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkRadar_ADA_On">
|
||||||
|
<property name="text">
|
||||||
|
<string>CheckBox</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="SpinSlider" name="spinSliderRadar_Antenna_Distance"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinRadar_Antenna_SwitchRate"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>SpinSlider</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>spinslider.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CDKView</class>
|
<class>CDKView</class>
|
||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
<header location="global">cdkview.h</header>
|
<header location="global">qcd_kview.h</header>
|
||||||
<slots>
|
<slots>
|
||||||
<signal>busyStatusChanged(bool)</signal>
|
<signal>busyStatusChanged(bool)</signal>
|
||||||
<slot>sendK()</slot>
|
<slot>sendK()</slot>
|
||||||
@@ -81,6 +134,7 @@
|
|||||||
<slot>loadK()</slot>
|
<slot>loadK()</slot>
|
||||||
<slot>clear()</slot>
|
<slot>clear()</slot>
|
||||||
<slot>clearK()</slot>
|
<slot>clearK()</slot>
|
||||||
|
<slot>refresh()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
@@ -93,11 +147,11 @@
|
|||||||
<slot>receiveK()</slot>
|
<slot>receiveK()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>571</x>
|
<x>264</x>
|
||||||
<y>60</y>
|
<y>60</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>410</x>
|
<x>264</x>
|
||||||
<y>152</y>
|
<y>152</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
@@ -109,11 +163,11 @@
|
|||||||
<slot>setDisabled(bool)</slot>
|
<slot>setDisabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>309</x>
|
<x>264</x>
|
||||||
<y>174</y>
|
<y>174</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>571</x>
|
<x>264</x>
|
||||||
<y>60</y>
|
<y>60</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
@@ -125,11 +179,11 @@
|
|||||||
<slot>clearK()</slot>
|
<slot>clearK()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>571</x>
|
<x>264</x>
|
||||||
<y>89</y>
|
<y>89</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>468</x>
|
<x>264</x>
|
||||||
<y>188</y>
|
<y>188</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
@@ -141,7 +195,7 @@
|
|||||||
<slot>sendK()</slot>
|
<slot>sendK()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>199</x>
|
<x>137</x>
|
||||||
<y>60</y>
|
<y>60</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
@@ -166,5 +220,21 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonRefresh</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>treeView</receiver>
|
||||||
|
<slot>refresh()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>223</x>
|
||||||
|
<y>114</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>217</x>
|
||||||
|
<y>134</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1005 B After Width: | Height: | Size: 1005 B |
|
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 717 B |
|
Before Width: | Height: | Size: 813 B After Width: | Height: | Size: 813 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1017 B After Width: | Height: | Size: 1017 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 563 B After Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 644 B After Width: | Height: | Size: 644 B |
|
Before Width: | Height: | Size: 802 B After Width: | Height: | Size: 802 B |
|
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 485 B |
|
Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 640 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 634 B |
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 544 B |
|
Before Width: | Height: | Size: 529 B After Width: | Height: | Size: 529 B |
|
Before Width: | Height: | Size: 571 B After Width: | Height: | Size: 571 B |
|
Before Width: | Height: | Size: 577 B After Width: | Height: | Size: 577 B |
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 579 B |
|
Before Width: | Height: | Size: 577 B After Width: | Height: | Size: 577 B |
|
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 639 B |
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 448 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 564 B After Width: | Height: | Size: 564 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 694 B After Width: | Height: | Size: 694 B |
|
Before Width: | Height: | Size: 658 B After Width: | Height: | Size: 658 B |
|
Before Width: | Height: | Size: 691 B After Width: | Height: | Size: 691 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 539 B |
|
Before Width: | Height: | Size: 929 B After Width: | Height: | Size: 929 B |
196
qcd_utils/qcd_core.cpp
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
#include "qcd_core.h"
|
||||||
|
#include "cdutils_core.h"
|
||||||
|
#include "piqt.h"
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QSlider>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <spinslider.h>
|
||||||
|
#include <clineedit.h>
|
||||||
|
|
||||||
|
using namespace CDUtils;
|
||||||
|
|
||||||
|
|
||||||
|
int __QCore_Initializer__::count_(0);
|
||||||
|
QCDCore * __QCore_Initializer__::__instance__(0);
|
||||||
|
|
||||||
|
|
||||||
|
__QCore_Initializer__::__QCore_Initializer__() {
|
||||||
|
count_++;
|
||||||
|
if (count_ > 1) return;
|
||||||
|
__instance__ = new QCDCore();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__QCore_Initializer__::~__QCore_Initializer__() {
|
||||||
|
count_--;
|
||||||
|
if (count_ > 0) return;
|
||||||
|
if (__instance__ != 0) {
|
||||||
|
delete __instance__;
|
||||||
|
__instance__ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QCDCore::QCDCore() {
|
||||||
|
setObjectName("QCDCore");
|
||||||
|
setName("QCDCore");
|
||||||
|
CONNECTU(CDCore::instance(), K_ChangedGlobal, this, K_ChangedGlobal);
|
||||||
|
updating = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QCDCore::~QCDCore() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCDCore::K_ChangedGlobal() {
|
||||||
|
QMetaObject::invokeMethod(this, "updateBindedWidgets", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCDCore::slotBool(bool v) {
|
||||||
|
QWidget * w = (QWidget*)sender();
|
||||||
|
if (!w || updating) return;
|
||||||
|
PIDeque<int> path = binded_widgets.value(w);
|
||||||
|
CDCore::instance()->k()[path].setValue(PIString::fromBool(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCDCore::slotInt(int v) {
|
||||||
|
QWidget * w = (QWidget*)sender();
|
||||||
|
if (!w || updating) return;
|
||||||
|
PIDeque<int> path = binded_widgets.value(w);
|
||||||
|
CDCore::instance()->k()[path].setValue(PIString::fromNumber(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCDCore::slotDouble(double v) {
|
||||||
|
QWidget * w = (QWidget*)sender();
|
||||||
|
if (!w || updating) return;
|
||||||
|
PIDeque<int> path = binded_widgets.value(w);
|
||||||
|
CDCore::instance()->k()[path].setValue(PIString::fromNumber(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCDCore::slotText(QString v) {
|
||||||
|
QWidget * w = (QWidget*)sender();
|
||||||
|
if (!w || updating) return;
|
||||||
|
PIDeque<int> path = binded_widgets.value(w);
|
||||||
|
CDCore::instance()->k()[path].setValue(Q2PIString(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int QCDCore::bindWindow(QWidget * wnd) {
|
||||||
|
if (!wnd) return 0;
|
||||||
|
CDCore::instance()->k().makePath();
|
||||||
|
return bindWidgets(wnd->findChildren<QWidget * >());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int QCDCore::bindWidgets(QList<QWidget * > wl) {
|
||||||
|
int ret = 0;
|
||||||
|
foreach (QWidget * w, wl)
|
||||||
|
if (bindWidget(w)) ++ret;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QCDCore::bindWidget(QWidget * w) {
|
||||||
|
if (!w) return false;
|
||||||
|
QString on = w->objectName();
|
||||||
|
PIVector<CDType * > ak = CDCore::instance()->k().children();
|
||||||
|
piForeachC (CDType * k, ak) {
|
||||||
|
if (!on.endsWith(PI2QString(k->name()))) continue;
|
||||||
|
QString cn = w->metaObject()->className();
|
||||||
|
bool ok = false;
|
||||||
|
if (cn == "QCheckBox" || cn == "QGroupBox") {
|
||||||
|
connect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)), Qt::UniqueConnection);
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar") {
|
||||||
|
connect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)), Qt::UniqueConnection);
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
if (cn == "QDoubleSpinBox" || cn == "SpinSlider") {
|
||||||
|
connect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)), Qt::UniqueConnection);
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
if (cn == "QLineEdit" || cn == "CLineEdit") {
|
||||||
|
connect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)), Qt::UniqueConnection);
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
if (!ok) continue;
|
||||||
|
binded_widgets[w] = k->path();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCDCore::updateBindedWidgets() {
|
||||||
|
QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
|
||||||
|
updating = true;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QWidget * w = it.next().key();
|
||||||
|
QString cn = w->metaObject()->className();
|
||||||
|
const CDType k(CDCore::instance()->k()[it.value()]);
|
||||||
|
if (cn == "QCheckBox") qobject_cast<QCheckBox*>(w)->setChecked(k.toBool());
|
||||||
|
if (cn == "QGroupBox") qobject_cast<QGroupBox*>(w)->setChecked(k.toBool());
|
||||||
|
if (cn == "QSpinBox") qobject_cast<QSpinBox*>(w)->setValue(k.toInt());
|
||||||
|
if (cn == "QSlider") qobject_cast<QSlider*>(w)->setValue(k.toInt());
|
||||||
|
if (cn == "QScrollBar") qobject_cast<QScrollBar*>(w)->setValue(k.toInt());
|
||||||
|
if (cn == "QDoubleSpinBox") qobject_cast<QDoubleSpinBox*>(w)->setValue(k.toDouble());
|
||||||
|
if (cn == "SpinSlider") qobject_cast<SpinSlider*>(w)->setValue(k.toDouble());
|
||||||
|
if (cn == "QLineEdit") qobject_cast<QLineEdit*>(w)->setText(PI2QString(k.value()));
|
||||||
|
if (cn == "CLineEdit") qobject_cast<CLineEdit*>(w)->setText(PI2QString(k.value()));
|
||||||
|
}
|
||||||
|
updating = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int QCDCore::unbindWindow(QWidget * wnd) {
|
||||||
|
if (!wnd) return 0;
|
||||||
|
return unbindWidgets(wnd->findChildren<QWidget * >());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int QCDCore::unbindWidgets(QList<QWidget * > wl) {
|
||||||
|
int ret = 0;
|
||||||
|
foreach (QWidget * w, wl)
|
||||||
|
if (unbindWidget(w)) ++ret;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QCDCore::unbindWidget(QWidget * w) {
|
||||||
|
if (!w) return false;
|
||||||
|
if (!binded_widgets.contains(w)) return false;
|
||||||
|
QString cn = w->metaObject()->className();
|
||||||
|
if (cn == "QCheckBox" || cn == "QGroupBox")
|
||||||
|
disconnect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)));
|
||||||
|
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar")
|
||||||
|
disconnect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)));
|
||||||
|
if (cn == "QDoubleSpinBox" || cn == "SpinSlider")
|
||||||
|
disconnect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)));
|
||||||
|
if (cn == "QLineEdit" || cn == "CLineEdit")
|
||||||
|
disconnect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)));
|
||||||
|
binded_widgets.remove(w);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCDCore::unbindAllWidgets() {
|
||||||
|
QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QWidget * w = it.next().key();
|
||||||
|
unbindWidget(w);
|
||||||
|
}
|
||||||
|
binded_widgets.clear();
|
||||||
|
}
|
||||||
65
qcd_utils/qcd_core.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#ifndef QCD_CORE_H
|
||||||
|
#define QCD_CORE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMap>
|
||||||
|
#include "piobject.h"
|
||||||
|
|
||||||
|
|
||||||
|
class QCDCore;
|
||||||
|
|
||||||
|
|
||||||
|
class __QCore_Initializer__ {
|
||||||
|
public:
|
||||||
|
__QCore_Initializer__();
|
||||||
|
~__QCore_Initializer__();
|
||||||
|
static int count_;
|
||||||
|
static QCDCore * __instance__;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class QCDCore: public QObject, public PIObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
PIOBJECT(QCDCore)
|
||||||
|
friend class __QCore_Initializer__;
|
||||||
|
public:
|
||||||
|
static QCDCore * instance() {return __QCore_Initializer__::__instance__;}
|
||||||
|
|
||||||
|
int bindWindow(QWidget * wnd);
|
||||||
|
int bindWidgets(QList<QWidget * > wl);
|
||||||
|
bool bindWidget(QWidget * w);
|
||||||
|
void updateBindedWidgets();
|
||||||
|
int unbindWindow(QWidget * wnd);
|
||||||
|
int unbindWidgets(QList<QWidget * > wl);
|
||||||
|
bool unbindWidget(QWidget * w);
|
||||||
|
void unbindAllWidgets();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QCDCore();
|
||||||
|
~QCDCore();
|
||||||
|
|
||||||
|
EVENT_HANDLER(void, K_ChangedGlobal);
|
||||||
|
|
||||||
|
QMap<QWidget * , PIDeque<int> > binded_widgets;
|
||||||
|
bool updating;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotBool(bool v);
|
||||||
|
void slotInt(int v);
|
||||||
|
void slotDouble(double v);
|
||||||
|
void slotText(QString v);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static __QCore_Initializer__ __QCore_initializer__;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // QCD_CORE_H
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "cd_kmodel.h"
|
#include "qcd_kmodel.h"
|
||||||
#include "cdutils_k.h"
|
#include "cdutils_k.h"
|
||||||
#include "piqt.h"
|
#include "piqt.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#ifndef CD_KMODEL_H
|
#ifndef QCD_KMODEL_H
|
||||||
#define CD_KMODEL_H
|
#define QCD_KMODEL_H
|
||||||
|
|
||||||
//#include "cdutils_k.h"
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
@@ -78,4 +77,4 @@ signals:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CD_KMODEL_H
|
#endif // QCD_KMODEL_H
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "cdutils_k.h"
|
#include "cdutils_k.h"
|
||||||
#include "cdkview.h"
|
#include "qcd_kview.h"
|
||||||
#include "cd_kmodel.h"
|
#include "qcd_kmodel.h"
|
||||||
#include "piqt.h"
|
#include "piqt.h"
|
||||||
#include "pifile.h"
|
#include "pifile.h"
|
||||||
|
|
||||||
@@ -69,6 +69,7 @@ void CDKView::saveK() {
|
|||||||
|
|
||||||
void CDKView::loadK() {
|
void CDKView::loadK() {
|
||||||
K.readFile();
|
K.readFile();
|
||||||
|
K.calculate();
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef CDKVIEW_H
|
#ifndef QCD_KVIEW_H
|
||||||
#define CDKVIEW_H
|
#define QCD_KVIEW_H
|
||||||
|
|
||||||
#include "piobject.h"
|
#include "piobject.h"
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
@@ -13,13 +13,14 @@ class CDKView : public QTreeView, public PIObject
|
|||||||
public:
|
public:
|
||||||
explicit CDKView(QWidget *parent = 0);
|
explicit CDKView(QWidget *parent = 0);
|
||||||
~CDKView();
|
~CDKView();
|
||||||
void refresh();
|
|
||||||
void setKFile(const QString & filename);
|
void setKFile(const QString & filename);
|
||||||
void startPing();
|
void startPing();
|
||||||
|
|
||||||
CDKItemModel * CDKModel() {return kmodel;}
|
CDKItemModel * CDKModel() {return kmodel;}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void refresh();
|
||||||
void sendK();
|
void sendK();
|
||||||
void receiveK();
|
void receiveK();
|
||||||
void saveK();
|
void saveK();
|
||||||
@@ -57,4 +58,4 @@ signals:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CDKVIEW_H
|
#endif // QCD_KVIEW_H
|
||||||