Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
solverstack
vite
Commits
d70b6dae
Commit
d70b6dae
authored
Mar 04, 2009
by
Pascal Noisette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
makefile test svg
parent
54bb59b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
59 deletions
+75
-59
src/interface/render_svg.cpp
src/interface/render_svg.cpp
+1
-52
src/interface/render_svg.hpp
src/interface/render_svg.hpp
+63
-3
tests/interface/makefile
tests/interface/makefile
+7
-0
tests/interface/test_svg.cpp
tests/interface/test_svg.cpp
+4
-4
No files found.
src/interface/render_svg.cpp
View file @
d70b6dae
...
@@ -2,46 +2,8 @@
...
@@ -2,46 +2,8 @@
using
namespace
std
;
using
namespace
std
;
void
Svg
::
rectangle
(
unsigned
long
w
,
unsigned
long
h
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
){
_buffer
<<
"<rect title='container' width='"
<<
w
<<
"' height='"
<<
h
<<
"' x='"
<<
x1
<<
"' y='"
<<
y1
<<
"' fill='rgb("
<<
r
<<
","
<<
g
<<
","
<<
b
<<
")'/>"
;
print
();
}
void
Svg
::
line
(
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
){
_buffer
<<
"<line title='line' x1='"
<<
x1
<<
"' y1='"
<<
y1
<<
"' x2='"
<<
x2
<<
"' y2='"
<<
y2
<<
"' />"
;
print
();
}
void
Svg
::
triangle
(
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
,
unsigned
long
x3
,
unsigned
long
y3
){
_buffer
<<
"<polyline title='triangle' class='triangle' points='"
<<
x1
<<
","
<<
y1
<<
" "
<<
x2
<<
","
<<
y2
<<
" "
<<
x3
<<
","
<<
y3
<<
"' />"
;
print
();
}
void
Svg
::
print
(){
if
(
_buffer
.
str
().
size
()
>
BUFFER_SIZE
){
_svg_file
.
write
(
_buffer
.
str
().
c_str
(),
_buffer
.
str
().
size
());
_buffer
.
flush
();
}
}
void
Svg
::
init
(
const
char
*
path
){
void
Svg
::
init
(
const
char
*
path
){
_svg_file
.
open
(
path
,
ofstream
::
out
|
ofstream
::
trunc
);
_svg_file
.
open
(
path
,
std
::
ofstream
::
out
|
std
::
ofstream
::
trunc
);
if
(
_svg_file
.
is_open
()
==
false
){
if
(
_svg_file
.
is_open
()
==
false
){
std
::
cerr
<<
"unable to open file"
;
std
::
cerr
<<
"unable to open file"
;
}
}
...
@@ -73,16 +35,3 @@ void Svg::end(){
...
@@ -73,16 +35,3 @@ void Svg::end(){
_buffer
.
flush
();
_buffer
.
flush
();
_svg_file
.
close
();
_svg_file
.
close
();
}
}
void
Svg
::
draw_container
(
const
Element_pos
x
,
const
Element_pos
y
,
const
Element_pos
w
,
const
Element_pos
h
){
rectangle
(
w
,
h
,
x
,
y
,
0xff
,
0x44
,
0xcc
);
}
void
Svg
::
draw_arrow
(
const
Element_pos
start_time
,
const
Element_pos
end_time
,
const
Element_pos
start_height
,
const
Element_pos
end_height
){
line
(
start_time
,
start_height
,
end_time
,
end_height
);
triangle
(
end_time
,
end_height
+
ARROWSIZE
,
end_time
,
end_height
-
ARROWSIZE
,
end_time
+
ARROWSIZE
,
end_height
);
//spike
}
void
Svg
::
draw_state
(
const
Element_pos
start
,
const
Element_pos
end
,
const
Element_pos
level
,
const
Element_pos
height
,
const
Element_col
r
,
const
Element_col
g
,
const
Element_col
b
){
rectangle
(
end
-
start
,
LEVEL
-
MARGIN
,
start
,
level
*
LEVEL
,
r
,
g
,
b
);
}
src/interface/render_svg.hpp
View file @
d70b6dae
...
@@ -29,7 +29,7 @@ private:
...
@@ -29,7 +29,7 @@ private:
std
::
ofstream
_svg_file
;
std
::
ofstream
_svg_file
;
inline
void
print
();
inline
void
print
();
inline
void
rectangle
(
unsigned
long
w
,
unsigned
long
h
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
);
inline
void
rectangle
(
unsigned
long
w
,
unsigned
long
h
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
);
inline
void
line
(
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
);
inline
void
line
(
long
unsigned
int
x1
,
long
unsigned
int
y1
,
long
unsigned
int
x2
,
long
unsigned
int
y2
);
inline
void
triangle
(
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
,
unsigned
long
x3
,
unsigned
long
y3
);
inline
void
triangle
(
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
,
unsigned
long
x3
,
unsigned
long
y3
);
public:
public:
/*!
/*!
...
@@ -80,6 +80,7 @@ public:
...
@@ -80,6 +80,7 @@ public:
void
draw_event
(
const
Element_pos
time
,
const
Element_pos
height
,
const
Element_pos
container_height
);
void
draw_event
(
const
Element_pos
time
,
const
Element_pos
height
,
const
Element_pos
container_height
);
void
end_draw
();
void
end_draw
();
};
};
...
@@ -114,11 +115,70 @@ inline void Svg::start_draw_states(){
...
@@ -114,11 +115,70 @@ inline void Svg::start_draw_states(){
inline
void
Svg
::
end_draw_states
(){
inline
void
Svg
::
end_draw_states
(){
}
}
inline
void
Svg
::
draw_event
(
const
Element_pos
time
,
const
Element_pos
height
,
const
Element_pos
container_height
){
}
inline
void
Svg
::
end_draw
(){
inline
void
Svg
::
end_draw
(){
}
}
void
Svg
::
rectangle
(
unsigned
long
w
,
unsigned
long
h
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
){
_buffer
<<
"<rect title='container' width='"
<<
w
<<
"' height='"
<<
h
<<
"' x='"
<<
x1
<<
"' y='"
<<
y1
<<
"' fill='rgb("
<<
r
<<
","
<<
g
<<
","
<<
b
<<
")'/>"
;
print
();
}
void
Svg
::
triangle
(
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
,
unsigned
long
x3
,
unsigned
long
y3
){
_buffer
<<
"<polyline title='triangle' class='triangle' points='"
<<
x1
<<
","
<<
y1
<<
" "
<<
x2
<<
","
<<
y2
<<
" "
<<
x3
<<
","
<<
y3
<<
"' />"
;
print
();
}
void
Svg
::
print
(){
if
(
_buffer
.
str
().
size
()
>
BUFFER_SIZE
){
_svg_file
.
write
(
_buffer
.
str
().
c_str
(),
_buffer
.
str
().
size
());
_buffer
.
flush
();
}
}
inline
void
Svg
::
line
(
long
unsigned
int
x1
,
long
unsigned
int
y1
,
long
unsigned
int
x2
,
long
unsigned
int
y2
){
_buffer
<<
"<line title='line' x1='"
<<
x1
<<
"' y1='"
<<
y1
<<
"' x2='"
<<
x2
<<
"' y2='"
<<
y2
<<
"' />"
;
print
();
}
inline
void
Svg
::
draw_arrow
(
const
Element_pos
start_time
,
const
Element_pos
end_time
,
const
Element_pos
start_height
,
const
Element_pos
end_height
){
Svg
::
line
(
start_time
,
start_height
,
end_time
,
end_height
);
Svg
::
triangle
(
end_time
,
end_height
+
ARROWSIZE
,
end_time
,
end_height
-
ARROWSIZE
,
end_time
+
ARROWSIZE
,
end_height
);
//spike
}
inline
void
Svg
::
draw_container
(
const
Element_pos
x
,
const
Element_pos
y
,
const
Element_pos
w
,
const
Element_pos
h
){
Svg
::
rectangle
(
w
,
h
,
x
,
y
,
0xff
,
0x44
,
0xcc
);
}
inline
void
Svg
::
draw_state
(
const
Element_pos
start
,
const
Element_pos
end
,
const
Element_pos
level
,
const
Element_pos
height
,
const
Element_col
r
,
const
Element_col
g
,
const
Element_col
b
){
Svg
::
rectangle
(
end
-
start
,
LEVEL
-
MARGIN
,
start
,
level
*
LEVEL
,
r
,
g
,
b
);
}
inline
void
Svg
::
draw_event
(
const
Element_pos
time
,
const
Element_pos
height
,
const
Element_pos
container_height
){
rectangle
(
1
,
container_height
*
LEVEL
,
time
,
container_height
,
0xff
,
0x44
,
0xcc
);
}
#endif // RENDER_SVG
#endif // RENDER_SVG
tests/interface/makefile
0 → 100755
View file @
d70b6dae
test_svg.o
:
test_svg.cpp
render_svg.o
:
../../src/interface/render_svg.cpp ../../src/interface/render_svg.hpp
g++
-g
-c
-Wall
../../src/interface/render_svg.cpp
-o
render_svg.o
test_svg
:
render_svg.o test_svg.o
g++
-g
-o
test_svg render_svg.o test_svg.o
\ No newline at end of file
tests/interface/test_svg.cpp
View file @
d70b6dae
#include "../
src
/render_svg.hpp"
#include "../
../src/interface
/render_svg.hpp"
using
namespace
std
;
using
namespace
std
;
int
main
()
int
main
()
...
@@ -13,9 +13,9 @@ int main()
...
@@ -13,9 +13,9 @@ int main()
s
.
draw_container
(
0
,
LEVEL
*
2
,
50
,
100
);
s
.
draw_container
(
0
,
LEVEL
*
2
,
50
,
100
);
s
.
draw_container
(
0
,
LEVEL
*
3
,
50
,
100
);
s
.
draw_container
(
0
,
LEVEL
*
3
,
50
,
100
);
s
.
draw_state
(
100
,
750
,
1
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
100
,
750
,
1
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
400
,
750
,
2
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
400
,
750
,
2
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
70
,
300
,
3
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
70
,
300
,
3
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_arrow
(
100
,
700
,
LEVEL
*
1
,
LEVEL
*
3
);
s
.
draw_arrow
(
100
,
700
,
LEVEL
*
1
,
LEVEL
*
3
);
s
.
draw_arrow
(
200
,
400
,
LEVEL
*
2
,
LEVEL
*
2
);
s
.
draw_arrow
(
200
,
400
,
LEVEL
*
2
,
LEVEL
*
2
);
...
...
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