Skip to content

Commit

Permalink
Move current editor implemtation with DearImGui inside DearImGui folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Apr 16, 2024
1 parent 64a705a commit 9560d1c
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 24 deletions.
38 changes: 20 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,29 @@ DESCRIPTION = Timed Petri Net Editor
STANDARD = --std=c++14
BUILD_TYPE = debug

###################################################
# Select backend for dear im gui: RayLib or GLFW3
#
#BACKEND ?= RayLib
BACKEND ?= GLFW3

###################################################
# Location of the project directory and Makefiles
#
P := .
M := $(P)/.makefile
include $(M)/Makefile.header

###################################################
# Editor using Dear ImGui backend.
# Select backend for dear im gui: RayLib or GLFW3
#
#DEAR_IMGUI_BACKEND ?= RayLib
DEAR_IMGUI_BACKEND ?= GLFW3
VPATH += $(P)/src/Editor/DearImGui
INCLUDES += -I$(P)/src/Editor/DearImGui

###################################################
# Check selected backend for dear im gui if compiled for html5
# Be sure to place this section after including MyMakefile
ifeq ($(ARCHI),Emscripten)
ifneq ($(BACKEND),RayLib)
ifneq ($(DEAR_IMGUI_BACKEND),RayLib)
$(warning Force RayLib backend for compiling with Emscripten)
BACKEND = RayLib
DEAR_IMGUI_BACKEND = RayLib
endif
endif

Expand All @@ -35,7 +38,6 @@ endif
#
VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net
VPATH += $(P)/src/Net/Imports VPATH += $(P)/src/Net/Exports
VPATH += $(P)/src/Editor $(P)/src/Editor/DearImGui

###################################################
# Inform Makefile where to find header files
Expand All @@ -61,7 +63,7 @@ LINKER_FLAGS += -ldl -lpthread
###################################################
# Set thirdpart Raylib
#
ifeq ($(BACKEND),RayLib)
ifeq ($(DEAR_IMGUI_BACKEND),RayLib)
INCLUDES += -I$(THIRDPART)/raylib/src
THIRDPART_LIBS += $(abspath $(THIRDPART)/raylib/src/$(ARCHI)/libraylib.a)

Expand All @@ -84,21 +86,21 @@ endif
###################################################
# Dear ImGui backends: Raylib
#
ifeq ($(BACKEND),RayLib)
ifeq ($(DEAR_IMGUI_BACKEND),RayLib)
VPATH += $(THIRDPART)/rlImGui
VPATH += $(P)/src/Editor/DearImGui/Backends/RayLib
INCLUDES += -I$(THIRDPART)/rlImGui
INCLUDES += -I$(P)/src/Editor/DearImGui/Backends/RayLib
DEARIMGUI_BACKEND_OBJS += rlImGui.o
DEARIMGUI_DEAR_IMGUI_BACKEND_OBJS += rlImGui.o
endif

###################################################
# Dear ImGui backends: OpenGL/GLFW3
#
ifeq ($(BACKEND),GLFW3)
ifeq ($(DEAR_IMGUI_BACKEND),GLFW3)
VPATH += $(P)/src/Editor/DearImGui/Backends/GLFW3
INCLUDES += -I$(P)/src/Editor/DearImGui/Backends/GLFW3
DEARIMGUI_BACKEND_OBJS += imgui_impl_glfw.o imgui_impl_opengl3.o
DEARIMGUI_DEAR_IMGUI_BACKEND_OBJS += imgui_impl_glfw.o imgui_impl_opengl3.o
endif

###################################################
Expand Down Expand Up @@ -163,8 +165,8 @@ endif
###################################################
# Check if Dear im gui backend has been set
#
ifeq ($(DEARIMGUI_BACKEND_OBJS),)
$(error "Define BACKEND either as RayLib or GLFW3")
ifeq ($(DEARIMGUI_DEAR_IMGUI_BACKEND_OBJS),)
$(error "Define DEAR_IMGUI_BACKEND either as RayLib or GLFW3")
endif

