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
03e92a41
Commit
03e92a41
authored
Mar 05, 2009
by
Pascal Noisette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retour ligne
parent
d68ea3f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
15 deletions
+63
-15
src/interface/render_svg.cpp
src/interface/render_svg.cpp
+1
-1
src/interface/render_svg.hpp
src/interface/render_svg.hpp
+60
-12
tests/interface/test_svg.cpp
tests/interface/test_svg.cpp
+2
-2
No files found.
src/interface/render_svg.cpp
View file @
03e92a41
...
...
@@ -42,7 +42,7 @@ void Svg::init(const char *path){
<<
"
\t\t\t
}
\n
"
<<
"
\t\t
path
\n
"
<<
"
\t\t\t
{
\n
"
<<
"
\t\t\t\t
fill:
green;stroke:black
;stroke-width:1
\n
"
<<
"
\t\t\t\t
fill:
none;stroke:green
;stroke-width:1
\n
"
<<
"
\t\t\t
}
\n
"
<<
"
\t
</style>
\n
"
<<
"
\t
<desc>Rectangles</desc>
\n
"
;
...
...
src/interface/render_svg.hpp
View file @
03e92a41
...
...
@@ -11,15 +11,14 @@
#define MARGIN 10 //distance between two object
#define ARROWSIZE 4 //spike size
#define WAIT_NEW_CHRONO 0
#define INIT 1
#define WAIT_FOR_POINT 2
#include "render.hpp"
#include "resource.hpp"
/*typedef unsigned long Element_count ;
typedef double Element_pos;
typedef unsigned char Element_col;
*/
class
Svg
:
public
Render
{
...
...
@@ -27,11 +26,12 @@ class Svg : public Render{
private:
std
::
ostringstream
_buffer
;
std
::
ostringstream
_chronogramme
;
int
_chronogramme_state
;
std
::
ofstream
_svg_file
;
inline
void
print
();
inline
void
rectangle
(
const
char
*
name
,
unsigned
long
w
,
unsigned
long
h
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
);
inline
void
line
(
const
char
*
name
,
long
unsigned
int
x1
,
long
unsigned
int
y1
,
long
unsigned
int
x2
,
long
unsigned
int
y2
);
inline
void
triangle
(
const
char
*
name
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
,
unsigned
long
x3
,
unsigned
long
y3
);
inline
void
rectangle
(
const
char
*
name
,
Element_pos
w
,
Element_pos
h
,
Element_pos
x1
,
Element_pos
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
);
inline
void
line
(
const
char
*
name
,
Element_pos
x1
,
Element_pos
y1
,
Element_pos
x2
,
Element_pos
y2
);
inline
void
triangle
(
const
char
*
name
,
Element_pos
x1
,
Element_pos
y1
,
Element_pos
x2
,
Element_pos
y2
,
Element_pos
x3
,
Element_pos
y3
);
public:
/*!
* \brief SVG header buiding
...
...
@@ -111,6 +111,7 @@ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, c
}
inline
void
Svg
::
start_draw_containers
(){
}
inline
void
Svg
::
end_draw_containers
(){
...
...
@@ -128,12 +129,59 @@ inline void Svg::end_draw_states(){
*******************/
inline
void
Svg
::
start_draw_counter
(){
_chronogramme_state
=
INIT
;
}
inline
void
Svg
::
draw_counter
(
const
Element_pos
x
,
const
Element_pos
y
){
if
(
_chronogramme_state
==
INIT
)
{
if
(
x
==
0
)
{
_chronogramme
<<
"
\n
<path d='M0 "
<<
y
;
_chronogramme_state
=
WAIT_FOR_POINT
;
}
else
std
::
cerr
<<
"draw_counter not initialised"
;
}
else
if
(
_chronogramme_state
==
WAIT_FOR_POINT
)
{
if
(
x
==
0
)
{
_chronogramme
<<
"'/>"
;
_svg_file
.
write
(
_chronogramme
.
str
().
c_str
(),
_chronogramme
.
str
().
size
());
_chronogramme
.
str
(
""
);
_chronogramme_state
=
WAIT_NEW_CHRONO
;
}
else
{
_chronogramme
<<
" L"
<<
x
<<
" "
<<
y
;
}
}
else
if
(
_chronogramme_state
==
WAIT_NEW_CHRONO
)
{
if
(
x
==
0
)
{
_chronogramme
<<
"
\n
<path d='M0 "
<<
y
;
_chronogramme_state
=
WAIT_FOR_POINT
;
}
else
std
::
cerr
<<
"draw_counter not initialised"
;
}
}
inline
void
Svg
::
end_draw_counter
(){
if
(
_chronogramme_state
!=
WAIT_NEW_CHRONO
)
std
::
cerr
<<
"draw_counter not un-initialised"
;
}
...
...
@@ -141,13 +189,13 @@ inline void Svg::end_draw(){
Svg
::
end
();
}
void
Svg
::
rectangle
(
const
char
*
name
,
unsigned
long
w
,
unsigned
long
h
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
){
void
Svg
::
rectangle
(
const
char
*
name
,
Element_pos
w
,
Element_pos
h
,
Element_pos
x1
,
Element_pos
y1
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
){
_buffer
<<
"
\n
<rect title='"
<<
name
<<
"' width='"
<<
w
<<
"' height='"
<<
h
<<
"' x='"
<<
x1
<<
"' y='"
<<
y1
<<
"' fill='rgb("
<<
r
<<
","
<<
g
<<
","
<<
b
<<
")'/>"
<<
std
::
endl
;
<<
")'/>"
;
print
();
}
...
...
@@ -155,12 +203,12 @@ void Svg::rectangle(const char* name,unsigned long w, unsigned long h,unsigned l
void
Svg
::
triangle
(
const
char
*
name
,
unsigned
long
x1
,
unsigned
long
y1
,
unsigned
long
x2
,
unsigned
long
y2
,
unsigned
long
x3
,
unsigned
long
y3
){
void
Svg
::
triangle
(
const
char
*
name
,
Element_pos
x1
,
Element_pos
y1
,
Element_pos
x2
,
Element_pos
y2
,
Element_pos
x3
,
Element_pos
y3
){
_buffer
<<
"
\n
<polyline title='"
<<
name
<<
"' class='triangle' points='"
<<
x1
<<
","
<<
y1
<<
" "
<<
x2
<<
","
<<
y2
<<
" "
<<
x3
<<
","
<<
y3
<<
"' />"
<<
std
::
endl
;
<<
"' />"
;
print
();
}
...
...
@@ -173,7 +221,7 @@ void Svg::print(){
inline
void
Svg
::
line
(
const
char
*
name
,
long
unsigned
int
x1
,
long
unsigned
int
y1
,
long
unsigned
int
x2
,
long
unsigned
int
y2
){
inline
void
Svg
::
line
(
const
char
*
name
,
Element_pos
x1
,
Element_pos
y1
,
Element_pos
x2
,
Element_pos
y2
){
_buffer
<<
"
\n
<line title='"
<<
name
<<
"' x1='"
<<
x1
<<
"' y1='"
<<
y1
<<
"' x2='"
<<
x2
...
...
tests/interface/test_svg.cpp
View file @
03e92a41
...
...
@@ -13,9 +13,9 @@ int main()
s
.
draw_container
(
0
,
LEVEL
*
2
,
50
,
100
);
s
.
draw_container
(
0
,
LEVEL
*
3
,
50
,
100
);
s
.
draw_state
(
100
,
750
,
1
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
100
,
750
.87
,
1
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
400
,
750
,
2
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
70
,
300
,
3
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
70
.756
,
300
,
3
,
NULL
,
0xff
,
0xcc
,
33
);
s
.
draw_arrow
(
100
,
700
,
LEVEL
*
1
,
LEVEL
*
3
);
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