Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PI2
PI2 View
Commits
4ab4167b
Commit
4ab4167b
authored
Jan 07, 2019
by
Martin Kröning
🦀
Browse files
Pass window title on MapApp construction
parent
d7e8027f
Changes
9
Hide whitespace changes
Inline
Side-by-side
pi2-demo/include/Map.hpp
View file @
4ab4167b
...
...
@@ -10,7 +10,7 @@ class Junction;
class
Map
{
public:
explicit
Map
(
std
::
istream
&
is
);
Map
(
std
::
istream
&
is
,
const
std
::
string
&
windowTitle
);
void
simulate
(
std
::
chrono
::
seconds
duration
,
double
speedFactor
,
double
frequency
);
...
...
pi2-demo/include/MapAppABIWrapper.hpp
View file @
4ab4167b
...
...
@@ -7,7 +7,7 @@ struct MapApp;
class
MapAppABIWrapper
{
public:
MapAppABIWrapper
();
MapAppABIWrapper
(
const
std
::
string
&
windowTitle
);
virtual
~
MapAppABIWrapper
();
void
addJunction
(
double
x
,
double
y
);
void
addRoad
(
const
std
::
string
&
laneThereName
,
...
...
pi2-demo/src/Map.cpp
View file @
4ab4167b
...
...
@@ -14,7 +14,8 @@
#include <utility>
#include <vector>
Map
::
Map
(
std
::
istream
&
is
)
:
time
(
0
)
{
Map
::
Map
(
std
::
istream
&
is
,
const
std
::
string
&
windowTitle
)
:
time
(
0
),
mapApp
(
windowTitle
)
{
std
::
string
type
;
while
(
is
>>
type
)
{
if
(
type
==
"KREUZUNG"
)
{
...
...
pi2-demo/src/MapAppABIWrapper.cpp
View file @
4ab4167b
...
...
@@ -3,7 +3,8 @@
#include <string>
#include <vector>
MapAppABIWrapper
::
MapAppABIWrapper
()
:
mapApp
(
mapAppCreate
())
{}
MapAppABIWrapper
::
MapAppABIWrapper
(
const
std
::
string
&
windowTitle
)
:
mapApp
(
mapAppCreate
(
windowTitle
.
c_str
()))
{}
MapAppABIWrapper
::~
MapAppABIWrapper
()
{
mapAppDestroy
(
mapApp
);
...
...
pi2-demo/src/main.cpp
View file @
4ab4167b
...
...
@@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
std
::
string
durationString
;
double
timescale
;
double
refreshRate
;
std
::
string
file
name
;
std
::
string
nativePath
name
;
po
::
options_description
visibleOptions
(
"Allowed options"
);
visibleOptions
.
add_options
()(
...
...
@@ -27,8 +27,8 @@ int main(int argc, char *argv[]) {
"help"
,
"display this help and exit"
);
po
::
options_description
hiddenOptions
(
"Hidden options"
);
hiddenOptions
.
add_options
()(
"input-file"
,
po
::
value
<
std
::
string
>
(
&
filename
),
"input file"
);
hiddenOptions
.
add_options
()(
"input-file"
,
po
::
value
<
std
::
string
>
(
&
nativePathname
),
"input file"
);
po
::
options_description
allOptions
;
allOptions
.
add
(
visibleOptions
).
add
(
hiddenOptions
);
...
...
@@ -53,9 +53,9 @@ int main(int argc, char *argv[]) {
}
if
(
variablesMap
.
count
(
"input-file"
)
>
0
)
{
std
::
ifstream
istrm
(
file
name
);
std
::
ifstream
istrm
(
nativePath
name
);
if
(
istrm
.
is_open
())
{
Map
map
(
istrm
);
Map
map
(
istrm
,
"pi2-demo - "
+
nativePathname
);
std
::
istringstream
buffer
(
durationString
);
int
hours
;
...
...
@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
map
.
simulate
(
duration
,
timescale
,
refreshRate
);
std
::
cout
<<
"Simulation done!"
<<
std
::
endl
;
}
else
{
std
::
cout
<<
"Failed to open "
<<
file
name
<<
std
::
endl
;
std
::
cout
<<
"Failed to open "
<<
nativePath
name
<<
std
::
endl
;
return
1
;
}
}
else
{
...
...
pi2-view/include/MapApp.hpp
View file @
4ab4167b
...
...
@@ -22,7 +22,7 @@ class ListBoxRow;
class
MapApp
{
public:
MapApp
();
MapApp
(
std
::
string
windowTitle
);
virtual
~
MapApp
();
void
addJunction
(
double
x
,
double
y
);
void
addRoad
(
std
::
string
laneThereName
,
std
::
string
laneBackName
,
...
...
pi2-view/include/MapAppABI.h
View file @
4ab4167b
...
...
@@ -15,7 +15,7 @@ struct MapApp;
/// You *have* to call mapAppDestroy(MapApp *) to avoid memory leaks.
///
/// \returns A pointer to the created MapApp
MapApp
*
mapAppCreate
();
MapApp
*
mapAppCreate
(
const
char
*
windowTitle
);
/// Destroys \p mapApp and frees its memory.
void
mapAppDestroy
(
MapApp
*
mapApp
);
...
...
pi2-view/src/MapApp.cpp
View file @
4ab4167b
...
...
@@ -28,13 +28,13 @@
const
std
::
vector
<
std
::
string
>
MapApp
::
zoomLevels
=
{
"60%"
,
"80%"
,
"100%"
};
MapApp
::
MapApp
()
MapApp
::
MapApp
(
std
::
string
windowTitle
)
:
app
(
Gtk
::
Application
::
create
()),
mapArea
(
junctions
,
roads
,
nameVehicleMap
),
listBox
(
nullptr
),
durationLabel
(
nullptr
),
laneLabel
(
nullptr
),
lanePositionPercentageLabel
(
nullptr
),
speedLabel
(
nullptr
),
remainingFuelLabel
(
nullptr
),
zoomComboBoxText
(
nullptr
)
{
win
.
set_title
(
"pi2-demo"
);
win
.
set_title
(
std
::
move
(
windowTitle
)
);
auto
builder
=
Gtk
::
Builder
::
create_from_resource
(
"/pi2-view/pi2-view.glade"
,
"box"
);
...
...
pi2-view/src/MapAppABI.cpp
View file @
4ab4167b
...
...
@@ -11,7 +11,9 @@
#include <valarray>
#include <vector>
gsl
::
owner
<
MapApp
*>
mapAppCreate
()
{
return
new
MapApp
();
}
gsl
::
owner
<
MapApp
*>
mapAppCreate
(
gsl
::
czstring
<>
windowTitle
)
{
return
new
MapApp
(
windowTitle
);
}
void
mapAppDestroy
(
gsl
::
owner
<
MapApp
*>
mapApp
)
{
delete
mapApp
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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