###################################################
Expand Down Expand Up @@ -196,9 +198,9 @@ LIB_OBJS += ExportJSON.o ExportSymfony.o ExportPnEditor.o
LIB_OBJS += ExportPetriLaTeX.o ExportJulia.o ExportGraphviz.o ExportDrawIO.o
LIB_OBJS += ExportGrafcetCpp.o ImportPNML.o ExportPNML.o Exports.o
LIB_OBJS += ImportJSON.o Imports.o
OBJS += $(DEARIMGUI_BACKEND_OBJS) $(DEARIMGUI_OBJS)
OBJS += $(DEARIMGUI_DEAR_IMGUI_BACKEND_OBJS) $(DEARIMGUI_OBJS)
OBJS += $(LIB_OBJS)
OBJS += DearUtils.o Drawable.o Application.o PetriEditor.o main.o
OBJS += DearUtils.o Drawable.o Application.o Editor.o main.o

###################################################
# Compile the project, the static and shared libraries
Expand Down
46 changes: 46 additions & 0 deletions include/TimedPetriNetEditor/PetriEditor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//=============================================================================
// TimedPetriNetEditor: A timed Petri net editor.
// Copyright 2021 -- 2023 Quentin Quadrat <lecrapouille@gmail.com>
//
// This file is part of TimedPetriNetEditor.
//
// TimedPetriNetEditor is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
//=============================================================================

#ifndef PETRI_NET_EDITOR_HPP
# define PETRI_NET_EDITOR_HPP

# include <string>

namespace tpne {

// ****************************************************************************
//! \brief Graphical User interface for manipulating and simulating Petri net.
// ****************************************************************************
class PetriNetEditor
{
public:

//-------------------------------------------------------------------------
//! \brief Starts the Petri net editor up, load the Petri file if given not
//! empty. Then call the infinite loop of the GUI.
//! \param[in] petri_file the path of the Petri net fil to load. Pass dummy
//! string if you do not want to load a Petri net file.
//-------------------------------------------------------------------------
virtual void run(std::string const& petri_file) = 0;
};

} // namespace tpne

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "TimedPetriNetEditor/PetriNet.hpp"
#include "TimedPetriNetEditor/Algorithms.hpp"
#include "TimedPetriNetEditor/SparseMatrix.hpp"
#include "Editor/PetriEditor.hpp"
#include "Editor/DearImGui/Editor.hpp"
#include "Editor/DearImGui/Drawable.hpp"
#include "Editor/DearImGui/DearUtils.hpp"
#include "Editor/DearImGui/KeyBindings.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
// along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
//=============================================================================

#ifndef PETRIEDITOR_HPP
# define PETRIEDITOR_HPP
#ifndef DEAR_IMGUI_PETRI_NET_EDITOR_HPP
# define DEAR_IMGUI_PETRI_NET_EDITOR_HPP

# include "Application.hpp" // Selected by Makefile
# include "TimedPetriNetEditor/PetriEditor.hpp"
# include "Net/Simulation.hpp"
# include "Net/Exports/Exports.hpp"
# include "Net/Imports/Imports.hpp"
Expand All @@ -33,7 +34,7 @@ namespace tpne {
// ****************************************************************************
//! \brief Graphical User interface for manipulating and simulating Petri net.
// ****************************************************************************
class Editor: public Application
class Editor: public PetriNetEditor, public Application
{
public:

Expand All @@ -48,7 +49,7 @@ class Editor: public Application
//! \param[in] petri_file the path of the Petri net fil to load. Pass dummy
//! string if you do not want to load a Petri net file.
//-------------------------------------------------------------------------
void run(std::string const& petri_file);
virtual void run(std::string const& petri_file) override;

private: // Inheritance from Application class

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Editor/PetriEditor.hpp"
#include "Editor.hpp" // Selected by Makefile
#include <unistd.h> // getopt

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 9560d1c

Please sign in to comment.