1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-26 12:18:51 -05:00

Re-enabled windows support. Event builder now instanced outside application. Some premake cleanup.

This commit is contained in:
Gordon McCann 2022-01-08 22:36:16 -05:00
parent 58b6612a3e
commit 34bf7e741b
34 changed files with 104 additions and 62 deletions

View File

@ -9,7 +9,7 @@ int main(int argc, const char** argv)
NAV_TRACE("Logger Initialized!"); NAV_TRACE("Logger Initialized!");
auto app = Navigator::CreateApplication(); auto app = Navigator::CreateApplication();
auto evb = Navigator::CreatePhysicsEventBuilder();
app->Run(); app->Run();
delete app; delete app;

View File

@ -1,6 +1,7 @@
#ifndef NAVIGATOR_H #ifndef NAVIGATOR_H
#define NAVIGATOR_H #define NAVIGATOR_H
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <memory> #include <memory>

View File

@ -17,7 +17,6 @@ namespace Navigator {
/*order is important, must be pMap then evb*/ /*order is important, must be pMap then evb*/
CreateParameterMap(); CreateParameterMap();
CreatePhysicsEventBuilder();
NavParameter par("joseph","mama"); NavParameter par("joseph","mama");
par.SetValue(8); par.SetValue(8);
@ -110,8 +109,8 @@ namespace Navigator {
void Application::Run() void Application::Run()
{ {
PhysicsStartEvent junk("/media/gordon/GordonData/gwm17/NavTests/data/", DataSource::SourceType::CompassOffline, 2000000); //PhysicsStartEvent junk("/media/gordon/GordonData/gwm17/NavTests/data/", DataSource::SourceType::CompassOffline, 2000000);
OnEvent(junk); //OnEvent(junk);
while(m_runFlag) while(m_runFlag)
{ {

View File

@ -14,7 +14,7 @@
namespace Navigator { namespace Navigator {
class Application class NAV_API Application
{ {
public: public:
Application(); Application();
@ -49,7 +49,7 @@ namespace Navigator {
static Application* s_instance; static Application* s_instance;
}; };
Application* CreateApplication(); NAV_API Application* CreateApplication();
} }
#endif #endif

View File

@ -1,11 +1,12 @@
#ifndef APP_EVENT_H #ifndef APP_EVENT_H
#define APP_EVENT_H #define APP_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h" #include "Event.h"
namespace Navigator { namespace Navigator {
class WindowCloseEvent : public Event class NAV_API WindowCloseEvent : public Event
{ {
public: public:
WindowCloseEvent() {}; WindowCloseEvent() {};
@ -14,7 +15,7 @@ namespace Navigator {
EVENT_TYPE_SETUP(WindowClose) EVENT_TYPE_SETUP(WindowClose)
}; };
class WindowResizeEvent : public Event class NAV_API WindowResizeEvent : public Event
{ {
public: public:
WindowResizeEvent(float x, float y) : WindowResizeEvent(float x, float y) :
@ -38,7 +39,7 @@ namespace Navigator {
float m_xSize, m_ySize; float m_xSize, m_ySize;
}; };
class AppUpdateEvent : public Event class NAV_API AppUpdateEvent : public Event
{ {
public: public:
AppUpdateEvent() = default; AppUpdateEvent() = default;

View File

@ -5,7 +5,7 @@
namespace Navigator { namespace Navigator {
enum class EventType enum class NAV_API EventType
{ {
None=0, None=0,
WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved, WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved,
@ -15,7 +15,7 @@ namespace Navigator {
PhysicsStart, PhysicsStop PhysicsStart, PhysicsStop
}; };
enum EventCategory enum NAV_API EventCategory
{ {
EventCategoryNone=0, EventCategoryNone=0,
EventCategoryApp=BIT(0), EventCategoryApp=BIT(0),
@ -33,7 +33,7 @@ namespace Navigator {
virtual EventType GetEventType() const override { return GetStaticType(); } \ virtual EventType GetEventType() const override { return GetStaticType(); } \
virtual const char* GetName() const override { return #type; } virtual const char* GetName() const override { return #type; }
class Event class NAV_API Event
{ {
friend class EventDispatcher; friend class EventDispatcher;
public: public:
@ -45,7 +45,7 @@ namespace Navigator {
bool handledFlag = false; bool handledFlag = false;
}; };
class EventDispatcher class NAV_API EventDispatcher
{ {
template<typename T> template<typename T>
using EventFunc = std::function<bool(T&)>; using EventFunc = std::function<bool(T&)>;
@ -74,7 +74,7 @@ namespace Navigator {
Event& m_event; Event& m_event;
}; };
inline std::ostream& operator<<(std::ostream& os, const Event& e) NAV_API inline std::ostream& operator<<(std::ostream& os, const Event& e)
{ {
return os << e.ToString(); return os << e.ToString();
} }

View File

@ -1,11 +1,12 @@
#ifndef KEY_EVENT_H #ifndef KEY_EVENT_H
#define KEY_EVENT_H #define KEY_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h" #include "Event.h"
namespace Navigator { namespace Navigator {
class KeyEvent : public Event class NAV_API KeyEvent : public Event
{ {
public: public:
inline int GetKeycode() const { return m_keycode; } inline int GetKeycode() const { return m_keycode; }
@ -20,7 +21,7 @@ namespace Navigator {
}; };
class KeyPressedEvent : public KeyEvent class NAV_API KeyPressedEvent : public KeyEvent
{ {
public: public:
KeyPressedEvent(int code, int count) : KeyPressedEvent(int code, int count) :
@ -44,7 +45,7 @@ namespace Navigator {
int m_repeatCount; int m_repeatCount;
}; };
class KeyReleasedEvent : public KeyEvent class NAV_API KeyReleasedEvent : public KeyEvent
{ {
public: public:
KeyReleasedEvent(int code) : KeyReleasedEvent(int code) :
@ -63,7 +64,7 @@ namespace Navigator {
}; };
class KeyTypedEvent : public KeyEvent class NAV_API KeyTypedEvent : public KeyEvent
{ {
public: public:
KeyTypedEvent(int code) : KeyTypedEvent(int code) :

View File

@ -1,12 +1,12 @@
#ifndef MOUSE_EVENT_H #ifndef MOUSE_EVENT_H
#define MOUSE_EVENT_H #define MOUSE_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h" #include "Event.h"
namespace Navigator { namespace Navigator {
class MouseMovedEvent : public Event class NAV_API MouseMovedEvent : public Event
{ {
public: public:
MouseMovedEvent(float x, float y) : MouseMovedEvent(float x, float y) :
@ -30,7 +30,7 @@ namespace Navigator {
float m_xPos, m_yPos; float m_xPos, m_yPos;
}; };
class MouseScrolledEvent : public Event class NAV_API MouseScrolledEvent : public Event
{ {
public: public:
MouseScrolledEvent(float x, float y) : MouseScrolledEvent(float x, float y) :
@ -54,7 +54,7 @@ namespace Navigator {
float m_xOffset, m_yOffset; float m_xOffset, m_yOffset;
}; };
class MouseButtonPressedEvent : public Event class NAV_API MouseButtonPressedEvent : public Event
{ {
public: public:
MouseButtonPressedEvent(int code) : MouseButtonPressedEvent(int code) :
@ -77,7 +77,7 @@ namespace Navigator {
int m_buttonCode; int m_buttonCode;
}; };
class MouseButtonReleasedEvent : public Event class NAV_API MouseButtonReleasedEvent : public Event
{ {
public: public:
MouseButtonReleasedEvent(int code) : MouseButtonReleasedEvent(int code) :

View File

@ -1,12 +1,13 @@
#ifndef PHYSICS_EVENT_H #ifndef PHYSICS_EVENT_H
#define PHYSICS_EVENT_H #define PHYSICS_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h" #include "Event.h"
#include "Navigator/Physics/DataSource.h" #include "Navigator/Physics/DataSource.h"
namespace Navigator { namespace Navigator {
class PhysicsStartEvent : public Event class NAV_API PhysicsStartEvent : public Event
{ {
public: public:
PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window) : PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window) :
@ -31,7 +32,7 @@ namespace Navigator {
uint64_t m_coincidenceWindow; uint64_t m_coincidenceWindow;
}; };
class PhysicsStopEvent : public Event class NAV_API PhysicsStopEvent : public Event
{ {
public: public:
PhysicsStopEvent() {} PhysicsStopEvent() {}

View File

@ -3,7 +3,7 @@
namespace Navigator { namespace Navigator {
class GraphicsContext class NAV_API GraphicsContext
{ {
public: public:
virtual void Init() = 0; virtual void Init() = 0;

View File

@ -1,9 +1,11 @@
#ifndef HISTOGRAM_H #ifndef HISTOGRAM_H
#define HISTOGRAM_H #define HISTOGRAM_H
#include "NavCore.h"
namespace Navigator { namespace Navigator {
class Histogram class NAV_API Histogram
{ {
public: public:
Histogram(const std::string& name, const std::string& param_x, const std::string& param_y="None") : Histogram(const std::string& name, const std::string& param_x, const std::string& param_y="None") :
@ -26,7 +28,7 @@ namespace Navigator {
bool m_initFlag; bool m_initFlag;
}; };
class Histogram1D : public Histogram class NAV_API Histogram1D : public Histogram
{ {
public: public:
Histogram1D(const std::string& name, const std::string& param, int bins, double min, double max); Histogram1D(const std::string& name, const std::string& param, int bins, double min, double max);
@ -47,7 +49,7 @@ namespace Navigator {
double m_xMax; double m_xMax;
}; };
class Histogram2D : public Histogram class NAV_API Histogram2D : public Histogram
{ {
public: public:
Histogram2D(const std::string& name, const std::string& param_x, const std::string& param_y, int bins_x, double min_x, double max_x, Histogram2D(const std::string& name, const std::string& param_x, const std::string& param_y, int bins_x, double min_x, double max_x,

View File

@ -1,11 +1,12 @@
#ifndef IMGUI_LAYER_H #ifndef IMGUI_LAYER_H
#define IMGUI_LAYER_H #define IMGUI_LAYER_H
#include "Navigator/NavCore.h"
#include "Navigator/Layer.h" #include "Navigator/Layer.h"
namespace Navigator { namespace Navigator {
class ImGuiLayer : public Layer class NAV_API ImGuiLayer : public Layer
{ {
public: public:
ImGuiLayer(); ImGuiLayer();

View File

@ -1,11 +1,12 @@
#ifndef LAYER_H #ifndef LAYER_H
#define LAYER_H #define LAYER_H
#include "NavCore.h"
#include "Events/Event.h" #include "Events/Event.h"
namespace Navigator { namespace Navigator {
class Layer class NAV_API Layer
{ {
public: public:
Layer(const std::string& name="Layer"); Layer(const std::string& name="Layer");

View File

@ -6,7 +6,7 @@
namespace Navigator { namespace Navigator {
class LayerStack class NAV_API LayerStack
{ {
public: public:
LayerStack(); LayerStack();

View File

@ -1,12 +1,13 @@
#ifndef LOGGER_H #ifndef LOGGER_H
#define LOGGER_H #define LOGGER_H
#include "NavCore.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "spdlog/fmt/ostr.h" #include "spdlog/fmt/ostr.h"
namespace Navigator { namespace Navigator {
class Logger class NAV_API Logger
{ {
public: public:

View File

@ -1,8 +1,15 @@
#ifndef NAVCORE_H #ifndef NAVCORE_H
#define NAVCORE_H #define NAVCORE_H
#ifdef NAV_WINDOWS #ifdef NAV_WINDOWS
#error "Navigator is not compatible with Windows!" #ifdef NAV_EXPORT
#define NAV_API __declspec(dllexport)
#else
#define NAV_API __declspec(dllimport)
#endif
#else
#define NAV_API
#endif #endif

View File

@ -1,11 +1,12 @@
#ifndef PARAMETER_MAP_H #ifndef PARAMETER_MAP_H
#define PARAMETER_MAP_H #define PARAMETER_MAP_H
#include "NavCore.h"
#include <atomic> #include <atomic>
namespace Navigator { namespace Navigator {
struct ParameterData struct NAV_API ParameterData
{ {
std::atomic<double> value=0.0; std::atomic<double> value=0.0;
std::atomic<bool> validFlag=false; std::atomic<bool> validFlag=false;
@ -15,7 +16,7 @@ namespace Navigator {
For use inside of the physics thread only!!!!!! Do not use elsewhere as complex operations on parameter values are !not! For use inside of the physics thread only!!!!!! Do not use elsewhere as complex operations on parameter values are !not!
guaranteed to be thread-safe, only the accesing is! guaranteed to be thread-safe, only the accesing is!
*/ */
class NavParameter class NAV_API NavParameter
{ {
public: public:
@ -36,7 +37,7 @@ namespace Navigator {
/* /*
Global parameter accesing, storage Global parameter accesing, storage
*/ */
class ParameterMap class NAV_API ParameterMap
{ {
public: public:
@ -62,7 +63,7 @@ namespace Navigator {
}; };
ParameterMap* CreateParameterMap(); NAV_API ParameterMap* CreateParameterMap();
} }
#endif #endif

View File

@ -13,7 +13,7 @@
namespace Navigator { namespace Navigator {
class AnalysisStack class NAV_API AnalysisStack
{ {
public: public:
AnalysisStack(); AnalysisStack();

View File

@ -1,11 +1,12 @@
#ifndef ANALYSIS_STAGE_H #ifndef ANALYSIS_STAGE_H
#define ANALYSIS_STAGE_H #define ANALYSIS_STAGE_H
#include "Navigator/NavCore.h"
#include "CompassHit.h" #include "CompassHit.h"
namespace Navigator { namespace Navigator {
class AnalysisStage class NAV_API AnalysisStage
{ {
public: public:
using RawPhysicsEvent = std::vector<CompassHit>; using RawPhysicsEvent = std::vector<CompassHit>;

View File

@ -11,12 +11,13 @@
#ifndef COMPASSFILE_H #ifndef COMPASSFILE_H
#define COMPASSFILE_H #define COMPASSFILE_H
#include "Navigator/NavCore.h"
#include "CompassHit.h" #include "CompassHit.h"
#include "ShiftMap.h" #include "ShiftMap.h"
namespace Navigator { namespace Navigator {
class CompassFile class NAV_API CompassFile
{ {
public: public:

View File

@ -1,9 +1,11 @@
#ifndef COMPASS_HIT_H #ifndef COMPASS_HIT_H
#define COMPASS_HIT_H #define COMPASS_HIT_H
#include "Navigator/NavCore.h"
namespace Navigator { namespace Navigator {
struct CompassHit struct NAV_API CompassHit
{ {
uint16_t board = 0; uint16_t board = 0;
uint16_t channel = 0; uint16_t channel = 0;

View File

@ -10,6 +10,7 @@
#ifndef COMPASSRUN_H #ifndef COMPASSRUN_H
#define COMPASSRUN_H #define COMPASSRUN_H
#include "Navigator/NavCore.h"
#include "DataSource.h" #include "DataSource.h"
#include "CompassFile.h" #include "CompassFile.h"
#include "ShiftMap.h" #include "ShiftMap.h"
@ -17,7 +18,7 @@
namespace Navigator { namespace Navigator {
class CompassRun : public DataSource class NAV_API CompassRun : public DataSource
{ {
public: public:

View File

@ -1,11 +1,12 @@
#ifndef DATA_SOURCE_H #ifndef DATA_SOURCE_H
#define DATA_SOURCE_H #define DATA_SOURCE_H
#include "Navigator/NavCore.h"
#include "CompassHit.h" #include "CompassHit.h"
namespace Navigator { namespace Navigator {
class DataSource class NAV_API DataSource
{ {
public: public:
enum class SourceType enum class SourceType
@ -28,9 +29,9 @@ namespace Navigator {
bool m_validFlag; bool m_validFlag;
}; };
DataSource* CreateDataSource(const std::string& loc, DataSource::SourceType type); NAV_API DataSource* CreateDataSource(const std::string& loc, DataSource::SourceType type);
std::string ConvertDataSourceTypeToString(DataSource::SourceType type); NAV_API std::string ConvertDataSourceTypeToString(DataSource::SourceType type);
} }
#endif #endif

View File

@ -11,7 +11,7 @@
namespace Navigator { namespace Navigator {
class PhysicsEventBuilder class NAV_API PhysicsEventBuilder
{ {
public: public:
PhysicsEventBuilder(); PhysicsEventBuilder();
@ -26,7 +26,7 @@ namespace Navigator {
void PushStage(AnalysisStage* stage); void PushStage(AnalysisStage* stage);
bool IsRunning() { return m_runFlag; } bool IsRunning() { return m_runFlag; }
inline static PhysicsEventBuilder& Get() { return *s_instance; } static PhysicsEventBuilder& Get() { return *s_instance; }
private: private:
AnalysisStack m_physStack; AnalysisStack m_physStack;
@ -40,7 +40,7 @@ namespace Navigator {
}; };
PhysicsEventBuilder* CreatePhysicsEventBuilder(); NAV_API PhysicsEventBuilder* CreatePhysicsEventBuilder();
} }

View File

@ -1,11 +1,12 @@
#ifndef PHYSICS_HIT_SORT_H #ifndef PHYSICS_HIT_SORT_H
#define PHYSICS_HIT_SORT_H #define PHYSICS_HIT_SORT_H
#include "Navigator/NavCore.h"
#include "CompassHit.h" #include "CompassHit.h"
namespace Navigator { namespace Navigator {
class PhysicsHitSort class NAV_API PhysicsHitSort
{ {
public: public:
using RawPhysicsEvent = std::vector<CompassHit>; using RawPhysicsEvent = std::vector<CompassHit>;

View File

@ -12,9 +12,11 @@
#ifndef SHIFTMAP_H #ifndef SHIFTMAP_H
#define SHIFTMAP_H #define SHIFTMAP_H
#include "Navigator/NavCore.h"
namespace Navigator { namespace Navigator {
class ShiftMap class NAV_API ShiftMap
{ {
public: public:
ShiftMap(); ShiftMap();

View File

@ -1,11 +1,12 @@
#ifndef RENDER_COMMAND_H #ifndef RENDER_COMMAND_H
#define RENDER_COMMAND_H #define RENDER_COMMAND_H
#include "Navigator/NavCore.h"
#include "RendererAPI.h" #include "RendererAPI.h"
namespace Navigator { namespace Navigator {
class RenderCommand class NAV_API RenderCommand
{ {
public: public:
inline static void SetClearColor(const float* color_array) { s_api->SetClearColor(color_array); } inline static void SetClearColor(const float* color_array) { s_api->SetClearColor(color_array); }

View File

@ -1,12 +1,13 @@
#ifndef RENDERER_H #ifndef RENDERER_H
#define RENDERER_H #define RENDERER_H
#include "Navigator/NavCore.h"
#include "RendererAPI.h" #include "RendererAPI.h"
#include "RenderCommand.h" #include "RenderCommand.h"
namespace Navigator { namespace Navigator {
class Renderer class NAV_API Renderer
{ {
public: public:

View File

@ -1,9 +1,11 @@
#ifndef RENDERER_API_H #ifndef RENDERER_API_H
#define RENDERER_API_H #define RENDERER_API_H
#include "Navigator/NavCore.h"
namespace Navigator { namespace Navigator {
class RendererAPI class NAV_API RendererAPI
{ {
public: public:
enum class API enum class API

View File

@ -6,7 +6,7 @@
namespace Navigator { namespace Navigator {
class WindowProperties class NAV_API WindowProperties
{ {
public: public:
unsigned int width, height; unsigned int width, height;
@ -19,7 +19,7 @@ namespace Navigator {
}; };
class Window class NAV_API Window
{ {
public: public:

View File

@ -1,13 +1,14 @@
#ifndef OPEGL_CONTEXT_H #ifndef OPEGL_CONTEXT_H
#define OPEGL_CONTEXT_H #define OPEGL_CONTEXT_H
#include "Navigator/NavCore.h"
#include "Navigator/GraphicsContext.h" #include "Navigator/GraphicsContext.h"
struct GLFWwindow; struct GLFWwindow;
namespace Navigator { namespace Navigator {
class OpenGLContext : public GraphicsContext class NAV_API OpenGLContext : public GraphicsContext
{ {
public: public:
OpenGLContext(GLFWwindow* window); OpenGLContext(GLFWwindow* window);

View File

@ -1,11 +1,12 @@
#ifndef OPENGL_RENDERER_API_H #ifndef OPENGL_RENDERER_API_H
#define OPENGL_RENDERER_API_H #define OPENGL_RENDERER_API_H
#include "Navigator/NavCore.h"
#include "Navigator/Renderer/RendererAPI.h" #include "Navigator/Renderer/RendererAPI.h"
namespace Navigator { namespace Navigator {
class OpenGLRendererAPI : public RendererAPI class NAV_API OpenGLRendererAPI : public RendererAPI
{ {
public: public:
virtual void Clear() override; virtual void Clear() override;

View File

@ -1,13 +1,14 @@
#ifndef OPENGL_WINDOW_H #ifndef OPENGL_WINDOW_H
#define OPENGL_WINDOW_H #define OPENGL_WINDOW_H
#include "Navigator/NavCore.h"
#include "Navigator/Window.h" #include "Navigator/Window.h"
#include "Navigator/GraphicsContext.h" #include "Navigator/GraphicsContext.h"
#include "GLFW/glfw3.h" #include "GLFW/glfw3.h"
namespace Navigator { namespace Navigator {
class OpenGLWindow : public Window class NAV_API OpenGLWindow : public Window
{ {
public: public:

View File

@ -24,7 +24,6 @@ project "Navigator"
kind "SharedLib" kind "SharedLib"
language "C++" language "C++"
cppdialect "C++17" cppdialect "C++17"
staticruntime "on"
targetdir ("lib/" .. outputdir .. "/%{prj.name}") targetdir ("lib/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}") objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
@ -84,8 +83,6 @@ project "Navigator"
defines "NAV_LINUX" defines "NAV_LINUX"
links { links {
"GL", "GL",
"GLU",
"glut",
"X11", "X11",
"dl" "dl"
} }
@ -106,6 +103,14 @@ project "Navigator"
"-pthread", "-pthread",
"-undefined dynamic_lookup" "-undefined dynamic_lookup"
} }
filter "system:windows"
defines "NAV_EXPORT"
postbuildcommands {
("{COPY} %{cfg.buildtarget.relpath} \"../bin/" .. outputdir .. "/NavProject/\"")
}
links {
"opengl32.lib"
}
filter "configurations:Debug" filter "configurations:Debug"
defines "NAV_DEBUG" defines "NAV_DEBUG"
@ -147,6 +152,7 @@ project "NavProject"
systemversion "latest" systemversion "latest"
filter "system:macosx" filter "system:macosx"
defines "NAV_APPLE"
sysincludedirs { sysincludedirs {
"Navigator/vendor/spdlog/include/", "Navigator/vendor/spdlog/include/",
"%{IncludeDirs.glfw}", "%{IncludeDirs.glfw}",
@ -154,6 +160,10 @@ project "NavProject"
"%{IncludeDirs.glad}", "%{IncludeDirs.glad}",
"%{IncludeDirs.ImPlot}" "%{IncludeDirs.ImPlot}"
} }
filter "system:windows"
defines "NAV_WINDOWS"
filter "system:linux"
defines "NAV_LINUX"