diff --git a/AT4.qrc b/AT4.qrc
new file mode 100644
index 0000000..dbc1310
--- /dev/null
+++ b/AT4.qrc
@@ -0,0 +1,17 @@
+
+
+ images/AxTrace.ico
+ images/capture.png
+ images/save.png
+
+ images/auto-scroll.png
+ images/copy.png
+ images/clean.png
+ images/clean-all.png
+
+ images/grid.png
+ images/setting.png
+
+ images/about.png
+
+
diff --git a/AT4_Camera2D.cpp b/AT4_Camera2D.cpp
new file mode 100644
index 0000000..a970bb7
--- /dev/null
+++ b/AT4_Camera2D.cpp
@@ -0,0 +1,115 @@
+#include "stdafx.h"
+#include "AT4_Camera2D.h"
+
+
+//--------------------------------------------------------------------------------------------
+Camera2D::Camera2D()
+ : m_scale(1.0)
+ , m_draging(false)
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+Camera2D::~Camera2D()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void Camera2D::_updateTransform(void)
+{
+ qreal screenRatio = (qreal)m_viewSize.width() / (qreal)m_viewSize.height();
+ qreal sceneRatio = abs(m_sceneRect.width() / m_sceneRect.height());
+
+ if (screenRatio > sceneRatio)
+ {
+ m_scale = m_viewSize.height() / abs(m_sceneRect.height()*1.2);
+ }
+ else
+ {
+ m_scale = m_viewSize.width() / abs(m_sceneRect.width()*1.2);
+ }
+
+ int flipX = m_sceneRect.width() > 0 ? 1 : -1;
+ int flipY = m_sceneRect.height() > 0 ? 1 : -1;
+
+ m_transform = QTransform::fromTranslate(-m_sceneRect.left(), -m_sceneRect.top());
+ m_transform *= QTransform::fromScale(flipX*m_scale, flipY*m_scale);
+ m_transform *= QTransform::fromTranslate((m_viewSize.width() - abs(m_sceneRect.width()) * m_scale) / 2, (m_viewSize.height() - abs(m_sceneRect.height()) * m_scale) / 2);
+}
+
+//--------------------------------------------------------------------------------------------
+void Camera2D::reset(const QSize& viewSize, const QRectF& sceneRect)
+{
+ if (viewSize==m_viewSize && m_sceneRect == sceneRect) return;
+
+ m_viewSize = viewSize;
+ m_sceneRect = sceneRect;
+
+ _updateTransform();
+}
+
+//--------------------------------------------------------------------------------------------
+void Camera2D::updateViewSize(const QSize& viewSize)
+{
+ m_viewSize = viewSize;
+}
+
+//--------------------------------------------------------------------------------------------
+QPointF Camera2D::screenToScene(const QPoint& pos)
+{
+ bool invertAble;
+ QTransform inv = m_transform.inverted(&invertAble);
+ if (invertAble) {
+ QPointF scenePos = inv * QPointF(pos);
+ return scenePos;
+ }
+
+ return QPointF(pos);
+}
+
+//--------------------------------------------------------------------------------------------
+void Camera2D::onMouseWheel(QWheelEvent *e)
+{
+ qreal scale = 1.0;
+ if (e->delta() > 0) {
+ scale = 1.2;
+ }
+ else {
+ scale = 0.9;
+ }
+
+ QPoint mousePoint = e->pos();
+ m_transform *= QTransform::fromTranslate(-mousePoint.x(), -mousePoint.y());
+ m_transform *= QTransform::fromScale(scale, scale);
+ m_transform *= QTransform::fromTranslate(mousePoint.x(), mousePoint.y());
+
+ m_scale *= scale;
+}
+
+//--------------------------------------------------------------------------------------------
+void Camera2D::beginDrag(QMouseEvent *e)
+{
+ m_draging = true;
+ m_beginDragPoint = e->pos();
+ m_tragingTransform = m_transform;
+}
+
+//--------------------------------------------------------------------------------------------
+void Camera2D::drag(QMouseEvent *e)
+{
+ if (!m_draging) return;
+
+ QPoint move = e->pos() - m_beginDragPoint;
+ m_transform = m_tragingTransform * QTransform::fromTranslate(move.x(), move.y());
+}
+
+//--------------------------------------------------------------------------------------------
+void Camera2D::endDrag(QMouseEvent *e)
+{
+ m_draging = false;
+
+ QPoint move = e->pos() - m_beginDragPoint;
+ m_transform = m_tragingTransform * QTransform::fromTranslate(move.x(), move.y());
+}
diff --git a/AT4_Camera2D.h b/AT4_Camera2D.h
new file mode 100644
index 0000000..cf89251
--- /dev/null
+++ b/AT4_Camera2D.h
@@ -0,0 +1,41 @@
+#pragma once
+
+class Camera2D
+{
+public:
+ void reset(const QSize& viewSize, const QRectF& sceneRect);
+
+ void updateViewSize(const QSize& viewSize);
+ const QSize& getViewSize(void) const { return m_viewSize; }
+
+ const QRectF& getSceneRect(void) const { return m_sceneRect; }
+
+ QPointF screenToScene(const QPoint& pos);
+
+ qreal getScale(void) const { return m_scale; }
+ const QTransform& getTransform(void) const { return m_transform; }
+
+ void onMouseWheel(QWheelEvent *e);
+ void beginDrag(QMouseEvent *e);
+ void drag(QMouseEvent *e);
+ void endDrag(QMouseEvent *e);
+ bool isDraging(void) const { return m_draging; }
+
+private:
+ void _updateTransform(void);
+
+private:
+ QSize m_viewSize;
+ QRectF m_sceneRect;
+
+ qreal m_scale;
+ QTransform m_transform;
+
+ bool m_draging;
+ QPoint m_beginDragPoint;
+ QTransform m_tragingTransform;
+
+public:
+ Camera2D();
+ ~Camera2D();
+};
diff --git a/AT4_ChildInterface.h b/AT4_ChildInterface.h
new file mode 100644
index 0000000..dc931bf
--- /dev/null
+++ b/AT4_ChildInterface.h
@@ -0,0 +1,25 @@
+#pragma once
+
+class IChild : public QObjectUserData
+{
+public:
+ enum Type
+ {
+ CT_LOG,
+ CT_VALUE,
+ CT_2DMAP,
+ };
+
+ virtual Type getType(void) const = 0;
+ virtual QString getTitle(void) const = 0;
+
+ virtual bool copyAble(void) const = 0;
+ virtual void onCopy(void) const = 0;
+
+ virtual void clean(void) = 0;
+
+ virtual void saveAs(void) = 0;
+
+ virtual void update(void) = 0;
+};
+
diff --git a/AT4_Config.cpp b/AT4_Config.cpp
new file mode 100644
index 0000000..582a0cd
--- /dev/null
+++ b/AT4_Config.cpp
@@ -0,0 +1,109 @@
+#include "stdafx.h"
+#include "AT4_Config.h"
+
+//--------------------------------------------------------------------------------------------
+Config::Config()
+{
+ // reset setting to default
+ _resetToDefaultSetting();
+}
+
+//--------------------------------------------------------------------------------------------
+Config::Config(const Config& other)
+{
+ // reset setting to default
+ _resetToDefaultSetting();
+ copyFrom(other);
+}
+
+//--------------------------------------------------------------------------------------------
+Config::~Config()
+{
+ saveSetting();
+}
+
+//--------------------------------------------------------------------------------------------
+void Config::_resetToDefaultSetting(void)
+{
+ m_bCapture = true;
+ m_bAutoScroll = true;
+ m_bShowGrid = true;
+ m_filterScript = m_defaultFilterScript = QString(
+ "function onLogMessage(msg)\r\n"
+ " local frontColor=COL_BLACK; \r\n"
+ " local backColor=COL_WHITE; \r\n"
+ " local logType=msg:get_log_type(); \r\n"
+ " if(logType==AXT_ERROR) then \r\n"
+ " frontColor=COL_RED; \r\n"
+ " end; \r\n"
+ " if(logType==AXT_FATAL) then \r\n"
+ " frontColor=COL_RED; \r\n"
+ " backColor=COL_YELLOW; \r\n"
+ " end; \r\n"
+ " return true, \"defult\", frontColor, backColor; \r\n"
+ "end\n\r\n"
+ "function onValueMessage(msg) \r\n"
+ " return true, \"defult\", COL_BLACK, COL_WHITE; \r\n"
+ "end; \r\n\r\n"
+ "function onActor2DMessage(msg)\r\n"
+ " return true, ACTOR_CIRCLE, 1, COL_WHITE, COL_GRAY; \r\n"
+ "end; \r\n"
+ );
+ m_maxLogCounts = 10000;
+}
+
+//--------------------------------------------------------------------------------------------
+void Config::copyFrom(const Config& other)
+{
+ m_bCapture = other.m_bCapture;
+ m_bAutoScroll = other.m_bAutoScroll;
+ m_filterScript = other.m_filterScript;
+ m_maxLogCounts = other.m_maxLogCounts;
+}
+
+//--------------------------------------------------------------------------------------------
+void Config::setFilterScript(const QString& script)
+{
+ m_filterScript = script;
+ saveSetting();
+}
+
+//--------------------------------------------------------------------------------------------
+void Config::setMainGeometry(const QByteArray& geometry)
+{
+ m_mainGeometry = geometry;
+}
+
+//--------------------------------------------------------------------------------------------
+void Config::setMaxLogCounts(int maxLogCounts)
+{
+ m_maxLogCounts = maxLogCounts;
+}
+
+//--------------------------------------------------------------------------------------------
+void Config::loadSetting(void)
+{
+ _resetToDefaultSetting();
+
+ //Load setting from disk
+ QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
+
+ m_bAutoScroll = settings.value("AutoScroll", m_bAutoScroll).toBool();
+ m_bShowGrid = settings.value("ShowGrid", m_bShowGrid).toBool();
+ m_mainGeometry = settings.value("MainGeometry", QByteArray()).toByteArray();
+ m_filterScript = settings.value("FilterScript", m_filterScript).toString();
+ m_maxLogCounts = settings.value("MaxLogCounts", m_maxLogCounts).toInt();
+}
+
+//--------------------------------------------------------------------------------------------
+void Config::saveSetting(void) const
+{
+ // Save setting to disk
+ QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
+
+ settings.setValue("AutoScroll", m_bAutoScroll);
+ settings.setValue("ShowGrid", m_bShowGrid);
+ settings.setValue("MainGeometry", m_mainGeometry);
+ settings.setValue("FilterScript", m_filterScript);
+ settings.setValue("MaxLogCounts", m_maxLogCounts);
+}
diff --git a/AT4_Config.h b/AT4_Config.h
new file mode 100644
index 0000000..4e8e4ce
--- /dev/null
+++ b/AT4_Config.h
@@ -0,0 +1,46 @@
+#pragma once
+
+class Config
+{
+public:
+ void loadSetting(void);
+ void saveSetting(void) const;
+ void copyFrom(const Config& other);
+
+ bool getCapture(void) const { return m_bCapture; }
+ void setCapture(bool c) { m_bCapture = c; }
+
+ bool getAutoScroll(void) const { return m_bAutoScroll; }
+ void setAutoScroll(bool a) { m_bAutoScroll = a; }
+
+ bool getShowGrid(void) const { return m_bShowGrid; }
+ void setShowGrid(bool s) { m_bShowGrid = s; }
+
+ const QString& getFilterScript(void) const { return m_filterScript; }
+ void setFilterScript(const QString& script);
+
+ const QByteArray& getMainGeometry(void) const { return m_mainGeometry; }
+ void setMainGeometry(const QByteArray& geometry);
+
+ const QString& getDefaultFilterScript(void) const { return m_defaultFilterScript; }
+
+ int getMaxLogCounts(void) const { return m_maxLogCounts; }
+ void setMaxLogCounts(int maxLogCounts);
+
+private:
+ void _resetToDefaultSetting(void);
+
+private:
+ bool m_bCapture;
+ bool m_bAutoScroll;
+ bool m_bShowGrid;
+ QString m_filterScript;
+ QString m_defaultFilterScript;
+ QByteArray m_mainGeometry;
+ int m_maxLogCounts;
+
+public:
+ Config();
+ Config(const Config& other);
+ ~Config();
+};
diff --git a/AT4_Filter.cpp b/AT4_Filter.cpp
new file mode 100644
index 0000000..b6f1f4d
--- /dev/null
+++ b/AT4_Filter.cpp
@@ -0,0 +1,164 @@
+#include "stdafx.h"
+#include "AT4_Filter.h"
+#include "AT4_Config.h"
+#include "AT4_Message.h"
+
+//--------------------------------------------------------------------------------------------
+Filter::Filter()
+ : m_config(nullptr)
+ , L(nullptr)
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+Filter::~Filter()
+{
+ lua_close(L);
+}
+
+//--------------------------------------------------------------------------------------------
+bool Filter::init(Config* cfg)
+{
+ assert(cfg);
+
+ m_config = cfg;
+
+ L = luaL_newstate();
+ luaL_openlibs(L);
+
+ //register functions
+ _luaopen(L);
+ LogMessage::_luaopen(L);
+ ValueMessage::_luaopen(L);
+ Begin2DSceneMessage::_luaopen(L);
+ Update2DActorMessage::_luaopen(L);
+
+ //reload script
+ if (!reloadScript(m_config->getFilterScript().toUtf8().toStdString().c_str()))
+ return false;
+
+ return true;
+}
+
+//--------------------------------------------------------------------------------------------
+bool Filter::reloadScript(const char* script)
+{
+ //run init lua script
+ if (luaL_dostring(L, script)) {
+ const char* error_msg = lua_tostring(L, -1);
+ QMessageBox msgBox;
+ msgBox.setWindowTitle(QString("LoadScript Error"));
+ msgBox.setText(QString::fromUtf8(error_msg));
+ msgBox.setIcon(QMessageBox::Critical);
+ msgBox.exec();
+ return false;
+ }
+ return true;
+}
+
+//--------------------------------------------------------------------------------------------
+bool Filter::tryLoadScript(const char* script, QString& errorMsg)
+{
+ lua_State* L2 = luaL_newstate();
+ luaL_openlibs(L2);
+
+ //register functions
+ _luaopen(L2);
+ LogMessage::_luaopen(L2);
+ ValueMessage::_luaopen(L2);
+ Begin2DSceneMessage::_luaopen(L2);
+ Update2DActorMessage::_luaopen(L2);
+
+ bool success = (luaL_dostring(L2, script) == 0);
+
+ errorMsg = QString::fromUtf8(lua_tostring(L2, -1));
+ lua_close(L2);
+
+ return success;
+}
+
+//--------------------------------------------------------------------------------------------
+void Filter::_luaopen(lua_State* L)
+{
+ lua_pushinteger(L, 0x000); lua_setglobal(L, "COL_BLACK");
+ lua_pushinteger(L, 0xFFF); lua_setglobal(L, "COL_WHITE");
+ lua_pushinteger(L, 0x00F); lua_setglobal(L, "COL_RED");
+ lua_pushinteger(L, 0x0F0); lua_setglobal(L, "COL_GREEN");
+ lua_pushinteger(L, 0xF00); lua_setglobal(L, "COL_BLUE");
+ lua_pushinteger(L, 0x777); lua_setglobal(L, "COL_GRAY");
+ lua_pushinteger(L, 0x0FF); lua_setglobal(L, "COL_YELLOW");
+ lua_pushinteger(L, 0x06F); lua_setglobal(L, "COL_ORANGE");
+ lua_pushinteger(L, 0xF0F); lua_setglobal(L, "COL_VIOLET");
+
+ lua_pushinteger(L, 0); lua_setglobal(L, "AXT_TRACE");
+ lua_pushinteger(L, 1); lua_setglobal(L, "AXT_DEBUG");
+ lua_pushinteger(L, 2); lua_setglobal(L, "AXT_INFO");
+ lua_pushinteger(L, 3); lua_setglobal(L, "AXT_WARN");
+ lua_pushinteger(L, 4); lua_setglobal(L, "AXT_ERROR");
+ lua_pushinteger(L, 5); lua_setglobal(L, "AXT_FATAL");
+ lua_pushinteger(L, 10); lua_setglobal(L, "AXT_USERDEF");
+
+ lua_pushinteger(L, 0); lua_setglobal(L, "ACTOR_CIRCLE");
+ lua_pushinteger(L, 1); lua_setglobal(L, "ACTOR_QUAD");
+}
+
+//--------------------------------------------------------------------------------------------
+void Filter::onLogMessage(const LogMessage* message, ListResult& result)
+{
+ lua_getglobal(L, "onLogMessage");
+
+ lua_pushlightuserdata(L, (void*)message);
+
+ luaL_getmetatable(L, LogMessage::MetaName);
+ lua_setmetatable(L, -2);
+ lua_pcall(L, 1, 4, 0);
+
+ result.display = (lua_toboolean(L, -4) != 0);
+ if (result.display) {
+ result.wndTitle = lua_tostring(L, -3);
+ result.fontColor = (uint16_t)(lua_tointeger(L, -2) & 0xFFF);
+ result.backColor = (uint16_t)(lua_tointeger(L, -1) & 0xFFF);
+ }
+
+ lua_pop(L, 4);
+}
+
+//--------------------------------------------------------------------------------------------
+void Filter::onValueMessage(const ValueMessage* message, ListResult& result)
+{
+ lua_getglobal(L, "onValueMessage");
+ lua_pushlightuserdata(L, (void*)message);
+
+ luaL_getmetatable(L, ValueMessage::MetaName);
+ lua_setmetatable(L, -2);
+ lua_pcall(L, 1, 4, 0);
+
+ result.display = (lua_toboolean(L, -4) != 0);
+ if (result.display) {
+ result.wndTitle = lua_tostring(L, -3);
+ result.fontColor = (uint16_t)(lua_tointeger(L, -2) & 0xFFFF);
+ result.backColor = (uint16_t)(lua_tointeger(L, -1) & 0xFFFF);
+ }
+ lua_pop(L, 4);
+}
+
+//--------------------------------------------------------------------------------------------
+void Filter::onActor2DMessage(const Update2DActorMessage* message, Actor2DResult& result)
+{
+ lua_getglobal(L, "onActor2DMessage");
+ lua_pushlightuserdata(L, (void*)message);
+
+ luaL_getmetatable(L, Update2DActorMessage::MetaName);
+ lua_setmetatable(L, -2);
+ lua_pcall(L, 1, 5, 0);
+
+ result.display = (lua_toboolean(L, -5) != 0);
+ if (result.display) {
+ result.type = (Actor2DType)lua_tointeger(L, -4);
+ result.size = lua_tointeger(L, -3);
+ result.borderColor = (uint16_t)(lua_tointeger(L, -2) & 0xFFFF);
+ result.fillColor = (uint16_t)(lua_tointeger(L, -1) & 0xFFFF);
+ }
+ lua_pop(L, 5);
+}
diff --git a/AT4_Filter.h b/AT4_Filter.h
new file mode 100644
index 0000000..410d4c0
--- /dev/null
+++ b/AT4_Filter.h
@@ -0,0 +1,60 @@
+#pragma once
+
+class Config;
+class LogMessage;
+class ValueMessage;
+class Update2DActorMessage;
+struct lua_State;
+
+class Filter
+{
+public:
+ struct ListResult
+ {
+ bool display;
+ QString wndTitle; //utf8
+ uint16_t fontColor;
+ uint16_t backColor;
+ };
+
+ enum Actor2DType
+ {
+ AT_CIRCLE,
+ AT_QUAD,
+ };
+
+ struct Actor2DResult
+ {
+ bool display;
+ Actor2DType type;
+ int size;
+ uint16_t borderColor;
+ uint16_t fillColor;
+ };
+
+public:
+ bool init(Config* cfg);
+
+ bool reloadScript(const char* script);
+ static bool tryLoadScript(const char* script, QString& errorMsg);
+
+ void onLogMessage(const LogMessage* message, ListResult& result);
+ void onValueMessage(const ValueMessage* message, ListResult& result);
+ void onActor2DMessage(const Update2DActorMessage* msg, Actor2DResult& result);
+
+ static QColor toQColor(uint16_t col) {
+ #define MAKE_DOUBLE(c) (((c)&0xF)<<4|((c)&0xF))
+ return QColor(MAKE_DOUBLE(col), MAKE_DOUBLE(col >> 4), MAKE_DOUBLE(col >> 8));
+ }
+
+private:
+ static void _luaopen(lua_State* L);
+
+private:
+ Config* m_config;
+ lua_State* L;
+
+public:
+ Filter();
+ virtual ~Filter();
+};
\ No newline at end of file
diff --git a/AxTrace/AT_Incoming.cpp b/AT4_Incoming.cpp
similarity index 78%
rename from AxTrace/AT_Incoming.cpp
rename to AT4_Incoming.cpp
index 167ab66..2511635 100644
--- a/AxTrace/AT_Incoming.cpp
+++ b/AT4_Incoming.cpp
@@ -1,29 +1,21 @@
-/***************************************************
+#include "stdafx.h"
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_Incoming.h"
-#include "AT_System.h"
-#include "AT_MessageQueue.h"
-#include "AT_Config.h"
-
-namespace AT3
-{
+#include "AT4_Incoming.h"
+#include "AT4_Interface.h"
+#include "AT4_System.h"
+#include "AT4_Config.h"
+#include "AT4_MessageQueue.h"
//--------------------------------------------------------------------------------------------
Incoming::Incoming()
- : m_server(0)
+ : m_server(nullptr)
{
}
//--------------------------------------------------------------------------------------------
Incoming::~Incoming()
{
- if (m_server){
+ if (m_server) {
delete m_server;
}
}
@@ -38,8 +30,8 @@ bool Incoming::init(void)
m_server = new cyclone::TcpServer("axtrace", nullptr);
m_server->m_listener.onMessage = std::bind(&Incoming::on_message, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
- m_server->bind(address, false);
- return m_server->start(2);
+ if (!(m_server->bind(address, false))) return false;
+ return m_server->start(cyclone::sys_api::get_cpu_counts());
}
//--------------------------------------------------------------------------------------------
@@ -49,8 +41,7 @@ void Incoming::on_message(cyclone::TcpServer* server, int32_t thread_index, cycl
if (System::getSingleton()->getConfig()->getCapture())
{
- SYSTEMTIME tTime;
- GetLocalTime(&tTime);
+ QDateTime timeNow = QDateTime::currentDateTime();
cyclone::RingBuf& input = conn->get_input_buf();
@@ -72,7 +63,7 @@ void Incoming::on_message(cyclone::TcpServer* server, int32_t thread_index, cycl
return;
}
- System::getSingleton()->getMessageQueue()->insertMessage(&input, head.length, &tTime);
+ System::getSingleton()->getMessageQueue()->insertMessage(&input, head.length, timeNow.time());
} while (true);
}
@@ -86,5 +77,3 @@ void Incoming::closeListen(void)
m_server->join();
}
-}
-
diff --git a/AxTrace/AT_Incoming.h b/AT4_Incoming.h
similarity index 57%
rename from AxTrace/AT_Incoming.h
rename to AT4_Incoming.h
index ca41347..f080b30 100644
--- a/AxTrace/AT_Incoming.h
+++ b/AT4_Incoming.h
@@ -1,22 +1,5 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
#pragma once
-namespace cyclone
-{
- class TcpServer;
- class Connection;
-}
-
-namespace AT3
-{
-
-/** Incoming module
-*/
class Incoming
{
public:
@@ -36,5 +19,3 @@ class Incoming
Incoming();
virtual ~Incoming();
};
-
-}
diff --git a/AxTrace/AT_Interface.h b/AT4_Interface.h
similarity index 63%
rename from AxTrace/AT_Interface.h
rename to AT4_Interface.h
index 9cba0f1..a0e480b 100644
--- a/AxTrace/AT_Interface.h
+++ b/AT4_Interface.h
@@ -1,14 +1,5 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
#pragma once
-namespace AT3
-{
-
/*---------------------------------------------------------------------------------------------*/
#define AXT_TRACE (0)
#define AXT_DEBUG (1)
@@ -37,15 +28,17 @@ namespace AT3
#define AXV_STR_UTF16 (12)
#define AXV_USER_DEF (100)
-#define AXTRACE_CMD_TYPE_LOG (1)
-#define AXTRACE_CMD_TYPE_VALUE (2)
-#define AXTRACE_CMD_TYPE_2D_CLEAN_MAP (3)
-#define AXTRACE_CMD_TYPE_2D_ACTOR (4)
+#define AXTRACE_CMD_TYPE_LOG (1)
+#define AXTRACE_CMD_TYPE_VALUE (2)
+#define AXTRACE_CMD_TYPE_2D_BEGIN_SCENE (3)
+#define AXTRACE_CMD_TYPE_2D_ACTOR (4)
+#define AXTRACE_CMD_TYPE_2D_END_SCENE (5)
#define AXTRACE_MAX_LOG_STRING_LENGTH (0x8000)
#define AXTRACE_MAX_VALUENAME_LENGTH (128)
#define AXTRACE_MAX_VALUE_LENGTH (1024)
-#define AXTRACE_MAX_MAP_NAME_LENGTH (128)
+#define AXTRACE_MAX_SCENE_NAME_LENGTH (128)
+#define AXTRACE_MAX_SCENE_DEFINE_LENGTH (2048)
/*---------------------------------------------------------------------------------------------*/
#pragma pack(push)
@@ -58,13 +51,13 @@ typedef struct
unsigned char type; /* command type AXTRACE_CMD_TYPE_* */
unsigned int pid; /* process id*/
unsigned int tid; /* thread id*/
- unsigned int style; /* trace style AXT_* */
} axtrace_head_s;
/* axtrace log data struct*/
typedef struct
{
axtrace_head_s head; /* common head */
+ unsigned int log_type; /* trace style AXT_* */
unsigned short code_page; /* code page */
unsigned short length; /* trace string length */
@@ -85,33 +78,45 @@ typedef struct
typedef struct
{
axtrace_head_s head; /* common head */
- double x_size; /* map size(x)*/
- double y_size; /* map size(y)*/
- unsigned short name_len; /* length of value name */
+ double left; /* left of scene*/
+ double top; /* top of scene*/
+ double right; /* right of scene*/
+ double bottom; /* bottom of scene*/
+ unsigned short name_len; /* length of scene name */
+ unsigned short define_len; /* length of scene define */
- /* [map name buf with '\0' ended]*/
-} axtrace_2d_clean_map_s;
+ /* [scene name buf with '\0' ended]*/
+ /* [scene define buf with '\0' ended]*/
+} axtrace_2d_begin_scene_s;
typedef struct
{
axtrace_head_s head; /* common head */
- unsigned int actor_id; /* id of actor */
+ __int64 actor_id; /* id of actor */
double x; /* position (x)*/
double y; /* position (y)*/
double dir; /* direction */
- unsigned short name_len; /* length of map name */
+ unsigned int style; /* user define style */
+ unsigned short name_len; /* length of scene name */
- /* [map name buf with '\0' ended]*/
+ /* [scene name buf with '\0' ended]*/
} axtrace_2d_actor_s;
typedef struct
{
- WORD wHour;
- WORD wMinute;
- WORD wSecond;
- WORD wMilliseconds;
-} AXIATRACE_TIME;
+ axtrace_head_s head; /* common head */
+ unsigned short name_len; /* length of scene name */
+
+ /* [scene name buf with '\0' ended]*/
+} axtrace_2d_end_scene_s;
+
+typedef struct
+{
+ unsigned short hour;
+ unsigned short minute;
+ unsigned short second;
+ unsigned short milliseconds;
+} axtrace_time_s;
#pragma pack(pop)
-}
diff --git a/AT4_LogChild.cpp b/AT4_LogChild.cpp
new file mode 100644
index 0000000..f7259bf
--- /dev/null
+++ b/AT4_LogChild.cpp
@@ -0,0 +1,309 @@
+#include "stdafx.h"
+
+#include "AT4_LogChild.h"
+#include "AT4_Message.h"
+#include "AT4_ChildInterface.h"
+#include "AT4_System.h"
+#include "AT4_Config.h"
+#include "AT4_MainWindow.h"
+
+//--------------------------------------------------------------------------------------------
+LogDataModel::LogDataModel(QObject *parent)
+ : QAbstractItemModel(parent)
+ , m_currentIndex(1)
+ , m_maxOverflowCounts(DEFAULT_MAX_OVERFLOW_COUNTS)
+{
+ m_maxLogCounts = System::getSingleton()->getConfig()->getMaxLogCounts();
+}
+
+//--------------------------------------------------------------------------------------------
+LogDataModel::~LogDataModel()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void LogDataModel::insertLog(const LogMessage* logMessage, const Filter::ListResult& filterResult)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount()+1);
+
+ LogData logData;
+ logData.logIndex = m_currentIndex++;
+ logData.logTime = logMessage->getTime();
+ logData.pid = logMessage->getProcessID();
+ logData.tid = logMessage->getThreadID();
+ logData.logContent = logMessage->getLog();
+ logData.backColor = Filter::toQColor(filterResult.backColor);
+ logData.frontColor = Filter::toQColor(filterResult.fontColor);
+
+ m_logVector.push_back(logData);
+
+ endInsertRows();
+}
+
+//--------------------------------------------------------------------------------------------
+void LogDataModel::clearAllLog(void)
+{
+ beginRemoveRows(QModelIndex(), 0, rowCount());
+ m_logVector.clear();
+ endRemoveRows();
+}
+
+//--------------------------------------------------------------------------------------------
+void LogDataModel::autoCheckOverflow(void)
+{
+ int currentCounts = m_logVector.size();
+
+ if (currentCounts > m_maxLogCounts + m_maxOverflowCounts) {
+ int needRemove = currentCounts - m_maxLogCounts;
+
+ beginRemoveRows(QModelIndex(), 0, needRemove-1);
+ m_logVector.erase(m_logVector.begin(), m_logVector.begin() + needRemove);
+ endRemoveRows();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+QVariant LogDataModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() >= m_logVector.size() || index.column() >= COLUMN_COUNTS)
+ return QVariant();
+
+ const LogData& logData = m_logVector[index.row()];
+
+ switch (role)
+ {
+ case Qt::BackgroundRole: return QBrush(logData.backColor);
+ case Qt::ForegroundRole: return QBrush(logData.frontColor);
+ case Qt::TextAlignmentRole: return QVariant(int(Qt::AlignLeft | Qt::AlignTop));
+ case Qt::DisplayRole: return data(index.row(), index.column());
+ default: return QVariant();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+QString LogDataModel::data(int row, int column) const
+{
+ if (row >= m_logVector.size() || column >= COLUMN_COUNTS)
+ return QString();
+
+ const LogData& logData = m_logVector[row];
+ switch (column)
+ {
+ case 0: return tr("%1").arg(logData.logIndex);
+ case 1: {
+ const axtrace_time_s& t = logData.logTime;
+ return tr("%1:%2 %3.%4")
+ .arg(t.hour, 2, 10, QLatin1Char('0'))
+ .arg(t.minute, 2, 10, QLatin1Char('0'))
+ .arg(t.second, 2, 10, QLatin1Char('0'))
+ .arg(t.milliseconds);
+ }
+ case 2: return tr("%1").arg(logData.pid);
+ case 3: return tr("%1").arg(logData.tid);
+ case 4: return logData.logContent;
+ default: return QString();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+Qt::ItemFlags LogDataModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+
+ return QAbstractItemModel::flags(index);
+}
+
+//--------------------------------------------------------------------------------------------
+QVariant LogDataModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ {
+ switch (section)
+ {
+ case 0: return tr("#");
+ case 1: return tr("Time");
+ case 2: return tr("PID");
+ case 3: return tr("TID");
+ case 4: return tr("Log");
+ default: return QString();
+ }
+ }
+
+ return QVariant();
+}
+
+//--------------------------------------------------------------------------------------------
+QModelIndex LogDataModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ if (!parent.isValid())
+ return createIndex(row, column);
+ else
+ return QModelIndex();
+}
+
+//--------------------------------------------------------------------------------------------
+class LogChildInterface : public IChild
+{
+public:
+ virtual Type getType(void) const { return CT_LOG; }
+
+ virtual bool copyAble(void) const {
+ return !(m_proxy->selectionModel()->selectedRows().empty());
+ }
+
+ virtual void onCopy(void) const
+ {
+ LogDataModel* model = (LogDataModel*)(m_proxy->model());
+
+ QModelIndexList rows = m_proxy->selectionModel()->selectedRows();
+ //sort by id
+ qSort(rows.begin(), rows.end(), [model](const QModelIndex &s1, const QModelIndex &s2){
+ return s1.row() < s2.row();
+ });
+
+ QString lines;
+ foreach(auto row, rows)
+ {
+ int rowIndex = row.row();
+ QString line = QString("%1\t%2\t%3\t%4\t%5\n").arg(
+ model->data(rowIndex, 0),
+ model->data(rowIndex, 1),
+ model->data(rowIndex, 2),
+ model->data(rowIndex, 3),
+ model->data(rowIndex, 4));
+
+ lines += line;
+ }
+
+ QApplication::clipboard()->setText(lines);
+ }
+
+ virtual QString getTitle(void) const {
+ return m_proxy->windowTitle();
+ }
+
+ virtual void clean(void)
+ {
+ LogDataModel* model = (LogDataModel*)(m_proxy->model());
+
+ model->clearAllLog();
+ update();
+ }
+
+ virtual void saveAs(void)
+ {
+ QString fileName = QFileDialog::getSaveFileName(nullptr, QString("Save As..."), QString("axtrace.log"), QString("Log file (*.log *.txt)"));
+ if (fileName.isEmpty()) return;
+
+ LogDataModel* model = (LogDataModel*)(m_proxy->model());
+
+ QFile file(fileName);
+ if (file.open(QFile::WriteOnly))
+ {
+ QTextStream stream(&file);
+ for (int rowIndex = 0; rowIndex < model->rowCount(); rowIndex++)
+ {
+ QString line = QString("%1\t%2\t%3\t%4\t%5\n").arg(
+ model->data(rowIndex, 0),
+ model->data(rowIndex, 1),
+ model->data(rowIndex, 2),
+ model->data(rowIndex, 3),
+ model->data(rowIndex, 4));
+ stream << line;
+ }
+ file.close();
+ }
+ }
+
+ virtual void update(void)
+ {
+ m_proxy->update();
+ }
+private:
+ LogChild* m_proxy;
+
+public:
+ LogChildInterface(LogChild* proxy) : m_proxy(proxy) { }
+ ~LogChildInterface() {}
+};
+
+//--------------------------------------------------------------------------------------------
+LogChild::LogChild(const QString& title)
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ m_title = title;
+ QString windowTitle = tr("Log:%1").arg(title);
+ setWindowTitle(windowTitle);
+
+ this->setUserData(0, new LogChildInterface(this));
+
+ m_bNeedScrollDown = false;
+}
+
+//--------------------------------------------------------------------------------------------
+LogChild::~LogChild()
+{
+ LogChildInterface* i = (LogChildInterface*)(this->userData(0));
+ delete i;
+
+ this->setUserData(0, nullptr);
+}
+
+//--------------------------------------------------------------------------------------------
+void LogChild::init(void)
+{
+ LogDataModel* model = new LogDataModel();
+
+ this->setModel(model);
+ this->header()->resizeSection(0, 40);
+ this->header()->resizeSection(0, 90);
+ this->header()->resizeSection(0, 50);
+ this->header()->resizeSection(0, 50);
+ this->setSortingEnabled(false);
+ this->setRootIsDecorated(false);
+ this->setSelectionMode(MultiSelection);
+
+ connect(this->selectionModel(), &QItemSelectionModel::selectionChanged, this, []() {
+ System::getSingleton()->getMainWindow()->notifySelectionChanged();
+ });
+
+ this->startTimer(100);
+}
+
+//--------------------------------------------------------------------------------------------
+void LogChild::closeEvent(QCloseEvent *event)
+{
+ System::getSingleton()->getMainWindow()->notifySubWindowClose(IChild::CT_LOG, m_title);
+ event->accept();
+}
+
+//--------------------------------------------------------------------------------------------
+void LogChild::timerEvent(QTimerEvent *event)
+{
+ if (m_bNeedScrollDown && System::getSingleton()->getConfig()->getAutoScroll()) {
+
+ this->scrollToBottom();
+ m_bNeedScrollDown = false;
+ }
+
+ LogDataModel* model = (LogDataModel*)(this->model());
+ model->autoCheckOverflow();
+}
+
+//--------------------------------------------------------------------------------------------
+void LogChild::insertLog(const LogMessage* logMessage, const Filter::ListResult& filterResult)
+{
+ LogDataModel* model = (LogDataModel*)(this->model());
+
+ model->insertLog(logMessage, filterResult);
+
+ m_bNeedScrollDown = true;
+ update();
+}
+
diff --git a/AT4_LogChild.h b/AT4_LogChild.h
new file mode 100644
index 0000000..9150969
--- /dev/null
+++ b/AT4_LogChild.h
@@ -0,0 +1,79 @@
+#pragma once
+
+#include
+#include
+#include
+#include "AT4_Filter.h"
+#include "AT4_Interface.h"
+
+class LogMessage;
+
+class LogDataModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ explicit LogDataModel(QObject *parent = 0);
+ ~LogDataModel();
+
+ void insertLog(const LogMessage* logMessage, const Filter::ListResult& filterResult);
+ void clearAllLog(void);
+ void autoCheckOverflow(void);
+
+ QVariant data(const QModelIndex &index, int role) const override;
+ QString data(int row, int column) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &index) const override {
+ return QModelIndex();
+ }
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override {
+ return m_logVector.size();
+ }
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override {
+ return COLUMN_COUNTS;
+ }
+
+private:
+ enum { COLUMN_COUNTS = 5, DEFAULT_MAX_OVERFLOW_COUNTS=10 };
+
+ struct LogData
+ {
+ quint32 logIndex;
+ axtrace_time_s logTime;
+ quint32 pid;
+ quint32 tid;
+ QString logContent;
+ QColor backColor;
+ QColor frontColor;
+ };
+
+ typedef QQueue LogVector;
+
+ LogVector m_logVector;
+ quint32 m_currentIndex;
+ qint32 m_maxLogCounts;
+ qint32 m_maxOverflowCounts;
+};
+
+class LogChild : public QTreeView
+{
+ Q_OBJECT
+
+public:
+ void init(void);
+ void insertLog(const LogMessage* logMessage, const Filter::ListResult& filterResult);
+
+protected:
+ void closeEvent(QCloseEvent *event) override;
+ void timerEvent(QTimerEvent *event) override;
+
+private:
+ QString m_title;
+ bool m_bNeedScrollDown;
+
+public:
+ LogChild(const QString& title);
+ virtual ~LogChild();
+};
diff --git a/AT4_LuaHighlighter.cpp b/AT4_LuaHighlighter.cpp
new file mode 100644
index 0000000..31f59d6
--- /dev/null
+++ b/AT4_LuaHighlighter.cpp
@@ -0,0 +1,131 @@
+#include "stdafx.h"
+#include "AT4_LuaHighlighter.h"
+
+//--------------------------------------------------------------------------------------------
+LuaHighlighter::LuaHighlighter(QTextDocument *parent)
+ : QSyntaxHighlighter(parent)
+{
+ HighlightingRule rule;
+
+ keywordFormat.setForeground(Qt::darkBlue);
+ keywordFormat.setFontWeight(QFont::Bold);
+ QStringList keywordPatterns;
+ keywordPatterns
+ << "\\band\\b"
+ << "\\bbreak\\b"
+ << "\\bdo\\b"
+ << "\\belse\\b"
+ << "\\belseif\\b"
+ << "\\bend\\b"
+ << "\\bfalse\\b"
+ << "\\bfor\\b"
+ << "\\bfunction\\b"
+ << "\\bif\\b"
+ << "\\bin\\b"
+ << "\\blocal\\b"
+ << "\\bnil\\b"
+ << "\\bnot\\b"
+ << "\\bor\\b"
+ << "\\brepeat\\b"
+ << "\\breturn\\b"
+ << "\\bthen\\b"
+ << "\\btrue\\b"
+ << "\\buntil\\b"
+ << "\\bwhile\\b";
+ foreach(const QString &pattern, keywordPatterns) {
+ rule.pattern = QRegularExpression(pattern);
+ rule.format = keywordFormat;
+ highlightingRules.append(rule);
+ }
+
+ functionFormat.setFontItalic(true);
+ functionFormat.setForeground(Qt::blue);
+ rule.pattern = QRegularExpression("\\b:\\s*[A-Za-z0-9_]+(?=\\()");
+ rule.format = functionFormat;
+ highlightingRules.append(rule);
+
+ keyFunctionFormat.setFontWeight(QFont::Bold);
+ keyFunctionFormat.setForeground(Qt::darkMagenta);
+ QStringList keyFunctions;
+ keyFunctions
+ << "\\bonLogMessage(?=\\()\\b"
+ << "\\bonValueMessage(?=\\()\\b"
+ << "\\bonActor2DMessage(?=\\()\\b";
+ foreach(const QString &pattern, keyFunctions) {
+ rule.pattern = QRegularExpression(pattern);
+ rule.format = keyFunctionFormat;
+ highlightingRules.append(rule);
+ }
+
+ keyEnumFormat.setForeground(Qt::darkMagenta);
+ QStringList keyEnums;
+ keyEnums
+ << "\\bCOL_BLACK\\b"
+
+ << "\\bCOL_WHITE\\b"
+ << "\\bCOL_RED\\b"
+ << "\\bCOL_GREEN\\b"
+ << "\\bCOL_BLUE\\b"
+ << "\\bCOL_GRAY\\b"
+ << "\\bCOL_YELLOW\\b"
+ << "\\bCOL_ORANGE\\b"
+ << "\\bCOL_VIOLET\\b"
+ << "\\bAXT_TRACE\\b"
+ << "\\bAXT_DEBUG\\b"
+ << "\\bAXT_INFO\\b"
+ << "\\bAXT_WARN\\b"
+ << "\\bAXT_ERROR\\b"
+ << "\\bAXT_FATAL\\b"
+ << "\\bAXT_USERDEF\\b"
+ << "\\bACTOR_CIRCLE\\b"
+ << "\\bACTOR_QUAD\\b";
+ foreach(const QString &pattern, keyEnums) {
+ rule.pattern = QRegularExpression(pattern);
+ rule.format = keyEnumFormat;
+ highlightingRules.append(rule);
+ }
+
+ singleLineCommentFormat.setForeground(Qt::darkGreen);
+ rule.pattern = QRegularExpression("--[^\n]*");
+ rule.format = singleLineCommentFormat;
+ highlightingRules.append(rule);
+
+ multiLineCommentFormat.setForeground(Qt::darkGreen);
+
+ commentStartExpression = QRegularExpression("--\\[\\[");
+ commentEndExpression = QRegularExpression("--\\]\\]");
+}
+
+//--------------------------------------------------------------------------------------------
+void LuaHighlighter::highlightBlock(const QString &text)
+{
+ foreach(const HighlightingRule &rule, highlightingRules) {
+ QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
+ while (matchIterator.hasNext()) {
+ QRegularExpressionMatch match = matchIterator.next();
+ setFormat(match.capturedStart(), match.capturedLength(), rule.format);
+ }
+ }
+
+ setCurrentBlockState(0);
+
+ int startIndex = 0;
+ if (previousBlockState() != 1)
+ startIndex = text.indexOf(commentStartExpression);
+
+ while (startIndex >= 0) {
+ QRegularExpressionMatch match = commentEndExpression.match(text, startIndex);
+ int endIndex = match.capturedStart();
+ int commentLength = 0;
+ if (endIndex == -1) {
+ setCurrentBlockState(1);
+ commentLength = text.length() - startIndex;
+ }
+ else {
+ commentLength = endIndex - startIndex
+ + match.capturedLength();
+ }
+ setFormat(startIndex, commentLength, multiLineCommentFormat);
+ startIndex = text.indexOf(commentStartExpression, startIndex + commentLength);
+ }
+}
diff --git a/AT4_LuaHighlighter.h b/AT4_LuaHighlighter.h
new file mode 100644
index 0000000..66de01d
--- /dev/null
+++ b/AT4_LuaHighlighter.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+QT_END_NAMESPACE
+
+class LuaHighlighter : public QSyntaxHighlighter
+{
+ Q_OBJECT
+
+public:
+ LuaHighlighter(QTextDocument *parent = 0);
+
+protected:
+ void highlightBlock(const QString &text) override;
+
+private:
+ struct HighlightingRule
+ {
+ QRegularExpression pattern;
+ QTextCharFormat format;
+ };
+ QVector highlightingRules;
+
+ QRegularExpression commentStartExpression;
+ QRegularExpression commentEndExpression;
+
+ QTextCharFormat keywordFormat;
+ QTextCharFormat keyFunctionFormat;
+ QTextCharFormat keyEnumFormat;
+ QTextCharFormat singleLineCommentFormat;
+ QTextCharFormat multiLineCommentFormat;
+ QTextCharFormat functionFormat;
+};
diff --git a/AT4_Main.cpp b/AT4_Main.cpp
new file mode 100644
index 0000000..e06224a
--- /dev/null
+++ b/AT4_Main.cpp
@@ -0,0 +1,19 @@
+#include "stdafx.h"
+
+#include "AT4_System.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(AT4);
+
+ QSurfaceFormat format;
+ format.setDepthBufferSize(24);
+ QSurfaceFormat::setDefaultFormat(format);
+
+ System theSystem;
+ if (!theSystem.init(argc, argv)) {
+ return 0;
+ }
+
+ return theSystem.run();
+}
diff --git a/AT4_MainWindow.cpp b/AT4_MainWindow.cpp
new file mode 100644
index 0000000..bfad1ba
--- /dev/null
+++ b/AT4_MainWindow.cpp
@@ -0,0 +1,545 @@
+#include "stdafx.h"
+
+#include "AT4_MainWindow.h"
+#include "AT4_LogChild.h"
+#include "AT4_ValueChild.h"
+#include "AT4_System.h"
+#include "AT4_MessageQueue.h"
+#include "AT4_Message.h"
+#include "AT4_Filter.h"
+#include "AT4_ChildInterface.h"
+#include "AT4_Config.h"
+#include "AT4_Map2DChild.h"
+#include "AT4_Scene2D.h"
+#include "AT4_SettingDialog.h"
+
+
+//--------------------------------------------------------------------------------------------
+MainWindow::MainWindow()
+ : m_mdiArea(new QMdiArea)
+{
+ m_mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ m_mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ //m_mdiArea->setViewMode(QMdiArea::TabbedView);
+ //m_mdiArea->setTabsClosable(true);
+ //m_mdiArea->setTabsMovable(true);
+ //m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
+
+ setCentralWidget(m_mdiArea);
+ connect(m_mdiArea, &QMdiArea::subWindowActivated,
+ this, &MainWindow::updateMenus);
+
+ createActions();
+ createStatusBar();
+ updateMenus();
+
+ _restoreSettings();
+
+ setWindowTitle(tr("AxTrace"));
+
+ setUnifiedTitleAndToolBarOnMac(true);
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::closeEvent(QCloseEvent *event)
+{
+ m_mdiArea->closeAllSubWindows();
+ if (m_mdiArea->currentSubWindow()) {
+ event->ignore();
+ } else {
+ System::getSingleton()->getConfig()->setMainGeometry(saveGeometry());
+ event->accept();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+bool MainWindow::event(QEvent* e)
+{
+ if (e->type() == AxTraceEvent::Type)
+ {
+ MessageVector msgVector;
+ System::getSingleton()->getMessageQueue()->popMessage(msgVector);
+
+ if (!msgVector.empty())
+ {
+ for (auto msg : msgVector)
+ {
+ _processAxTraceData(msg);
+ msg->reccycleMessage();
+ }
+ msgVector.clear();
+ }
+ }
+ return QMainWindow::event(e);
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_processAxTraceData(Message* msg)
+{
+ switch (msg->getType())
+ {
+ case AXTRACE_CMD_TYPE_LOG:
+ _insertLog((LogMessage*)msg);
+ break;
+
+ case AXTRACE_CMD_TYPE_VALUE:
+ _insertValue((ValueMessage*)msg);
+ break;
+
+ case AXTRACE_CMD_TYPE_2D_BEGIN_SCENE:
+ _begin2DScene((Begin2DSceneMessage*)msg);
+ break;
+
+ case AXTRACE_CMD_TYPE_2D_ACTOR:
+ _update2DActor((Update2DActorMessage*)msg);
+ break;
+
+ case AXTRACE_CMD_TYPE_2D_END_SCENE:
+ _end2DScene((End2DSceneMessage*)msg);
+ break;
+
+ default: break;
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_insertLog(LogMessage* msg)
+{
+ Filter::ListResult filterResult;
+ System::getSingleton()->getFilter()->onLogMessage(msg, filterResult);
+ if (!filterResult.display) return;
+
+ LogChild* child = getLogChild(filterResult.wndTitle);
+ assert(child);
+
+ child->insertLog(msg, filterResult);
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_insertValue(ValueMessage* msg)
+{
+ Filter::ListResult filterResult;
+ System::getSingleton()->getFilter()->onValueMessage(msg, filterResult);
+ if (!filterResult.display) return;
+
+ ValueChild* child = getValueChild(filterResult.wndTitle);
+ child->insertValue(msg, filterResult);
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_begin2DScene(Begin2DSceneMessage* msg)
+{
+ Map2DChild* child = getMap2DChild(msg->getSceneName());
+ child->beginScene(msg);
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_update2DActor(Update2DActorMessage* msg)
+{
+ Filter::Actor2DResult filterResult;
+ System::getSingleton()->getFilter()->onActor2DMessage(msg, filterResult);
+ if (!filterResult.display) return;
+
+ Map2DChild* child = getMap2DChild(msg->getSceneName());
+ child->updateActor(msg, filterResult);
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_end2DScene(End2DSceneMessage* msg)
+{
+ Map2DChild* child = getMap2DChild(msg->getSceneName());
+ child->endScene(msg);
+}
+
+//--------------------------------------------------------------------------------------------
+LogChild* MainWindow::getLogChild(const QString& title)
+{
+ auto it = m_logChildMap.find(title);
+ if (it != m_logChildMap.end()) return it.value();
+
+ LogChild *child = new LogChild(title);
+ QMdiSubWindow* parent = m_mdiArea->addSubWindow(child);
+
+ parent->resize(m_mdiArea->size()/2);
+
+ child->init();
+ child->show();
+
+ m_logChildMap.insert(title, child);
+ return child;
+}
+
+//--------------------------------------------------------------------------------------------
+ValueChild* MainWindow::getValueChild(const QString& title)
+{
+ auto it = m_valueChildMap.find(title);
+ if (it != m_valueChildMap.end()) return it.value();
+
+ ValueChild* child = new ValueChild(title);
+ QMdiSubWindow* parent = m_mdiArea->addSubWindow(child);
+
+ parent->resize(m_mdiArea->size() / 2);
+
+ child->init();
+ child->show();
+
+ m_valueChildMap.insert(title, child);
+ return child;
+}
+
+//--------------------------------------------------------------------------------------------
+Map2DChild* MainWindow::getMap2DChild(const QString& title)
+{
+ auto it = m_map2dChildMap.find(title);
+ if (it != m_map2dChildMap.end()) return it.value();
+
+ Map2DChild* child = new Map2DChild(title);
+
+ QMdiSubWindow* parent = m_mdiArea->addSubWindow(child);
+ parent->resize(m_mdiArea->size() / 2);
+
+ child->init(parent);
+ child->show();
+
+ m_map2dChildMap.insert(title, child);
+ return child;
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onSaveAs()
+{
+ IChild* activeChild = activeMdiChild();
+ if (activeChild)
+ activeChild->saveAs();
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onCapture()
+{
+ Config* config = System::getSingleton()->getConfig();
+ config->setCapture(!(config->getCapture()));
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onAutoScroll()
+{
+ Config* config = System::getSingleton()->getConfig();
+ config->setAutoScroll(!(config->getAutoScroll()));
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onShowGrid()
+{
+ Config* config = System::getSingleton()->getConfig();
+ config->setShowGrid(!(config->getShowGrid()));
+
+ auto windows = m_mdiArea->subWindowList();
+
+ foreach(auto window, windows) {
+ IChild *child = (IChild *)(window->widget()->userData(0));
+ if (child && child->getType()== IChild::CT_2DMAP)
+ child->update();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onCopy()
+{
+ IChild* activeChild = activeMdiChild();
+ if (activeChild)
+ activeChild->onCopy();
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onClean()
+{
+ IChild* activeChild = activeMdiChild();
+ if (activeChild)
+ activeChild->clean();
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onCleanAll()
+{
+ auto windows = m_mdiArea->subWindowList();
+
+ foreach(auto window, windows) {
+ IChild *child = (IChild *)(window->widget()->userData(0));
+ if (child)
+ child->clean();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onSetting()
+{
+ SettingDialog dialog(this);
+
+ if (dialog.exec() == QDialog::Accepted)
+ {
+ if (System::getSingleton()->getFilter()->reloadScript(dialog.getScript().toUtf8().toStdString().c_str()))
+ {
+ System::getSingleton()->getConfig()->setFilterScript(dialog.getScript());
+ }
+ else
+ {
+ //It should not happen
+ QMessageBox::critical(this, tr("AxTrace 4"), tr("LoadScript Error"), QMessageBox::Ok);
+ }
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_onAbout()
+{
+ QMessageBox msgBox;
+ msgBox.setWindowTitle(tr("About AxTrace"));
+ msgBox.setTextFormat(Qt::RichText);
+ msgBox.setText(tr("AXIA|Trace 4
Copyright www.thecodeway.com"));
+ msgBox.exec();
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::notifySubWindowClose(IChild::Type t, const QString& title)
+{
+ switch (t)
+ {
+ case IChild::CT_LOG:
+ {
+ m_logChildMap.remove(title);
+ }
+ break;
+
+ case IChild::CT_VALUE:
+ {
+ m_valueChildMap.remove(title);
+ }
+ break;
+
+ case IChild::CT_2DMAP:
+ {
+ m_map2dChildMap.remove(title);
+ }
+ break;
+
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::updateMenus()
+{
+ bool hasMdiChild = (activeMdiChild() != 0);
+ IChild* activeChild = activeMdiChild();
+ Config* config = System::getSingleton()->getConfig();
+
+ m_saveAsAct->setEnabled(hasMdiChild);
+ m_captureAct->setChecked(config->getCapture());
+
+ m_autoScrollAct->setEnabled(activeChild && activeChild->getType() == IChild::CT_LOG);
+ m_autoScrollAct->setChecked(config->getAutoScroll());
+
+ m_showGridAct->setEnabled(activeChild && activeChild->getType() == IChild::CT_2DMAP);
+ m_showGridAct->setChecked(config->getShowGrid());
+
+ m_copyAct->setEnabled(activeChild && activeChild->copyAble());
+ m_cleanAct->setEnabled(hasMdiChild);
+ m_cleanAllAct->setEnabled(hasMdiChild);
+
+ m_closeAct->setEnabled(hasMdiChild);
+ m_closeAllAct->setEnabled(hasMdiChild);
+ m_tileAct->setEnabled(hasMdiChild);
+ m_cascadeAct->setEnabled(hasMdiChild);
+ m_nextAct->setEnabled(hasMdiChild);
+ m_previousAct->setEnabled(hasMdiChild);
+ m_windowMenuSeparatorAct->setVisible(hasMdiChild);
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::updateWindowMenu()
+{
+ m_windowMenu->clear();
+ m_windowMenu->addAction(m_closeAct);
+ m_windowMenu->addAction(m_closeAllAct);
+ m_windowMenu->addSeparator();
+ m_windowMenu->addAction(m_tileAct);
+ m_windowMenu->addAction(m_cascadeAct);
+ m_windowMenu->addSeparator();
+ m_windowMenu->addAction(m_nextAct);
+ m_windowMenu->addAction(m_previousAct);
+ m_windowMenu->addAction(m_windowMenuSeparatorAct);
+
+ QList windows = m_mdiArea->subWindowList();
+ m_windowMenuSeparatorAct->setVisible(!windows.isEmpty());
+
+ for (int i = 0; i < windows.size(); ++i) {
+ QMdiSubWindow *mdiSubWindow = windows.at(i);
+ IChild *child = (IChild *)(mdiSubWindow->widget()->userData(0));
+
+ QString text = child->getTitle();
+
+ QAction *action = m_windowMenu->addAction(text, mdiSubWindow, [this, mdiSubWindow]() {
+ m_mdiArea->setActiveSubWindow(mdiSubWindow);
+ });
+ action->setCheckable(true);
+ action ->setChecked(child == activeMdiChild());
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::createActions()
+{
+ QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
+ QToolBar *mainToolBar = addToolBar(tr("Main"));
+
+ const QIcon saveAsIcon = QIcon::fromTheme("document-save-as", QIcon(":/images/save.png"));
+ m_saveAsAct = new QAction(saveAsIcon, tr("Save &As..."), this);
+ m_saveAsAct->setShortcuts(QKeySequence::SaveAs);
+ m_saveAsAct->setStatusTip(tr("Save the document under a new name"));
+ connect(m_saveAsAct, &QAction::triggered, this, &MainWindow::_onSaveAs);
+ fileMenu->addAction(m_saveAsAct);
+ mainToolBar->addAction(m_saveAsAct);
+
+ const QIcon captureIcon = QIcon(":/images/capture.png");
+ m_captureAct = new QAction(captureIcon, tr("&Capture"), this);
+ m_captureAct->setStatusTip(tr("Start/Stop capture"));
+ m_captureAct->setCheckable(true);
+ connect(m_captureAct, &QAction::triggered, this, &MainWindow::_onCapture);
+ fileMenu->addAction(m_captureAct);
+ mainToolBar->addAction(m_captureAct);
+
+ fileMenu->addSeparator();
+
+ const QIcon exitIcon = QIcon::fromTheme("application-exit");
+ QAction *exitAct = fileMenu->addAction(exitIcon, tr("E&xit"), qApp, &QApplication::closeAllWindows);
+ exitAct->setShortcuts(QKeySequence::Quit);
+ exitAct->setStatusTip(tr("Exit the application"));
+ fileMenu->addAction(exitAct);
+
+ mainToolBar->addSeparator();
+
+ //----------------------------
+ QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
+
+ const QIcon autoScrollIcon = QIcon(":/images/auto-scroll.png");
+ m_autoScrollAct = new QAction(autoScrollIcon, tr("Auto &Scroll"), this);
+ m_autoScrollAct->setStatusTip(tr("Auto scroll to latest log"));
+ m_autoScrollAct->setCheckable(true);
+ connect(m_autoScrollAct, &QAction::triggered, this, &MainWindow::_onAutoScroll);
+ editMenu->addAction(m_autoScrollAct);
+ mainToolBar->addAction(m_autoScrollAct);
+
+ const QIcon showGridIcon = QIcon(":/images/grid.png");
+ m_showGridAct = new QAction(showGridIcon, tr("Show &Grid"), this);
+ m_showGridAct->setStatusTip(tr("Show/Hide scene grid"));
+ m_showGridAct->setCheckable(true);
+ connect(m_showGridAct, &QAction::triggered, this, &MainWindow::_onShowGrid);
+ editMenu->addAction(m_showGridAct);
+ mainToolBar->addAction(m_showGridAct);
+
+
+ const QIcon copyIcon = QIcon::fromTheme("edit-copy", QIcon(":/images/copy.png"));
+ m_copyAct = new QAction(copyIcon, tr("&Copy"), this);
+ m_copyAct->setShortcuts(QKeySequence::Copy);
+ m_copyAct->setStatusTip(tr("Copy the current selection's contents to the clipboard"));
+ connect(m_copyAct, &QAction::triggered, this, &MainWindow::_onCopy);
+ editMenu->addAction(m_copyAct);
+ mainToolBar->addAction(m_copyAct);
+
+ const QIcon cleanIcon = QIcon(":/images/clean.png");
+ m_cleanAct = new QAction(cleanIcon, tr("C&lean"), this);
+ m_cleanAct->setStatusTip(tr("Clean current window"));
+ connect(m_cleanAct, &QAction::triggered, this, &MainWindow::_onClean);
+ editMenu->addAction(m_cleanAct);
+ mainToolBar->addAction(m_cleanAct);
+
+ const QIcon cleanAllIcon = QIcon(":/images/clean-all.png");
+ m_cleanAllAct = new QAction(cleanAllIcon, tr("Clean &All"), this);
+ m_cleanAllAct->setStatusTip(tr("Clean all windows"));
+ connect(m_cleanAllAct, &QAction::triggered, this, &MainWindow::_onCleanAll);
+ editMenu->addAction(m_cleanAllAct);
+ mainToolBar->addAction(m_cleanAllAct);
+
+ editMenu->addSeparator();
+ mainToolBar->addSeparator();
+
+ const QIcon settingIcon = QIcon(":/images/setting.png");
+ m_settingAct = new QAction(settingIcon, tr("S&etting..."), this);
+ m_settingAct->setStatusTip(tr("Open setting window"));
+ m_settingAct->setEnabled(true);
+ connect(m_settingAct, &QAction::triggered, this, &MainWindow::_onSetting);
+ editMenu->addAction(m_settingAct);
+ mainToolBar->addAction(m_settingAct);
+
+ //----------------------------
+
+ m_windowMenu = menuBar()->addMenu(tr("&Window"));
+ connect(m_windowMenu, &QMenu::aboutToShow, this, &MainWindow::updateWindowMenu);
+
+ m_closeAct = new QAction(tr("Cl&ose"), this);
+ m_closeAct->setStatusTip(tr("Close the active window"));
+ connect(m_closeAct, &QAction::triggered,
+ m_mdiArea, &QMdiArea::closeActiveSubWindow);
+
+ m_closeAllAct = new QAction(tr("Close &All"), this);
+ m_closeAllAct->setStatusTip(tr("Close all the windows"));
+ connect(m_closeAllAct, &QAction::triggered, m_mdiArea, &QMdiArea::closeAllSubWindows);
+
+ m_tileAct = new QAction(tr("&Tile"), this);
+ m_tileAct->setStatusTip(tr("Tile the windows"));
+ connect(m_tileAct, &QAction::triggered, m_mdiArea, &QMdiArea::tileSubWindows);
+
+ m_cascadeAct = new QAction(tr("&Cascade"), this);
+ m_cascadeAct->setStatusTip(tr("Cascade the windows"));
+ connect(m_cascadeAct, &QAction::triggered, m_mdiArea, &QMdiArea::cascadeSubWindows);
+
+ m_nextAct = new QAction(tr("Ne&xt"), this);
+ m_nextAct->setShortcuts(QKeySequence::NextChild);
+ m_nextAct->setStatusTip(tr("Move the focus to the next window"));
+ connect(m_nextAct, &QAction::triggered, m_mdiArea, &QMdiArea::activateNextSubWindow);
+
+ m_previousAct = new QAction(tr("Pre&vious"), this);
+ m_previousAct->setShortcuts(QKeySequence::PreviousChild);
+ m_previousAct->setStatusTip(tr("Move the focus to the previous window"));
+ connect(m_previousAct, &QAction::triggered, m_mdiArea, &QMdiArea::activatePreviousSubWindow);
+
+ m_windowMenuSeparatorAct = new QAction(this);
+ m_windowMenuSeparatorAct->setSeparator(true);
+
+ updateWindowMenu();
+
+ menuBar()->addSeparator();
+
+ QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
+
+ QAction *aboutAct = helpMenu->addAction(QIcon(":/images/about.png"), tr("&About"), this, &MainWindow::_onAbout);
+ aboutAct->setStatusTip(tr("Show the application's About box"));
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::createStatusBar()
+{
+ statusBar()->showMessage(tr("Ready"));
+}
+
+//--------------------------------------------------------------------------------------------
+void MainWindow::_restoreSettings(void)
+{
+ const QByteArray& geometry = System::getSingleton()->getConfig()->getMainGeometry();
+
+ if (geometry.isEmpty()) {
+ const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
+ resize(availableGeometry.width() / 2, availableGeometry.height() / 2);
+ move((availableGeometry.width() - width()) / 2,
+ (availableGeometry.height() - height()) / 2);
+ } else {
+ restoreGeometry(geometry);
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+IChild *MainWindow::activeMdiChild() const
+{
+ if (QMdiSubWindow *activeSubWindow = m_mdiArea->activeSubWindow())
+ return (IChild *)(activeSubWindow->widget()->userData(0));
+ return nullptr;
+}
diff --git a/AT4_MainWindow.h b/AT4_MainWindow.h
new file mode 100644
index 0000000..5fe92b9
--- /dev/null
+++ b/AT4_MainWindow.h
@@ -0,0 +1,126 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include
+#include
+#include "AT4_ChildInterface.h"
+
+class IChild;
+class LogChild;
+class ValueChild;
+class Map2DChild;
+class Message;
+class LogMessage;
+class ValueMessage;
+class Begin2DSceneMessage;
+class Update2DActorMessage;
+class End2DSceneMessage;
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QMenu;
+class QMdiArea;
+class QMdiSubWindow;
+class QCustomEvent;
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public:
+
+ class AxTraceEvent : public QEvent
+ {
+ public:
+ enum { Type = QEvent::User + 100 };
+
+ AxTraceEvent() : QEvent((QEvent::Type)Type) {}
+ ~AxTraceEvent() {}
+ };
+
+public:
+ LogChild* getLogChild(const QString& title);
+ ValueChild* getValueChild(const QString& title);
+ Map2DChild* getMap2DChild(const QString& title);
+
+ void notifySelectionChanged(void)
+ {
+ updateMenus();
+ }
+
+ void notifySubWindowClose(IChild::Type t, const QString& title);
+
+private:
+ void _processAxTraceData(Message* msg);
+ void _insertLog(LogMessage* msg);
+ void _insertValue(ValueMessage* msg);
+ void _begin2DScene(Begin2DSceneMessage* msg);
+ void _update2DActor(Update2DActorMessage* msg);
+ void _end2DScene(End2DSceneMessage* msg);
+
+private:
+ typedef QMap LogChildMap;
+ LogChildMap m_logChildMap;
+
+ typedef QMap ValueChildMap;
+ ValueChildMap m_valueChildMap;
+
+ typedef QMap Map2DChildMap;
+ Map2DChildMap m_map2dChildMap;
+
+private slots:
+ void _onSaveAs();
+ void _onCapture();
+ void _onAutoScroll();
+ void _onShowGrid();
+ void _onCopy();
+ void _onClean();
+ void _onCleanAll();
+ void _onSetting();
+ void _onAbout();
+
+ void updateMenus();
+ void updateWindowMenu();
+
+private:
+ void closeEvent(QCloseEvent *event) override;
+ bool event(QEvent* e) override;
+
+ void createActions();
+ void createStatusBar();
+
+ void _restoreSettings(void);
+
+ IChild *activeMdiChild() const;
+
+ QMdiArea *m_mdiArea;
+
+ QMenu *m_windowMenu;
+
+ QAction* m_saveAsAct;
+ QAction* m_captureAct;
+
+ QAction* m_autoScrollAct;
+ QAction* m_showGridAct;
+ QAction* m_copyAct;
+ QAction* m_cleanAct;
+ QAction* m_cleanAllAct;
+
+ QAction* m_settingAct;
+ QAction* m_aboutAct;
+
+ QAction *m_closeAct;
+ QAction *m_closeAllAct;
+ QAction *m_tileAct;
+ QAction *m_cascadeAct;
+ QAction *m_nextAct;
+ QAction *m_previousAct;
+
+ QAction *m_windowMenuSeparatorAct;
+};
+
+#endif
diff --git a/AT4_Map2DChild.cpp b/AT4_Map2DChild.cpp
new file mode 100644
index 0000000..c59153f
--- /dev/null
+++ b/AT4_Map2DChild.cpp
@@ -0,0 +1,403 @@
+#include "stdafx.h"
+
+#include "AT4_Map2DChild.h"
+#include "AT4_ChildInterface.h"
+#include "AT4_Scene2D.h"
+#include "AT4_Camera2D.h"
+#include "AT4_System.h"
+#include "AT4_MainWindow.h"
+#include "AT4_Message.h"
+#include "AT4_System.h"
+#include "AT4_Config.h"
+
+//--------------------------------------------------------------------------------------------
+class Map2DChildInterface : public IChild
+{
+public:
+ virtual Type getType(void) const { return CT_2DMAP; }
+
+ virtual QString getTitle(void) const {
+ return m_proxy->windowTitle();
+ }
+
+ virtual bool copyAble(void) const {
+ return false;
+ }
+
+ virtual void onCopy(void) const {
+
+ }
+
+ virtual void clean(void)
+ {
+ m_proxy->clean();
+ }
+
+ virtual void saveAs(void) {
+
+ }
+
+ virtual void update(void)
+ {
+ m_proxy->update();
+ }
+
+private:
+ Map2DChild* m_proxy;
+
+public:
+ Map2DChildInterface(Map2DChild* proxy) : m_proxy(proxy) { }
+ ~Map2DChildInterface() {}
+};
+
+//--------------------------------------------------------------------------------------------
+QPen* Map2DChild::m_cachedPen[Map2DChild::MAX_COLOR_COUNTS] = { nullptr };
+QBrush* Map2DChild::m_cachedBrush[Map2DChild::MAX_COLOR_COUNTS] = { nullptr };
+
+//--------------------------------------------------------------------------------------------
+Map2DChild::Map2DChild(const QString& title)
+ : m_scene(nullptr)
+ , m_camera(nullptr)
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ m_title = title;
+ QString windowTitle = tr("2DMap:%1").arg(title);
+ setWindowTitle(windowTitle);
+ setAutoFillBackground(false);
+
+ m_camera = new Camera2D();
+ this->setUserData(0, new Map2DChildInterface(this));
+}
+
+//--------------------------------------------------------------------------------------------
+Map2DChild::~Map2DChild()
+{
+ Map2DChildInterface* i = (Map2DChildInterface*)(this->userData(0));
+ delete i;
+
+ this->setUserData(0, nullptr);
+ delete m_camera;
+ delete m_scene;
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::init(QWidget* parent)
+{
+ this->setParent(parent);
+
+ m_backgroundBrush = QBrush(QColor(83, 83, 83));
+ m_sceneBrush = QBrush(QColor(77, 128, 244));
+ m_sceneBorderPen = QPen(Qt::white);
+ m_sceneGridPen = QPen(Qt::gray);
+ m_infoTextPen = QPen(Qt::white);
+ m_infoTextFont.setPixelSize(16);
+ setMouseTracking(true);
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::clean(void)
+{
+ if (m_scene)
+ {
+ m_scene->clean();
+ update();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::beginScene(Begin2DSceneMessage* msg)
+{
+ if (!m_scene)
+ {
+ m_scene = new Scene2D(msg);
+ m_camera->reset(size(), m_scene->getSceneRect());
+ }
+
+ m_scene->beginScene(msg);
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::updateActor(Update2DActorMessage* msg, const Filter::Actor2DResult& filterResult)
+{
+ if (m_scene)
+ {
+ m_scene->updateActor(msg, filterResult);
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::endScene(End2DSceneMessage* msg)
+{
+ if (m_scene)
+ {
+ m_scene->endScene(msg);
+ m_camera->reset(size(), m_scene->getSceneRect());
+ }
+
+ update();
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::closeEvent(QCloseEvent *event)
+{
+ System::getSingleton()->getMainWindow()->notifySubWindowClose(IChild::CT_2DMAP, m_title);
+ event->accept();
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::mousePressEvent(QMouseEvent *e)
+{
+ if (!m_camera) return;
+
+ if (e->button() == Qt::LeftButton) {
+ grabMouse();
+ m_camera->beginDrag(e);
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::mouseMoveEvent(QMouseEvent *e)
+{
+ if (!m_camera) return;
+
+ m_cursorPosView = QPointF(e->pos());
+ m_cursorPosScene = m_camera->screenToScene(e->pos());
+ if (m_camera->isDraging()) {
+ m_camera->drag(e);
+ }
+
+ update();
+}
+//--------------------------------------------------------------------------------------------
+void Map2DChild::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (!m_camera) return;
+
+ if (e->button() == Qt::LeftButton) {
+ releaseMouse();
+ m_camera->endDrag(e);
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::wheelEvent(QWheelEvent *e)
+{
+ if (!m_camera) return;
+
+ m_camera->onMouseWheel(e);
+ update();
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::resizeGL(int w, int h)
+{
+ if (!m_camera) return;
+
+ m_camera->updateViewSize(QSize(w, h));
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::paintEvent(QPaintEvent *event)
+{
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
+
+ painter.fillRect(event->rect(), m_backgroundBrush);
+ QString mouseTips;
+
+ painter.save();
+ if (m_scene)
+ {
+ painter.setTransform(m_camera->getTransform());
+
+ const QRectF& sceneRect = m_scene->getSceneRect();
+
+ //scene background
+ m_sceneBorderPen.setWidthF(1.0 / m_camera->getScale());
+ painter.setPen(m_sceneBorderPen);
+ painter.fillRect(m_scene->getSceneRect(), m_sceneBrush);
+
+ //scene grid
+ if (m_scene->isGridDefined() && System::getSingleton()->getConfig()->getShowGrid())
+ {
+ m_sceneGridPen.setWidthF(1.0 / m_camera->getScale());
+ painter.setPen(m_sceneGridPen);
+
+ _drawGrid(painter);
+ }
+
+ Filter* filter = System::getSingleton()->getFilter();
+
+ //actor
+ m_scene->walk([&](const Scene2D::Actor& actor)
+ {
+ painter.setBrush(getCachedBrush(actor.fillColor));
+
+ QPen& actorPen = getCachedPen(actor.borderColor);
+ actorPen.setWidthF(1.0 / m_camera->getScale());
+ painter.setPen(actorPen);
+
+ painter.save();
+
+ QTransform localMove = QTransform::fromTranslate(actor.pos.x(), actor.pos.y());
+ localMove.rotateRadians(actor.dir);
+ painter.setTransform(localMove, true);
+
+ _getMouseTips(painter.transform(), actor, mouseTips);
+
+ switch (actor.type)
+ {
+ case Filter::AT_CIRCLE:
+ {
+ painter.drawEllipse(QPointF(0.0, 0.0), actor.size, actor.size);
+ painter.drawLine(QPointF(0.0, 0.0), QPointF(actor.size*1.2, 0.0));
+ }
+ break;
+
+ case Filter::AT_QUAD:
+ {
+ painter.drawRect(QRectF(-actor.size, -actor.size, actor.size*2, actor.size*2));
+ painter.drawLine(QPointF(0.0, 0.0), QPointF(actor.size*1.2, 0.0));
+ }
+ break;
+ }
+
+ painter.restore();
+ });
+ }
+ painter.restore();
+
+ if (m_scene)
+ {
+ painter.setPen(m_infoTextPen);
+ painter.setFont(m_infoTextFont);
+
+ QString infoText = QString("SceneSize:%1,%2\nMouse:%3,%4\n%5")
+ .arg(abs(m_scene->getSceneRect().width()))
+ .arg(abs(m_scene->getSceneRect().height()))
+ .arg(m_cursorPosScene.x())
+ .arg(m_cursorPosScene.y())
+ .arg(mouseTips);
+ painter.drawText(QRect(0, 0, m_camera->getViewSize().width(), m_camera->getViewSize().height()), Qt::AlignLeft|Qt::AlignTop, infoText);
+ }
+
+ painter.end();
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::_drawGrid(QPainter& painter)
+{
+ const QRectF& sceneRect = m_scene->getSceneRect();
+ const QSizeF& gridSize = m_scene->getGridSize();
+
+ //draw v line
+ double minX = qMin(sceneRect.left(), sceneRect.left() + sceneRect.width());
+ double maxX = qMax(sceneRect.left(), sceneRect.left() + sceneRect.width());
+
+ for (double x = m_scene->getGridPoint().x(); x > minX; x -= gridSize.width())
+ {
+ if (x < maxX) {
+ painter.drawLine(QPointF(x, sceneRect.bottom()), QPointF(x, sceneRect.top()));
+ }
+ }
+
+ for (double x = m_scene->getGridPoint().x() + gridSize.width(); x < maxX; x += gridSize.width())
+ {
+ if (x > minX) {
+ painter.drawLine(QPointF(x, sceneRect.bottom()), QPointF(x, sceneRect.top()));
+ }
+ }
+
+ //draw h line
+ double minY = qMin(sceneRect.top(), sceneRect.top()+sceneRect.height());
+ double maxY = qMax(sceneRect.top(), sceneRect.top() + sceneRect.height());
+
+ for (double y = m_scene->getGridPoint().y(); y > minY; y-=gridSize.height())
+ {
+ if (y < maxY) {
+ painter.drawLine(QPointF(sceneRect.left(), y), QPointF(sceneRect.right(), y));
+ }
+ }
+
+ for (double y = m_scene->getGridPoint().y() + gridSize.height(); y < maxY; y += gridSize.height())
+ {
+ if (y > minY)
+ {
+ painter.drawLine(QPointF(sceneRect.left(), y), QPointF(sceneRect.right(), y));
+ }
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::_getMouseTips(const QTransform& localMove, const Scene2D::Actor& actor, QString& mouseTips)
+{
+ //calc cursor pos
+ bool invertible;
+ QTransform localMoveInvert = localMove.inverted(&invertible);
+ if (!invertible) return;
+
+ QPointF pos = localMoveInvert * m_cursorPosView;
+
+ switch (actor.type)
+ {
+ case Filter::AT_CIRCLE:
+ {
+ if (QPointF::dotProduct(pos, pos) > (actor.size*actor.size)) return;
+ }
+ break;
+
+ case Filter::AT_QUAD:
+ {
+ if (pos.x() < -actor.size || pos.x() > actor.size || pos.y() < -actor.size || pos.y() > actor.size) return;
+ }
+ break;
+
+ default: return;
+ }
+
+ QString tips = QString("-------------\nID:%1\nPos:%2,%3\n")
+ .arg(actor.actorID)
+ .arg(actor.pos.x()).arg(actor.pos.y());
+
+ mouseTips += tips;
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::initCachedObject(void)
+{
+ for (int i = 0; i < MAX_COLOR_COUNTS; i++) {
+ m_cachedPen[i] = nullptr;
+ m_cachedBrush[i] = nullptr;
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Map2DChild::deleteCachedObject(void)
+{
+ for (int i = 0; i < MAX_COLOR_COUNTS; i++) {
+ if (m_cachedPen[i] != nullptr) delete m_cachedPen[i];
+ if (m_cachedBrush[i] != nullptr) delete m_cachedBrush[i];
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+QPen& Map2DChild::getCachedPen(uint16_t color)
+{
+ QPen* pen = m_cachedPen[color & 0xFFF];
+ if (pen != nullptr) return *pen;
+
+ pen = m_cachedPen[color & 0xFFF] = new QPen(Filter::toQColor(color));
+ return *pen;
+}
+
+//--------------------------------------------------------------------------------------------
+QBrush& Map2DChild::getCachedBrush(uint16_t color)
+{
+ QBrush* brush = m_cachedBrush[color & 0xFFF];
+ if (brush != nullptr) return *brush;
+
+ brush = m_cachedBrush[color & 0xFFF] = new QBrush(Filter::toQColor(color));
+ return *brush;
+}
diff --git a/AT4_Map2DChild.h b/AT4_Map2DChild.h
new file mode 100644
index 0000000..b8c4941
--- /dev/null
+++ b/AT4_Map2DChild.h
@@ -0,0 +1,74 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include "AT4_Scene2D.h"
+
+#include "AT4_Filter.h"
+
+class Camera2D;
+class Begin2DSceneMessage;
+class Update2DActorMessage;
+class End2DSceneMessage;
+
+class Map2DChild : public QOpenGLWidget, protected QOpenGLFunctions
+{
+ Q_OBJECT
+
+public:
+ void init(QWidget* parent);
+ void clean(void);
+ void beginScene(Begin2DSceneMessage* msg);
+ void updateActor(Update2DActorMessage* msg, const Filter::Actor2DResult& filterResult);
+ void endScene(End2DSceneMessage* msg);
+
+protected:
+ void closeEvent(QCloseEvent *event) override;
+ void mousePressEvent(QMouseEvent *e) override;
+ void mouseMoveEvent(QMouseEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent *e) override;
+ void wheelEvent(QWheelEvent *e) override;
+
+ void paintEvent(QPaintEvent *event) override;
+ void resizeGL(int w, int h) override;
+
+private:
+ QString m_title;
+
+ QBrush m_backgroundBrush;
+ QBrush m_sceneBrush;
+ QPen m_sceneBorderPen;
+ QPen m_sceneGridPen;
+ QPen m_infoTextPen;
+ QFont m_infoTextFont;
+
+ Scene2D* m_scene;
+ Camera2D* m_camera;
+
+ QPointF m_cursorPosView;
+ QPointF m_cursorPosScene;
+
+private:
+ void _getMouseTips(const QTransform& localMove, const Scene2D::Actor& actor, QString& mouseTips);
+ void _drawGrid(QPainter& painter);
+
+public:
+ static void initCachedObject(void);
+ static void deleteCachedObject(void);
+
+private:
+ static QPen& getCachedPen(uint16_t color);
+ static QBrush& getCachedBrush(uint16_t color);
+
+ enum { MAX_COLOR_COUNTS = 0xFFF };
+ static QPen* m_cachedPen[MAX_COLOR_COUNTS];
+ static QBrush* m_cachedBrush[MAX_COLOR_COUNTS];
+
+public:
+ Map2DChild(const QString& title);
+ virtual ~Map2DChild();
+};
+
diff --git a/AT4_Message.cpp b/AT4_Message.cpp
new file mode 100644
index 0000000..a43d53e
--- /dev/null
+++ b/AT4_Message.cpp
@@ -0,0 +1,558 @@
+#include "stdafx.h"
+#include "AT4_Message.h"
+
+//--------------------------------------------------------------------------------------------
+Message::Message()
+ : m_processID(0)
+ , m_threadID(0)
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+Message::~Message()
+{
+
+}
+
+//-------------------------------------------------------------------------------------
+int Message::_lua_get_type(lua_State *L)
+{
+ const Message* msg = (const Message*)lua_touserdata(L, 1);
+ lua_pushinteger(L, msg->getType());
+ return 1;
+}
+
+//-------------------------------------------------------------------------------------
+int Message::_lua_get_process_id(lua_State *L)
+{
+ const Message* msg = (const Message*)lua_touserdata(L, 1);
+ lua_pushinteger(L, msg->getProcessID());
+ return 1;
+}
+
+//-------------------------------------------------------------------------------------
+int Message::_lua_get_thread_id(lua_State *L)
+{
+ const Message* msg = (const Message*)lua_touserdata(L, 1);
+ lua_pushinteger(L, msg->getThreadID());
+ return 1;
+}
+
+//--------------------------------------------------------------------------------------------
+QQueue LogMessage::s_messagePool;
+
+//--------------------------------------------------------------------------------------------
+LogMessage::LogMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+LogMessage::~LogMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void LogMessage::build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
+{
+ static QThreadStorage memoryCache;
+
+ memcpy(&m_time, &traceTime, sizeof(axtrace_time_s));
+ m_processID = head.pid;
+ m_threadID = head.tid;
+
+ axtrace_log_s logHead;
+ size_t len = ringBuf->memcpy_out(&logHead, sizeof(axtrace_log_s));
+ assert(len == sizeof(axtrace_log_s));
+
+ m_logType = logHead.log_type;
+
+ int logLength = logHead.length;
+
+ QByteArray& cache = memoryCache.localData();
+ if (cache.size() < logLength + 2)
+ cache.resize(logLength + 2);
+
+ len = ringBuf->memcpy_out(cache.data(), logLength);
+ assert(len == logLength);
+
+ cache.data()[logLength] = 0;
+ cache.data()[logLength+1] = 0;
+
+ switch (logHead.code_page)
+ {
+ case ATC_UTF16:
+ m_log = QString::fromUtf16((const ushort*)cache.data());
+ break;
+ case ATC_UTF8:
+ m_log = QString::fromUtf8(cache);
+ break;
+ case ATC_ACP:
+ m_log = QString::fromLocal8Bit(cache);
+ break;
+ }
+}
+
+
+//-------------------------------------------------------------------------------------
+int LogMessage::_lua_get_log_type(lua_State *L)
+{
+ const LogMessage* msg = (const LogMessage*)lua_touserdata(L, 1);
+ lua_pushinteger(L, msg->getLogType());
+ return 1;
+}
+
+//-------------------------------------------------------------------------------------
+int LogMessage::_lua_get_log(lua_State *L)
+{
+ const LogMessage* msg = (const LogMessage*)lua_touserdata(L, 1);
+
+ QByteArray msgUtf8 = msg->getLog().toUtf8();
+ lua_pushstring(L, msgUtf8.data());
+
+ return 1;
+}
+
+//--------------------------------------------------------------------------------------------
+const char* LogMessage::MetaName = "AxTrace.LogMessage";
+
+void LogMessage::_luaopen(lua_State *L)
+{
+ static luaL_Reg msg_data_meta[] =
+ {
+ { "get_type", Message::_lua_get_type },
+ { "get_pid", Message::_lua_get_process_id },
+ { "get_tid", Message::_lua_get_thread_id },
+
+ { "get_log_type", LogMessage::_lua_get_log_type },
+ { "get_log", LogMessage::_lua_get_log },
+
+ { 0, 0 }
+ };
+
+
+ //PlayerData meta table
+ luaL_newmetatable(L, LogMessage::MetaName);
+ lua_pushvalue(L, -1); /* push metatable */
+ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
+
+ luaL_register(L, NULL, msg_data_meta); /* file methods */
+}
+
+//--------------------------------------------------------------------------------------------
+QQueue ValueMessage::s_messagePool;
+
+//--------------------------------------------------------------------------------------------
+ValueMessage::ValueMessage()
+ : m_valueBuf(nullptr)
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+ValueMessage::~ValueMessage()
+{
+ if (m_valueBuf && m_valueBuf != m_standValueBuf)
+ {
+ delete[] m_valueBuf;
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueMessage::build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
+{
+ memcpy(&m_time, &traceTime, sizeof(axtrace_time_s));
+ m_processID = head.pid;
+ m_threadID = head.tid;
+
+ axtrace_value_s value_head;
+ size_t len = ringBuf->memcpy_out(&value_head, sizeof(value_head));
+ assert(len == sizeof(value_head));
+
+ m_valueType = value_head.value_type;
+ m_valueSize = value_head.value_len;
+
+ //copy name
+ char tempName[AXTRACE_MAX_VALUENAME_LENGTH];
+ int name_length = value_head.name_len;
+ //TODO: check name length
+ len = ringBuf->memcpy_out(tempName, name_length);
+ assert(len == name_length);
+ tempName[name_length - 1] = 0; //make sure last char is '\0'
+ m_name = QString::fromUtf8(tempName);
+
+ //value
+ if (m_valueSize > STANDARD_VALUE_SIZE)
+ {
+ //big value
+ m_valueBuf = new char[m_valueSize];
+ memset(m_valueBuf, 0, m_valueSize);
+ }
+ else
+ {
+ m_valueBuf = m_standValueBuf;
+ }
+
+ //value
+ len = ringBuf->memcpy_out(m_valueBuf, m_valueSize);
+ assert(len == m_valueSize);
+
+ //make sure '\0' ended
+ if (m_valueType == AXV_STR_ACP || m_valueType == AXV_STR_UTF8)
+ {
+ ((char*)m_valueBuf)[m_valueSize - 1] = 0;
+ }
+ else if (m_valueType == AXV_STR_UTF16)
+ {
+ ((char*)m_valueBuf)[m_valueSize - 1] = 0;
+ ((char*)m_valueBuf)[m_valueSize - 2] = 0;
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueMessage::getValueAsString(QString& value) const
+{
+ const static QString ERROR_VALUE("");
+
+ switch (m_valueType)
+ {
+ case AXV_INT8:
+ value = QString::number(*((int8_t*)m_valueBuf));
+ break;
+
+ case AXV_UINT8:
+ value = QString::number(*((uint8_t*)m_valueBuf));
+ break;
+
+ case AXV_INT16:
+ value = QString::number(*((int16_t*)m_valueBuf));
+ break;
+
+ case AXV_UINT16:
+ value = QString::number(*((uint16_t*)m_valueBuf));
+ break;
+
+ case AXV_INT32:
+ value = QString::number(*((int32_t*)m_valueBuf));
+ break;
+
+ case AXV_UINT32:
+ value = QString::number(*((uint32_t*)m_valueBuf));
+ break;
+
+ case AXV_INT64:
+ value = QString::number(*((int64_t*)m_valueBuf));
+ break;
+
+ case AXV_UINT64:
+ value = QString::number(*((uint64_t*)m_valueBuf));
+ break;
+
+ case AXV_FLOAT32:
+ value = QString::number(*((float*)m_valueBuf));
+ break;
+
+ case AXV_FLOAT64:
+ value = QString::number(*((double*)m_valueBuf));
+ break;
+
+ case AXV_STR_UTF16:
+ value = QString::fromUtf16((const ushort*)m_valueBuf);
+ break;
+
+ case AXV_STR_UTF8:
+ value = QString::fromUtf8((const char*)m_valueBuf);
+ break;
+
+ case AXV_STR_ACP:
+ value = QString::fromLocal8Bit((const char*)m_valueBuf);
+ break;
+
+ default:
+ value = ERROR_VALUE;
+ break;
+ }
+}
+
+//-------------------------------------------------------------------------------------
+int ValueMessage::_lua_get_value(lua_State *L)
+{
+ const ValueMessage* msg = (const ValueMessage*)lua_touserdata(L, 1);
+
+ QString value_as_string;
+ msg->getValueAsString(value_as_string);
+
+ QByteArray msgUtf8 = value_as_string.toUtf8();
+ lua_pushstring(L, msgUtf8.data());
+ return 1;
+}
+
+//--------------------------------------------------------------------------------------------
+const char* ValueMessage::MetaName = "AxTrace.ValueMessage";
+
+void ValueMessage::_luaopen(lua_State *L)
+{
+ static luaL_Reg msg_data_meta[] =
+ {
+ { "get_type", Message::_lua_get_type },
+ { "get_pid", Message::_lua_get_process_id },
+ { "get_tid", Message::_lua_get_thread_id },
+
+ { "get_value", ValueMessage::_lua_get_value },
+
+ { 0, 0 }
+ };
+
+
+ //PlayerData meta table
+ luaL_newmetatable(L, ValueMessage::MetaName);
+ lua_pushvalue(L, -1); /* push metatable */
+ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
+
+ luaL_register(L, NULL, msg_data_meta); /* file methods */
+}
+
+//--------------------------------------------------------------------------------------------
+QQueue Begin2DSceneMessage::s_messagePool;
+
+//--------------------------------------------------------------------------------------------
+Begin2DSceneMessage::Begin2DSceneMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+Begin2DSceneMessage::~Begin2DSceneMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void Begin2DSceneMessage::build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
+{
+ memcpy(&m_time, &traceTime, sizeof(axtrace_time_s));
+ m_processID = head.pid;
+ m_threadID = head.tid;
+
+ axtrace_2d_begin_scene_s value_head;
+ size_t len = ringBuf->memcpy_out(&value_head, sizeof(value_head));
+ assert(len == sizeof(value_head));
+
+ m_sceneRect = QRectF(value_head.left, value_head.top, value_head.right-value_head.left, value_head.bottom-value_head.top);
+
+ //copy name
+ char tempBuf[AXTRACE_MAX_SCENE_DEFINE_LENGTH];
+ int name_length = value_head.name_len;
+ //TODO: check name length
+ len = ringBuf->memcpy_out(tempBuf, name_length);
+ assert(len == name_length);
+ tempBuf[name_length - 1] = 0; //make sure last char is '\0'
+ m_sceneName = QString::fromUtf8(tempBuf);
+
+ //copy define
+ int define_length = value_head.define_len;
+ len = ringBuf->memcpy_out(tempBuf, define_length);
+ assert(len == define_length);
+ tempBuf[define_length] = 0;
+
+ //make json object
+ if (define_length > 0)
+ {
+ QJsonParseError jerror;
+ QJsonDocument jsonDocument = QJsonDocument::fromJson(tempBuf, &jerror);
+ if (jerror.error == QJsonParseError::NoError)
+ {
+ m_sceneDefine = jsonDocument.object();
+ }
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+const char* Begin2DSceneMessage::MetaName = "AxTrace.Begin2DScene";
+
+void Begin2DSceneMessage::_luaopen(lua_State *L)
+{
+ static luaL_Reg msg_data_meta[] =
+ {
+ { "get_type", Message::_lua_get_type },
+ { "get_pid", Message::_lua_get_process_id },
+ { "get_tid", Message::_lua_get_thread_id },
+
+ { 0, 0 }
+ };
+
+
+ //PlayerData meta table
+ luaL_newmetatable(L, Begin2DSceneMessage::MetaName);
+ lua_pushvalue(L, -1); /* push metatable */
+ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
+
+ luaL_register(L, NULL, msg_data_meta); /* file methods */
+}
+
+//--------------------------------------------------------------------------------------------
+QQueue Update2DActorMessage::s_messagePool;
+
+//--------------------------------------------------------------------------------------------
+Update2DActorMessage::Update2DActorMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+Update2DActorMessage::~Update2DActorMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void Update2DActorMessage::build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
+{
+ memcpy(&m_time, &traceTime, sizeof(axtrace_time_s));
+ m_processID = head.pid;
+ m_threadID = head.tid;
+
+ axtrace_2d_actor_s value_head;
+ size_t len = ringBuf->memcpy_out(&value_head, sizeof(value_head));
+ assert(len == sizeof(value_head));
+
+ m_actorID = (qint64)value_head.actor_id;
+ m_position = QPointF((qreal)value_head.x, (qreal)value_head.y);
+ m_dir = (qreal)value_head.dir;
+ m_style = (quint32)value_head.style;
+
+ //copy name
+ char tempName[AXTRACE_MAX_SCENE_NAME_LENGTH];
+ int name_length = value_head.name_len;
+ //TODO: check name length
+ len = ringBuf->memcpy_out(tempName, name_length);
+ assert(len == name_length);
+ tempName[name_length - 1] = 0; //make sure last char is '\0'
+ m_sceneName = QString::fromUtf8(tempName);
+}
+
+//-------------------------------------------------------------------------------------
+int Update2DActorMessage::_lua_get_actor_id(lua_State *L)
+{
+ const Update2DActorMessage* msg = (const Update2DActorMessage*)lua_touserdata(L, 1);
+
+ lua_pushinteger(L, msg->getActorID());
+ return 1;
+}
+
+//-------------------------------------------------------------------------------------
+int Update2DActorMessage::_lua_get_actor_position(lua_State *L)
+{
+ const Update2DActorMessage* msg = (const Update2DActorMessage*)lua_touserdata(L, 1);
+
+ const QPointF& pos = msg->getActorPosition();
+ lua_pushnumber(L, pos.x());
+ lua_pushnumber(L, pos.y());
+ return 2;
+}
+
+//-------------------------------------------------------------------------------------
+int Update2DActorMessage::_lua_get_actor_dir(lua_State *L)
+{
+ const Update2DActorMessage* msg = (const Update2DActorMessage*)lua_touserdata(L, 1);
+
+ lua_pushnumber(L, msg->getActorDir());
+ return 1;
+}
+
+//-------------------------------------------------------------------------------------
+int Update2DActorMessage::_lua_get_actor_style(lua_State *L)
+{
+ const Update2DActorMessage* msg = (const Update2DActorMessage*)lua_touserdata(L, 1);
+
+ lua_pushinteger(L, msg->getActorStyle());
+ return 1;
+}
+
+//--------------------------------------------------------------------------------------------
+const char* Update2DActorMessage::MetaName = "AxTrace.Actor2DMessage";
+
+void Update2DActorMessage::_luaopen(lua_State *L)
+{
+ static luaL_Reg msg_data_meta[] =
+ {
+ { "get_type", Message::_lua_get_type },
+ { "get_pid", Message::_lua_get_process_id },
+ { "get_tid", Message::_lua_get_thread_id },
+
+ { "get_actor_id", Update2DActorMessage::_lua_get_actor_id },
+ { "get_actor_position", Update2DActorMessage::_lua_get_actor_position },
+ { "get_actor_dir", Update2DActorMessage::_lua_get_actor_dir },
+ { "get_actor_style", Update2DActorMessage::_lua_get_actor_style },
+
+ { 0, 0 }
+ };
+
+
+ //PlayerData meta table
+ luaL_newmetatable(L, Update2DActorMessage::MetaName);
+ lua_pushvalue(L, -1); /* push metatable */
+ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
+
+ luaL_register(L, NULL, msg_data_meta); /* file methods */
+}
+
+//--------------------------------------------------------------------------------------------
+QQueue End2DSceneMessage::s_messagePool;
+
+//--------------------------------------------------------------------------------------------
+End2DSceneMessage::End2DSceneMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+End2DSceneMessage::~End2DSceneMessage()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void End2DSceneMessage::build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
+{
+ memcpy(&m_time, &traceTime, sizeof(axtrace_time_s));
+ m_processID = head.pid;
+ m_threadID = head.tid;
+
+ axtrace_2d_end_scene_s value_head;
+ size_t len = ringBuf->memcpy_out(&value_head, sizeof(value_head));
+ assert(len == sizeof(value_head));
+
+ //copy name
+ char tempName[AXTRACE_MAX_SCENE_NAME_LENGTH];
+ int name_length = value_head.name_len;
+ //TODO: check name length
+ len = ringBuf->memcpy_out(tempName, name_length);
+ assert(len == name_length);
+ tempName[name_length - 1] = 0; //make sure last char is '\0'
+ m_sceneName = QString::fromUtf8(tempName);
+}
+
+//--------------------------------------------------------------------------------------------
+const char* End2DSceneMessage::MetaName = "AxTrace.End2DScene";
+
+void End2DSceneMessage::_luaopen(lua_State *L)
+{
+ static luaL_Reg msg_data_meta[] =
+ {
+ { "get_type", Message::_lua_get_type },
+ { "get_pid", Message::_lua_get_process_id },
+ { "get_tid", Message::_lua_get_thread_id },
+
+ { 0, 0 }
+ };
+
+ //PlayerData meta table
+ luaL_newmetatable(L, End2DSceneMessage::MetaName);
+ lua_pushvalue(L, -1); /* push metatable */
+ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
+
+ luaL_register(L, NULL, msg_data_meta); /* file methods */
+}
diff --git a/AT4_Message.h b/AT4_Message.h
new file mode 100644
index 0000000..f26b69c
--- /dev/null
+++ b/AT4_Message.h
@@ -0,0 +1,206 @@
+#pragma once
+
+#include "AT4_Interface.h"
+
+class Message
+{
+public:
+ virtual void build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf) = 0;
+ virtual unsigned int getType(void) const = 0;
+
+ unsigned int getProcessID(void) const { return m_processID; }
+ unsigned int getThreadID(void) const { return m_threadID; }
+ const axtrace_time_s& getTime(void) const { return m_time; }
+
+protected:
+ unsigned int m_processID;
+ unsigned int m_threadID;
+ axtrace_time_s m_time;
+
+protected:
+ static int _lua_get_type(lua_State *L);
+ static int _lua_get_process_id(lua_State *L);
+ static int _lua_get_thread_id(lua_State *L);
+
+public:
+ Message();
+ virtual ~Message();
+
+public:
+ virtual void reccycleMessage(void) = 0;
+};
+
+typedef QVector< Message* > MessageVector;
+
+#define DEFINE_POOL(Name) \
+public: \
+ static int debugCounts(void) { return (int)s_messagePool.size(); } \
+ static Name* allocMessage(void) \
+ { \
+ if (s_messagePool.empty()) { \
+ return new Name(); \
+ } \
+ else { \
+ Name* msg = s_messagePool.front(); \
+ s_messagePool.pop_front(); \
+ return msg; \
+ } \
+ } \
+ virtual void reccycleMessage() \
+ { \
+ s_messagePool.push_back(this); \
+ } \
+ static void deletePool(void) \
+ { \
+ for(auto msg : s_messagePool) { \
+ delete msg; \
+ } \
+ s_messagePool.clear(); \
+ } \
+private: \
+ static QQueue s_messagePool;
+
+class LogMessage : public Message
+{
+public:
+ static const char* MetaName;
+ static void _luaopen(lua_State *L);
+
+ virtual void build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
+ virtual unsigned int getType(void) const { return AXTRACE_CMD_TYPE_LOG; }
+
+ unsigned int getLogType(void) const { return m_logType; }
+ const QString& getLog(void) const { return m_log; }
+
+private:
+ unsigned int m_logType;
+ QString m_log;
+
+protected:
+ static int _lua_get_log_type(lua_State *L);
+ static int _lua_get_log(lua_State *L);
+
+public:
+ LogMessage();
+ virtual ~LogMessage();
+
+ DEFINE_POOL(LogMessage);
+};
+
+class ValueMessage : public Message
+{
+public:
+ static const char* MetaName;
+ static void _luaopen(lua_State *L);
+
+ virtual void build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
+ virtual unsigned int getType(void) const { return AXTRACE_CMD_TYPE_VALUE; }
+
+ const QString& getName(void) const { return m_name; }
+ void getValueAsString(QString& value) const;
+
+private:
+ QString m_name;
+
+ unsigned int m_valueType;
+ size_t m_valueSize;
+ void* m_valueBuf;
+
+ enum { STANDARD_VALUE_SIZE = 32 };
+ unsigned char m_standValueBuf[STANDARD_VALUE_SIZE];
+
+protected:
+ static int _lua_get_value(lua_State *L);
+
+public:
+ ValueMessage();
+ virtual ~ValueMessage();
+
+ DEFINE_POOL(ValueMessage);
+};
+
+class Begin2DSceneMessage : public Message
+{
+public:
+ static const char* MetaName;
+ static void _luaopen(lua_State *L);
+
+ virtual void build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
+ virtual unsigned int getType(void) const { return AXTRACE_CMD_TYPE_2D_BEGIN_SCENE; }
+
+ const QString& getSceneName(void) const { return m_sceneName; }
+ const QRectF& getSceneRect(void) const { return m_sceneRect; }
+ const QJsonObject& getSceneDefine(void) const { return m_sceneDefine; }
+
+private:
+ QString m_sceneName;
+ QRectF m_sceneRect;
+ QJsonObject m_sceneDefine;
+
+public:
+ Begin2DSceneMessage();
+ virtual ~Begin2DSceneMessage();
+
+ DEFINE_POOL(Begin2DSceneMessage);
+};
+
+class Update2DActorMessage : public Message
+{
+public:
+ static const char* MetaName;
+ static void _luaopen(lua_State *L);
+
+ virtual void build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
+ virtual unsigned int getType(void) const { return AXTRACE_CMD_TYPE_2D_ACTOR; }
+
+ const QString& getSceneName(void) const { return m_sceneName; }
+ qint64 getActorID(void) const { return m_actorID; }
+ const QPointF& getActorPosition(void) const { return m_position; }
+ qreal getActorDir(void) const { return m_dir; }
+ quint32 getActorStyle(void) const { return m_style; }
+
+private:
+ QString m_sceneName;
+ qint64 m_actorID;
+ QPointF m_position;
+ qreal m_dir;
+ quint32 m_style;
+
+protected:
+ static int _lua_get_actor_id(lua_State *L);
+ static int _lua_get_actor_position(lua_State *L);
+ static int _lua_get_actor_dir(lua_State *L);
+ static int _lua_get_actor_style(lua_State *L);
+
+public:
+ Update2DActorMessage();
+ virtual ~Update2DActorMessage();
+
+ DEFINE_POOL(Update2DActorMessage);
+};
+
+
+class End2DSceneMessage : public Message
+{
+public:
+ static const char* MetaName;
+ static void _luaopen(lua_State *L);
+
+ virtual void build(const axtrace_time_s& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
+ virtual unsigned int getType(void) const { return AXTRACE_CMD_TYPE_2D_END_SCENE; }
+
+ const QString& getSceneName(void) const { return m_sceneName; }
+
+private:
+ QString m_sceneName;
+
+protected:
+ static int _lua_get_actor_id(lua_State *L);
+
+public:
+ End2DSceneMessage();
+ virtual ~End2DSceneMessage();
+
+ DEFINE_POOL(End2DSceneMessage);
+};
+
diff --git a/AT4_MessageQueue.cpp b/AT4_MessageQueue.cpp
new file mode 100644
index 0000000..6b1df27
--- /dev/null
+++ b/AT4_MessageQueue.cpp
@@ -0,0 +1,117 @@
+#include "stdafx.h"
+#include "AT4_MessageQueue.h"
+#include "AT4_Interface.h"
+#include "AT4_System.h"
+#include "AT4_MainWindow.h"
+
+//--------------------------------------------------------------------------------------------
+MessageQueue::MessageQueue()
+{
+ m_ring_buf = new cyclone::RingBuf();
+ m_counts = 0;
+}
+
+//--------------------------------------------------------------------------------------------
+MessageQueue::~MessageQueue()
+{
+ delete m_ring_buf; m_ring_buf = 0;
+}
+
+//--------------------------------------------------------------------------------------------
+void MessageQueue::insertMessage(cyclone::RingBuf* buf, size_t msg_length, const QTime& timeNow)
+{
+ axtrace_time_s t;
+ t.hour = timeNow.hour();
+ t.minute = timeNow.minute();
+ t.second = timeNow.second();
+ t.milliseconds = timeNow.msec();
+
+ {
+ QMutexLocker locker(&m_lock);
+
+ m_ring_buf->memcpy_into(&t, sizeof(axtrace_time_s));
+ buf->copyto(m_ring_buf, msg_length);
+
+ m_counts++;
+
+ QCoreApplication::postEvent(System::getSingleton()->getMainWindow(), new MainWindow::AxTraceEvent());
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+Message* MessageQueue::_popMessage(void)
+{
+ axtrace_time_s traceTime;
+
+ size_t len = m_ring_buf->memcpy_out(&traceTime, sizeof(axtrace_time_s));
+ assert(len == sizeof(axtrace_time_s));
+
+ axtrace_head_s head;
+ len = m_ring_buf->peek(0, &head, sizeof(head));
+ assert(len == sizeof(axtrace_head_s));
+
+ Message* message = nullptr;
+ switch (head.type)
+ {
+ case AXTRACE_CMD_TYPE_LOG:
+ {
+ message = LogMessage::allocMessage();
+ }
+ break;
+
+ case AXTRACE_CMD_TYPE_VALUE:
+ {
+ message = ValueMessage::allocMessage();
+ }
+ break;
+
+ case AXTRACE_CMD_TYPE_2D_BEGIN_SCENE:
+ {
+ message = Begin2DSceneMessage::allocMessage();
+ }
+ break;
+
+ case AXTRACE_CMD_TYPE_2D_ACTOR:
+ {
+ message = Update2DActorMessage::allocMessage();
+ }
+ break;
+
+ case AXTRACE_CMD_TYPE_2D_END_SCENE:
+ {
+ message = End2DSceneMessage::allocMessage();
+ }
+ break;
+
+ default:
+ return message;
+ }
+
+ message->build(traceTime, head, m_ring_buf);
+ return message;
+}
+
+//--------------------------------------------------------------------------------------------
+void MessageQueue::popMessage(MessageVector& msgVector)
+{
+ if (m_counts <= 0) return;
+
+ {
+ QMutexLocker locker(&m_lock);
+ msgVector.reserve(m_counts);
+
+ do
+ {
+ if (m_ring_buf->empty()) break;
+
+ Message* msg = _popMessage();
+ assert(msg != 0);
+ if (msg == nullptr) continue;
+
+ msgVector.push_back(msg);
+
+ } while (true);
+
+ m_counts = 0;
+ }
+}
diff --git a/AT4_MessageQueue.h b/AT4_MessageQueue.h
new file mode 100644
index 0000000..3ccbae0
--- /dev/null
+++ b/AT4_MessageQueue.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "AT4_Message.h"
+
+class MessageQueue
+{
+public:
+ /** insert message to queue(should call by incoming thread)*/
+ void insertMessage(cyclone::RingBuf* buf, size_t msg_length, const QTime& tTime);
+ /** pop message to queue(should call by main thread)*/
+ void popMessage(MessageVector& message);
+ /** clean all message directorly */
+ void cleanMessage(void);
+
+private:
+ Message* _popMessage(void);
+
+private:
+ enum { DEFAULT_RINGBUF_SIZE = 2048, MAX_RINGBUF_SIZE = 1024 * 1024 * 8 };
+ cyclone::RingBuf* m_ring_buf;
+ QMutex m_lock;
+ QAtomicInt m_counts;
+
+public:
+ MessageQueue();
+ virtual ~MessageQueue();
+};
diff --git a/AT4_Scene2D.cpp b/AT4_Scene2D.cpp
new file mode 100644
index 0000000..f112728
--- /dev/null
+++ b/AT4_Scene2D.cpp
@@ -0,0 +1,138 @@
+#include "stdafx.h"
+#include "AT4_Scene2D.h"
+#include "AT4_Message.h"
+
+//--------------------------------------------------------------------------------------------
+Scene2D::Scene2D(Begin2DSceneMessage* msg)
+ : m_sceneName(msg->getSceneName())
+ , m_sceneRect(msg->getSceneRect())
+ , m_actorMapIndex(0)
+ , m_updating(false)
+ , m_updatingRect(msg->getSceneRect())
+{
+ _parserSceneDefine(msg->getSceneDefine());
+}
+
+//--------------------------------------------------------------------------------------------
+Scene2D::~Scene2D()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void Scene2D::beginScene(const Begin2DSceneMessage* msg)
+{
+ ActorMap& updatingActorsMap = m_actorMap[1-m_actorMapIndex];
+
+ m_updating = true;
+ m_updatingRect = msg->getSceneRect();
+ updatingActorsMap.clear();
+ m_updatingSceneDefine = msg->getSceneDefine();
+}
+
+//--------------------------------------------------------------------------------------------
+void Scene2D::updateActor(const Update2DActorMessage* msg, const Filter::Actor2DResult& filterResult)
+{
+ if (!m_updating) return;
+ ActorMap& updatingActorsMap = m_actorMap[1 - m_actorMapIndex];
+
+ ActorMap::iterator it = updatingActorsMap.find(msg->getActorID());
+ if (it == updatingActorsMap.end()) {
+ Actor actor;
+ actor.actorID = msg->getActorID();
+ actor.pos = msg->getActorPosition();
+ actor.dir = msg->getActorDir();
+ actor.type = filterResult.type;
+ actor.size = filterResult.size;
+ actor.fillColor = filterResult.fillColor;
+ actor.borderColor = filterResult.borderColor;
+
+ updatingActorsMap.insert(msg->getActorID(), actor);
+ }
+ else
+ {
+ Actor& actor = *it;
+
+ actor.pos = msg->getActorPosition();
+ actor.dir = msg->getActorDir();
+ actor.type = filterResult.type;
+ actor.size = filterResult.size;
+ actor.fillColor = filterResult.fillColor;
+ actor.borderColor = filterResult.borderColor;
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Scene2D::endScene(const End2DSceneMessage* msg)
+{
+ if (!m_updating) return;
+
+ m_updating = false;
+ m_actorMapIndex = 1 - m_actorMapIndex;
+ m_sceneRect = m_updatingRect;
+
+ _parserSceneDefine(m_updatingSceneDefine);
+}
+
+//--------------------------------------------------------------------------------------------
+void Scene2D::clean(void)
+{
+ ActorMap& actorsMap = m_actorMap[m_actorMapIndex];
+
+ actorsMap.clear();
+}
+
+//--------------------------------------------------------------------------------------------
+void Scene2D::walk(Scene2D::ActorWalkFunc walkFunc)
+{
+ ActorMap& actorsMap = m_actorMap[m_actorMapIndex];
+
+ for (ActorMap::iterator it = actorsMap.begin(); it != actorsMap.end(); ++it)
+ {
+ const Actor& actor = it.value();
+ walkFunc(actor);
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+void Scene2D::_parserSceneDefine(const QJsonObject& sceneInfo)
+{
+ m_gridDefined = false;
+
+ //parser gridSize
+ if (sceneInfo.contains("gridSize") && sceneInfo["gridSize"].isArray()) {
+ QJsonArray gridSizeArray = sceneInfo["gridSize"].toArray();
+ if (gridSizeArray.size() >= 2) {
+ m_gridSize = QSizeF(abs(gridSizeArray[0].toDouble()), abs(gridSizeArray[1].toDouble()));
+
+ m_gridDefined = true;
+ }
+ }
+
+ //default gridPoint
+ m_gridPoint = QPointF(0, 0);
+
+ //parser gridSize
+ if (m_gridDefined && sceneInfo.contains("gridPoint") && sceneInfo["gridPoint"].isArray()) {
+ QJsonArray gridPointArray = sceneInfo["gridPoint"].toArray();
+ if (gridPointArray.size() >= 2) {
+ double gridPointX = gridPointArray[0].toDouble();
+ double gridPointY = gridPointArray[1].toDouble();
+
+ double absPointX = abs(gridPointX);
+ double absPointY = abs(gridPointY);
+
+ int flagX = gridPointX > 0 ? 1 : -1;
+ int flagY = gridPointY > 0 ? 1 : -1;
+
+ if (absPointX > m_gridSize.width()) {
+ gridPointX = flagX*(absPointX - (int)(absPointX / m_gridSize.width()) * m_gridSize.width());
+ }
+ if (gridPointY > m_gridSize.height()) {
+ gridPointY = flagY * (absPointY - (int)(absPointY / m_gridSize.height()) * m_gridSize.height());
+ }
+
+ m_gridPoint = QPointF(gridPointX, gridPointY);
+ }
+ }
+}
diff --git a/AT4_Scene2D.h b/AT4_Scene2D.h
new file mode 100644
index 0000000..a255dc1
--- /dev/null
+++ b/AT4_Scene2D.h
@@ -0,0 +1,64 @@
+#pragma once
+
+#include
+
+class Begin2DSceneMessage;
+class Update2DActorMessage;
+class End2DSceneMessage;
+
+#include "AT4_Filter.h"
+
+class Scene2D
+{
+public:
+ struct Actor
+ {
+ qint64 actorID;
+ QPointF pos;
+ qreal dir;
+ Filter::Actor2DType type;
+ quint16 borderColor;
+ quint16 fillColor;
+ qreal size;
+ };
+
+public:
+ void beginScene(const Begin2DSceneMessage* msg);
+ void updateActor(const Update2DActorMessage* msg, const Filter::Actor2DResult& filterResult);
+ void endScene(const End2DSceneMessage* msg);
+
+ void clean(void);
+
+ typedef std::function ActorWalkFunc;
+ void walk(ActorWalkFunc walkFunc);
+
+ const QString& getSceneName(void) const { return m_sceneName; }
+ const QRectF& getSceneRect(void) const { return m_sceneRect; }
+
+ bool isGridDefined(void) const { return m_gridDefined; }
+ const QSizeF& getGridSize(void) const { return m_gridSize; }
+ const QPointF& getGridPoint(void) const { return m_gridPoint; }
+
+private:
+ void _parserSceneDefine(const QJsonObject& sceneInfo);
+
+private:
+ QString m_sceneName;
+ QRectF m_sceneRect;
+ int m_actorMapIndex;
+
+ bool m_gridDefined;
+ QSizeF m_gridSize;
+ QPointF m_gridPoint;
+
+ typedef QHash< qint64, Actor > ActorMap;
+ ActorMap m_actorMap[2];
+
+ bool m_updating;
+ QRectF m_updatingRect;
+ QJsonObject m_updatingSceneDefine;
+
+public:
+ Scene2D(Begin2DSceneMessage* msg);
+ ~Scene2D();
+};
diff --git a/AT4_SettingDialog.cpp b/AT4_SettingDialog.cpp
new file mode 100644
index 0000000..89951ec
--- /dev/null
+++ b/AT4_SettingDialog.cpp
@@ -0,0 +1,188 @@
+#include "stdafx.h"
+#include "AT4_SettingDialog.h"
+#include "AT4_System.h"
+#include "AT4_Config.h"
+#include "AT4_LuaHighlighter.h"
+#include "AT4_Filter.h"
+
+//--------------------------------------------------------------------------------------------
+CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
+{
+ lineNumberArea = new LineNumberArea(this);
+
+ connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
+ connect(this, SIGNAL(updateRequest(QRect, int)), this, SLOT(updateLineNumberArea(QRect, int)));
+ connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
+
+ updateLineNumberAreaWidth(0);
+ highlightCurrentLine();
+}
+
+//--------------------------------------------------------------------------------------------
+int CodeEditor::lineNumberAreaWidth()
+{
+ int digits = 1;
+ int max = qMax(1, blockCount());
+ while (max >= 10) {
+ max /= 10;
+ ++digits;
+ }
+
+ int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
+
+ return space;
+}
+
+//--------------------------------------------------------------------------------------------
+void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
+{
+ setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
+}
+
+//--------------------------------------------------------------------------------------------
+void CodeEditor::updateLineNumberArea(const QRect &rect, int dy)
+{
+ if (dy)
+ lineNumberArea->scroll(0, dy);
+ else
+ lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
+
+ if (rect.contains(viewport()->rect()))
+ updateLineNumberAreaWidth(0);
+}
+
+//--------------------------------------------------------------------------------------------
+void CodeEditor::resizeEvent(QResizeEvent *e)
+{
+ QPlainTextEdit::resizeEvent(e);
+
+ QRect cr = contentsRect();
+ lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
+}
+
+//--------------------------------------------------------------------------------------------
+void CodeEditor::highlightCurrentLine()
+{
+ QList extraSelections;
+
+ if (!isReadOnly()) {
+ QTextEdit::ExtraSelection selection;
+
+ QColor lineColor = QColor(Qt::yellow).lighter(160);
+
+ selection.format.setBackground(lineColor);
+ selection.format.setProperty(QTextFormat::FullWidthSelection, true);
+ selection.cursor = textCursor();
+ selection.cursor.clearSelection();
+ extraSelections.append(selection);
+ }
+
+ setExtraSelections(extraSelections);
+}
+
+//--------------------------------------------------------------------------------------------
+void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
+{
+ QPainter painter(lineNumberArea);
+ painter.fillRect(event->rect(), Qt::lightGray);
+
+ QTextBlock block = firstVisibleBlock();
+ int blockNumber = block.blockNumber();
+ int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top();
+ int bottom = top + (int)blockBoundingRect(block).height();
+
+ while (block.isValid() && top <= event->rect().bottom()) {
+ if (block.isVisible() && bottom >= event->rect().top()) {
+ QString number = QString::number(blockNumber + 1);
+ painter.setPen(Qt::black);
+ painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
+ Qt::AlignRight, number);
+ }
+
+ block = block.next();
+ top = bottom;
+ bottom = top + (int)blockBoundingRect(block).height();
+ ++blockNumber;
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+SettingDialog::SettingDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ QFont font;
+ font.setFamily("Courier");
+ font.setFixedPitch(true);
+ font.setPointSize(10);
+
+ m_editor = new CodeEditor;
+ m_editor->setFont(font);
+
+ m_highlighter = new LuaHighlighter(m_editor->document());
+
+ Config* config = System::getSingleton()->getConfig();
+ m_editor->setPlainText(config->getFilterScript());
+
+ m_defaultButton = new QPushButton(tr("Default"));
+ connect(m_defaultButton, SIGNAL(clicked()), this, SLOT(resetScript()));
+
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok
+ | QDialogButtonBox::Cancel);
+
+ connect(m_buttons, &QDialogButtonBox::accepted, this, &SettingDialog::verify);
+ connect(m_buttons, &QDialogButtonBox::rejected, this, &SettingDialog::reject);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(m_editor);
+
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->addWidget(m_defaultButton);
+ buttonLayout->addWidget(m_buttons);
+
+ mainLayout->addLayout(buttonLayout);
+
+ setLayout(mainLayout);
+ resize(1024, 512);
+ setWindowTitle(tr("AxTrace Setting Dialog"));
+}
+
+//--------------------------------------------------------------------------------------------
+SettingDialog::~SettingDialog()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void SettingDialog::verify()
+{
+ QString errorMsg;
+
+ if (!Filter::tryLoadScript(m_editor->toPlainText().toUtf8().toStdString().c_str(), errorMsg))
+ {
+ QMessageBox::critical(this, tr("LoadScript Error"), errorMsg, QMessageBox::Ok);
+ return;
+ }
+
+ if (QMessageBox::Yes != QMessageBox::warning(this,
+ tr("Compile Script Success!"), tr("Do you want reload filter script now?"),
+ QMessageBox::Yes | QMessageBox::No))
+ {
+ return;
+ }
+
+ m_script = m_editor->toPlainText();
+ accept();
+}
+
+//--------------------------------------------------------------------------------------------
+void SettingDialog::resetScript()
+{
+ if (QMessageBox::Yes != QMessageBox::question(this,
+ tr("Axtrace 4"), tr("Do you want reset filter script to default?"),
+ QMessageBox::Yes | QMessageBox::No))
+ {
+ return;
+ }
+
+ m_editor->setPlainText(System::getSingleton()->getConfig()->getDefaultFilterScript());
+}
diff --git a/AT4_SettingDialog.h b/AT4_SettingDialog.h
new file mode 100644
index 0000000..12cbb03
--- /dev/null
+++ b/AT4_SettingDialog.h
@@ -0,0 +1,76 @@
+#pragma once
+
+#include
+#include
+
+class LuaHighlighter;
+
+QT_BEGIN_NAMESPACE
+class QDialogButtonBox;
+QT_END_NAMESPACE
+
+
+class CodeEditor : public QPlainTextEdit
+{
+ Q_OBJECT
+
+public:
+ CodeEditor(QWidget *parent = 0);
+
+ void lineNumberAreaPaintEvent(QPaintEvent *event);
+ int lineNumberAreaWidth();
+
+protected:
+ void resizeEvent(QResizeEvent *event) override;
+
+private slots:
+ void updateLineNumberAreaWidth(int newBlockCount);
+ void highlightCurrentLine();
+ void updateLineNumberArea(const QRect &, int);
+
+private:
+ QWidget *lineNumberArea;
+};
+
+class LineNumberArea : public QWidget
+{
+public:
+ LineNumberArea(CodeEditor *editor) : QWidget(editor) {
+ codeEditor = editor;
+ }
+
+ QSize sizeHint() const override {
+ return QSize(codeEditor->lineNumberAreaWidth(), 0);
+ }
+
+protected:
+ void paintEvent(QPaintEvent *event) override {
+ codeEditor->lineNumberAreaPaintEvent(event);
+ }
+
+private:
+ CodeEditor *codeEditor;
+};
+
+class SettingDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ const QString& getScript(void) const { return m_script; }
+
+public slots:
+ void verify();
+ void resetScript();
+
+private:
+ CodeEditor* m_editor;
+ QDialogButtonBox* m_buttons;
+ QPushButton* m_defaultButton;
+ LuaHighlighter* m_highlighter;
+ QString m_script;
+
+public:
+ SettingDialog(QWidget *parent = nullptr);
+ ~SettingDialog();
+};
diff --git a/AT4_System.cpp b/AT4_System.cpp
new file mode 100644
index 0000000..5bfb1cd
--- /dev/null
+++ b/AT4_System.cpp
@@ -0,0 +1,93 @@
+#include "stdafx.h"
+#include "AT4_System.h"
+#include "AT4_MainWindow.h"
+#include "AT4_Config.h"
+#include "AT4_Incoming.h"
+#include "AT4_MessageQueue.h"
+#include "AT4_Filter.h"
+#include "AT4_Scene2D.h"
+#include "AT4_Map2DChild.h"
+
+//--------------------------------------------------------------------------------------------
+System* System::s_singleton = nullptr;
+
+//--------------------------------------------------------------------------------------------
+System::System()
+ : m_theApplication(nullptr)
+ , m_config(nullptr)
+ , m_incoming(nullptr)
+ , m_mainWindow(nullptr)
+ , m_messageQueue(nullptr)
+ , m_filter(nullptr)
+{
+ s_singleton = this;
+}
+
+//--------------------------------------------------------------------------------------------
+System::~System()
+{
+ Map2DChild::deleteCachedObject();
+ LogMessage::deletePool();
+ ValueMessage::deletePool();
+ Begin2DSceneMessage::deletePool();
+ Update2DActorMessage::deletePool();
+ End2DSceneMessage::deletePool();
+
+ delete m_filter;
+ delete m_messageQueue;
+ delete m_mainWindow;
+ delete m_incoming;
+ delete m_config;
+ delete m_theApplication;
+}
+
+//--------------------------------------------------------------------------------------------
+bool System::init(int argc, char *argv[])
+{
+ m_theApplication = new QApplication(argc, argv);
+ QCoreApplication::setApplicationName("AxTrace4");
+ QCoreApplication::setOrganizationName("thecodeway.com");
+ QCoreApplication::setApplicationVersion("4.0");
+ m_theApplication->setWindowIcon(QIcon(":/images/AxTrace.ico"));
+
+ QCommandLineParser parser;
+ parser.setApplicationDescription("AxTrace");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(*m_theApplication);
+
+ //allocate managers
+ m_config = new Config();
+ m_incoming = new Incoming();
+ m_messageQueue = new MessageQueue();
+ m_filter = new Filter();
+
+ Map2DChild::initCachedObject();
+
+ //init managers
+ m_config->loadSetting();
+ if (!(m_filter->init(m_config))) {
+ return false;
+ }
+
+ if (!(m_incoming->init())) {
+ return false;
+ }
+
+ return true;
+}
+
+//--------------------------------------------------------------------------------------------
+int System::run(void)
+{
+ m_mainWindow = new MainWindow();
+ m_mainWindow->show();
+
+ //enter loop...
+ int retCode = m_theApplication->exec();
+
+ m_config->saveSetting();
+ m_incoming->closeListen();
+
+ return retCode;
+}
\ No newline at end of file
diff --git a/AT4_System.h b/AT4_System.h
new file mode 100644
index 0000000..c6739eb
--- /dev/null
+++ b/AT4_System.h
@@ -0,0 +1,37 @@
+#pragma once
+
+class MainWindow;
+class Incoming;
+class Config;
+class MessageQueue;
+class Filter;
+
+class System
+{
+public:
+ bool init(int argc, char *argv[]);
+ int run(void);
+
+public:
+ Config* getConfig(void) { return m_config; }
+ MainWindow* getMainWindow(void) { return m_mainWindow; }
+ MessageQueue* getMessageQueue(void) { return m_messageQueue; }
+ Filter* getFilter(void) { return m_filter; }
+
+private:
+ QApplication* m_theApplication;
+ Config* m_config;
+ Incoming* m_incoming;
+ MainWindow* m_mainWindow;
+ MessageQueue* m_messageQueue;
+ Filter* m_filter;
+
+public:
+ System();
+ ~System();
+
+ static System* getSingleton(void) { return s_singleton; };
+
+private:
+ static System* s_singleton;
+};
diff --git a/AT4_ValueChild.cpp b/AT4_ValueChild.cpp
new file mode 100644
index 0000000..fa0e4d7
--- /dev/null
+++ b/AT4_ValueChild.cpp
@@ -0,0 +1,280 @@
+#include "stdafx.h"
+
+#include "AT4_ValueChild.h"
+#include "AT4_Message.h"
+#include "AT4_ChildInterface.h"
+#include "AT4_System.h"
+#include "AT4_MainWindow.h"
+
+//--------------------------------------------------------------------------------------------
+ValueDataModel::ValueDataModel(QObject *parent)
+ : QAbstractItemModel(parent)
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+ValueDataModel::~ValueDataModel()
+{
+
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueDataModel::insertValue(const ValueMessage* valueMessage, const Filter::ListResult& filterResult)
+{
+ const QString& name = valueMessage->getName();
+ int idx;
+
+ auto it = m_valueHashMap.find(name);
+ if (it == m_valueHashMap.end())
+ {
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+
+ idx = m_valueVector.size();
+
+ Value value;
+ value.valueName = name;
+
+ m_valueVector.push_back(value);
+ m_valueHashMap.insert(name, idx);
+
+ endInsertRows();
+ }
+ else
+ {
+ idx = it.value();
+ }
+
+ Value& value = m_valueVector[idx];
+
+ const axtrace_time_s& t = valueMessage->getTime();
+ value.updateTime = tr("%1:%2 %3.%4")
+ .arg(t.hour, 2, 10, QLatin1Char('0'))
+ .arg(t.minute, 2, 10, QLatin1Char('0'))
+ .arg(t.second, 2, 10, QLatin1Char('0'))
+ .arg(t.milliseconds);
+
+ QString valueData;
+ valueMessage->getValueAsString(valueData);
+ value.valueData = valueData;
+
+ value.backColor = Filter::toQColor(filterResult.backColor);
+ value.frontColor = Filter::toQColor(filterResult.fontColor);
+
+ dataChanged(index(idx, 0), index(idx, COLUMN_COUNTS));
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueDataModel::clearAllValue(void)
+{
+ beginRemoveRows(QModelIndex(), 0, rowCount());
+ m_valueVector.clear();
+ m_valueHashMap.clear();
+ endRemoveRows();
+}
+
+//--------------------------------------------------------------------------------------------
+QVariant ValueDataModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() >= m_valueVector.size() || index.column() >= COLUMN_COUNTS)
+ return QVariant();
+
+ const Value& value = m_valueVector[index.row()];
+
+ switch (role)
+ {
+ case Qt::BackgroundRole: return QBrush(value.backColor);
+ case Qt::ForegroundRole: return QBrush(value.frontColor);
+ case Qt::TextAlignmentRole: return QVariant(int(Qt::AlignLeft | Qt::AlignTop));
+ case Qt::DisplayRole: return data(index.row(), index.column());
+ default: return QVariant();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+QString ValueDataModel::data(int row, int column) const
+{
+ if (row >= m_valueVector.size() || column >= COLUMN_COUNTS)
+ return QString();
+
+ const Value& value = m_valueVector[row];
+ switch (column)
+ {
+ case 0: return value.updateTime;
+ case 1: return value.valueName;
+ case 2: return value.valueData;
+ default: return QString();
+ }
+}
+
+//--------------------------------------------------------------------------------------------
+Qt::ItemFlags ValueDataModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+
+ return QAbstractItemModel::flags(index);
+}
+
+//--------------------------------------------------------------------------------------------
+QVariant ValueDataModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ {
+ if (section == 0) return QVariant(tr("Time"));
+ else if (section == 1) return QVariant(tr("Name"));
+ else return QVariant(tr("Value"));
+ }
+
+ return QVariant();
+}
+
+//--------------------------------------------------------------------------------------------
+QModelIndex ValueDataModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ if (!parent.isValid())
+ return createIndex(row, column);
+ else
+ return QModelIndex();
+}
+
+//--------------------------------------------------------------------------------------------
+class ValueChildInterface : public IChild
+{
+public:
+ virtual Type getType(void) const { return CT_VALUE; }
+
+ virtual bool copyAble(void) const {
+ return !(m_proxy->selectionModel()->selectedRows().empty());
+ }
+ virtual void onCopy(void) const
+ {
+ ValueDataModel* model = (ValueDataModel*)(m_proxy->model());
+
+ QModelIndexList rows = m_proxy->selectionModel()->selectedRows();
+ //sort by id
+ qSort(rows.begin(), rows.end(), [model](const QModelIndex &s1, const QModelIndex &s2) {
+ return s1.row() < s2.row();
+ });
+
+ QString lines;
+ foreach(auto row, rows)
+ {
+ QString line = QString("%1\t%2\t%3\n").arg(
+ model->data(row.row(), 0),
+ model->data(row.row(), 1),
+ model->data(row.row(), 2));
+
+ lines += line;
+ }
+
+ QApplication::clipboard()->setText(lines);
+ }
+
+ virtual QString getTitle(void) const
+ {
+ return m_proxy->windowTitle();
+ }
+
+ virtual void clean(void)
+ {
+ ValueDataModel* model = (ValueDataModel*)(m_proxy->model());
+ model->clearAllValue();
+ }
+
+ virtual void saveAs(void)
+ {
+ QString fileName = QFileDialog::getSaveFileName(nullptr, QString("Save As..."), QString("axtrace.log"), QString("Log file (*.log *.txt)"));
+ if (fileName.isEmpty()) return;
+
+ ValueDataModel* model = (ValueDataModel*)(m_proxy->model());
+
+ QFile file(fileName);
+ if (file.open(QFile::WriteOnly))
+ {
+ QTextStream stream(&file);
+ for (int rowIndex = 0; rowIndex < model->rowCount(); rowIndex++)
+ {
+ QString line = QString("%1\t%2\t%3\n").arg(
+ model->data(rowIndex, 0),
+ model->data(rowIndex, 1),
+ model->data(rowIndex, 2));
+ stream << line;
+ }
+ file.close();
+ }
+ }
+
+ virtual void update(void)
+ {
+ m_proxy->update();
+ }
+private:
+ ValueChild* m_proxy;
+
+public:
+ ValueChildInterface(ValueChild* proxy) : m_proxy(proxy) { }
+ ~ValueChildInterface() {}
+};
+
+//--------------------------------------------------------------------------------------------
+ValueChild::ValueChild(const QString& title)
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ m_title = title;
+ QString windowTitle = tr("Value:%1").arg(title);
+ setWindowTitle(windowTitle);
+
+ this->setUserData(0, new ValueChildInterface(this));
+}
+
+//--------------------------------------------------------------------------------------------
+ValueChild::~ValueChild()
+{
+ ValueChildInterface* i = (ValueChildInterface*)(this->userData(0));
+ delete i;
+
+ this->setUserData(0, nullptr);
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueChild::init(void)
+{
+ this->setModel(new ValueDataModel());
+ this->header()->resizeSection(0, 120);
+ this->header()->resizeSection(1, 200);
+ this->setSortingEnabled(false);
+ this->setRootIsDecorated(false);
+ this->setSelectionMode(MultiSelection);
+
+ connect(this->selectionModel(), &QItemSelectionModel::selectionChanged, this, []() {
+ System::getSingleton()->getMainWindow()->notifySelectionChanged();
+ });
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueChild::insertValue(const ValueMessage* valueMessage, const Filter::ListResult& filterResult)
+{
+ ValueDataModel* model = (ValueDataModel*)(this->model());
+
+ model->insertValue(valueMessage, filterResult);
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueChild::closeEvent(QCloseEvent *event)
+{
+ System::getSingleton()->getMainWindow()->notifySubWindowClose(IChild::CT_VALUE, m_title);
+ event->accept();
+}
+
+//--------------------------------------------------------------------------------------------
+void ValueChild::clearAllValue(void)
+{
+ ValueDataModel* model = (ValueDataModel*)(this->model());
+
+ model->clearAllValue();
+}
diff --git a/AT4_ValueChild.h b/AT4_ValueChild.h
new file mode 100644
index 0000000..6de84c9
--- /dev/null
+++ b/AT4_ValueChild.h
@@ -0,0 +1,72 @@
+#pragma once
+
+#include
+#include "AT4_Filter.h"
+
+class ValueMessage;
+
+class ValueDataModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ explicit ValueDataModel(QObject *parent = 0);
+ ~ValueDataModel();
+
+ void insertValue(const ValueMessage* valueMessage, const Filter::ListResult& filterResult);
+ void clearAllValue(void);
+
+ QVariant data(const QModelIndex &index, int role) const override;
+ QString data(int row, int column) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &index) const override {
+ return QModelIndex();
+ }
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override {
+ return m_valueVector.size();
+ }
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override {
+ return COLUMN_COUNTS;
+ }
+
+private:
+ enum { COLUMN_COUNTS = 3 };
+
+ struct Value
+ {
+ QString updateTime;
+ QString valueName;
+ QString valueData;
+ QColor backColor;
+ QColor frontColor;
+ };
+
+ typedef QVector ValueVector;
+ typedef QHash ValueHashMap;
+
+ ValueVector m_valueVector;
+ ValueHashMap m_valueHashMap;
+};
+
+
+class ValueChild : public QTreeView
+{
+ Q_OBJECT
+
+public:
+ void init(void);
+ void insertValue(const ValueMessage* valueMessage, const Filter::ListResult& filterResult);
+ void clearAllValue(void);
+
+private:
+ QString m_title;
+
+protected:
+ void closeEvent(QCloseEvent *event) override;
+
+public:
+ ValueChild(const QString& title);
+ virtual ~ValueChild();
+};
diff --git a/AxTrace.rc b/AxTrace.rc
new file mode 100644
index 0000000..6ee751e
--- /dev/null
+++ b/AxTrace.rc
@@ -0,0 +1,38 @@
+#include "winres.h"
+
+IDI_ICON1 ICON "images/AxTrace.ico"
+
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 4, 0, 0, 0
+ PRODUCTVERSION 4, 0, 0, 0
+ FILEFLAGSMASK 0x3fL
+ #ifdef _DEBUG
+ FILEFLAGS 0x1L
+ #else
+ FILEFLAGS 0x0L
+ #endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "080404b0"
+ BEGIN
+ VALUE "CompanyName", "thecodeway.com"
+ VALUE "FileDescription", "AxTrace4"
+ VALUE "FileVersion", "4.0.0.0"
+ VALUE "InternalName", "AxTrace.rc"
+ VALUE "LegalCopyright", "Copyright (C) thecodeway.com 2018"
+ VALUE "OriginalFilename", "AxTrace.rc"
+ VALUE "ProductName", "Axia|Trace4"
+ VALUE "ProductVersion", "4.0.0.0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x804, 1200
+ END
+END
diff --git a/AxTrace/AT_2DCamera.cpp b/AxTrace/AT_2DCamera.cpp
deleted file mode 100644
index 80ea0ab..0000000
--- a/AxTrace/AT_2DCamera.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "stdafx.h"
-#include "AT_2DCamera.h"
-
-namespace AT3
-{
-
-//-------------------------------------------------------------------------------------------------------------------
-Graphics2DCamera::Graphics2DCamera(onCameraAdjust callBack, void* param)
- : m_callBack(callBack)
- , m_param(param)
- , m_viewZoom(1.f)
- , m_viewCenter(1.f, 0.f)
-{
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-Graphics2DCamera::~Graphics2DCamera()
-{
-
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DCamera::_update(void)
-{
- Real ratio = (Real)m_winSize.x / (Real)m_winSize.y;
-
- fVector2 extents(ratio*(Real)DEFAULT_HALF_HEIGHT, (Real)DEFAULT_HALF_HEIGHT);
- extents /= m_viewZoom;
-
- fVector2 lower = m_viewCenter - extents;
- fVector2 upper = m_viewCenter + extents;
-
- if (m_callBack)
- {
- m_callBack(m_winSize.x, m_winSize.y, lower, upper, m_param);
- }
-}
-
-
-//-------------------------------------------------------------------------------------------------------------------
-fVector2 Graphics2DCamera::convertScreenToWorld(int x, int y)
-{
- Real u = x / float(m_winSize.x);
- Real v = (m_winSize.y - y) / Real(m_winSize.y);
-
- Real ratio = (Real)m_winSize.x / (Real)m_winSize.y;
-
- fVector2 extents(ratio*(Real)DEFAULT_HALF_HEIGHT, (Real)DEFAULT_HALF_HEIGHT);
- extents /= m_viewZoom;
-
- fVector2 lower = m_viewCenter - extents;
- fVector2 upper = m_viewCenter + extents;
-
- fVector2 p;
-
- p.x = (1.0f - u) * lower.x + u * upper.x;
- p.y = (1.0f - v) * lower.y + v * upper.y;
-
- return p;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-Real Graphics2DCamera::convertScreenSizeToWorld(Real size)
-{
- return size*(DEFAULT_HALF_HEIGHT / m_viewZoom) / (m_winSize.y / 2);
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DCamera::setWindowSize(int width, int height)
-{
- m_winSize.x = width;
- m_winSize.y = height;
-
- _update();
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DCamera::setViewZoom(Real viewZoom)
-{
- if (viewZoom>20.0 || viewZoom<0.01) return;
-
- m_viewZoom = viewZoom;
-
- _update();
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DCamera::pan(const fVector2& offset)
-{
- m_viewCenter -= offset;
-
- _update();
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DCamera::setSceneSize(const fVector2& sceneSize)
-{
- const float SCREEN_SCALE = 1.2f;
-
- m_viewCenter = 0.5f * sceneSize;
-
- Real screenRatio = (Real)m_winSize.x / (Real)m_winSize.y;
- Real sceneRatio = sceneSize.x / sceneSize.y;
-
- if (sceneRatio > screenRatio) {
- //use width
- m_viewZoom = DEFAULT_HALF_HEIGHT*screenRatio / (sceneSize.x*SCREEN_SCALE / 2.f);
- }
- else {
- //use height
- m_viewZoom = DEFAULT_HALF_HEIGHT / (sceneSize.y*SCREEN_SCALE / 2.f);
- }
-
- _update();
-}
-
-}
diff --git a/AxTrace/AT_2DCamera.h b/AxTrace/AT_2DCamera.h
deleted file mode 100644
index 2694a9c..0000000
--- a/AxTrace/AT_2DCamera.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#pragma once
-
-#include "AT_Math.h"
-
-namespace AT3
-{
-
-/** ¼Ç¼ÉãÏñ»úÊý¾Ý
-*/
-class Graphics2DCamera
-{
-public:
- /** ÉãÏñ»ú·¢Éú±ä»¯Ê±µÄ»Øµ÷º¯Êý */
- typedef void(*onCameraAdjust)(int sreenWidth, int screenHeight, const fVector2& lowPos, const fVector2& upperPos, void* param);
-
-public:
- /** ÉèÖô°¿Ú´óС */
- void setWindowSize(int width, int height);
- /** »ñµÃ´°¿Ú´óС */
- const iVector2& getWindowSize(void) const { return m_winSize; }
-
- /** ÆÁÄ»×ø±êת»»ÎªÂß¼×ø±ê */
- fVector2 convertScreenToWorld(int x, int y);
-
- /** ÆÁÄ»³¤¶Èת»»ÎªÂß¼³¤¶È */
- Real convertScreenSizeToWorld(Real size);
-
- /** ÉèÖ÷ÅËõϵÊý */
- void setViewZoom(Real viewZoom);
- /** »ñµÃ·ÅËõϵÊý */
- Real getViewZoom(void) const { return m_viewZoom; }
-
- /** Òƶ¯ÉãÏñ»ú */
- void pan(const fVector2& offset);
-
- /** ´«ÈëÐèÒª¹Û²ìµÄ³¡¾°µÄ´óС£¬
- * ¸Ãº¯Êý»á¸ù¾Ý³¡¾°µÄ´óСµ÷ÕûÉãÏñ»ú²ÎÊý£¬ÒÔ±£Ö¤Õû¸ö³¡¾°³öÏÖÔÚÊÓÒ°ÖÐ
- */
- void setSceneSize(const fVector2& sceneSize);
-
-protected:
- /** ¸üР*/
- void _update(void);
-
-protected:
- enum { DEFAULT_HALF_HEIGHT = 256, }; //!< ȱʡһ°ë¸ß¶ÈÆÁÄ»¶ÔÓ¦µÄÏÖʵ¸ß¶È
-
- iVector2 m_winSize; //!< ´°¿Ú´óС
- Real m_viewZoom; //!< ·ÅËõϵÊý£¬È±Ê¡1.0
- fVector2 m_viewCenter; //!< ÊÓµãÖÐÐÄ£¬È±Ê¡[0,0]
-
- onCameraAdjust m_callBack; //!< »Øµ÷º¯Êý
- void* m_param;
-
-public:
- Graphics2DCamera(onCameraAdjust callBack, void* param);
- ~Graphics2DCamera();
-};
-
-}
diff --git a/AxTrace/AT_2DFrame.cpp b/AxTrace/AT_2DFrame.cpp
deleted file mode 100644
index af0a11e..0000000
--- a/AxTrace/AT_2DFrame.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2016
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_2DFrame.h"
-#include "AT_Util.h"
-#include "AT_System.h"
-#include "AT_MainFrame.h"
-#include "AT_Config.h"
-#include "AT_Message.h"
-#include "AT_2DCamera.h"
-#include "AT_2DScene.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-Graphics2DFrameWnd::Graphics2DFrameWnd(CUpdateUIBase* pUpdateUI, const std::string& windowTitle)
- : m_pUpdateUI(pUpdateUI)
- , m_windowTitle(windowTitle)
- , m_wndCanvas(this)
-{
-}
-
-//--------------------------------------------------------------------------------------------
-Graphics2DFrameWnd::~Graphics2DFrameWnd()
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DFrameWnd::initGL(int screen_x, int screen_y)
-{
- m_camera = new Graphics2DCamera(_onCameraAdjust, this);
- m_scene = new Graphics2DScene(this);
-
- //init opengl status
- glShadeModel(GL_SMOOTH); // Enable Smooth Shading
-
- glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
- glClearDepth(1.0f); // Depth Buffer Setup
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LINE_SMOOTH);
- glDepthFunc(GL_LEQUAL);
-
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DFrameWnd::render(void)
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
-
- fVector2 lowPos = m_lowPos;
- fVector2 upperPos = m_upperPos;
- gluOrtho2D(lowPos.x, upperPos.x, lowPos.y, upperPos.y);
-
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
-
-
- m_scene->render();
-
-
- glFlush();
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DFrameWnd::_onCameraAdjust(int sreenWidth, int screenHeight, const fVector2& lowPos, const fVector2& upperPos, void* param)
-{
- Graphics2DFrameWnd* pThis = (Graphics2DFrameWnd*)param;
-
- glViewport(0, 0, sreenWidth, screenHeight);
-
- pThis->m_lowPos = lowPos;
- pThis->m_upperPos = upperPos;
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DFrameWnd::redraw(void)
-{
- m_wndCanvas.InvalidateRect(0);
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT Graphics2DFrameWnd::OnEditClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- return TRUE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT Graphics2DFrameWnd::OnCreate(UINT, WPARAM, LPARAM, BOOL& bHandled)
-{
- m_hWndClient = m_wndCanvas.Create(m_hWnd, rcDefault, NULL,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
- 0);
-
- bHandled = TRUE;
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT Graphics2DFrameWnd::OnSize(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- int width = LOWORD(lParam);
- int height = HIWORD(lParam);
- if (width > 0 && height > 0 && m_wndCanvas.m_hWnd != 0)
- {
- m_wndCanvas.MoveWindow(0, 0, width, height);
- }
- bHandled = FALSE;
- return FALSE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT Graphics2DFrameWnd::OnSetFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- System::getSingleton()->getMainFrame()->onChildActive(this);
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT Graphics2DFrameWnd::OnClose(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- System::getSingleton()->getMainFrame()->onChildDestroy(this);
- bHandled = FALSE;
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DFrameWnd::cleanMap(const G2DCleanMapMessage* message, const Filter::Result& filter)
-{
- double x_size = message->get_x_size();
- double y_size = message->get_y_size();
- fColor borderColor(fColor::convert_RGB555_to_RGB888(filter.fontColor));
- fColor backgroundColor(fColor::convert_RGB555_to_RGB888(filter.backColor));
-
- m_scene->cleanScene((Real)x_size, (Real)y_size, borderColor, backgroundColor);
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DFrameWnd::updateActor(const G2DActorMessage* message)
-{
- m_scene->updateActor(message->get_id(), message->get_x(), message->get_y(), message->get_dir());
-}
-
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_2DFrame.h b/AxTrace/AT_2DFrame.h
deleted file mode 100644
index 7b14b1c..0000000
--- a/AxTrace/AT_2DFrame.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2016
-***************************************************/
-#pragma once
-#include "Resource.h"
-#include "AT_ChildFrame.h"
-#include "AT_Util.h"
-#include "AT_Filter.h"
-#include "AT_2DView.h"
-#include "AT_Math.h"
-
-namespace AT3
-{
-//pre-define
-class LogMessage;
-class Graphics2DScene;
-class Graphics2DCamera;
-
-/** ChildFrame - Trace text
-*/
-class Graphics2DFrameWnd : public CMDIChildWindowImpl, public IChildFrame
-{
-public:
- /** get child type */
- virtual CHILD_STYLE getChildType(void) { return CS_2D_FRAME; }
- /** get window title*/
- virtual const std::string& getWindowTitle(void) { return m_windowTitle; }
- /** redraw */
- virtual void redraw(void);
-
- virtual HWND getNativeWnd(void) { return m_hWnd; }
- Graphics2DCamera* getCamera(void) { return m_camera; }
-
- void initGL(int screen_x, int screen_y);
- void render(void);
-
- void cleanMap(const G2DCleanMapMessage* message, const Filter::Result& filter);
- void updateActor(const G2DActorMessage* message);
-
- /*************************************************************************
- Inherit Methods
- *************************************************************************/
-public:
- DECLARE_FRAME_WND_CLASS(NULL, IDR_TRACE_FRAME_TYPE)
-
- virtual void OnFinalMessage(HWND /*hWnd*/)
- {
- delete this;
- }
-
- BEGIN_MSG_MAP(Graphics2DFrameWnd)
- MESSAGE_HANDLER(WM_CREATE, OnCreate)
- MESSAGE_HANDLER(WM_SIZE, OnSize)
- MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
- MESSAGE_HANDLER(WM_CLOSE, OnClose)
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear)
- COMMAND_ID_HANDLER(ID_EDIT_CLEARALL, OnEditClear)
- CHAIN_MSG_MAP(CMDIChildWindowImpl)
- CHAIN_CLIENT_COMMANDS()
- CHAIN_MSG_MAP_MEMBER(m_wndCanvas)
- END_MSG_MAP()
-
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnEditClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
-
- static void _onCameraAdjust(int sreenWidth, int screenHeight, const fVector2& lowPos, const fVector2& upperPos, void* param);
-
- /*************************************************************************
- Implementation Data
- *************************************************************************/
-private:
- Graphics2DView m_wndCanvas;
- CUpdateUIBase* m_pUpdateUI;
- std::string m_windowTitle;
- Graphics2DScene* m_scene;
- Graphics2DCamera* m_camera;
- fVector2 m_lowPos;
- fVector2 m_upperPos;
-
- /*************************************************************************
- Construction and Destruction
- *************************************************************************/
-public:
- Graphics2DFrameWnd(CUpdateUIBase* pUpdateUI, const std::string& windowTitle);
- ~Graphics2DFrameWnd();
-};
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_2DScene.cpp b/AxTrace/AT_2DScene.cpp
deleted file mode 100644
index fa4fb3c..0000000
--- a/AxTrace/AT_2DScene.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2016
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_2DScene.h"
-#include "AT_2DFrame.h"
-#include "AT_2DCamera.h"
-#include "AT_Canvas.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-struct Graphics2DScene::Actor
-{
- unsigned int id;
- fVector2 pos;
- Real dir;
-};
-
-//--------------------------------------------------------------------------------------------
-Graphics2DScene::Graphics2DScene(Graphics2DFrameWnd* frame)
- : m_frame(frame)
- , m_active(false)
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-Graphics2DScene::~Graphics2DScene()
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DScene::cleanScene(Real x_size, Real y_size, const fColor& borderColor, const fColor& backgroundColor)
-{
- m_active = true;
- m_size.x = x_size;
- m_size.y = y_size;
- m_backgroundColor = backgroundColor;
- m_borderColor = borderColor;
-
- m_frame->getCamera()->setSceneSize(fVector2(x_size, y_size));
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DScene::updateActor(unsigned int id, Real x, Real y, Real dir)
-{
- Actor* actor;
-
- //is already exist?
- ActorMap::iterator it = m_actorMap.find(id);
- if (it != m_actorMap.end()) {
- actor = it->second;
- }
- else {
- //new
- actor = new Actor;
- m_actorMap.insert(std::make_pair(id, actor));
- }
-
- actor->id = id;
- actor->pos.x = x;
- actor->pos.y = y;
- actor->dir = dir;
-}
-
-//--------------------------------------------------------------------------------------------
-void Graphics2DScene::render(void)
-{
- if (!m_active) return;
-
-
- //draw scene
- fVector2 sceneBorder[4] = { { 0.f, 0.f },{ m_size.x, 0.f },{ m_size.x, m_size.y },{ 0.f, m_size.y } };
- Canvas::drawSolidPolygon(sceneBorder, 4, m_backgroundColor);
- Canvas::drawPolygon(sceneBorder, 4, m_borderColor);
-
-
- //draw actor
- ActorMap::const_iterator it, _end = m_actorMap.end();
-
- for (it = m_actorMap.begin(); it != _end; ++it) {
- const Actor* actor = it->second;
-
- glColor3f(255.f / 255.f, 153.5F / 255.f, 255.f / 255.f);
- Canvas::drawSolidCircle(actor->pos, 1.f, fColor(1.0f, 0.0f, 0.0f, 1.0f));
- }
-
-}
-
-
-
-}
diff --git a/AxTrace/AT_2DScene.h b/AxTrace/AT_2DScene.h
deleted file mode 100644
index 07eddfd..0000000
--- a/AxTrace/AT_2DScene.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#pragma once
-
-#include "AT_Math.h"
-#include "AT_Color.h"
-
-namespace AT3
-{
-
-//pre-define
-class Graphics2DFrameWnd;
-
-class Graphics2DScene
-{
-public:
- void cleanScene(Real x_size, Real y_size, const fColor& borderColor, const fColor& backgroundColor);
- void updateActor(unsigned int id, Real x, Real y, Real dir);
-
- void render(void);
-
-private:
- Graphics2DFrameWnd* m_frame;
- bool m_active;
-
- fVector2 m_size;
- fColor m_backgroundColor;
- fColor m_borderColor;
-
- //pre-define
- struct Actor;
-
- //Actor map
- typedef std::map< unsigned int, Actor* > ActorMap;
- ActorMap m_actorMap;
-
-
-public:
- Graphics2DScene(Graphics2DFrameWnd* frame);
- ~Graphics2DScene();
-};
-
-}
diff --git a/AxTrace/AT_2DView.cpp b/AxTrace/AT_2DView.cpp
deleted file mode 100644
index 8d10a25..0000000
--- a/AxTrace/AT_2DView.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "StdAfx.h"
-#include "AT_2DView.h"
-#include "AT_2DFrame.h"
-#include "AT_2DCamera.h"
-
-namespace AT3
-{
-
-//-------------------------------------------------------------------------------------------------------------------
-Graphics2DView::Graphics2DView(Graphics2DFrameWnd* frame)
- : m_frame(frame)
-{
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-Graphics2DView::~Graphics2DView()
-{
-
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DView::OnGLInit(void)
-{
- //init system
- RECT rect;
- GetClientRect(&rect);
-
- m_frame->initGL(rect.right - rect.left, rect.bottom - rect.top);
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DView::OnGLRender(void)
-{
- m_frame->render();
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DView::OnGLResize(int width, int height)
-{
- m_frame->getCamera()->setWindowSize(width, height);
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-LRESULT Graphics2DView::OnMouseMove(UINT key, const CPoint& point)
-{
- //get mouse focus position
- _printMousePosition(point.x, point.y);
-
- return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-LRESULT Graphics2DView::OnMouseLButtonDown(UINT key, const CPoint& point)
-{
-
- return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-LRESULT Graphics2DView::OnMouseLButtonUp(UINT key, const CPoint& point)
-{
-
- return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-LRESULT Graphics2DView::OnMouseMButtonDown(UINT key, const CPoint& point)
-{
-
- return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-LRESULT Graphics2DView::OnMouseMButtonUp(UINT key, const CPoint& point)
-{
-
- return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-LRESULT Graphics2DView::OnMouseWheel(UINT key, short zDelta, const CPoint& point)
-{
-
- return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Graphics2DView::_printMousePosition(int x, int y)
-{
- fVector2 pos = m_frame->getCamera()->convertScreenToWorld(x, y);
-
- wchar_t wszTitleWithPos[MAX_PATH] = { 0 };
- StringCchPrintf(wszTitleWithPos, MAX_PATH, L"2D:%s (%.1f,%.1f)",
- convertUTF8ToUTF16(m_frame->getWindowTitle().c_str(), m_frame->getWindowTitle().length()),
- pos.x, pos.y);
-
- ::SetWindowTextW(m_frame->getNativeWnd(), wszTitleWithPos);
-}
-
-}
diff --git a/AxTrace/AT_2DView.h b/AxTrace/AT_2DView.h
deleted file mode 100644
index 4287e13..0000000
--- a/AxTrace/AT_2DView.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#pragma once
-
-#include "AtlOpengl.h"
-
-namespace AT3
-{
-
-//pre-define
-class Grphics2DMessage;
-class Graphics2DFrameWnd;
-
-/** OpenGL Canvas Window
-*/
-class Graphics2DView : public CWindowImpl, COpenGL
-{
-public:
- DECLARE_WND_CLASS_EX(NULL, 0, -1)
-
- void OnGLInit(void);
- void OnGLRender(void);
- void OnGLResize(int cx, int cy);
-
- BEGIN_MSG_MAP(Graphics2DView)
- MSG_WM_MOUSEMOVE(OnMouseMove)
- MSG_WM_LBUTTONDOWN(OnMouseLButtonDown)
- MSG_WM_LBUTTONUP(OnMouseLButtonUp)
- MSG_WM_MBUTTONDOWN(OnMouseMButtonDown)
- MSG_WM_MBUTTONUP(OnMouseMButtonUp)
- MSG_WM_MOUSEWHEEL(OnMouseWheel)
-
- CHAIN_MSG_MAP(COpenGL)
- END_MSG_MAP()
-
- /******************************************************
- Message Handle
- *******************************************************/
- LRESULT OnMouseMove(UINT key, const CPoint& point);
- LRESULT OnMouseLButtonDown(UINT key, const CPoint& point);
- LRESULT OnMouseLButtonUp(UINT key, const CPoint& point);
- LRESULT OnMouseMButtonDown(UINT key, const CPoint& point);
- LRESULT OnMouseMButtonUp(UINT key, const CPoint& point);
- LRESULT OnMouseWheel(UINT key, short zDelta, const CPoint& point);
-
-private:
- Graphics2DFrameWnd* m_frame;
-
- void _printMousePosition(int x, int y);
-
-public:
- Graphics2DView(Graphics2DFrameWnd* frame);
- virtual ~Graphics2DView();
-};
-
-}
diff --git a/AxTrace/AT_AboutDlg.cpp b/AxTrace/AT_AboutDlg.cpp
deleted file mode 100644
index 7c7a6dd..0000000
--- a/AxTrace/AT_AboutDlg.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#include "StdAfx.h"
-#include "AT_AboutDlg.h"
-
-namespace AT3
-{
-
-
-
-//--------------------------------------------------------------------------------------------
-LRESULT AboutDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- CenterWindow(GetParent());
- return (LRESULT)TRUE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT AboutDlg::OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- EndDialog(wID);
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT AboutDlg::OnSyslinkClick(int id, LPNMHDR pNMHdr, BOOL& bHandled)
-{
- PNMLINK pNMLink = (PNMLINK)pNMHdr;
- LITEM item = pNMLink->item;
-
- // Judging by the index of the link
- if (item.iLink == 0) // If it is the first link
- {
- ShellExecute(NULL, L"open", item.szUrl, NULL, NULL, SW_SHOW);
- }
- return 0;
-
-}
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_AboutDlg.h b/AxTrace/AT_AboutDlg.h
deleted file mode 100644
index 77a9795..0000000
--- a/AxTrace/AT_AboutDlg.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-#include "resource.h"
-
-namespace AT3
-{
-
-/** About Dialog Class
-*/
-class AboutDlg : public CDialogImpl
-{
-public:
- enum { IDD = IDD_DIALOG_ABOUT };
-
- BEGIN_MSG_MAP(AboutDlg)
- MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
- NOTIFY_HANDLER(IDC_SYSLINK_HOME, NM_CLICK, OnSyslinkClick)
- NOTIFY_HANDLER(IDC_SYSLINK_HOME, NM_RETURN, OnSyslinkClick)
- COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
- COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
- END_MSG_MAP()
-
- /** Init Dialog
- */
- LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- /** On Close
- */
- LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
-
- LRESULT OnSyslinkClick(int id, LPNMHDR pNMHdr, BOOL& bHandled);
-};
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_Canvas.cpp b/AxTrace/AT_Canvas.cpp
deleted file mode 100644
index a738311..0000000
--- a/AxTrace/AT_Canvas.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "StdAfx.h"
-#include "AT_Canvas.h"
-
-namespace AT3
-{
-
-//-------------------------------------------------------------------------------------------------------------------
-void Canvas::drawPolygon(const fVector2* vertices, unsigned int vertexCount, const fColor& color, Real width)
-{
- glColor4f(color.r, color.g, color.b, color.a);
- glLineWidth((GLfloat)width);
- glBegin(GL_LINE_LOOP);
- for (unsigned int i = 0; i < vertexCount; ++i)
- {
- glVertex2d(vertices[i].x, vertices[i].y);
- }
- glEnd();
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Canvas::drawSolidPolygon(const fVector2* vertices, unsigned int vertexCount, const fColor& color)
-{
- glColor4f(color.r, color.g, color.b, color.a);
-
- glBegin(GL_TRIANGLE_FAN);
- for (unsigned int i = 0; i < vertexCount; ++i)
- {
- glVertex2d(vertices[i].x, vertices[i].y);
- }
- glEnd();
-
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-void Canvas::drawSolidCircle(const fVector2& center, Real radius, const fColor& color)
-{
- const float k_segments = 32.0f;
- const float k_increment = (float)MATH_PI_DOUBLE / k_segments;
- float theta = 0.0f;
-
- glColor4f(color.r, color.g, color.b, color.a);
-
- glBegin(GL_TRIANGLE_FAN);
-
- for (int i = 0; i < k_segments; ++i)
- {
- fVector2 p = center + radius * fVector2(cosf(theta), sinf(theta));
-
- glVertex2d(p.x, p.y);
- theta += k_increment;
- }
- glEnd();
-}
-
-}
diff --git a/AxTrace/AT_Canvas.h b/AxTrace/AT_Canvas.h
deleted file mode 100644
index 3aa35d9..0000000
--- a/AxTrace/AT_Canvas.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-
-#include "AT_Math.h"
-#include "AT_Color.h"
-
-namespace AT3
-{
-/** »²¼Àà
-*/
-class Canvas
-{
-public:
- static void drawPolygon(const fVector2* vertices, unsigned int vertexCount, const fColor& color, Real width=(Real)1.0);
- static void drawSolidPolygon(const fVector2* vertices, unsigned int vertexCount, const fColor& color);
-
- static void drawSolidCircle(const fVector2& center, Real radius, const fColor& color);
-};
-
-}
diff --git a/AxTrace/AT_ChildFrame.h b/AxTrace/AT_ChildFrame.h
deleted file mode 100644
index ac19bad..0000000
--- a/AxTrace/AT_ChildFrame.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-
-
-namespace AT3
-{
-/** ChildFrame base interface
-*/
-class IChildFrame
-{
-public:
- enum CHILD_STYLE
- {
- CS_LOG_FRAME,
- CS_VALUE_FRAME,
- CS_2D_FRAME,
- };
-
- /** get child type */
- virtual CHILD_STYLE getChildType(void) = 0;
- /** get window title*/
- virtual const std::string& getWindowTitle(void) = 0;
- /** get native wnd handle */
- virtual HWND getNativeWnd(void) = 0;
- /** redraw */
- virtual void redraw(void) = 0;
-};
-
-}
diff --git a/AxTrace/AT_Color.cpp b/AxTrace/AT_Color.cpp
deleted file mode 100644
index 0e4e452..0000000
--- a/AxTrace/AT_Color.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "StdAfx.h"
-#include "AT_Color.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-uint32_t fColor::convert_RGB555_to_RGB888(uint16_t rgb, uint16_t a)
-{
- // 0bbb bbgg gggr rrrr
- // |
- // v
- // 0000 0000 bbbb b000 gggg g000 rrrr r000
- uint32_t r = (rgb & 0x000F) * 0xFF / 0xF;
- uint32_t g = ((rgb & 0x00F0) >> 4) * 0xFF / 0xF;
- uint32_t b = ((rgb & 0x0F00) >> 8) * 0xFF / 0xF;
-
- return ((uint32_t)(((BYTE)(r) | ((WORD)((BYTE)(g)) << 8)) | (((DWORD)(BYTE)(b)) << 16)) | (((DWORD)(BYTE)(a)) << 24));
-}
-
-}
diff --git a/AxTrace/AT_Color.h b/AxTrace/AT_Color.h
deleted file mode 100644
index 2fa8d22..0000000
--- a/AxTrace/AT_Color.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-namespace AT3
-{
-
-class fColor
-{
-public:
- float r, g, b, a;
-
-public:
- static uint32_t convert_RGB555_to_RGB888(uint16_t rgb, uint16_t a=255);
-
-public:
- fColor() : r(0.f), g(0.f), b(0.f), a(0.f) {}
- fColor(float _r, float _g, float _b, float _a) : r(_r), g(_g), b(_b), a(_a) {}
- fColor(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a) : r(_r / 255.f), g(_g / 255.f), b(_b / 255.f), a(_a / 255.f) {}
- fColor(unsigned int color)
- : r((color & 0xFF) / 255.f)
- , g(((color >> 8) & 0xFF) / 255.f)
- , b(((color >> 16) & 0xFF) / 255.f)
- , a(((color >> 24) & 0xFF) / 255.f) {
- }
-};
-
-}
diff --git a/AxTrace/AT_Config.cpp b/AxTrace/AT_Config.cpp
deleted file mode 100644
index e98ff47..0000000
--- a/AxTrace/AT_Config.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#include "StdAfx.h"
-#include "AT_Config.h"
-#include "AT_Util.h"
-#include "AT_Filter.h"
-
-#include "utf/ConvertUTF.h"
-
-namespace AT3
-{
-/** Regist key
-*/
-const TCHAR* g_szAxTrace3Key = _T("SOFTWARE\\AXIA\\AxTrace3");
-
-//--------------------------------------------------------------------------------------------
-Config::Config()
- : m_hFont(0)
-{
- // reset setting to default
- _resetDefaultSetting();
-}
-
-//--------------------------------------------------------------------------------------------
-Config::Config(const Config& other)
- : m_hFont(0)
-{
- // reset setting to default
- _resetDefaultSetting();
- copyFrom(other);
-}
-
-//--------------------------------------------------------------------------------------------
-Config::~Config()
-{
- if(m_hFont) ::DeleteObject(m_hFont);
-}
-
-//--------------------------------------------------------------------------------------------
-void Config::_resetDefaultSetting(void)
-{
- m_bCapture = true;
- m_bAutoscroll = true;
-
- m_bAlwaysOnTop = false;
- m_bShowMilliseconds = true;
-
- if(m_hFont) ::DeleteObject(m_hFont);
-
- LOGFONT lf={0};
- ::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
- m_hFont = CreateFontIndirect(&lf);
-
- //set default
- COLORREF colBak = GetSysColor(COLOR_WINDOW);
- COLORREF colFront = GetSysColor(COLOR_WINDOWTEXT);
-
- m_filterScript =
- "function onLogMessage(msg) \r\n"
- " local frontColor=COL_BLACK; \r\n"
- " local backColor=COL_WHITE; \r\n"
- " local msgStyle=msg:get_style(); \r\n"
- " if(msgStyle==AXT_ERROR) then \r\n"
- " frontColor=COL_RED; \r\n"
- " end; \r\n"
- " if(msgStyle==AXT_FATAL) then \r\n"
- " frontColor=COL_RED; \r\n"
- " backColor=COL_YELLOW; \r\n"
- " end; \r\n"
- " return true, \"defult\", frontColor, backColor; \r\n"
- "end; \r\n"
- "\r\n"
- "function onValueMessage(msg) \r\n"
- " return true, \"defult\", COL_BLACK, COL_WHITE; \r\n"
- "end; \r\n"
- "function on2DCleanMapMessage(msg) \r\n"
- "return true, msg:get_mapname(), COL_WHITE, 0xf93;\r\n"
- "end;\r\n"
- ;
-}
-
-//--------------------------------------------------------------------------------------------
-void Config::setFilterScript(const char* script)
-{
- m_filterScript = script;
- saveSetting();
-}
-
-//--------------------------------------------------------------------------------------------
-void Config::copyFrom(const Config& other)
-{
- m_bCapture = other.m_bCapture;
- m_bAutoscroll = other.m_bAutoscroll;
- m_bAlwaysOnTop = other.m_bAlwaysOnTop;
- m_bShowMilliseconds = other.m_bShowMilliseconds;
-
- if(m_hFont) ::DeleteObject(m_hFont);
- LOGFONT lf={0};
- GetObject(other.m_hFont, sizeof(lf),&lf);
- m_hFont = CreateFontIndirect(&lf);
-
- m_filterScript = other.m_filterScript;
-}
-
-//--------------------------------------------------------------------------------------------
-void Config::loadSetting(void)
-{
- _resetDefaultSetting();
-
- DWORD type = REG_DWORD;
- DWORD size = sizeof(DWORD);
- DWORD dwTemp;
- TCHAR wszTemp[MAX_PATH] = { 0 };
-
- #define LOAD_BOOL_FROM_REG(param, name) \
- if(ERROR_SUCCESS == SHGetValue(HKEY_CURRENT_USER, g_szAxTrace3Key, name, &type, &dwTemp, &size)) \
- { \
- param = (dwTemp!=0); \
- }
-
- LOAD_BOOL_FROM_REG(m_bAlwaysOnTop, _T("AlwaysOnTop"));
- LOAD_BOOL_FROM_REG(m_bShowMilliseconds, _T("ShowMillisenconds"));
-
- //get font
- LOGFONT lf;
- type=REG_BINARY;
- size=sizeof(lf);
- if(ERROR_SUCCESS == SHGetValue(HKEY_CURRENT_USER, g_szAxTrace3Key, _T("Font"), &type, &lf, &size))
- {
- setFont(&lf);
- }
-
- // Load filter script
- wchar_t* szScriptBuf = new wchar_t[Filter::MAX_SCRIPT_LENGTH_IN_CHAR];
- size = Filter::MAX_SCRIPT_LENGTH_IN_CHAR * sizeof(wchar_t);
- if (ERROR_SUCCESS == SHGetValue(HKEY_CURRENT_USER, g_szAxTrace3Key, _T("FilterScript"), &type, szScriptBuf, &size))
- {
- m_filterScript = convertUTF16ToUTF8(szScriptBuf, size/ sizeof(wchar_t));
- }
-}
-
-//--------------------------------------------------------------------------------------------
-void Config::saveSetting(void) const
-{
- DWORD dwTemp;
-
- // Save dword value to regist
- #define SAVE_BOOL_TO_REG(param, name) \
- dwTemp = (param) ? 1 : 0; \
- SHSetValue(HKEY_CURRENT_USER, g_szAxTrace3Key, \
- name, REG_DWORD, &dwTemp, sizeof(DWORD));
-
- SAVE_BOOL_TO_REG(m_bAlwaysOnTop, _T("AlwaysOnTop"));
- SAVE_BOOL_TO_REG(m_bShowMilliseconds, _T("ShowMillisenconds"));
-
- //save font data
- LOGFONT lf;
- GetObject(m_hFont, sizeof(lf), &lf);
- SHSetValue(HKEY_CURRENT_USER, g_szAxTrace3Key, _T("Font"), REG_BINARY, &lf, sizeof(lf));
-
- // Filter script
- const wchar_t* wszScript = convertUTF8ToUTF16(m_filterScript.c_str(), m_filterScript.length()+1);
- SHSetValue(HKEY_CURRENT_USER, g_szAxTrace3Key, _T("FilterScript"),
- REG_SZ, wszScript, (DWORD)_tcslen(wszScript) * sizeof(wchar_t));
-}
-
-//--------------------------------------------------------------------------------------------
-void Config::setFont(LPLOGFONT lf)
-{
- if(m_hFont) ::DeleteObject(m_hFont);
- m_hFont = CreateFontIndirect(lf);
-}
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_Config.h b/AxTrace/AT_Config.h
deleted file mode 100644
index a9565dd..0000000
--- a/AxTrace/AT_Config.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-
-namespace AT3
-{
-
-/**Config System
-*/
-class Config
-{
- /*************************************************************************
- Public Methods
- *************************************************************************/
-public:
- /** Load setting from regist*/
- void loadSetting(void);
- /** Save setting to regist */
- void saveSetting(void) const;
- /** copy other to self*/
- void copyFrom(const Config& other);
-
- bool getCapture(void) const { return m_bCapture; }
- void setCapture(bool c) { m_bCapture=c; }
- bool getAutoScroll(void) const { return m_bAutoscroll; }
- void setAutoScroll(bool a) { m_bAutoscroll=a; }
- HFONT getFont(void) const { return m_hFont; }
- void setFont(LPLOGFONT lf);
-
- const std::string& getFilterScript(void) const { return m_filterScript; }
- void setFilterScript(const char* script);
-
- /*************************************************************************
- Implementation Methods
- *************************************************************************/
-private:
- /** Reset setting to default
- */
- void _resetDefaultSetting(void);
-
- /*************************************************************************
- Implementation Data
- *************************************************************************/
-private:
- bool m_bCapture; //!< Capturing or stop capture (default : true)
- bool m_bAutoscroll; //!< Auto scroll trace window (default : true)
- bool m_bAlwaysOnTop; //!< Mainframe always on top (default : false)
- bool m_bShowMilliseconds; //!< Show milliseconds (default : true)
-
- HFONT m_hFont;
- std::string m_filterScript;
-
- /*************************************************************************
- Construction and Destruction
- *************************************************************************/
-public:
- Config();
- Config(const Config& other);
- ~Config();
-};
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_Filter.cpp b/AxTrace/AT_Filter.cpp
deleted file mode 100644
index f1b9e94..0000000
--- a/AxTrace/AT_Filter.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_Filter.h"
-#include "AT_Config.h"
-#include "AT_System.h"
-#include "AT_MainFrame.h"
-#include "AT_Message.h"
-#include "AT_Util.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-Filter::Filter()
- : L(0)
- , m_cfg(0)
- , m_hNotepadProcess(0)
- , m_hMonitorThread(0)
-{
-}
-
-//--------------------------------------------------------------------------------------------
-Filter::~Filter()
-{
-}
-
-//--------------------------------------------------------------------------------------------
-void Filter::init(Config* cfg)
-{
- assert(cfg);
-
- L = luaL_newstate();
- luaL_openlibs(L);
-
- //register functions
- Filter::_luaopen(L);
- Message::_luaopen(L);
-
- m_cfg = cfg;
-}
-
-//--------------------------------------------------------------------------------------------
-bool Filter::reloadScript(const char* script, HWND hwnd)
-{
- //run init lua script
- if (luaL_dostring(L, script)) {
- const char* error_msg = lua_tostring(L, -1);
- MessageBoxA(hwnd, error_msg, "LoadScript Error", MB_OK | MB_ICONSTOP);
- return false;
- }
- return true;
-}
-
-//--------------------------------------------------------------------------------------------
-void Filter::_luaopen(lua_State* L)
-{
- lua_pushinteger(L, 0x000); lua_setglobal(L, "COL_BLACK");
- lua_pushinteger(L, 0xFFF); lua_setglobal(L, "COL_WHITE");
- lua_pushinteger(L, 0x00F); lua_setglobal(L, "COL_RED");
- lua_pushinteger(L, 0x0F0); lua_setglobal(L, "COL_GREEN");
- lua_pushinteger(L, 0xF00); lua_setglobal(L, "COL_BLUE");
- lua_pushinteger(L, 0x777); lua_setglobal(L, "COL_GRAY");
- lua_pushinteger(L, 0x0FF); lua_setglobal(L, "COL_YELLOW");
- lua_pushinteger(L, 0x06F); lua_setglobal(L, "COL_ORANGE");
- lua_pushinteger(L, 0xF0F); lua_setglobal(L, "COL_VIOLET");
-
- lua_pushinteger(L, 0); lua_setglobal(L, "AXT_TRACE");
- lua_pushinteger(L, 1); lua_setglobal(L, "AXT_DEBUG");
- lua_pushinteger(L, 2); lua_setglobal(L, "AXT_INFO");
- lua_pushinteger(L, 3); lua_setglobal(L, "AXT_WARN");
- lua_pushinteger(L, 4); lua_setglobal(L, "AXT_ERROR");
- lua_pushinteger(L, 5); lua_setglobal(L, "AXT_FATAL");
- lua_pushinteger(L, 10); lua_setglobal(L, "AXT_USERDEF");
-}
-
-//--------------------------------------------------------------------------------------------
-void Filter::onLogMessage(const LogMessage* message, Result& result)
-{
- lua_getglobal(L, "onLogMessage");
-
- lua_pushlightuserdata(L, (void*)message);
-
- luaL_getmetatable(L, Message::MESSAGE_META_NAME);
- lua_setmetatable(L, -2);
- lua_pcall(L, 1, 4, 0);
-
- result.display = (lua_toboolean(L, -4)!=0);
- if (result.display) {
- result.wndTitle = lua_tostring(L, -3);
- result.fontColor = (uint16_t)(lua_tointeger(L, -2) & 0xFFF);
- result.backColor = (uint16_t)(lua_tointeger(L, -1) & 0xFFF);
- }
-
- lua_pop(L, 4);
-}
-
-//--------------------------------------------------------------------------------------------
-void Filter::onValueMessage(const ValueMessage* message, Result& result)
-{
- lua_getglobal(L, "onValueMessage");
- lua_pushlightuserdata(L, (void*)message);
-
- luaL_getmetatable(L, Message::MESSAGE_META_NAME);
- lua_setmetatable(L, -2);
- lua_pcall(L, 1, 4, 0);
-
- result.display = (lua_toboolean(L, -4) != 0);
- if (result.display) {
- result.wndTitle = lua_tostring(L, -3);
- result.fontColor = (uint16_t)(lua_tointeger(L, -2) & 0xFFFF);
- result.backColor = (uint16_t)(lua_tointeger(L, -1) & 0xFFFF);
- }
- lua_pop(L, 4);
-}
-
-//--------------------------------------------------------------------------------------------
-void Filter::on2DCleanMapMessage(const G2DCleanMapMessage* message, Result& result)
-{
- result.display = true;
-
- lua_getglobal(L, "on2DCleanMapMessage");
-
- lua_pushlightuserdata(L, (void*)message);
-
- luaL_getmetatable(L, Message::MESSAGE_META_NAME);
- lua_setmetatable(L, -2);
- lua_pcall(L, 1, 4, 0);
-
- result.display = (lua_toboolean(L, -4) != 0);
- if (result.display) {
- result.wndTitle = lua_tostring(L, -3);
- result.fontColor = (uint16_t)(lua_tointeger(L, -2) & 0xFFF);
- result.backColor = (uint16_t)(lua_tointeger(L, -1) & 0xFFF);
- }
-
- lua_pop(L, 4);
-}
-
-//--------------------------------------------------------------------------------------------
-void Filter::on2DActorMessage(const G2DActorMessage* message, Result& result)
-{
- result.display = true;
- result.wndTitle = message->getMapName();
-}
-
-//--------------------------------------------------------------------------------------------
-static BOOL CALLBACK _findCurrentNotepad(HWND hWnd, LPARAM lParam)
-{
- DWORD notepadProcessID = (DWORD)lParam;
-
- DWORD processID=0;
- ::GetWindowThreadProcessId(hWnd, &processID);
-
- if (processID == notepadProcessID) {
- ::SetForegroundWindow(hWnd);
- return false;
- }
- return true;
-}
-
-//--------------------------------------------------------------------------------------------
-bool Filter::editScriptWithNotepad(void)
-{
- if (m_hNotepadProcess != 0 && ::WaitForSingleObject(m_hNotepadProcess, 0)!=WAIT_OBJECT_0) {
- //set current notepad window to foreground
- EnumWindows(_findCurrentNotepad, (LPARAM)m_dwNotepadProcessID);
- return true;
- }
-
- //get temp path
- wchar_t wszTempPath[MAX_PATH] = { 0 };
- GetTempPath(MAX_PATH, wszTempPath);
- PathAppend(wszTempPath, L"axtrace_temp");
- if (!CreateDirectory(wszTempPath, 0) && ::GetLastError() != ERROR_ALREADY_EXISTS) {
- return false;
- }
- m_strTempPath = wszTempPath;
-
- //create temp file
- wchar_t wszTempFile[MAX_PATH] = { 0 };
- StringCchCopy(wszTempFile, MAX_PATH, wszTempPath);
- PathAppend(wszTempFile, L"script.lua");
- HANDLE hTempFile = ::CreateFile(wszTempFile,
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- 0,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_ARCHIVE,
- 0);
-
- if (hTempFile == INVALID_HANDLE_VALUE) {
- return false;
- }
- m_strTempFile = wszTempFile;
-
- //write script to file
- DWORD dwBytesWrite;
- if (!::WriteFile(hTempFile, m_cfg->getFilterScript().c_str(), (DWORD)m_cfg->getFilterScript().length(), &dwBytesWrite, 0) ||
- dwBytesWrite != m_cfg->getFilterScript().length())
- {
- CloseHandle(hTempFile);
- return false;
- }
- CloseHandle(hTempFile);
-
- //get file attribute
- WIN32_FILE_ATTRIBUTE_DATA wfad;
- if (!GetFileAttributesEx(wszTempFile, GetFileExInfoStandard, &wfad)) {
- return false;
- }
- m_timeScriptLastWriteTime = wfad.ftLastWriteTime;
-
- //command line
- wchar_t wszNotepad[MAX_PATH] = { 0 };
- ::GetSystemDirectory(wszNotepad, MAX_PATH);
- ::PathAppend(wszNotepad, L"notepad.exe");
-
- wchar_t wszCommandLine[MAX_PATH] = { 0 };
- StringCchPrintf(wszCommandLine, MAX_PATH, L"%s \"%s\"", wszNotepad, wszTempFile);
-
- //create a notepad process to edit
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- ZeroMemory(&si, sizeof(STARTUPINFO));
- ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
-
- si.cb = sizeof(STARTUPINFO);
- si.dwFlags = STARTF_USESHOWWINDOW;
- si.wShowWindow = SW_SHOW;
-
- if (CreateProcess(NULL, wszCommandLine, NULL, NULL,
- FALSE, CREATE_DEFAULT_ERROR_MODE, NULL,
- wszTempPath, &si, &pi) == FALSE) {
- return false;
- }
- m_hNotepadProcess = pi.hProcess;
- m_dwNotepadProcessID = pi.dwProcessId;
-
- //create monitor thread
- unsigned int thread_id;
- m_hMonitorThread = (HANDLE)::_beginthreadex(0, 0,
- _monitor_thread_entry, (void*)(this),
- THREAD_QUERY_INFORMATION | THREAD_SUSPEND_RESUME, &thread_id);
-
-
- return true;
-}
-
-//--------------------------------------------------------------------------------------------
-unsigned int Filter::_monitor_thread_entry(void)
-{
- HANDLE hChangeEvent = FindFirstChangeNotification(m_strTempPath.c_str(), FALSE,
- FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_ATTRIBUTES|FILE_NOTIFY_CHANGE_LAST_WRITE);
- if (hChangeEvent == INVALID_HANDLE_VALUE) {
- return 1;
- }
-
- for (;;) {
- HANDLE hWaitEvent[2];
- hWaitEvent[0] = m_hNotepadProcess;
- hWaitEvent[1] = hChangeEvent;
-
- DWORD result = ::WaitForMultipleObjects(2, hWaitEvent, FALSE, INFINITE);
-
- if (result == WAIT_OBJECT_0) {
- //notepad process be closed
- break;
- }
- else if (result == WAIT_OBJECT_0 + 1) {
- //is script file be modified
- WIN32_FILE_ATTRIBUTE_DATA wfad;
- if (!GetFileAttributesEx(m_strTempFile.c_str(), GetFileExInfoStandard, &wfad)) {
- return false;
- }
- if (wfad.ftLastWriteTime.dwHighDateTime != m_timeScriptLastWriteTime.dwHighDateTime ||
- wfad.ftLastWriteTime.dwLowDateTime!= m_timeScriptLastWriteTime.dwLowDateTime) {
- //notify main thread to reload script
- System::getSingleton()->getMainFrame()->SendMessageW(MainFrame::WM_ON_RELOADSCRIPT_MESSAGE, (WPARAM)m_strTempFile.c_str(), 0);
-
- m_timeScriptLastWriteTime = wfad.ftLastWriteTime;
- }
-
- //wait next change
- if (FALSE == FindNextChangeNotification(hChangeEvent)) {
- break;
- }
- continue;
- }
-
- }
-
- //Close change event
- FindCloseChangeNotification(hChangeEvent);
-
- //close notepad process;
- CloseHandle(m_hNotepadProcess);
- m_hNotepadProcess = 0;
-
- CloseHandle(m_hMonitorThread);
- m_hMonitorThread = 0;
-
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-bool Filter::tryReloadScriptFile(const char* script, std::string& errorMessage)
-{
- lua_State* testL = luaL_newstate();
- luaL_openlibs(testL);
-
- Filter::_luaopen(testL);
- Message::_luaopen(testL);
-
- //run init lua script
- if (luaL_dostring(testL, script)) {
- errorMessage = lua_tostring(testL, -1);
- lua_close(testL);
- return false;
- }
-
- //check necessary function
- lua_getglobal(testL, "onLogMessage");
- if (!lua_isfunction(testL, -1)) {
- errorMessage = "Missing function \"onLogMessage\"";
- lua_close(testL);
- return false;
- }
- lua_pop(testL, 1);
-
- lua_getglobal(testL, "onValueMessage");
- if (!lua_isfunction(testL, -1)) {
- errorMessage = "Missing function \"onValueMessage\"";
- lua_close(testL);
- return false;
- }
- lua_pop(testL, 1);
-
- lua_close(testL);
- return true;
-}
-
-}
diff --git a/AxTrace/AT_Filter.h b/AxTrace/AT_Filter.h
deleted file mode 100644
index faf37f8..0000000
--- a/AxTrace/AT_Filter.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#pragma once
-
-namespace AT3
-{
-
-//predefine
-class LogMessage;
-class ValueMessage;
-class G2DCleanMapMessage;
-class G2DActorMessage;
-class Config;
-
-class Filter
-{
-public:
-
- struct Result
- {
- bool display;
- std::string wndTitle; //utf8
- uint16_t fontColor;
- uint16_t backColor;
- };
-
- enum { MAX_SCRIPT_LENGTH_IN_CHAR = 1024*1024*2 };
-
-public:
- void init(Config* cfg);
- bool reloadScript(const char* script, HWND hwnd);
- bool tryReloadScriptFile(const char* script, std::string& errorMessage);
-
- void onLogMessage(const LogMessage* message, Result& result);
- void onValueMessage(const ValueMessage* message, Result& result);
- void on2DCleanMapMessage(const G2DCleanMapMessage* message, Result& result);
- void on2DActorMessage(const G2DActorMessage* message, Result& result);
-
- bool editScriptWithNotepad(void);
-
-public:
- static void _luaopen(lua_State* L);
-
-private:
- lua_State* L;
- Config* m_cfg;
- std::wstring m_strTempPath;
- std::wstring m_strTempFile;
- HANDLE m_hNotepadProcess;
- HANDLE m_hMonitorThread;
- DWORD m_dwNotepadProcessID;
- FILETIME m_timeScriptLastWriteTime;
-
-private:
- static unsigned int __stdcall _monitor_thread_entry(void* param) {
- return ((Filter*)param)->_monitor_thread_entry();
- }
- unsigned int _monitor_thread_entry(void);
-
-public:
- Filter();
- virtual ~Filter();
-};
-
-}
diff --git a/AxTrace/AT_Global.h b/AxTrace/AT_Global.h
deleted file mode 100644
index ae23d71..0000000
--- a/AxTrace/AT_Global.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#pragma once
-
-namespace AT3
-{
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_ListCtrlEx.cpp b/AxTrace/AT_ListCtrlEx.cpp
deleted file mode 100644
index a87f3d7..0000000
--- a/AxTrace/AT_ListCtrlEx.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_ListCtrlEx.h"
-#include "AT_Config.h"
-#include "AT_System.h"
-#include "AT_Color.h"
-
-namespace AT3
-{
-//--------------------------------------------------------------------------------------------
-CListCtrlEx::CListCtrlEx()
-{
-
-}
-//--------------------------------------------------------------------------------------------
-CListCtrlEx::~CListCtrlEx()
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT CListCtrlEx::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
-{
- // Colors
- clrBk = ::GetSysColor(COLOR_WINDOW);
-
- clrCellBk = RGB(0x00,0xFF,0x00);
- clrCell = RGB(0xff,0,0);
-
- clrGridBk = RGB(0x00,0x00,0xFF);
- clrGrid = RGB(0x7f,0,0);
-
- bHandled = FALSE;
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT CListCtrlEx::OnShowWindow(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
-{
- SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
- SetFont(System::getSingleton()->getConfig()->getFont());
- SetBkColor(clrBk);
-
- bHandled = FALSE;
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-DWORD CListCtrlEx::OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
-{
- return CDRF_NOTIFYITEMDRAW;
-}
-
-//--------------------------------------------------------------------------------------------
-DWORD CListCtrlEx::OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW pCD)
-{
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(pCD);
-
- const Config* config = System::getSingleton()->getConfig();
-
- uint32_t color = (uint32_t)(pCD->lItemlParam);
-
- pLVCD->clrText = fColor::convert_RGB555_to_RGB888((uint16_t)(color>>16), 0);
- pLVCD->clrTextBk = fColor::convert_RGB555_to_RGB888((uint16_t)color, 0);
- return CDRF_DODEFAULT;
-}
-
-//--------------------------------------------------------------------------------------------
-void CListCtrlEx::scrollToBottom(void)
-{
- int n = GetItemCount();
- if(n>0)
- {
- EnsureVisible(n-1, FALSE);
- }
-}
-
-//--------------------------------------------------------------------------------------------
-void CListCtrlEx::copyToClipboard(void)
-{
- int nItem = (int)GetNextItem(-1, LVIS_SELECTED);
-
- if(nItem<0) return;
- if(!OpenClipboard()) return;
-
- int columnCounts = Header_GetItemCount(ListView_GetHeader(m_hWnd));
-
- std::wstring strClip;
- wchar_t wszTemp[MAX_SUBITEM_LENGTH]={0};
- while(nItem>=0)
- {
- for (int i = 0; iGetItemCount();
- for(int i=0; i, public CCustomDraw
-{
-public:
- BEGIN_MSG_MAP(CListCtrlEx)
- MESSAGE_HANDLER(WM_CREATE, OnCreate)
- MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow)
-
- CHAIN_MSG_MAP(CCustomDraw)
- END_MSG_MAP()
-
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnShowWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
-
- DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/);
- DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW pCD);
-
-public:
- enum { MAX_SUBITEM_LENGTH=2048 }; //hack...
-
- /** scroll to bottom */
- void scrollToBottom(void);
- /** copy select to clipboard */
- void copyToClipboard(void);
- /** save as a file*/
- void saveToFile(void);
-
-private:
- COLORREF clrCell, clrCellBk, clrRow, clrRowBk, clrGrid, clrGridBk, clrBk;
-
-public:
- CListCtrlEx();
- ~CListCtrlEx();
-};
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_LogFrame.cpp b/AxTrace/AT_LogFrame.cpp
deleted file mode 100644
index 4fac257..0000000
--- a/AxTrace/AT_LogFrame.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_LogFrame.h"
-#include "AT_Util.h"
-#include "AT_System.h"
-#include "AT_MainFrame.h"
-#include "AT_Config.h"
-#include "AT_Message.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-LogFrameWnd::LogFrameWnd(CUpdateUIBase* pUpdateUI, const std::string& windowTitle)
- : m_pUpdateUI(pUpdateUI)
- , m_windowTitle(windowTitle)
- , m_nLogIndex(0)
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-LogFrameWnd::~LogFrameWnd()
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-void LogFrameWnd::redraw(void)
-{
- m_wndListView.SetFont(System::getSingleton()->getConfig()->getFont());
- m_wndListView.InvalidateRect(0);
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT LogFrameWnd::OnEditCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_wndListView.copyToClipboard();
- return TRUE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT LogFrameWnd::OnEditClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_wndListView.DeleteAllItems();
- m_nLogIndex = 0;
- return TRUE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT LogFrameWnd::OnEditSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- int count=m_wndListView.GetItemCount();
- for(int i=0; i0 && height>0 && m_wndListView.m_hWnd!=0 )
- {
- RECT rect;
- GetClientRect(&rect);
-
- int total = 0;
- for (int i = 0; i < 4; i++)
- total += m_wndListView.GetColumnWidth(i);
-
- m_wndListView.MoveWindow(0, 0, width, height);
- m_wndListView.SetColumnWidth(4, width - total - 32);
- }
- bHandled = FALSE;
- return FALSE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT LogFrameWnd::OnSetFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- System::getSingleton()->getMainFrame()->onChildActive(this);
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-void LogFrameWnd::insertLog(const LogMessage* message, const Filter::Result& filter)
-{
- const AXIATRACE_TIME* tTime = message->getTraceTime();
- unsigned int styleID = message->getStyleID();
-
- int nCount = m_wndListView.GetItemCount();
-
- wchar_t wszTemp[MAX_PATH];
- StringCchPrintfW(wszTemp, MAX_PATH, _T("%d"), m_nLogIndex++);
- m_wndListView.InsertItem(nCount, wszTemp);
-
- //Time
- StringCchPrintfW(wszTemp, MAX_PATH, _T("%02d:%02d %02d.%d"), tTime->wHour, tTime->wMinute, tTime->wSecond, tTime->wMilliseconds);
- m_wndListView.SetItemText(nCount, 1, wszTemp);
-
- //PID
- StringCchPrintfW(wszTemp, MAX_PATH, _T("%d"), message->getProcessID());
- m_wndListView.SetItemText(nCount, 2, wszTemp);
-
- //TID
- StringCchPrintfW(wszTemp, MAX_PATH, _T("%d"), message->getThreadID());
- m_wndListView.SetItemText(nCount, 3, wszTemp);
-
- //may be multi line
- const wchar_t* current = message->getLogBuf();
- do
- {
- const wchar_t* end = wcschr(current, L'\n');
- if(end==0)
- {
- if(m_wndListView.GetItemCount()!=nCount+1)
- {
- m_wndListView.InsertItem(nCount, _T(""));
- }
- m_wndListView.SetItemText(nCount, 4, current);
- m_wndListView.SetItemData(nCount, (DWORD_PTR)((filter.fontColor<<16) | filter.backColor));
- break;
- }
- else
- {
- size_t lineChar = end-current;
- wchar_t* lineBuf = (wchar_t*)m_bufMaxLine.request((lineChar+1)*sizeof(wchar_t));
- memcpy(lineBuf, current, lineChar*sizeof(wchar_t));
- lineBuf[lineChar]=0;
-
- if(m_wndListView.GetItemCount()!=nCount+1)
- {
- m_wndListView.InsertItem(nCount, _T(""));
- }
- m_wndListView.SetItemText(nCount, 4, lineBuf);
- m_wndListView.SetItemData(nCount, (DWORD_PTR)((filter.fontColor << 16) | filter.backColor));
-
- //next
- nCount++;
- current=end+1;
- }
- }while(true);
-
- if(System::getSingleton()->getConfig()->getAutoScroll())
- {
- m_wndListView.scrollToBottom();
- }
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT LogFrameWnd::OnClose(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- System::getSingleton()->getMainFrame()->onChildDestroy(this);
- bHandled=FALSE;
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT LogFrameWnd::OnFileSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_wndListView.saveToFile();
- return 1;
-}
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_LogFrame.h b/AxTrace/AT_LogFrame.h
deleted file mode 100644
index 94a7eeb..0000000
--- a/AxTrace/AT_LogFrame.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-#include "Resource.h"
-#include "AT_ListCtrlEx.h"
-#include "AT_ChildFrame.h"
-#include "AT_Util.h"
-#include "AT_Filter.h"
-
-namespace AT3
-{
-//pre-define
-class LogMessage;
-
-/** ChildFrame - Trace text
-*/
-class LogFrameWnd : public CMDIChildWindowImpl, public IChildFrame
-{
-public:
- /** insert a log message */
- void insertLog(const LogMessage* message, const Filter::Result& filter);
- /** get child type */
- virtual CHILD_STYLE getChildType(void) { return CS_LOG_FRAME; }
- /** get window title*/
- virtual const std::string& getWindowTitle(void) { return m_windowTitle; }
- /** redraw */
- virtual void redraw(void);
- /** get native wnd handle */
- virtual HWND getNativeWnd(void) { return m_hWnd; }
-
- /*************************************************************************
- Inherit Methods
- *************************************************************************/
-public:
- DECLARE_FRAME_WND_CLASS(NULL, IDR_TRACE_FRAME_TYPE)
-
- virtual void OnFinalMessage(HWND /*hWnd*/)
- {
- delete this;
- }
-
- BEGIN_MSG_MAP(LogFrameWnd)
- MESSAGE_HANDLER(WM_CREATE, OnCreate)
- MESSAGE_HANDLER(WM_SIZE, OnSize)
- MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
- MESSAGE_HANDLER(WM_CLOSE, OnClose)
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear)
- COMMAND_ID_HANDLER(ID_EDIT_CLEARALL, OnEditClear)
- COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy)
- COMMAND_ID_HANDLER(ID_EDIT_SELECTALL, OnEditSelectAll)
- COMMAND_ID_HANDLER(ID_FILE_SAVEAS, OnFileSaveAs)
- CHAIN_MSG_MAP(CMDIChildWindowImpl)
- CHAIN_CLIENT_COMMANDS()
- CHAIN_MSG_MAP_MEMBER(m_wndListView)
- END_MSG_MAP()
-
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnEditClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnEditCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnEditSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnFileSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
-
- /*************************************************************************
- Implementation Data
- *************************************************************************/
-private:
- CListCtrlEx m_wndListView;
- CUpdateUIBase* m_pUpdateUI;
- std::string m_windowTitle;
- int m_nLogIndex;
- AutoSizeBuf m_bufMaxLine;
-
- /*************************************************************************
- Construction and Destruction
- *************************************************************************/
-public:
- LogFrameWnd(CUpdateUIBase* pUpdateUI, const std::string& windowTitle);
- ~LogFrameWnd();
-};
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_Main.cpp b/AxTrace/AT_Main.cpp
deleted file mode 100644
index d76989b..0000000
--- a/AxTrace/AT_Main.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_System.h"
-
-//Axtrace system
-AT3::System g_theSystem;
-
-//WinMain Function
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nCmdShow)
-{
- INITCOMMONCONTROLSEX iccx;
- iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
- iccx.dwICC = ICC_LINK_CLASS;
- InitCommonControlsEx(&iccx);
-
- // Init system
- if(!g_theSystem.init(hInstance, lpCmdLine)) return 1;
-
- // Run system
- g_theSystem.run();
-
- // Release system
- g_theSystem.release();
-
- return 0;
-}
-
diff --git a/AxTrace/AT_MainFrame.cpp b/AxTrace/AT_MainFrame.cpp
deleted file mode 100644
index 9eb2ff9..0000000
--- a/AxTrace/AT_MainFrame.cpp
+++ /dev/null
@@ -1,386 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_System.h"
-#include "AT_MainFrame.h"
-#include "AT_AboutDlg.h"
-#include "AT_LogFrame.h"
-#include "AT_ValueFrame.h"
-#include "AT_2DFrame.h"
-
-#include "AT_Config.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-MainFrame::MainFrame()
- : m_mdiStatus(MS_MDI)
- , m_currentActiveChild(0)
-{
-}
-
-//--------------------------------------------------------------------------------------------
-MainFrame::~MainFrame()
-{
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- // Create MDIClient
- CreateMDIClient();
-
- // Set Main Title
- SetWindowText(_T("AxTrace"));
-
- // Create MDI CommandBar
- m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
- m_CmdBar.SetMDIClient(m_hWndClient);
- m_CmdBar.AttachMenu(GetMenu());
- SetMenu(NULL);
-
- m_hMainMenu = LoadMenu(System::getSingleton()->getAppModule().m_hInst, MAKEINTRESOURCE(IDR_MAINFRAME));
- m_hChildMenu = LoadMenu(System::getSingleton()->getAppModule().m_hInst, MAKEINTRESOURCE(IDR_TRACEFRAME));
-
- // Create Toolbar
- HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);
- UIAddToolBar(hWndToolBar);
-
- // Create Rebar
- CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);
- AddSimpleReBarBand(m_CmdBar);
- AddSimpleReBarBand(hWndToolBar, NULL, TRUE);
-
- // Set Menu status
- updateButtons(MS_MDI);
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- DestroyMenu(m_hChildMenu);
- DestroyMenu(m_hMainMenu);
- bHandled=FALSE;
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnAxTraceMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- System::getSingleton()->OnIdle();
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnAppExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- PostMessage(WM_CLOSE);
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnSystemRecive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- Config* config = System::getSingleton()->getConfig();
- config->setCapture(!(config->getCapture()));
- updateButtons();
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnSystemAutoscroll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- Config* config = System::getSingleton()->getConfig();
- config->setAutoScroll(!(config->getAutoScroll()));
- updateButtons();
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnActiveWndEditCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- if(m_currentActiveChild)
- {
- SendMessage(m_currentActiveChild->getNativeWnd(), WM_COMMAND, MAKELONG(wID, wNotifyCode), (LPARAM)hWndCtl);
- }
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnAllWndEditCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- LogWndMap::iterator it_trace, end_trace=m_logWndMap.end();
- for(it_trace=m_logWndMap.begin(); it_trace!=end_trace; it_trace++)
- {
- SendMessage(((IChildFrame*)it_trace->second)->getNativeWnd(), WM_COMMAND, MAKELONG(wID, wNotifyCode), (LPARAM)hWndCtl);
- }
-
- ValueWndMap::iterator it_value, end_value=m_valueWndMap.end();
- for(it_value=m_valueWndMap.begin(); it_value!=end_value; it_value++)
- {
- SendMessage(((IChildFrame*)it_value->second)->getNativeWnd(), WM_COMMAND, MAKELONG(wID, wNotifyCode), (LPARAM)hWndCtl);
- }
-
- Graphics2DWndMap::iterator it_2D, end_2D = m_2DWndMap.end();
- for (it_2D = m_2DWndMap.begin(); it_2D != end_2D; it_2D++)
- {
- SendMessage(((IChildFrame*)it_2D->second)->getNativeWnd(), WM_COMMAND, MAKELONG(wID, wNotifyCode), (LPARAM)hWndCtl);
- }
-
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnAppAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- AboutDlg dlg;
- dlg.DoModal();
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnOptionFilter(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- System::getSingleton()->getFilter()->editScriptWithNotepad();
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnMDISetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- updateButtons(MS_MDI);
- m_CmdBar.AttachMenu(m_hMainMenu);
-
- bHandled = FALSE;
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-void MainFrame::onChildActive(IChildFrame* child)
-{
- m_currentActiveChild = child;
-
- if(m_currentActiveChild->getChildType()==IChildFrame::CS_LOG_FRAME)
- {
- m_CmdBar.AttachMenu(m_hChildMenu);
- updateButtons(MS_LOG_FRAME);
- }
- else if(m_currentActiveChild->getChildType()==IChildFrame::CS_VALUE_FRAME)
- {
- m_CmdBar.AttachMenu(m_hChildMenu);
- updateButtons(MS_VALUE_FRAME);
- }
- else if (m_currentActiveChild->getChildType() == IChildFrame::CS_2D_FRAME)
- {
- m_CmdBar.AttachMenu(m_hChildMenu);
- updateButtons(MS_2D_FRAME);
- }
-}
-
-//--------------------------------------------------------------------------------------------
-void MainFrame::onChildDestroy(IChildFrame* child)
-{
- assert(child);
- if(child==0) return;
-
- if(m_currentActiveChild==child) m_currentActiveChild=0;
- if(child->getChildType()==IChildFrame::CS_LOG_FRAME)
- {
- m_logWndMap.erase(child->getWindowTitle());
- }
- else if(child->getChildType()==IChildFrame::CS_VALUE_FRAME)
- {
- m_valueWndMap.erase(child->getWindowTitle());
- }
- else if (child->getChildType() == IChildFrame::CS_2D_FRAME)
- {
- m_2DWndMap.erase(child->getWindowTitle());
- }
-}
-
-//--------------------------------------------------------------------------------------------
-void MainFrame::updateButtons(MDI_STATUS status)
-{
- if(status!=MS_UNKNOWN) m_mdiStatus=status;
- else status = m_mdiStatus;
-
- //-----
- UISetCheck(ID_VIEW_TOOLBAR, 1);
- UISetCheck(ID_VIEW_STATUS_BAR, 1);
- UISetCheck(ID_SYSTEM_RECEIVE, System::getSingleton()->getConfig()->getCapture());
- UISetCheck(ID_SYSTEM_AUTOSCROLL, System::getSingleton()->getConfig()->getAutoScroll());
- UIEnable(ID_HELP, FALSE); //NOT SUPPORT YET...
-
- if(status==MS_MDI)
- {
- UIEnable(ID_FILE_SAVEAS, FALSE);
- UIEnable(ID_SYSTEM_AUTOSCROLL, FALSE);
- UIEnable(ID_EDIT_CLEAR, FALSE);
- UIEnable(ID_EDIT_CLEARALL, FALSE);
- }
- else if(status==MS_LOG_FRAME)
- {
- UIEnable(ID_FILE_SAVEAS, TRUE);
- UIEnable(ID_SYSTEM_AUTOSCROLL, TRUE);
- UIEnable(ID_EDIT_CLEAR, TRUE);
- UIEnable(ID_EDIT_CLEARALL, TRUE);
- }
- else if(status==MS_VALUE_FRAME)
- {
- UIEnable(ID_FILE_SAVEAS, TRUE);
- UIEnable(ID_SYSTEM_AUTOSCROLL, FALSE);
- UIEnable(ID_EDIT_CLEAR, TRUE);
- UIEnable(ID_EDIT_CLEARALL, TRUE);
- }
- else if (status == MS_2D_FRAME)
- {
- UIEnable(ID_FILE_SAVEAS, FALSE);
- UIEnable(ID_SYSTEM_AUTOSCROLL, FALSE);
- UIEnable(ID_EDIT_CLEAR, TRUE);
- UIEnable(ID_EDIT_CLEARALL, TRUE);
- }
-}
-
-//--------------------------------------------------------------------------------------------
-LogFrameWnd* MainFrame::getLogWnd(const std::string& windowTitle)
-{
- LogWndMap::iterator it = m_logWndMap.find(windowTitle);
- if(it!=m_logWndMap.end()) return it->second;
-
- wchar_t temp[64]={0};
- StringCchPrintfW(temp, 64, _T("Log:%s"), convertUTF8ToUTF16(windowTitle.c_str(), windowTitle.length()+1));
-
- LogFrameWnd* pChild = new LogFrameWnd((CUpdateUIBase*)this, windowTitle);
- pChild->CreateEx(m_hWndClient, NULL, temp);
-
- m_logWndMap.insert(std::make_pair(windowTitle, pChild));
- return pChild;
-}
-
-//--------------------------------------------------------------------------------------------
-ValueFrameWnd* MainFrame::getValueWnd(const std::string& windowTitle)
-{
- ValueWndMap::iterator it = m_valueWndMap.find(windowTitle);
- if(it!=m_valueWndMap.end()) return it->second;
-
- wchar_t temp[64]={0};
- StringCchPrintfW(temp, 64, _T("Value:%s"), convertUTF8ToUTF16(windowTitle.c_str(), windowTitle.length()+1));
-
- ValueFrameWnd* pChild = new ValueFrameWnd((CUpdateUIBase*)this, windowTitle);
- pChild->CreateEx(m_hWndClient, NULL, temp);
-
- m_valueWndMap.insert(std::make_pair(windowTitle, pChild));
- return pChild;
-}
-
-//--------------------------------------------------------------------------------------------
-Graphics2DFrameWnd* MainFrame::get2DWnd(const std::string& windowTitle)
-{
- Graphics2DWndMap::iterator it = m_2DWndMap.find(windowTitle);
- if (it != m_2DWndMap.end()) return it->second;
-
- wchar_t temp[64] = { 0 };
- StringCchPrintfW(temp, 64, _T("2D:%s"), convertUTF8ToUTF16(windowTitle.c_str(), windowTitle.length() + 1));
-
- Graphics2DFrameWnd* pChild = new Graphics2DFrameWnd((CUpdateUIBase*)this, windowTitle);
- pChild->CreateEx(m_hWndClient, NULL, temp);
-
- m_2DWndMap.insert(std::make_pair(windowTitle, pChild));
- return pChild;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnOptionHideToolBar(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- BOOL bNew = !::IsWindowVisible(m_hWndToolBar);
- ::ShowWindow(m_hWndToolBar, bNew ? SW_SHOWNOACTIVATE : SW_HIDE);
- UISetCheck(ID_OPTION_HIDE_TOOLBAR, !bNew);
- SetMenu(bNew ? 0 : (m_currentActiveChild ? m_hChildMenu : m_hMainMenu));
-
- UpdateLayout();
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnWindowCascade(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- MDICascade(0);
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnWindowTile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- MDITile(MDITILE_HORIZONTAL);
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnSettingFont(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- LOGFONT lf;
- GetObject(System::getSingleton()->getConfig()->getFont(), sizeof(lf), &lf);
-
- CFontDialog dlg(&lf, CF_SCREENFONTS, 0, m_hWnd);
- if(IDOK!=dlg.DoModal()) return 0;
-
- dlg.GetCurrentFont(&lf);
-
- System::getSingleton()->getConfig()->setFont(&lf);
- System::getSingleton()->getConfig()->saveSetting();
-
- //redraw all frame
- LogWndMap::iterator it_log, end_log=m_logWndMap.end();
- for(it_log=m_logWndMap.begin(); it_log!=end_log; it_log++)
- {
- ((IChildFrame*)it_log->second)->redraw();
- }
-
- ValueWndMap::iterator it_value, end_value=m_valueWndMap.end();
- for(it_value=m_valueWndMap.begin(); it_value!=end_value; it_value++)
- {
- ((IChildFrame*)it_value->second)->redraw();
- }
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT MainFrame::OnReloadFilterScriptMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- const wchar_t* wszScriptFile = (const wchar_t*)wParam;
-
- ::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
-
- std::string newScript;
- if (!loadFileToString(wszScriptFile, newScript)) {
- //open script file error
- MessageBox(L"Open script file error!", L"LoadScript Error", MB_OK | MB_ICONSTOP);
- }
- else {
- std::string errorMessage;
- if (System::getSingleton()->getFilter()->tryReloadScriptFile(newScript.c_str(), errorMessage)) {
-
- if (IDYES == MessageBox(L"Compile script success, reload now?", L"LoadScript", MB_YESNO | MB_ICONQUESTION)) {
- bool success = System::getSingleton()->getFilter()->reloadScript(newScript.c_str(), m_hWnd);
- assert(success);
-
- //save
- System::getSingleton()->getConfig()->setFilterScript(newScript.c_str());
- }
- }
- else {
- MessageBoxA(m_hWnd, errorMessage.c_str(), "LoadScript error", MB_OK | MB_ICONSTOP);
- }
- }
- ::SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
- return 0;
-}
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_MainFrame.h b/AxTrace/AT_MainFrame.h
deleted file mode 100644
index d095e9e..0000000
--- a/AxTrace/AT_MainFrame.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-#include "resource.h"
-
-namespace AT3
-{
-//pre-define
-class LogFrameWnd;
-class ValueFrameWnd;
-class Graphics2DFrameWnd;
-class IChildFrame;
-
-/** Main Frame
-*/
-class MainFrame : public CMDIFrameWindowImpl, CUpdateUI,
- public CMessageFilter, public CIdleHandler
-{
- /*************************************************************************
- Inherit Methods
- *************************************************************************/
-public:
- DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)
- enum {
- WM_ON_AXTRACE_MESSAGE=WM_USER+100,
- WM_ON_RELOADSCRIPT_MESSAGE
- };
-
- virtual BOOL PreTranslateMessage(MSG* pMsg)
- {
- return CMDIFrameWindowImpl::PreTranslateMessage(pMsg);
- }
-
- virtual BOOL OnIdle()
- {
- UIUpdateToolBar();
- return FALSE;
- }
-
- BEGIN_MSG_MAP(MainFrame)
- MESSAGE_HANDLER(WM_CREATE, OnCreate)
- MESSAGE_HANDLER(WM_CLOSE, OnClose)
- MESSAGE_HANDLER(WM_ON_AXTRACE_MESSAGE, OnAxTraceMessage)
- MESSAGE_HANDLER(WM_ON_RELOADSCRIPT_MESSAGE, OnReloadFilterScriptMessage)
-
- COMMAND_ID_HANDLER(ID_APP_EXIT, OnAppExit)
- COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
- COMMAND_ID_HANDLER(ID_SYSTEM_RECEIVE, OnSystemRecive)
- COMMAND_ID_HANDLER(ID_SYSTEM_AUTOSCROLL, OnSystemAutoscroll)
- COMMAND_ID_HANDLER(ID_OPTION_FILTER, OnOptionFilter)
- COMMAND_ID_HANDLER(ID_WINDOW_CASCADE, OnWindowCascade)
- COMMAND_ID_HANDLER(ID_WINDOW_TILE_HORZ, OnWindowTile)
- COMMAND_ID_HANDLER(ID_OPTION_FONT, OnSettingFont)
- COMMAND_ID_HANDLER(ID_OPTION_HIDE_TOOLBAR, OnOptionHideToolBar)
-
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnActiveWndEditCommand)
- COMMAND_ID_HANDLER(ID_EDIT_CLEARALL, OnAllWndEditCommand)
- COMMAND_ID_HANDLER(ID_EDIT_COPY, OnActiveWndEditCommand)
- COMMAND_ID_HANDLER(ID_EDIT_SELECTALL, OnActiveWndEditCommand)
- COMMAND_ID_HANDLER(ID_FILE_SAVEAS, OnActiveWndEditCommand)
-
- MESSAGE_HANDLER(WM_MDISETMENU, OnMDISetMenu)
- CHAIN_MDI_CHILD_COMMANDS()
- CHAIN_MSG_MAP(CUpdateUI)
- CHAIN_MSG_MAP(CMDIFrameWindowImpl)
- END_MSG_MAP()
-
- BEGIN_UPDATE_UI_MAP(MainFrame)
- UPDATE_ELEMENT(ID_OPTION_HIDE_TOOLBAR, UPDUI_MENUPOPUP)
- UPDATE_ELEMENT(ID_HELP, UPDUI_MENUPOPUP)
- UPDATE_ELEMENT(ID_OPTION_FILTER, UPDUI_MENUPOPUP)
- UPDATE_ELEMENT(ID_FILE_SAVEAS, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
- UPDATE_ELEMENT(ID_SYSTEM_RECEIVE, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
- UPDATE_ELEMENT(ID_SYSTEM_AUTOSCROLL, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
- UPDATE_ELEMENT(ID_EDIT_CLEAR, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
- UPDATE_ELEMENT(ID_EDIT_CLEARALL, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
- END_UPDATE_UI_MAP()
-
- /** On MainFrame Create
- */
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- /** On MainFrame Create
- */
- LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- /** On Command ID_APP_ABOUT
- */
- LRESULT OnMDISetMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnAxTraceMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnOptionHideToolBar(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnAppExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnSystemRecive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnSystemAutoscroll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnAppAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnActiveWndEditCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnAllWndEditCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnOptionFilter(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnWindowCascade(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnWindowTile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnSettingFont(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnReloadFilterScriptMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
-
-public:
- enum MDI_STATUS
- {
- MS_UNKNOWN,
-
- MS_MDI,
- MS_LOG_FRAME,
- MS_VALUE_FRAME,
- MS_2D_FRAME,
- };
- /** Update ui buttons on menu and toolbar */
- void updateButtons(MDI_STATUS status=MS_UNKNOWN);
-
-public:
- LogFrameWnd* getLogWnd(const std::string& windowTitle);
- ValueFrameWnd* getValueWnd(const std::string& windowTitle);
- Graphics2DFrameWnd* get2DWnd(const std::string& windowTitle);
-
- void onChildActive(IChildFrame* child);
- void onChildDestroy(IChildFrame* child);
-
- /*************************************************************************
- Implementation Data
- *************************************************************************/
-private:
- CMDICommandBarCtrl m_CmdBar; //!< Command Bar Control.
-
- typedef std::map< std::string, LogFrameWnd* > LogWndMap;
- LogWndMap m_logWndMap;
-
- typedef std::map< std::string, ValueFrameWnd* > ValueWndMap;
- ValueWndMap m_valueWndMap;
-
- typedef std::map< std::string, Graphics2DFrameWnd* > Graphics2DWndMap;
- Graphics2DWndMap m_2DWndMap;
-
- MDI_STATUS m_mdiStatus;
- IChildFrame* m_currentActiveChild;
-
- HMENU m_hMainMenu;
- HMENU m_hChildMenu;
-
- /*************************************************************************
- Construction and Destruction
- *************************************************************************/
-public:
- MainFrame();
- ~MainFrame();
-};
-
-}
diff --git a/AxTrace/AT_Math.cpp b/AxTrace/AT_Math.cpp
deleted file mode 100644
index 0057715..0000000
--- a/AxTrace/AT_Math.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "stdafx.h"
-#include "AT_Math.h"
-
-namespace AT3
-{
-
-//-------------------------------------------------------------------------------------------------------------------
-/** ¸¡µãÊý±È½Ï
-@return
--1 : ab
-*/
-int floatCompare(Real a, Real b, Real tolerance)
-{
- Real c = a - b;
-
- if (c > tolerance) return 1;
- else if (c < -tolerance) return -1;
- return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-const fVector2 fVector2::ZERO(0, 0);
-
-//-------------------------------------------------------------------------------------------------------------------
-Real fVector2::length(void) const
-{
- return sqrt(x*x+y*y);
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-Real fVector2::normalize(void)
-{
- Real len = sqrt(x*x+y*y);
- if(floatCompare(len, 0)<=0) return 0.0;
-
- Real inv_len = 1.0f/len;
-
- x *= inv_len;
- y *= inv_len;
-
- return len;
-}
-
-}
diff --git a/AxTrace/AT_Math.h b/AxTrace/AT_Math.h
deleted file mode 100644
index ce6a003..0000000
--- a/AxTrace/AT_Math.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#pragma once
-
-namespace AT3
-{
-
-typedef double Real;
-
-/** 整数二维å‘é‡
-*/
-struct iVector2
-{
- iVector2() : x(0), y(0) {}
- iVector2(int _x, int _y) : x(_x), y(_y) {}
- iVector2(const iVector2& other) : x(other.x), y(other.y) {}
-
- int x, y;
-};
-
-//pi!
-#define MATH_PI (Real)(3.14159265)
-#define MATH_PI_DOUBLE (Real)(3.14159265*2.0)
-#define MATH_PI_HALF (Real)(3.14159265*0.5)
-#define MATH_PI_QUARTER (Real)(3.14159265*0.25)
-
-int floatCompare(Real a, Real b, Real tolerance = std::numeric_limits::epsilon());
-
-/** 浮点数二维å‘é‡
-*/
-struct fVector2
-{
- fVector2() : x(0), y(0) {}
- fVector2(Real _x, Real _y) : x(_x), y(_y) {}
- fVector2(const fVector2& other) : x(other.x), y(other.y) {}
-
- Real length(void) const;
- Real normalize(void);
- Real square(void) const { return x*x+y*y; }
- void set(Real _x, Real _y) { x=_x; y=_y; }
-
- void operator *= (Real a)
- {
- x *= a; y *= a;
- }
- void operator /= (Real a)
- {
- x /= a; y /= a;
- }
- void operator += (const fVector2& a)
- {
- x += a.x; y += a.y;
- }
- void operator -= (const fVector2& a)
- {
- x -= a.x; y -= a.y;
- }
-
- Real x, y;
-
- //常用é™æ€å‘é‡
- static const fVector2 ZERO;
-};
-
-//点数组
-typedef std::vector< fVector2 > PointVector;
-
-//å‘é‡ç›¸åŠ
-inline fVector2 operator + (const fVector2& a, const fVector2& b)
-{
- return fVector2(a.x + b.x, a.y + b.y);
-}
-
-//å‘é‡ç›¸å‡
-inline fVector2 operator - (const fVector2& a, const fVector2& b)
-{
- return fVector2(a.x - b.x, a.y - b.y);
-}
-//å‘é‡*浮点数
-inline fVector2 operator * (Real s, const fVector2& a)
-{
- return fVector2(s * a.x, s * a.y);
-}
-// å‘é‡æ˜¯å¦ç›¸ç‰
-inline bool operator == (const fVector2& a, const fVector2& b)
-{
- return a.x==b.x && a.y == b.y;
-}
-
-// å‘é‡æ˜¯å¦ä¸ç›¸ç‰
-inline bool operator != (const fVector2& a, const fVector2& b)
-{
- return a.x!=b.x || a.y != b.y;
-}
-//点积
-inline Real dotProduct(const fVector2& a, const fVector2& b)
-{
- return a.x*b.x + a.y*b.y;
-}
-
-//å‰ç§¯
-inline Real crossProduct(const fVector2& a, const fVector2& b)
-{
- return a.x * b.y - a.y * b.x;
-}
-
-//比较大å°ï¼Œæ–¹ä¾¿æŸäº›è¿ç®—,比较åæ ‡å¤§å°ï¼Œå…ˆæ¯”较x, å†æ¯”较y
-inline bool operator > (const fVector2& a, const fVector2& b)
-{
- return (a.x > b.x || ((a.x==b.x) && a.y > b.y));
-}
-
-}
diff --git a/AxTrace/AT_Message.cpp b/AxTrace/AT_Message.cpp
deleted file mode 100644
index 922cc5a..0000000
--- a/AxTrace/AT_Message.cpp
+++ /dev/null
@@ -1,437 +0,0 @@
-#include "StdAfx.h"
-#include "AT_Message.h"
-#include "AT_Util.h"
-#include "utf/ConvertUTF.h"
-
-namespace AT3
-{
-
-const char* Message::MESSAGE_META_NAME = "AxTrace.Message";
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-//Base Message
-//////////////////////////////////////////////////////////////////////////////////////////////
-Message::Message(void)
- : m_nProcessID(0)
- , m_nThreadID(0)
- , m_nStyleID(0)
-{
-}
-
-//--------------------------------------------------------------------------------------------
-Message::~Message(void)
-{
-}
-
-//-------------------------------------------------------------------------------------
-int _lua_get_type(lua_State *L)
-{
- const Message* msg = (const Message*)lua_touserdata(L, 1);
- lua_pushinteger(L, msg->getTraceType());
- return 1;
-}
-
-//-------------------------------------------------------------------------------------
-int _lua_get_process_id(lua_State *L)
-{
- const Message* msg = (const Message*)lua_touserdata(L, 1);
- lua_pushinteger(L, msg->getProcessID());
- return 1;
-}
-
-//-------------------------------------------------------------------------------------
-int _lua_get_thread_id(lua_State *L)
-{
- const Message* msg = (const Message*)lua_touserdata(L, 1);
- lua_pushinteger(L, msg->getThreadID());
- return 1;
-}
-
-//-------------------------------------------------------------------------------------
-int _lua_get_style(lua_State *L)
-{
- const Message* msg = (const Message*)lua_touserdata(L, 1);
- lua_pushinteger(L, msg->getStyleID());
- return 1;
-}
-
-//-------------------------------------------------------------------------------------
-int _lua_get_content(lua_State *L)
-{
- const Message* msg = (const Message*)lua_touserdata(L, 1);
-
- if (msg->getTraceType() == AXTRACE_CMD_TYPE_LOG) {
- const wchar_t* msg_content = ((LogMessage*)msg)->getLogBuf();
- size_t msg_char_length = ((LogMessage*)msg)->getLogSizeChar() + 1;
-
- lua_pushstring(L, convertUTF16ToUTF8(msg_content, msg_char_length));
-
- return 1;
- }
- else if (msg->getTraceType() == AXTRACE_CMD_TYPE_VALUE)
- {
- std::wstring value_as_string;
-
- ((ValueMessage*)msg)->getValueAsString(value_as_string);
-
- lua_pushstring(L, convertUTF16ToUTF8(value_as_string.c_str(), value_as_string.length()+1));
- return 1;
- }
- return 0;
-}
-
-//-------------------------------------------------------------------------------------
-int _lua_get_mapname(lua_State *L)
-{
- const Message* msg = (const Message*)lua_touserdata(L, 1);
-
- if (msg->getTraceType() == AXTRACE_CMD_TYPE_2D_CLEAN_MAP) {
- lua_pushstring(L, ((G2DCleanMapMessage*)msg)->getMapName());
- return 1;
- }else if(msg->getTraceType() == AXTRACE_CMD_TYPE_2D_ACTOR) {
- lua_pushstring(L, ((G2DActorMessage*)msg)->getMapName());
- return 1;
- }
-
- return 0;
-}
-
-//--------------------------------------------------------------------------------------------
-void Message::_luaopen(lua_State *L)
-{
- static luaL_Reg msg_data_meta[] =
- {
- { "get_type", _lua_get_type },
- { "get_process_id", _lua_get_process_id },
- { "get_thread_id", _lua_get_thread_id },
- { "get_style", _lua_get_style },
- { "get_content", _lua_get_content },
-
- //for 2d messages
- { "get_mapname", _lua_get_mapname },
-
- { 0, 0 }
- };
-
-
- //PlayerData meta table
- luaL_newmetatable(L, MESSAGE_META_NAME);
- lua_pushvalue(L, -1); /* push metatable */
- lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
-
- luaL_register(L, NULL, msg_data_meta); /* file methods */
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-//Log Message
-//////////////////////////////////////////////////////////////////////////////////////////////
-LogMessage::LogMessage(void)
- : m_pLogBuf(0)
- , m_pLogBufInChar(0)
- , Message()
-{
-}
-
-//--------------------------------------------------------------------------------------------
-LogMessage::~LogMessage(void)
-{
- if(m_pLogBuf)
- {
- delete[] m_pLogBuf; m_pLogBuf=0;
- }
-}
-
-
-//--------------------------------------------------------------------------------------------
-void LogMessage::build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
-{
- void* rc = 0;
- memcpy(&m_traceTime, &traceTime, sizeof(m_traceTime));
-
- m_nProcessID = head.pid;
- m_nThreadID = head.tid;
- m_nStyleID = head.style;
-
- axtrace_log_s log_head;
- size_t len = ringBuf->memcpy_out(&log_head, sizeof(log_head));
- assert(len == sizeof(log_head));
-
- //get codepage
- int codePage = log_head.code_page;
-
- //get log length
- int logLength = log_head.length;
-
- //get log
- if(m_pLogBuf) delete[] m_pLogBuf;
-
- if(codePage == ATC_UTF16)
- {
- m_pLogBufInChar = logLength/2;
- m_pLogBuf=new wchar_t[m_pLogBufInChar+1];
-
- size_t len = ringBuf->memcpy_out(m_pLogBuf, logLength);
- assert(len == logLength);
-
- m_pLogBuf[m_pLogBufInChar]=0;
- }
- else if(codePage == ATC_UTF8)
- {
- char* tempBuf = new char[logLength];
- size_t len = ringBuf->memcpy_out(tempBuf, logLength);
- assert(len == logLength);
-
- //convert to utf16
- m_pLogBufInChar = logLength;
- m_pLogBuf=new wchar_t[m_pLogBufInChar+1];
-
- const UTF8* sourceStart = (const UTF8*)tempBuf;
- UTF16* targetStart = (UTF16*)m_pLogBuf;
-
- ::ConvertUTF8toUTF16(&sourceStart, sourceStart+logLength,
- &targetStart, (UTF16*)(m_pLogBuf+m_pLogBufInChar+1), strictConversion);
-
- delete[] tempBuf; tempBuf=0;
-
- *targetStart = 0;
- m_pLogBufInChar = wcslen(m_pLogBuf);
-
- }
- else if(codePage == ATC_ACP)
- {
- char* tempBuf = new char[logLength+1];
- size_t len = ringBuf->memcpy_out(tempBuf, logLength);
- assert(len == logLength);
-
- tempBuf[logLength] = 0;
-
- m_pLogBufInChar = logLength;
- m_pLogBuf=new wchar_t[m_pLogBufInChar+1];
- ::MultiByteToWideChar(CP_ACP, 0, tempBuf, logLength+1, m_pLogBuf, (int)m_pLogBufInChar+1);
-
- delete[] tempBuf; tempBuf=0;
-
- m_pLogBufInChar = wcslen(m_pLogBuf);
- }
- else
- {
- //error!
- assert(false);
- }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-//Value Message
-//////////////////////////////////////////////////////////////////////////////////////////////
-ValueMessage::ValueMessage(void)
- : Message()
- , m_valueBuf(0)
- , m_valueSize(0)
-{
- memset(m_name, 0, AXTRACE_MAX_VALUENAME_LENGTH*sizeof(wchar_t));
-}
-
-//--------------------------------------------------------------------------------------------
-ValueMessage::~ValueMessage(void)
-{
- if(m_valueBuf && m_valueBuf!=m_standValueBuf)
- {
- delete[] m_valueBuf;
- }
-}
-
-//--------------------------------------------------------------------------------------------
-void ValueMessage::build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
-{
- memcpy(&m_traceTime, &traceTime, sizeof(m_traceTime));
-
- m_nProcessID = head.pid;
- m_nThreadID = head.tid;
- m_nStyleID = head.style;
-
- axtrace_value_s value_head;
- size_t len = ringBuf->memcpy_out(&value_head, sizeof(value_head));
- assert(len == sizeof(value_head));
-
- m_valuetype = value_head.value_type;
- m_valueSize = value_head.value_len;
-
- //copy name
- char tempName[AXTRACE_MAX_VALUENAME_LENGTH];
- int name_length = value_head.name_len;
- //TODO: check name length
- len = ringBuf->memcpy_out(tempName, name_length);
- assert(len == name_length);
- tempName[name_length-1] = 0; //make sure last char is '\0'
- wcscpy_s(m_name, AXTRACE_MAX_VALUENAME_LENGTH, convertUTF8ToUTF16(tempName, name_length+1));
-
- //value
- if (m_valueSize>STANDARD_VALUE_SIZE)
- {
- //big value
- m_valueBuf = new char[m_valueSize];
- memset(m_valueBuf, 0, m_valueSize);
- }
- else
- {
- m_valueBuf = m_standValueBuf;
- }
-
- //value
- len = ringBuf->memcpy_out(m_valueBuf, m_valueSize);
- assert(len == m_valueSize);
-
- //make sure '\0' ended
- if (m_valuetype == AXV_STR_ACP || m_valuetype == AXV_STR_UTF8)
- {
- ((char*)m_valueBuf)[m_valueSize-1] = 0;
- }
- else if (m_valuetype == AXV_STR_UTF16)
- {
- ((char*)m_valueBuf)[m_valueSize-1] = 0;
- ((char*)m_valueBuf)[m_valueSize-2] = 0;
- }
-}
-
-//--------------------------------------------------------------------------------------------
-void ValueMessage::getValueAsString(std::wstring& value) const
-{
- const int TEMP_STR_SIZE = 512;
- wchar_t temp[TEMP_STR_SIZE]={0};
-
- switch(m_valuetype)
- {
- case AXV_INT8:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%d", *((__int8*)m_valueBuf)); break;
- case AXV_UINT8:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%u", *((unsigned __int8*)m_valueBuf)); break;
- case AXV_INT16:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%d", *((__int16*)m_valueBuf)); break;
- case AXV_UINT16:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%u", *((unsigned __int16*)m_valueBuf)); break;
- case AXV_INT32:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%d", *((__int32*)m_valueBuf)); break;
- case AXV_UINT32:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%u", *((unsigned __int32*)m_valueBuf)); break;
- case AXV_FLOAT32:
- {
- float abs_value = abs(*((float*)m_valueBuf));
- bool need_scientific_notation = ((abs_value>(1e+16)) || ((abs_value>0.f) && abs_value<(1e-16)));
-
- StringCchPrintfW(temp, TEMP_STR_SIZE, need_scientific_notation ? L"%e" : L"%.8f", *((float*)m_valueBuf));
- }
- break;
- case AXV_INT64:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%I64d", *((__int64*)m_valueBuf)); break;
- case AXV_UINT64:
- StringCchPrintfW(temp, TEMP_STR_SIZE, L"%I64u", *((unsigned __int64*)m_valueBuf)); break;
- case AXV_FLOAT64:
- {
- double abs_value = abs(*((double*)m_valueBuf));
- bool need_scientific_notation = ((abs_value>(1e+16)) || (abs_value>0.0 && (abs_value<(1e-16))));
-
- StringCchPrintfW(temp, TEMP_STR_SIZE, need_scientific_notation ? L"%e" : L"%.16f", *((double*)m_valueBuf));
- }
- break;
- case AXV_STR_ACP:
- {
- wchar_t* wszBuf = new wchar_t[m_valueSize];
- ::MultiByteToWideChar(CP_ACP, 0, (const char*)m_valueBuf, (int)m_valueSize, wszBuf, (int)m_valueSize);
- value = wszBuf;
- delete[] wszBuf;
- }
- return;
- case AXV_STR_UTF8:
- value = convertUTF8ToUTF16((const char*)m_valueBuf, m_valueSize); return;
- case AXV_STR_UTF16:
- value = (const wchar_t*)m_valueBuf; return;
- }
-
- value = temp;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-//Graphics2D Clean Map Message
-//////////////////////////////////////////////////////////////////////////////////////////////
-G2DCleanMapMessage::G2DCleanMapMessage(void)
- : Message()
-{
-}
-
-//--------------------------------------------------------------------------------------------
-G2DCleanMapMessage::~G2DCleanMapMessage(void)
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-void G2DCleanMapMessage::build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
-{
- void* rc = 0;
- memcpy(&m_traceTime, &traceTime, sizeof(m_traceTime));
-
- m_nProcessID = head.pid;
- m_nThreadID = head.tid;
- m_nStyleID = head.style;
-
- axtrace_2d_clean_map_s cleanmap_head;
- size_t len = ringBuf->memcpy_out(&cleanmap_head, sizeof(axtrace_2d_clean_map_s));
- assert(len == sizeof(axtrace_2d_clean_map_s));
-
- char tempName[AXTRACE_MAX_MAP_NAME_LENGTH];
- int name_length = cleanmap_head.name_len;
-
- //TODO: check name length
- len = ringBuf->memcpy_out(tempName, name_length);
- assert(len == name_length);
- tempName[name_length - 1] = 0; //make sure last char is '\0'
-
- StringCbCopyA(m_map_name, AXTRACE_MAX_MAP_NAME_LENGTH, tempName);
- x_size = cleanmap_head.x_size;
- y_size = cleanmap_head.y_size;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-//Graphics2D Actor Message
-//////////////////////////////////////////////////////////////////////////////////////////////
-G2DActorMessage::G2DActorMessage(void)
- : Message()
-{
-}
-
-//--------------------------------------------------------------------------------------------
-G2DActorMessage::~G2DActorMessage(void)
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-void G2DActorMessage::build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf)
-{
- void* rc = 0;
- memcpy(&m_traceTime, &traceTime, sizeof(m_traceTime));
-
- m_nProcessID = head.pid;
- m_nThreadID = head.tid;
- m_nStyleID = head.style;
-
- axtrace_2d_actor_s actor_head;
- size_t len = ringBuf->memcpy_out(&actor_head, sizeof(axtrace_2d_actor_s));
- assert(len == sizeof(axtrace_2d_actor_s));
-
- char tempName[AXTRACE_MAX_MAP_NAME_LENGTH];
- int name_length = actor_head.name_len;
-
- //TODO: check name length
- len = ringBuf->memcpy_out(tempName, name_length);
- assert(len == name_length);
- tempName[name_length - 1] = 0; //make sure last char is '\0'
-
- StringCbCopyA(m_map_name, AXTRACE_MAX_MAP_NAME_LENGTH, tempName);
- actor_id = actor_head.actor_id;
- x_pos = actor_head.x;
- y_pos = actor_head.y;
- dir = actor_head.dir;
-}
-}
diff --git a/AxTrace/AT_Message.h b/AxTrace/AT_Message.h
deleted file mode 100644
index 517bba9..0000000
--- a/AxTrace/AT_Message.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-
-#include "AT_Interface.h"
-
-namespace cyclone
-{
- class RingBuf;
-}
-
-namespace AT3
-{
-/** Axtrace Message base class
-*/
-class Message
-{
-public:
- static const char* MESSAGE_META_NAME;
-
- /** build message */
- virtual void build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf) = 0;
- /** get trace type*/
- virtual unsigned int getTraceType(void) const = 0;
- /** get process id*/
- unsigned int getProcessID(void) const { return m_nProcessID; }
- /** get thread id*/
- unsigned int getThreadID(void) const { return m_nThreadID; }
- /** get Style id*/
- unsigned int getStyleID(void) const { return m_nStyleID; }
- /** get trace time */
- const AXIATRACE_TIME* getTraceTime(void) const { return &m_traceTime; }
-
-public:
- static void _luaopen(lua_State *L);
-
-protected:
- unsigned int m_nProcessID;
- unsigned int m_nThreadID;
- unsigned int m_nStyleID;
- AXIATRACE_TIME m_traceTime;
-
-public:
- Message();
- virtual ~Message();
-};
-
-/** Log message
-*/
-class LogMessage : public Message
-{
-public:
- /** build message */
- virtual void build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
- /** get trace type*/
- virtual unsigned int getTraceType(void) const { return AXTRACE_CMD_TYPE_LOG; }
-
- /** get log size*/
- size_t getLogSizeChar(void) const { return m_pLogBufInChar; }
- /** get content buf*/
- const wchar_t* getLogBuf(void) const { return m_pLogBuf; }
-
-private:
- wchar_t* m_pLogBuf;
- size_t m_pLogBufInChar;
-
-public:
- LogMessage();
- virtual ~LogMessage();
-};
-
-/** Value Message
-*/
-class ValueMessage : public Message
-{
-public:
- /** build message */
- virtual void build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
- /** get trace type*/
- virtual unsigned int getTraceType(void) const { return AXTRACE_CMD_TYPE_VALUE; }
-
- /** get name */
- const wchar_t* getValueName(void) const { return m_name; }
- /** get value as string */
- void getValueAsString(std::wstring& value) const;
-
-private:
- unsigned int m_valuetype;
- wchar_t m_name[AXTRACE_MAX_VALUENAME_LENGTH];
-
- void* m_valueBuf;
- size_t m_valueSize;
-
- enum { STANDARD_VALUE_SIZE =32 };
- unsigned char m_standValueBuf[STANDARD_VALUE_SIZE];
-
-public:
- ValueMessage();
- virtual ~ValueMessage();
-};
-
-/** Graphics2D Init/Clean Map Message
-*/
-class G2DCleanMapMessage : public Message
-{
-public:
- /** build message */
- virtual void build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
- /** get trace type*/
- virtual unsigned int getTraceType(void) const { return AXTRACE_CMD_TYPE_2D_CLEAN_MAP; }
-
- const char* getMapName(void) const { return m_map_name; }
- double get_x_size(void) const { return x_size; }
- double get_y_size(void) const { return y_size; }
-
-private:
- char m_map_name[AXTRACE_MAX_MAP_NAME_LENGTH];
- double x_size;
- double y_size;
-
-public:
- G2DCleanMapMessage();
- virtual ~G2DCleanMapMessage();
-};
-
-
-/** Graphics2D Create/Update Actor Message
-*/
-class G2DActorMessage : public Message
-{
-public:
- /** build message */
- virtual void build(const AXIATRACE_TIME& traceTime, const axtrace_head_s& head, cyclone::RingBuf* ringBuf);
- /** get trace type*/
- virtual unsigned int getTraceType(void) const { return AXTRACE_CMD_TYPE_2D_ACTOR; }
-
- const char* getMapName(void) const { return m_map_name; }
- unsigned int get_id(void) const { return actor_id; }
- double get_x(void) const { return x_pos; }
- double get_y(void) const { return y_pos; }
- double get_dir(void) const { return dir; }
-
-private:
- char m_map_name[AXTRACE_MAX_MAP_NAME_LENGTH];
- unsigned int actor_id;
- double x_pos;
- double y_pos;
- double dir;
-
-public:
- G2DActorMessage();
- virtual ~G2DActorMessage();
-};
-
-typedef std::vector< Message* > MessageVector;
-
-}
diff --git a/AxTrace/AT_MessageQueue.cpp b/AxTrace/AT_MessageQueue.cpp
deleted file mode 100644
index c91652b..0000000
--- a/AxTrace/AT_MessageQueue.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_MessageQueue.h"
-#include "AT_Util.h"
-#include "AT_System.h"
-#include "AT_MainFrame.h"
-
-#include "AT_Interface.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-MessageQueue::MessageQueue()
- : m_hNotEmptySignal(0)
-{
- m_ring_buf = new cyclone::RingBuf();
-
- InitializeCriticalSection(&m_criticalSection);
- m_hNotEmptySignal = CreateEvent(0, TRUE, FALSE, 0);
-}
-
-//--------------------------------------------------------------------------------------------
-MessageQueue::~MessageQueue()
-{
- delete m_ring_buf; m_ring_buf = 0;
- DeleteCriticalSection(&m_criticalSection);
- CloseHandle(m_hNotEmptySignal);
-}
-
-//--------------------------------------------------------------------------------------------
-bool MessageQueue::insertMessage(cyclone::RingBuf* buf, size_t msg_length, const LPSYSTEMTIME tTime)
-{
- AXIATRACE_TIME traceTime;
- traceTime.wHour = tTime->wHour;
- traceTime.wMinute = tTime->wMinute;
- traceTime.wSecond = tTime->wSecond;
- traceTime.wMilliseconds = tTime->wMilliseconds;
-
- //enter lock
- {
- AutoLock autoLock(&m_criticalSection);
-
- //copy time fist
- m_ring_buf->memcpy_into(&traceTime, sizeof(traceTime));
- //copy trace memory
- buf->copyto(m_ring_buf, msg_length);
-
- //Set singnal
- SetEvent(m_hNotEmptySignal);
- PostMessage(System::getSingleton()->getMainFrame()->m_hWnd, MainFrame::WM_ON_AXTRACE_MESSAGE, 0, 0);
-
- }
- return true;
-}
-
-//--------------------------------------------------------------------------------------------
-Message* MessageQueue::_popMessage(void)
-{
- void* rc = 0;
-
- AXIATRACE_TIME traceTime;
- size_t len = m_ring_buf->memcpy_out(&traceTime, sizeof(traceTime));
- //rc = ringbuf_memcpy_from(&traceTime, m_ringBuf, sizeof(traceTime));
- assert(len == sizeof(traceTime));
-
- axtrace_head_s head;
- len = m_ring_buf->peek(0, &head, sizeof(head));
- //rc = ringbuf_memcpy_from(&head, m_ringBuf, sizeof(head));
- assert(len==sizeof(head));
-
- Message* message = 0;
- switch(head.type)
- {
- case AXTRACE_CMD_TYPE_LOG:
- {
- LogMessage* msg = new LogMessage();
- msg->build(traceTime, head, m_ring_buf);
- message = msg;
- }
- break;
- case AXTRACE_CMD_TYPE_VALUE:
- {
- ValueMessage* msg = new ValueMessage();
- msg->build(traceTime, head, m_ring_buf);
- message = msg;
- }
- break;
-
- case AXTRACE_CMD_TYPE_2D_CLEAN_MAP:
- {
- G2DCleanMapMessage* msg = new G2DCleanMapMessage();
- msg->build(traceTime, head, m_ring_buf);
- message = msg;
- }
- break;
-
- case AXTRACE_CMD_TYPE_2D_ACTOR:
- {
- G2DActorMessage* msg = new G2DActorMessage();
- msg->build(traceTime, head, m_ring_buf);
- message = msg;
- }
- break;
- default: assert(false); break;
- }
-
- return message;
-}
-
-//--------------------------------------------------------------------------------------------
-void MessageQueue::processMessage(MessageVector& msgVector)
-{
- //is there any message?
- if(WAIT_OBJECT_0 != WaitForSingleObject(m_hNotEmptySignal, 0)) return;
-
- //enter lock
- {
- AutoLock autoLock(&m_criticalSection);
-
- do
- {
- if (m_ring_buf->empty()) break;
-
- Message* msg = _popMessage();
- assert(msg != 0);
-
- msgVector.push_back(msg);
- }while(true);
-
- ResetEvent(m_hNotEmptySignal);
- }
-}
-
-}
diff --git a/AxTrace/AT_MessageQueue.h b/AxTrace/AT_MessageQueue.h
deleted file mode 100644
index ac128bd..0000000
--- a/AxTrace/AT_MessageQueue.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-
-#include "AT_Message.h"
-
-namespace cyclone
-{
- class RingBuf;
-}
-
-namespace AT3
-{
-
-/** Axtrace Message Queue
-*/
-class MessageQueue
-{
-public:
- /** insert message to queue(should call by incoming thread)*/
- bool insertMessage(cyclone::RingBuf* buf, size_t msg_length, const LPSYSTEMTIME tTime);
- /** process message in quueu(should call by main thread)*/
- void processMessage(MessageVector& message);
-
-private:
- Message* _popMessage(void);
-
-private:
- enum { DEFAULT_RINGBUF_SIZE = 2048, MAX_RINGBUF_SIZE = 1024*1024*8 };
- CRITICAL_SECTION m_criticalSection;
- HANDLE m_hNotEmptySignal;
- cyclone::RingBuf* m_ring_buf;
-
-public:
- MessageQueue();
- virtual ~MessageQueue();
-};
-
-}
diff --git a/AxTrace/AT_System.cpp b/AxTrace/AT_System.cpp
deleted file mode 100644
index 4eecb36..0000000
--- a/AxTrace/AT_System.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-#include "StdAfx.h"
-#include "AT_System.h"
-#include "AT_Config.h"
-#include "AT_MainFrame.h"
-#include "AT_Incoming.h"
-#include "AT_MessageQueue.h"
-#include "AT_LogFrame.h"
-#include "AT_ValueFrame.h"
-#include "AT_Filter.h"
-#include "AT_2DFrame.h"
-
-namespace AT3
-{
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-//System
-//////////////////////////////////////////////////////////////////////////////////////////////
-System* System::s_pMe = 0;
-//--------------------------------------------------------------------------------------------
-System::System()
- : m_hMutex(0)
- , m_hInstance(0)
- , m_theConfig(0)
- , m_wndMainFrame(0)
- , m_pIncoming(0)
- , m_msgQueue(0)
- , m_filter(0)
-{
- s_pMe = this;
-}
-
-//--------------------------------------------------------------------------------------------
-System::~System()
-{
-}
-
-//--------------------------------------------------------------------------------------------
-bool System::init(HINSTANCE hInstance, LPSTR lpCmdLine)
-{
- m_hInstance = hInstance;
- m_strCmdLine = lpCmdLine;
-
- m_theConfig = new Config;
- m_wndMainFrame = new MainFrame;
- m_pIncoming = new Incoming;
- m_msgQueue = new MessageQueue;
- m_filter = new Filter;
-
- // Init WTL app module
- ::InitCommonControls();
- m_AppModule.Init(NULL, m_hInstance);
-
- // try load system setting from regist
- m_theConfig->loadSetting();
-
- // init filter
- m_filter->init(m_theConfig);
- if (!(m_filter->reloadScript(m_theConfig->getFilterScript().c_str(), ::GetDesktopWindow()))) {
- return false;
- }
-
- //init receive thread
- return m_pIncoming->init();
-}
-
-//--------------------------------------------------------------------------------------------
-void System::run(void)
-{
- m_AppModule.AddMessageLoop(&m_theMsgLoop);
-
- // Create Main Frame and show it
- if(m_wndMainFrame->CreateEx() == NULL) return;
-
- m_theMsgLoop.AddMessageFilter(m_wndMainFrame);
- m_theMsgLoop.AddIdleHandler(m_wndMainFrame);
- m_theMsgLoop.AddIdleHandler(this);
-
- m_wndMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
-
- // Run Message loop
- m_theMsgLoop.Run();
-}
-
-//--------------------------------------------------------------------------------------------
-void System::release(void)
-{
- //close listen thread
- m_pIncoming->closeListen();
- // save setting to regist
- m_theConfig->saveSetting();
-
- // Close WTL App Module
- m_AppModule.RemoveMessageLoop();
- m_AppModule.Term();
-
- delete m_theConfig; m_theConfig=0;
- delete m_wndMainFrame; m_wndMainFrame=0;
- delete m_pIncoming; m_pIncoming=0;
- delete m_msgQueue; m_msgQueue=0;
-}
-
-//--------------------------------------------------------------------------------------------
-BOOL System::OnIdle(void)
-{
- MessageVector msgVector;
- m_msgQueue->processMessage(msgVector);
- if(!msgVector.empty())
- {
- for(size_t i=0; igetTraceType())
- {
- case AXTRACE_CMD_TYPE_LOG: //string log
- _insertStringLog((LogMessage*)message);
- break;
-
- case AXTRACE_CMD_TYPE_VALUE: //value
- _watchValue((ValueMessage*)message);
- break;
-
- case AXTRACE_CMD_TYPE_2D_CLEAN_MAP: //graphics 2d
- _2DCleanMap((G2DCleanMapMessage*)message);
- break;
-
- case AXTRACE_CMD_TYPE_2D_ACTOR:
- _2DUpdateActor((G2DActorMessage*)message);
- break;
- default: break;
- }
-}
-
-//--------------------------------------------------------------------------------------------
-void System::_insertStringLog(const LogMessage* message)
-{
- Filter::Result filterResult;
- m_filter->onLogMessage(message, filterResult);
-
- if (!filterResult.display) return;
-
- LogFrameWnd* logWnd = m_wndMainFrame->getLogWnd(filterResult.wndTitle);
- assert(logWnd!=0);
-
- logWnd->insertLog(message, filterResult);
-}
-
-//--------------------------------------------------------------------------------------------
-void System::_watchValue(const ValueMessage* message)
-{
- Filter::Result filterResult;
- m_filter->onValueMessage(message, filterResult);
-
- if (!filterResult.display) return;
-
- ValueFrameWnd* valueWnd = m_wndMainFrame->getValueWnd(filterResult.wndTitle);
- assert(valueWnd!=0);
-
- std::wstring value;
- message->getValueAsString(value);
- valueWnd->watchValue(message->getStyleID(), message->getTraceTime(), message->getValueName(), value.c_str(), filterResult);
-}
-
-//--------------------------------------------------------------------------------------------
-void System::_2DCleanMap(const G2DCleanMapMessage* message)
-{
- Filter::Result filterResult;
- m_filter->on2DCleanMapMessage(message, filterResult);
-
- if (!filterResult.display) return;
-
- Graphics2DFrameWnd* _2dWnd = m_wndMainFrame->get2DWnd(filterResult.wndTitle);
- assert(_2dWnd != 0);
-
- _2dWnd->cleanMap(message, filterResult);
-}
-
-//--------------------------------------------------------------------------------------------
-void System::_2DUpdateActor(const G2DActorMessage* message)
-{
- Filter::Result filterResult;
- m_filter->on2DActorMessage(message, filterResult);
-
- if (!filterResult.display) return;
-
- Graphics2DFrameWnd* _2dWnd = m_wndMainFrame->get2DWnd(filterResult.wndTitle);
- assert(_2dWnd != 0);
-
- _2dWnd->updateActor(message);
-}
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_System.h b/AxTrace/AT_System.h
deleted file mode 100644
index 9bc27d9..0000000
--- a/AxTrace/AT_System.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-
-namespace AT3
-{
-/** pre-define class
-*/
-class Config;
-class MainFrame;
-class Incoming;
-class MessageQueue;
-class Message;
-class LogMessage;
-class ValueMessage;
-class G2DCleanMapMessage;
-class G2DActorMessage;
-class Filter;
-
-/**Global System
-*/
-class System : public CIdleHandler
-{
- /*************************************************************************
- Public Methods
- *************************************************************************/
-public:
- /** Get singleton
- */
- static System* getSingleton(void) { return s_pMe; };
- /** System init
- */
- bool init(HINSTANCE hInstance, LPSTR lpCmdLine);
- /** System run
- */
- void run(void);
- /** System shut down
- */
- void release(void);
-
- /** Get main frame */
- MainFrame* getMainFrame(void) { return m_wndMainFrame; }
- /** Get Message Looper*/
- CMessageLoop* getMessageLoop(void) { return &m_theMsgLoop; }
- /** Get Message Queue */
- MessageQueue* getMessageQueue(void) { return m_msgQueue; }
- /** get config*/
- Config* getConfig(void) { return m_theConfig; }
- /** get app module */
- CAppModule& getAppModule(void) { return m_AppModule; }
- /** get filter */
- Filter* getFilter(void) { return m_filter; }
-
- /*************************************************************************
- Inherit Methods
- *************************************************************************/
-public:
- /** Interface for WTL idle processing
- */
- virtual BOOL OnIdle(void);
-
-private:
- /** process Axtrace data node */
- void _processAxTraceData(const Message* message);
- /** insert string log*/
- void _insertStringLog(const LogMessage* message);
- /** insert string log*/
- void _watchValue(const ValueMessage* message);
- /** insert 2d map*/
- void _2DCleanMap(const G2DCleanMapMessage* message);
- /** update 2d actor */
- void _2DUpdateActor(const G2DActorMessage* message);
-
- /*************************************************************************
- Implementation Data
- *************************************************************************/
-private:
- static System* s_pMe;
-
- HANDLE m_hMutex; //!< Global mutex
- HINSTANCE m_hInstance; //!< App instance
- std::string m_strCmdLine; //!< Command line
- CAppModule m_AppModule; //!< Global WTL Application Module
- CMessageLoop m_theMsgLoop; //!< WTL Message looper
- Config* m_theConfig; //!< Global config system
- MainFrame* m_wndMainFrame; //!< Main MDI Frame
- Incoming* m_pIncoming; //!< Incoming thread to receive msg
- MessageQueue* m_msgQueue; //!< Message Queue
- Filter* m_filter; //!< Display filter
-
- /*************************************************************************
- Construction and Destruction
- *************************************************************************/
-public:
- System();
- ~System();
-
-};
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_Util.cpp b/AxTrace/AT_Util.cpp
deleted file mode 100644
index c969c63..0000000
--- a/AxTrace/AT_Util.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_Util.h"
-#include "utf/ConvertUTF.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-void PrintMemoryToString(const char* pMemory, int sizeOfBytes, std::wstring& strOutput)
-{
- // address
- wchar_t szTemp[MAX_PATH];
- StringCchPrintfW(szTemp, MAX_PATH, L"%08X\t", (unsigned int)(UINT_PTR)pMemory);
-
- strOutput = szTemp;
-
- //contents(as bytes data)
- for(int i=0; i= ' ' && theChar <= '~')
- {
- szTemp[0] = theChar; szTemp[1]=0;
- }
- else
- {
- szTemp[0]='.'; szTemp[1]=0;
- }
-
- strOutput += szTemp;
- }
-}
-
-//--------------------------------------------------------------------------------------------
-wchar_t* _getStaticWideCharBuf(size_t sizeInChar, size_t* bufSizeInChar=0)
-{
- static wchar_t* s_wszBuf = 0;
- static size_t s_wszBufSizeInChar = 0;
-
- size_t oldSize = s_wszBufSizeInChar;
- while(sizeInChar>s_wszBufSizeInChar)
- {
- s_wszBufSizeInChar = ((s_wszBufSizeInChar==0) ? 1 : s_wszBufSizeInChar*2);
- }
-
- if(s_wszBufSizeInChar != oldSize)
- {
- wchar_t* newBuf = new wchar_t[s_wszBufSizeInChar];
- if(s_wszBuf)
- {
- delete[] s_wszBuf;
- }
-
- s_wszBuf = newBuf;
- }
-
- if(bufSizeInChar) *bufSizeInChar = s_wszBufSizeInChar;
- return s_wszBuf;
-}
-
-//--------------------------------------------------------------------------------------------
-char* _getStaticCharBuf(size_t sizeInByte, size_t* bufSizeInByte = 0)
-{
- static char* s_szBuf = 0;
- static size_t s_szBufSizeInByte = 0;
-
- size_t oldSize = s_szBufSizeInByte;
- while (sizeInByte>s_szBufSizeInByte)
- {
- s_szBufSizeInByte = ((s_szBufSizeInByte == 0) ? 1 : s_szBufSizeInByte * 2);
- }
-
- if (s_szBufSizeInByte != oldSize)
- {
- char* newBuf = new char[s_szBufSizeInByte];
- if (s_szBuf)
- {
- delete[] s_szBuf;
- }
-
- s_szBuf = newBuf;
- }
-
- if (bufSizeInByte) *bufSizeInByte = s_szBufSizeInByte;
- return s_szBuf;
-}
-
-//--------------------------------------------------------------------------------------------
-const wchar_t* convertUTF8ToUTF16(const char* utf8_string, size_t byte_len)
-{
- enum { MAX_CHARACTER = 8*1024*1024 };
-
- if(utf8_string==0 || byte_len ==0) return L"";
- if(byte_len>MAX_CHARACTER) byte_len = MAX_CHARACTER;
-
- //get wsz buf
- size_t wszCharCount = 0;
- wchar_t* wszBuf = _getStaticWideCharBuf(byte_len, &wszCharCount);
- wszBuf[0]=0;
-
- UTF8* pSourceStart = (UTF8*)utf8_string;
- UTF16* pTargetStart = (UTF16*)wszBuf;
-
- ConvertUTF8toUTF16((const UTF8 **)&pSourceStart, pSourceStart+ byte_len, &pTargetStart, pTargetStart+wszCharCount, strictConversion);
-
- return wszBuf;
-}
-
-//--------------------------------------------------------------------------------------------
-const char* convertUTF16ToUTF8(const wchar_t* utf16_string, size_t char_len)
-{
- enum { MAX_CHARACTER = 8 * 1024 * 1024 };
-
- if (utf16_string == 0 || char_len == 0) return "";
- if (char_len>MAX_CHARACTER) char_len = MAX_CHARACTER;
-
- size_t bufLength = 0;
- char* buf = _getStaticCharBuf(char_len*4, &bufLength);
-
- UTF8* buf_start = (UTF8*)buf;
- const UTF16* msg_start = (const UTF16*)utf16_string;
-
- ConvertUTF16toUTF8(&msg_start, msg_start+char_len, &buf_start, buf_start+ bufLength, strictConversion);
-
- return buf;
-}
-
-//--------------------------------------------------------------------------------------------
-AutoSizeBuf::AutoSizeBuf()
- : m_pBuf(0)
- , m_nSize(0)
-{
-}
-
-//--------------------------------------------------------------------------------------------
-AutoSizeBuf::~AutoSizeBuf()
-{
- if(m_pBuf) delete[] m_pBuf;
- m_pBuf=0;
- m_nSize=0;
-}
-
-//--------------------------------------------------------------------------------------------
-void* AutoSizeBuf::request(size_t sizeOfBytes)
-{
- size_t oldSize = m_nSize;
- size_t newSize = m_nSize;
- while(sizeOfBytes>newSize)
- {
- newSize = ((newSize==0) ? 1 : newSize*2);
- if(newSize>MAX_SIZE_OF_BYTES) return 0; //exception!
- }
-
- if(newSize != oldSize)
- {
- char* newBuf = new char[newSize];
- if(m_pBuf)
- {
- memcpy(newBuf, m_pBuf, oldSize);
- delete[] m_pBuf;
- }
-
- m_pBuf = newBuf;
- m_nSize = newSize;
- }
-
- return (void*)m_pBuf;
-}
-
-//--------------------------------------------------------------------------------------------
-bool loadFileToString(const wchar_t* wszFileName, std::string& fileContent)
-{
- assert(wszFileName);
-
- // Open the file
- HANDLE hFile = CreateFile(wszFileName,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_SEQUENTIAL_SCAN,
- NULL);
-
- if (hFile == INVALID_HANDLE_VALUE) {
- return false;
- }
-
- DWORD dwFileSize = GetFileSize(hFile, 0);
-
- //allocate memory
- char* tempMemory = new char[dwFileSize+1];
-
- //read file
- DWORD dwBytesRead;
- if (!ReadFile(hFile, tempMemory, dwFileSize, &dwBytesRead, NULL) || dwBytesRead != dwFileSize) {
- CloseHandle(hFile);
- delete[] tempMemory;
- return false;
- }
- CloseHandle(hFile);
-
- tempMemory[dwFileSize] = 0;
-
- fileContent = tempMemory;
- delete[] tempMemory;
-
- return true;
-}
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_Util.h b/AxTrace/AT_Util.h
deleted file mode 100644
index ba2eded..0000000
--- a/AxTrace/AT_Util.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-
-namespace AT3
-{
-
-/** print memory contents to string(for debug)
-*/
-void PrintMemoryToString(const char* pMemory, int sizeOfBytes, std::wstring& strOutput);
-
-/** auto lock
-*/
-struct AutoLock
-{
- LPCRITICAL_SECTION pCriticalSection;
- AutoLock(LPCRITICAL_SECTION p) : pCriticalSection(p) { ::EnterCriticalSection(pCriticalSection); }
- ~AutoLock() { ::LeaveCriticalSection(pCriticalSection); }
-};
-
-/** convert to utf16 string(return as static memory block, call by main thread only)*/
-const wchar_t* convertUTF8ToUTF16(const char* utf8_string, size_t byte_len);
-/** convert to utf8 string(return as static memory block, call by main thread only)*/
-const char* convertUTF16ToUTF8(const wchar_t* utf16_string, size_t char_len);
-
-/**memory buf
-*/
-class AutoSizeBuf
-{
-public:
- enum { MAX_SIZE_OF_BYTES=1024*1024*256 };
-
- void* request(size_t sizeOfBytes);
- size_t capcity(void) const { return m_nSize; }
-
-private:
- char* m_pBuf;
- size_t m_nSize;
-
-public:
- AutoSizeBuf();
- ~AutoSizeBuf();
-};
-
-/** load small text file to string */
-bool loadFileToString(const wchar_t* wszFileName, std::string& fileContent);
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_ValueFrame.cpp b/AxTrace/AT_ValueFrame.cpp
deleted file mode 100644
index 57e30fa..0000000
--- a/AxTrace/AT_ValueFrame.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-#include "StdAfx.h"
-#include "AT_ValueFrame.h"
-#include "AT_Util.h"
-#include "AT_System.h"
-#include "AT_MainFrame.h"
-
-namespace AT3
-{
-
-//--------------------------------------------------------------------------------------------
-ValueFrameWnd::ValueFrameWnd(CUpdateUIBase* pUpdateUI, const std::string& windowTitle)
- : m_pUpdateUI(pUpdateUI)
- , m_windowTitle(windowTitle)
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-ValueFrameWnd::~ValueFrameWnd()
-{
-
-}
-
-//--------------------------------------------------------------------------------------------
-void ValueFrameWnd::redraw(void)
-{
- m_wndListView.InvalidateRect(0);
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT ValueFrameWnd::OnEditCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_wndListView.copyToClipboard();
- return TRUE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT ValueFrameWnd::OnEditClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_wndListView.DeleteAllItems();
- m_valueHashMap.clear();
- return TRUE;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT ValueFrameWnd::OnEditSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- int count=m_wndListView.GetItemCount();
- for(int i=0; i0 && height>0 && m_wndListView.m_hWnd!=0 )
- {
- RECT rect;
- GetClientRect(&rect);
-
- int nWidth0 = m_wndListView.GetColumnWidth(0);
- int nWidth1 = m_wndListView.GetColumnWidth(1);
-
- m_wndListView.SetColumnWidth(2, width-nWidth0-nWidth1-32);
-
- }
- bHandled = FALSE;
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT ValueFrameWnd::OnSetFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- System::getSingleton()->getMainFrame()->onChildActive(this);
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-void ValueFrameWnd::watchValue(unsigned int styleID, const AXIATRACE_TIME* tTime, const wchar_t* valueName, const wchar_t* value, const Filter::Result& filter)
-{
- int nIndex = 0;
-
- wchar_t szTime[64];
- StringCchPrintfW(szTime, 64, _T("%02d:%02d %02d.%03d"), tTime->wHour, tTime->wMinute, tTime->wSecond, tTime->wMilliseconds);
-
- //find in hash map
- ValueHashMap::iterator it = m_valueHashMap.find(valueName);
- if(it==m_valueHashMap.end())
- {
- nIndex = m_wndListView.GetItemCount();
- m_valueHashMap.insert(std::make_pair(valueName, nIndex));
-
- m_wndListView.InsertItem(nIndex, szTime);
- m_wndListView.SetItemText(nIndex, 1, valueName);
- }
- else
- {
- nIndex = it->second;
- m_wndListView.SetItemText(nIndex, 0, szTime);
- }
-
- m_wndListView.SetItemText(nIndex, 2, value);
- m_wndListView.SetItemData(nIndex, (DWORD_PTR)((filter.fontColor << 16) | filter.backColor));
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT ValueFrameWnd::OnClose(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- System::getSingleton()->getMainFrame()->onChildDestroy(this);
- bHandled = FALSE;
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------
-LRESULT ValueFrameWnd::OnFileSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_wndListView.saveToFile();
- return 1;
-}
-
-
-}
\ No newline at end of file
diff --git a/AxTrace/AT_ValueFrame.h b/AxTrace/AT_ValueFrame.h
deleted file mode 100644
index 7cc5969..0000000
--- a/AxTrace/AT_ValueFrame.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-#pragma once
-#include "Resource.h"
-#include "AT_ListCtrlEx.h"
-#include "AT_ChildFrame.h"
-#include "AT_Interface.h"
-#include "AT_Filter.h"
-
-namespace AT3
-{
-/** ChildFrame - Value watcher
-*/
-class ValueFrameWnd : public CMDIChildWindowImpl, public IChildFrame
-{
-public:
- void watchValue(unsigned int styleID, const AXIATRACE_TIME* tTime, const wchar_t* valueName, const wchar_t* value, const Filter::Result& filterResult);
- /** get child type */
- virtual CHILD_STYLE getChildType(void) { return CS_VALUE_FRAME; }
- /** get window title*/
- virtual const std::string& getWindowTitle(void) { return m_windowTitle; }
- /** redraw */
- virtual void redraw(void);
- /** get native wnd handle */
- virtual HWND getNativeWnd(void) { return m_hWnd; }
-
- /*************************************************************************
- Inherit Methods
- *************************************************************************/
-public:
- DECLARE_FRAME_WND_CLASS(NULL, IDR_TRACE_FRAME_TYPE)
-
- virtual void OnFinalMessage(HWND /*hWnd*/)
- {
- delete this;
- }
-
- BEGIN_MSG_MAP(TraceFrameWnd)
- MESSAGE_HANDLER(WM_CREATE, OnCreate)
- MESSAGE_HANDLER(WM_SIZE, OnSize)
- MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
- MESSAGE_HANDLER(WM_CLOSE, OnClose)
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear)
- COMMAND_ID_HANDLER(ID_EDIT_CLEARALL, OnEditClear)
- COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy)
- COMMAND_ID_HANDLER(ID_EDIT_SELECTALL, OnEditSelectAll)
- COMMAND_ID_HANDLER(ID_FILE_SAVEAS, OnFileSaveAs)
- CHAIN_CLIENT_COMMANDS()
- CHAIN_MSG_MAP(CMDIChildWindowImpl)
- CHAIN_MSG_MAP_MEMBER(m_wndListView)
- END_MSG_MAP()
-
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnClose(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnEditClear(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnEditCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnEditSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnFileSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
-
- /*************************************************************************
- Implementation Data
- *************************************************************************/
-private:
- CListCtrlEx m_wndListView;
- CUpdateUIBase* m_pUpdateUI;
- std::string m_windowTitle;
-
- //value map
- typedef std::unordered_map< std::wstring, int > ValueHashMap;
- ValueHashMap m_valueHashMap;
-
- /*************************************************************************
- Construction and Destruction
- *************************************************************************/
-public:
- ValueFrameWnd(CUpdateUIBase* pUpdateUI, const std::string& windowTitle);
- ~ValueFrameWnd();
-};
-
-}
\ No newline at end of file
diff --git a/AxTrace/AtlOpengl.h b/AxTrace/AtlOpengl.h
deleted file mode 100644
index 4a118fc..0000000
--- a/AxTrace/AtlOpengl.h
+++ /dev/null
@@ -1,155 +0,0 @@
-#ifndef __ATLOPENGL_H__
-#define __ATLOPENGL_H__
-
-#pragma once
-
-#ifndef __cplusplus
- #error ATL requires C++ compilation (use a .cpp suffix)
-#endif
-
-#ifndef __ATLAPP_H__
- #error atlopengl.h requires atlapp.h to be included first
-#endif
-
-#ifndef __ATLWIN_H__
- #error atlopengl.h requires atlwin.h to be included first
-#endif
-
-#ifndef __ATLGDI_H__
- #error atlopengl.h requires atlgdi.h to be included first
-#endif
-
-#if (WINVER < 0x0400)
- #error WTL requires Windows version 4.0 or higher
-#endif
-
-
-#ifdef _ATL_NO_OPENGL
- #error atlopengl.h requires OpenGL support
-#endif
-
-// required libraries
-#ifndef _ATL_NO_OPENGL_UTIL
- #include
- #pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */
-#endif
-
-namespace WTL
-{
-
-/////////////////////////////////////////////////////////////////////////////
-// CGLMessageLoop - used for OpenGL animation
-
-class CGLMessageLoop : public CMessageLoop {
-
- BOOL OnIdle(int nIdleCount) {
- return !CMessageLoop::OnIdle(nIdleCount);
- }
-
-};
-
-/////////////////////////////////////////////////////////////////////////////
-// COpenGL
-
-template
-class ATL_NO_VTABLE COpenGL
-{
-public:
-
- HGLRC m_hRC; // Handle to RC
-
-// Message map and handlers
- typedef COpenGL thisClass;
-
- BEGIN_MSG_MAP(thisClass)
- MESSAGE_HANDLER(WM_CREATE, OnCreate)
- MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
- MESSAGE_HANDLER(WM_PAINT, OnPaint)
- MESSAGE_HANDLER(WM_SIZE, OnSize)
- MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
- END_MSG_MAP()
-
- LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- T* pT = static_cast(this);
- CClientDC dc(pT->m_hWnd);
-
- // Fill in the pixel format descriptor.
- PIXELFORMATDESCRIPTOR pfd;
- memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
- pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 24;
- pfd.cDepthBits = 32;
- pfd.iLayerType = PFD_MAIN_PLANE ;
-
- int nPixelFormat = dc.ChoosePixelFormat(&pfd);
- ATLASSERT(nPixelFormat != 0);
-
- BOOL bResult = dc.SetPixelFormat (nPixelFormat, &pfd);
- ATLASSERT(bResult);
-
- m_hRC = dc.wglCreateContext();
- ATLASSERT(m_hRC);
-
- dc.wglMakeCurrent(m_hRC);
- pT->OnGLInit();
- dc.wglMakeCurrent(NULL);
-
- bHandled = FALSE;
- return 0;
- }
-
- LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- if (m_hRC) {
- ::wglDeleteContext(m_hRC);
- m_hRC = NULL;
- }
-
- bHandled = FALSE;
- return 0;
- }
-
- LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- T* pT = static_cast(this);
- CPaintDC dc(pT->m_hWnd);
- dc.wglMakeCurrent(m_hRC);
- pT->OnGLRender();
- dc.SwapBuffers();
- dc.wglMakeCurrent(NULL);
-
- return 0;
- }
-
- LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- T* pT = static_cast(this);
- int cx = LOWORD(lParam);
- int cy = HIWORD(lParam);
-
- if (cx==0 || cy==0 || pT->m_hWnd==NULL)
- return 0;
-
- CClientDC dc(pT->m_hWnd);
- dc.wglMakeCurrent(m_hRC);
- pT->OnGLResize(cx, cy);
- dc.wglMakeCurrent(NULL);
-
- bHandled = FALSE;
- return 0;
- }
-
- LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- return 1;
- }
-
-};
-
-}; //namespace WTL
-
-#endif // __ATLOPENGL_H__
\ No newline at end of file
diff --git a/AxTrace/AxTrace.rc b/AxTrace/AxTrace.rc
deleted file mode 100644
index e837375..0000000
--- a/AxTrace/AxTrace.rc
+++ /dev/null
@@ -1,326 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// Chinese (Simplified, PRC) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
-LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
-#pragma code_page(936)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_MAINFRAME MENU
-BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "&Exit", ID_APP_EXIT
- END
- POPUP "&Options"
- BEGIN
- MENUITEM "&Receive\tCtrl+R", ID_SYSTEM_RECEIVE
- MENUITEM "&Hide Toolbar", 40032
- MENUITEM SEPARATOR
- MENUITEM "Filter &Setting...", ID_OPTION_FILTER
- MENUITEM "&Font...", ID_OPTION_FONT
- END
- POPUP "&Help"
- BEGIN
- MENUITEM "Help...\tF1", ID_HELP, INACTIVE
- MENUITEM "&About", ID_APP_ABOUT
- END
-END
-
-IDR_TRACEFRAME MENU
-BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "&Save as...\tCtrl+S", ID_FILE_SAVEAS
- MENUITEM SEPARATOR
- MENUITEM "&Exit", ID_APP_EXIT
- END
- POPUP "&Edit"
- BEGIN
- MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
- MENUITEM "Select &All\tCtrl+A", ID_EDIT_SELECTALL
- MENUITEM SEPARATOR
- MENUITEM "C&lear\tCtrl+X", ID_EDIT_CLEAR
- MENUITEM "Cl&ear All\tCtrl+Shift+X", ID_EDIT_CLEARALL
- END
- POPUP "&Options"
- BEGIN
- MENUITEM "&Receive\tCtrl+R", ID_SYSTEM_RECEIVE
- MENUITEM "A&uto Scroll\tCtrl+U", ID_SYSTEM_AUTOSCROLL
- MENUITEM "&Hide Toolbar", ID_OPTION_HIDE_TOOLBAR
- MENUITEM SEPARATOR
- MENUITEM "Filter &Setting...", ID_OPTION_FILTER
- MENUITEM "&Font...", ID_OPTION_FONT
- END
- POPUP "&Window"
- BEGIN
- MENUITEM "&Cascade", ID_WINDOW_CASCADE
- MENUITEM "&Tile", ID_WINDOW_TILE_HORZ
- END
- POPUP "&Help"
- BEGIN
- MENUITEM "Help...\tF1", ID_HELP, INACTIVE
- MENUITEM "&About", ID_APP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_DIALOG_ABOUT DIALOGEX 0, 0, 211, 63
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "About AxTrace"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,154,42,50,14
- ICON IDR_MAINFRAME,IDC_STATIC,7,7,21,20
- LTEXT "Axia|Trace3",IDC_STATIC,41,7,162,10
- CONTROL "(C)Copyright www.thecodeway.com",IDC_SYSLINK_HOME,
- "SysLink",WS_TABSTOP,41,20,162,14
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,0,1,0
- PRODUCTVERSION 3,0,1,0
- FILEFLAGSMASK 0x17L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "080404b0"
- BEGIN
- VALUE "CompanyName", "TheCodeway.com"
- VALUE "FileDescription", "Axia Trace Application"
- VALUE "FileVersion", "3.0.1.0"
- VALUE "InternalName", "AxTrace Receiver"
- VALUE "LegalCopyright", "Copyright TheCodeway.com(C) 2016"
- VALUE "OriginalFilename", "AxTrace.exe"
- VALUE "ProductName", " AxTrace Application"
- VALUE "ProductVersion", "3.0.1.0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x804, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Toolbar
-//
-
-IDR_MAINFRAME TOOLBAR 16, 15
-BEGIN
- BUTTON ID_FILE_SAVEAS
- SEPARATOR
- BUTTON ID_SYSTEM_RECEIVE
- BUTTON ID_SYSTEM_AUTOSCROLL
- SEPARATOR
- BUTTON ID_EDIT_CLEAR
- BUTTON ID_EDIT_CLEARALL
- SEPARATOR
- BUTTON ID_APP_ABOUT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDR_MAINFRAME BITMAP "res\\MainToolBar.bmp"
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_DIALOG_ABOUT, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 204
- TOPMARGIN, 7
- BOTTOMMARGIN, 56
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDR_MAINFRAME ICON "res\\AxTrace.ico"
-
-IDR_TRACE_FRAME_TYPE ICON "res\\AxTrace_TraceFrame.ico"
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_MAINFRAME ACCELERATORS
-BEGIN
- "X", ID_EDIT_CLEAR, VIRTKEY, CONTROL, NOINVERT
- "X", ID_EDIT_CLEARALL, VIRTKEY, SHIFT, CONTROL, NOINVERT
- "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
- "A", ID_EDIT_SELECTALL, VIRTKEY, CONTROL, NOINVERT
- "S", ID_FILE_SAVEAS, VIRTKEY, CONTROL, NOINVERT
- "R", ID_SYSTEM_RECEIVE, VIRTKEY, CONTROL, NOINVERT
- "U", ID_SYSTEM_AUTOSCROLL, VIRTKEY, CONTROL, NOINVERT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// AFX_DIALOG_LAYOUT
-//
-
-IDD_DIALOG_ABOUT AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
- ID_SYSTEM_RECEIVE "Receive Message or Shut it down\nReceive Message or Shut it down"
- ID_WINDOW_TILE "Arrange windows so they overlap\nCascade Windows"
-END
-
-STRINGTABLE
-BEGIN
- ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows"
- ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows"
-END
-
-STRINGTABLE
-BEGIN
- ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
- ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
-END
-
-STRINGTABLE
-BEGIN
- ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
- ID_APP_EXIT "Quit the application;\nExit"
-END
-
-STRINGTABLE
-BEGIN
- ID_EDIT_CLEAR "Clear current active view\nClear"
- ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
-END
-
-STRINGTABLE
-BEGIN
- ID_FILE_SAVEAS "Save the active document with a new name\nSave As"
- ID_EDIT_CLEARALL "Clear all view\nClear all"
- ID_OPTION_FONT "Open font setting dialog\rFont"
-END
-
-STRINGTABLE
-BEGIN
- ID_OPTION_FILTER "Open filter script file...\nFilter"
-END
-
-#endif // Chinese (Simplified, PRC) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/AxTrace/CMakeLists.txt b/AxTrace/CMakeLists.txt
deleted file mode 100644
index eb246a2..0000000
--- a/AxTrace/CMakeLists.txt
+++ /dev/null
@@ -1,125 +0,0 @@
-#
-# AxTrace
-#Copyright(C) thecodeway.com
-#
-#
-cmake_minimum_required (VERSION 3.0)
-
-set(AXTRACE_SOURCES_CPP
- AT_AboutDlg.cpp
- AT_Config.cpp
- AT_Incoming.cpp
- AT_ListCtrlEx.cpp
- AT_Main.cpp
- AT_MainFrame.cpp
- AT_Message.cpp
- AT_MessageQueue.cpp
- AT_System.cpp
- AT_LogFrame.cpp
- AT_Util.cpp
- AT_ValueFrame.cpp
- AT_Filter.cpp
- AT_Math.cpp
- AT_2DFrame.cpp
- AT_2DView.cpp
- AT_2DScene.cpp
- AT_2DCamera.cpp
- AT_Canvas.cpp
- AT_Color.cpp
-)
-
-set(AXTRACE_SOURCES_CPP_PRECOMPILED
- StdAfx.cpp
-)
-
-set(AXTRACE_SOURCES_UTF
- utf/ConvertUTF.c
- utf/ConvertUTF.h
-)
-
-source_group("Source Files\\utf" FILES ${AXTRACE_SOURCES_UTF})
-
-set(AXTRACE_SOURCES_INC
- AT_AboutDlg.h
- AT_ChildFrame.h
- AT_Config.h
- AT_Global.h
- AT_Incoming.h
- AT_Interface.h
- AT_ListCtrlEx.h
- AT_MainFrame.h
- AT_Message.h
- AT_MessageQueue.h
- AT_System.h
- AT_LogFrame.h
- AT_Util.h
- AT_ValueFrame.h
- AT_Filter.h
- AT_Math.h
- AT_2DFrame.h
- AT_2DView.h
- AT_2DScene.h
- AT_2DCamera.h
- AT_Canvas.h
- AT_Color.h
- AtlOpengl.h
- resource.h
- StdAfx.h
-)
-
-set(AXTRACE_SOURCES_RC
- AxTrace.rc
- res/AxTrace.ico
- res/AxTrace_TraceFrame.ico
- res/MainToolBar.bmp
-)
-source_group("Resource Files" FILES ${AXTRACE_SOURCES_RC})
-
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}/WTL
- ${CMAKE_CURRENT_SOURCE_DIR}/../luajit
- $ENV{CYCLONE_SDK_ROOT}/include
-)
-
-link_directories(
- $ENV{CYCLONE_SDK_ROOT}/lib
-)
-
-add_definitions(-D_UNICODE -DUNICODE -D_ATL_NO_OLD_NAMES)
-
-foreach(src_file ${AXTRACE_SOURCES_CPP})
- set_source_files_properties(
- ${src_file}
- PROPERTIES
- COMPILE_FLAGS "/Yustdafx.h"
- )
-endforeach()
-
-set_source_files_properties(${AXTRACE_SOURCES_CPP_PRECOMPILED}
- PROPERTIES
- COMPILE_FLAGS "/Ycstdafx.h"
-)
-
-ADD_EXECUTABLE(AxTrace WIN32
- ${AXTRACE_SOURCES_CPP_PRECOMPILED}
- ${AXTRACE_SOURCES_CPP}
- ${AXTRACE_SOURCES_UTF}
- ${AXTRACE_SOURCES_RC}
- ${AXTRACE_SOURCES_INC}
-)
-
-if(CMAKE_CL_64)
-target_link_libraries(AxTrace
- ws2_32
- cyclone
- winmm
- ${CMAKE_CURRENT_SOURCE_DIR}/../luajit/lua51_x64.lib
-)
-else()
-target_link_libraries(AxTrace
- ws2_32
- cyclone
- winmm
- ${CMAKE_CURRENT_SOURCE_DIR}/../luajit/lua51_x86.lib
-)
-endif()
\ No newline at end of file
diff --git a/AxTrace/StdAfx.cpp b/AxTrace/StdAfx.cpp
deleted file mode 100644
index 8827985..0000000
--- a/AxTrace/StdAfx.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-
-#include "StdAfx.h"
diff --git a/AxTrace/StdAfx.h b/AxTrace/StdAfx.h
deleted file mode 100644
index 4d87452..0000000
--- a/AxTrace/StdAfx.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/***************************************************
-
- AXIA|Trace3
-
- (C) Copyright Jean. 2013
-***************************************************/
-
-
-#pragma once
-
-#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN
-#endif
-
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0501 //for WindowsXP
-#endif
-
-#ifndef _WIN32_WINDOWS
-#define _WIN32_WINDOWS 0x0410 //for Windows98
-#endif
-
-#ifndef _WIN32_IE
-#define _WIN32_IE 0x0400 //for IE4.0
-#endif
-
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include