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
b22ce8f8
Commit
b22ce8f8
authored
Feb 26, 2009
by
Pascal Noisette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a pretty arrow
parent
2a729774
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
13 deletions
+92
-13
interface/src/render_svg.cpp
interface/src/render_svg.cpp
+72
-8
interface/src/render_svg.hpp
interface/src/render_svg.hpp
+18
-5
interface/test/test_svg.cpp
interface/test/test_svg.cpp
+2
-0
No files found.
interface/src/render_svg.cpp
View file @
b22ce8f8
...
@@ -6,14 +6,39 @@ using namespace std;
...
@@ -6,14 +6,39 @@ using namespace std;
void
Svg
::
rectangle
(){
void
Svg
::
rectangle
(){
_buffer
<<
"<rect title='container' width='"
<<
_w
_buffer
<<
"<rect title='container' width='"
<<
_w
<<
"' height='"
<<
_h
<<
"' height='"
<<
_h
<<
"' x='"
<<
_x
<<
"' x='"
<<
_x
1
<<
"' y='"
<<
_y
<<
"' y='"
<<
_y
1
<<
"' fill='rgb("
<<
_r
<<
","
<<
_g
<<
","
<<
_b
<<
"' fill='rgb("
<<
_r
<<
","
<<
_g
<<
","
<<
_b
<<
")'/>"
;
<<
")'/>"
;
print
();
print
();
}
}
void
Svg
::
line
(){
_buffer
<<
"<line title='line' x1='"
<<
_x1
<<
"' y1='"
<<
_y1
<<
"' x2='"
<<
_x2
<<
"' y2='"
<<
_y2
<<
"' />"
;
print
();
}
void
Svg
::
triangle
(){
_buffer
<<
"<polyline title='triangle' class='triangle' points='"
<<
_x1
<<
","
<<
_y1
<<
" "
<<
_x2
<<
","
<<
_y2
<<
" "
<<
_x3
<<
","
<<
_y3
<<
"' />"
;
print
();
}
void
Svg
::
print
(){
void
Svg
::
print
(){
if
(
_buffer
.
str
().
size
()
>
BUFFER_SIZE
){
if
(
_buffer
.
str
().
size
()
>
BUFFER_SIZE
){
...
@@ -31,7 +56,25 @@ void Svg::init(const char *path){
...
@@ -31,7 +56,25 @@ void Svg::init(const char *path){
if
(
_svg_file
.
is_open
()
==
false
){
if
(
_svg_file
.
is_open
()
==
false
){
std
::
cerr
<<
"unable to open file"
;
std
::
cerr
<<
"unable to open file"
;
}
}
_buffer
<<
"<?xml version='1.0' encoding='utf-8' standalone='no'?>
\n
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
\n
<svg xmlns='http://www.w3.org/2000/svg' x='0' y='0' width='1280' height='728' id='svg2'>
\n\t
<style type='text/css' id='stylecss' >
\n\t\t
rect:hover
\n\t\t\t
{
\n\t\t\t\t
fill:#8fbbd0;
\n\t\t\t
}
\n\t
</style>
\n\t
<desc>Rectangles</desc>
\n
"
;
_buffer
<<
"<?xml version='1.0' encoding='utf-8' standalone='no'?>
\n
"
<<
"<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
\n
"
<<
"<svg xmlns='http://www.w3.org/2000/svg' x='0' y='0' width='1280' height='728' id='svg2'>
\n
"
<<
"
\t
<style type='text/css' id='stylecss' >
\n
"
<<
"
\t\t
rect:hover
\n
"
<<
"
\t\t\t
{
\n
"
<<
"
\t\t\t\t
fill:#8fbbd0;
\n
"
<<
"
\t\t\t
}
\n
"
<<
"
\t\t
line
\n
"
<<
"
\t\t\t
{
\n
"
<<
"
\t\t\t\t
fill:white;stroke:black;stroke-width:1
\n
"
<<
"
\t\t\t
}
\n
"
<<
"
\t\t
#triangle
\n
"
<<
"
\t\t\t
{
\n
"
<<
"
\t\t\t\t
fill:black;stroke:black;stroke-width:1
\n
"
<<
"
\t\t\t
}
\n
"
<<
"
\t
</style>
\n
"
<<
"
\t
<desc>Rectangles</desc>
\n
"
;
print
();
print
();
}
}
...
@@ -49,20 +92,41 @@ void Svg::draw_container(const Element_pos x, const Element_pos y, const Element
...
@@ -49,20 +92,41 @@ void Svg::draw_container(const Element_pos x, const Element_pos y, const Element
_b
=
0xcc
;
_b
=
0xcc
;
_w
=
(
unsigned
long
)
w
;
_w
=
(
unsigned
long
)
w
;
_h
=
(
unsigned
long
)
h
;
_h
=
(
unsigned
long
)
h
;
_x
=
(
unsigned
long
)
x
;
_x
1
=
(
unsigned
long
)
x
;
_y
=
(
unsigned
long
)
y
;
_y
1
=
(
unsigned
long
)
y
;
rectangle
();
rectangle
();
}
}
void
Svg
::
draw_arrow
(
const
Element_pos
start_time
,
const
Element_pos
end_time
,
const
Element_pos
start_height
,
const
Element_pos
end_height
){
_x1
=
(
unsigned
long
)
start_time
;
_x2
=
(
unsigned
long
)
end_time
;
_y1
=
(
unsigned
long
)
start_height
;
_y2
=
(
unsigned
long
)
end_height
;
line
();
_x1
=
(
unsigned
long
)
end_time
;
_x2
=
(
unsigned
long
)
end_time
;
_x3
=
(
unsigned
long
)
end_time
+
ARROWSIZE
;
_y1
=
(
unsigned
long
)
end_height
+
ARROWSIZE
;
_y2
=
(
unsigned
long
)
end_height
-
ARROWSIZE
;
_y3
=
(
unsigned
long
)
end_height
;
triangle
();
//spike
}
void
Svg
::
draw_state
(
const
Element_pos
start
,
const
Element_pos
end
,
const
Element_count
level
,
const
Element_col
r
,
const
Element_col
g
,
const
Element_col
b
){
void
Svg
::
draw_state
(
const
Element_pos
start
,
const
Element_pos
end
,
const
Element_count
level
,
const
Element_col
r
,
const
Element_col
g
,
const
Element_col
b
){
_r
=
(
unsigned
char
)
r
;
_r
=
(
unsigned
char
)
r
;
_g
=
(
unsigned
char
)
g
;
_g
=
(
unsigned
char
)
g
;
_b
=
(
unsigned
char
)
b
;
_b
=
(
unsigned
char
)
b
;
_w
=
(
unsigned
long
)(
end
-
start
);
_w
=
(
unsigned
long
)(
end
-
start
);
_h
=
(
unsigned
long
)
LEVEL
-
10
;
_h
=
(
unsigned
long
)
LEVEL
-
MARGIN
;
_x
=
(
unsigned
long
)
start
;
_x
1
=
(
unsigned
long
)
start
;
_y
=
(
unsigned
long
)
level
*
LEVEL
;
_y
1
=
(
unsigned
long
)
level
*
LEVEL
;
rectangle
();
rectangle
();
}
}
interface/src/render_svg.hpp
View file @
b22ce8f8
...
@@ -2,17 +2,18 @@
...
@@ -2,17 +2,18 @@
#define RENDER_SVG
#define RENDER_SVG
#include <stdio.h>
#include <iostream>
#include <iostream>
#include <sstream>
#include <sstream>
#include <fstream>
#include <fstream>
#define BUFFER_SIZE 2048 //character number stored before flush the _buffer
#define BUFFER_SIZE 2048 //character number stored before flush the _buffer
#define LEVEL 110 //distance between two containers
#define LEVEL 110 //distance between two containers
#define MARGIN 10 //distance between two object
#define ARROWSIZE 4 //spike size
typedef
unsigned
long
Element_count
;
typedef
unsigned
long
Element_count
;
typedef
double
Element_pos
;
typedef
double
Element_pos
;
typedef
unsigned
int
Element_col
;
typedef
unsigned
char
Element_col
;
class
Svg
{
class
Svg
{
...
@@ -20,11 +21,16 @@ class Svg{
...
@@ -20,11 +21,16 @@ class Svg{
private:
private:
std
::
ostringstream
_buffer
;
std
::
ostringstream
_buffer
;
std
::
string
_object_class
;
std
::
ofstream
_svg_file
;
std
::
ofstream
_svg_file
;
unsigned
int
_r
,
_g
,
_b
;
unsigned
int
_r
,
_g
,
_b
;
// 0 < _r,_g,_b < 255 and displayed as int
unsigned
long
_x
,
_y
,
_w
,
_h
;
unsigned
long
_w
,
_h
;
void
print
();
unsigned
long
_x1
,
_y1
,
_x2
,
_y2
,
_x3
,
_y3
;
inline
void
print
();
inline
void
rectangle
();
inline
void
rectangle
();
inline
void
line
();
inline
void
triangle
();
public:
public:
/*!
/*!
* \brief SVG header buiding
* \brief SVG header buiding
...
@@ -56,6 +62,13 @@ public:
...
@@ -56,6 +62,13 @@ public:
* \param level refer to the container which state belongs to.
* \param level refer to the container which state belongs to.
*/
*/
void
draw_state
(
const
Element_pos
start
,
const
Element_pos
end
,
const
Element_count
level
,
const
Element_col
r
,
const
Element_col
g
,
const
Element_col
b
)
;
void
draw_state
(
const
Element_pos
start
,
const
Element_pos
end
,
const
Element_count
level
,
const
Element_col
r
,
const
Element_col
g
,
const
Element_col
b
)
;
/*!
* \brief Draw an arrow
*
*/
void
draw_arrow
(
const
Element_pos
start_time
,
const
Element_pos
end_time
,
const
Element_pos
start_height
,
const
Element_pos
end_height
);
};
};
#endif // RENDER_SVG
#endif // RENDER_SVG
interface/test/test_svg.cpp
View file @
b22ce8f8
...
@@ -17,6 +17,8 @@ int main()
...
@@ -17,6 +17,8 @@ int main()
s
.
draw_state
(
400
,
750
,
2
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
400
,
750
,
2
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
70
,
300
,
3
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
70
,
300
,
3
,
0xff
,
0xcc
,
33
);
s
.
draw_arrow
(
100
,
700
,
LEVEL
*
1
,
LEVEL
*
3
);
s
.
draw_arrow
(
200
,
400
,
LEVEL
*
2
,
LEVEL
*
2
);
s
.
end
();
s
.
end
();
return
0
;
return
0
;
...
...
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