Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
Gauthier Quesnel
irritator
Commits
0264d282
Commit
0264d282
authored
Apr 16, 2021
by
Gauthier Quesnel
Committed by
Gauthier Quesnel
Apr 21, 2021
Browse files
gui: adding sources editor
parent
d0a1bdca
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
app/gui/CMakeLists.txt
View file @
0264d282
...
...
@@ -4,6 +4,7 @@ project(irritator-gui VERSION 0.1.0 LANGUAGES CXX)
set
(
gui_sources
dialog-file.cpp gui.hpp imnodes.cpp imnodes.hpp implot.h implot.cpp
window-logger.cpp node-editor.hpp node-editor.cpp simulation-editor.cpp
sources.cpp
${
PROJECT_SOURCE_DIR
}
/../../external/imgui/imgui.cpp
${
PROJECT_SOURCE_DIR
}
/../../external/imgui/imgui.h
${
PROJECT_SOURCE_DIR
}
/../../external/imgui/imgui_demo.cpp
...
...
app/gui/dialog-file.cpp
View file @
0264d282
...
...
@@ -23,11 +23,11 @@
#include
<pwd.h>
#include
<unistd.h>
#elif defined(__APPLE__)
#include
<sys/param.h>
#include
<sys/mount.h>
#include
<errno.h>
#include
<mach-o/dyld.h>
#include
<pwd.h>
#include
<sys/mount.h>
#include
<sys/param.h>
#include
<unistd.h>
#elif defined(_WIN32)
#include
<KnownFolders.h>
...
...
app/gui/node-editor.cpp
View file @
0264d282
...
...
@@ -2993,6 +2993,7 @@ application_show()
ImGui
::
MenuItem
(
"Simulation"
,
nullptr
,
&
app
.
show_simulation
);
ImGui
::
MenuItem
(
"Plot"
,
nullptr
,
&
app
.
show_plot
);
ImGui
::
MenuItem
(
"Sources"
,
nullptr
,
&
app
.
show_sources
);
ImGui
::
MenuItem
(
"Settings"
,
nullptr
,
&
app
.
show_settings
);
ImGui
::
MenuItem
(
"Log"
,
nullptr
,
&
app
.
show_log
);
...
...
@@ -3037,6 +3038,9 @@ application_show()
if
(
app
.
show_demo
)
ImGui
::
ShowDemoWindow
();
if
(
app
.
show_sources
)
app
.
srcs
.
show
(
&
app
.
show_sources
);
return
ret
;
}
...
...
app/gui/node-editor.hpp
View file @
0264d282
...
...
@@ -6,9 +6,11 @@
#define ORG_VLEPROJECT_IRRITATOR_APP_NODE_EDITOR_2020
#include
<irritator/core.hpp>
#include
<irritator/external_source.hpp>
#include
<filesystem>
#include
<fstream>
#include
<map>
#include
<thread>
#include
<variant>
#include
<vector>
...
...
@@ -295,6 +297,22 @@ using observation_output = std::variant<std::monostate,
file_output_id
,
file_discrete_output_id
>
;
struct
sources
{
std
::
map
<
int
,
irt
::
source
::
constant
>
csts
;
std
::
map
<
int
,
irt
::
source
::
binary_file
>
bins
;
std
::
map
<
int
,
irt
::
source
::
text_file
>
texts
;
int
csts_next_id
=
1
;
int
bins_next_id
=
1
;
int
texts_next_id
=
1
;
irt
::
source
::
constant
*
new_constant
()
noexcept
;
irt
::
source
::
binary_file
*
new_binary_file
()
noexcept
;
irt
::
source
::
text_file
*
new_text_file
()
noexcept
;
void
show
(
bool
*
is_show
);
};
struct
editor
{
small_string
<
16
>
name
;
...
...
@@ -358,9 +376,8 @@ struct editor
void
observation_outputs_free
(
const
u32
index
)
noexcept
{
observation_dispatch
(
index
,
[](
auto
&
outs
,
auto
out_id
)
{
outs
.
free
(
out_id
);
});
observation_dispatch
(
index
,
[](
auto
&
outs
,
auto
out_id
)
{
outs
.
free
(
out_id
);
});
observation_outputs
[
index
]
=
std
::
monostate
{};
}
...
...
@@ -516,11 +533,14 @@ struct application
void
show
(
bool
*
is_open
);
}
settings
;
sources
srcs
;
bool
show_log
=
true
;
bool
show_simulation
=
true
;
bool
show_demo
=
false
;
bool
show_plot
=
true
;
bool
show_settings
=
false
;
bool
show_sources
=
false
;
editor
*
alloc_editor
();
void
free_editor
(
editor
&
ed
);
...
...
app/gui/sources.cpp
0 → 100644
View file @
0264d282
This diff is collapsed.
Click to expand it.
lib/include/irritator/core.hpp
View file @
0264d282
...
...
@@ -4606,6 +4606,7 @@ struct external_source
sz
index
=
0
;
// of data and size.
sz
size
=
0
;
u64
id
=
0
;
u32
type
=
0
;
function_ref
<
bool
(
external_source
&
src
)
>
expand
;
...
...
lib/include/irritator/external_source.hpp
View file @
0264d282
...
...
@@ -8,13 +8,26 @@
#include
<irritator/core.hpp>
#include
<array>
#include
<filesystem>
#include
<fstream>
namespace
irt
::
source
{
struct
constant
{
double
value
;
bool
operator
()(
external_source
&
src
)
{
src
.
index
=
0
;
return
true
;
}
};
struct
binary_file
{
std
::
array
<
char
,
1024
*
1024
>
buffer
;
std
::
filesystem
::
path
file_path
;
std
::
ifstream
ifs
;
sz
buffer_size
=
0
;
bool
use_rewind
=
false
;
...
...
@@ -23,6 +36,13 @@ struct binary_file
bool
init
(
external_source
&
src
)
{
if
(
!
ifs
)
{
ifs
.
open
(
file_path
);
if
(
!
ifs
)
return
false
;
}
if
(
!
read
(
src
))
return
false
;
}
...
...
@@ -61,6 +81,7 @@ private:
struct
text_file
{
std
::
array
<
double
,
1024
*
1024
/
8
>
buffer
;
std
::
filesystem
::
path
file_path
;
std
::
ifstream
ifs
;
bool
use_rewind
=
false
;
...
...
@@ -68,6 +89,13 @@ struct text_file
bool
init
(
external_source
&
src
)
{
if
(
!
ifs
)
{
ifs
.
open
(
file_path
);
if
(
!
ifs
)
return
false
;
}
if
(
!
read
(
src
))
return
false
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment