Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
vite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
vite
Commits
498a277c
Commit
498a277c
authored
16 years ago
by
Pascal Noisette
Browse files
Options
Downloads
Patches
Plain Diff
a voir avec firefox...
parent
2d1320b5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
interface/src/render_svg.cpp
+37
-18
37 additions, 18 deletions
interface/src/render_svg.cpp
interface/src/render_svg.hpp
+14
-10
14 additions, 10 deletions
interface/src/render_svg.hpp
interface/tests/test_svg.cpp
+11
-5
11 additions, 5 deletions
interface/tests/test_svg.cpp
with
62 additions
and
33 deletions
interface/src/render_svg.cpp
+
37
−
18
View file @
498a277c
...
@@ -4,42 +4,60 @@
...
@@ -4,42 +4,60 @@
void
Svg
::
rectangle
()
void
Svg
::
rectangle
()
{
{
sprintf
(
_conteneur
,
"<rect title='container' width='%ld' height='%ld' x='%ld' y='%ld' fill='rgb(%d,%d,%d)' />"
,
_w
,
_h
,
_x
,
_y
,
_r
,
_g
,
_b
);
_buffer
<<
"<rect title='container' width='"
<<
_w
afficher
(
_conteneur
);
<<
"' height='"
<<
_h
<<
"' x='"
<<
_x
<<
"' y='"
<<
_y
<<
"' fill='rgb("
<<
_r
<<
","
<<
_g
<<
","
<<
_b
<<
")'/>"
;
afficher
();
}
}
void
Svg
::
afficher
(
char
*
s
)
void
Svg
::
afficher
()
{
{
printf
(
s
);
if
(
_buffer
.
str
().
size
()
>
BUFFER_SIZE
){
svg_file
.
write
(
_buffer
.
str
().
c_str
(),
_buffer
.
str
().
size
());
_buffer
.
flush
();
}
}
}
void
Svg
::
init
()
void
Svg
::
init
(
char
*
path
)
{
{
char
*
entete
=
"<?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
"
;
afficher
(
entete
);
}
svg_file
.
open
(
path
,
ofstream
::
out
|
ofstream
::
trunc
);
if
(
svg_file
.
is_open
()
==
false
){
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
"
;
afficher
();
}
void
Svg
::
end
()
void
Svg
::
end
()
{
{
char
*
end_of_document
=
"</svg>"
;
_buffer
<<
"</svg>"
;
afficher
(
end_of_document
);
svg_file
.
write
(
_buffer
.
str
().
c_str
(),
_buffer
.
str
().
size
());
_buffer
.
flush
();
svg_file
.
close
();
}
}
void
Svg
::
draw_container
(
const
Element_pos
x
,
const
Element_pos
y
,
const
Element_pos
w
,
const
Element_pos
h
)
void
Svg
::
draw_container
(
const
Element_pos
x
,
const
Element_pos
y
,
const
Element_pos
w
,
const
Element_pos
h
)
{
{
_r
=
47
;
_g
=
54
;
_b
=
153
;
_r
=
0xff
;
_g
=
0x44
;
_b
=
0xcc
;
_w
=
(
unsigned
long
)
w
;
_w
=
(
unsigned
long
)
w
;
_h
=
(
unsigned
long
)
h
;
_h
=
(
unsigned
long
)
h
;
_x
=
(
unsigned
long
)
x
;
_x
=
(
unsigned
long
)
x
;
_y
=
(
unsigned
long
)
y
;
_y
=
(
unsigned
long
)
y
;
rectangle
();
rectangle
();
}
}
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
)
{
{
...
@@ -48,10 +66,11 @@
...
@@ -48,10 +66,11 @@
_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
)
1
0
0
;
_h
=
(
unsigned
long
)
LEVEL
-
10
;
_x
=
(
unsigned
long
)
start
;
_x
=
(
unsigned
long
)
start
;
_y
=
(
unsigned
long
)
50
;
_y
=
(
unsigned
long
)
level
*
LEVEL
;
rectangle
();
rectangle
();
}
}
This diff is collapsed.
Click to expand it.
interface/src/render_svg.hpp
+
14
−
10
View file @
498a277c
#ifndef RENDER_SGV
#ifndef RENDER_SGV
#define RENDER_SVG
#define RENDER_SVG
#include
<stdio.h>
#include
<stdio.h>
#include
<iostream>
#include
<sstream>
#include
<fstream>
#define BUFFER_SIZE 2048
#define LEVEL 110
using
namespace
std
;
typedef
long
Element_count
;
typedef
unsigned
long
Element_count
;
typedef
double
Element_pos
;
typedef
double
Element_pos
;
typedef
double
Element_col
;
typedef
unsigned
int
Element_col
;
class
Svg
{
class
Svg
{
private:
private:
ostringstream
_buffer
;
char
_conteneur
[
2048
]
;
ofstream
svg_file
;
unsigned
char
_r
,
_g
,
_b
;
unsigned
int
_r
,
_g
,
_b
;
unsigned
long
_x
,
_y
,
_w
,
_h
;
unsigned
long
_x
,
_y
,
_w
,
_h
;
void
afficher
();
void
afficher
(
char
*
s
);
void
rectangle
();
void
rectangle
();
public:
public:
/*!
/*!
* \brief SVG header buiding
* \brief SVG header buiding
*/
*/
void
init
();
void
init
(
char
*
path
);
/*!
/*!
* \brief SVG bottom file buiding
* \brief SVG bottom file buiding
...
...
This diff is collapsed.
Click to expand it.
interface/tests/test_svg.cpp
+
11
−
5
View file @
498a277c
#include
<iostream>
#include
"../src/render_svg.hpp"
#include
"../src/render_svg.hpp"
using
namespace
std
;
using
namespace
std
;
...
@@ -7,10 +7,16 @@ int main()
...
@@ -7,10 +7,16 @@ int main()
Svg
s
;
Svg
s
;
s
.
init
();
s
.
init
(
"./out.svg"
);
s
.
draw_container
(
0
,
100
,
100
,
100
);
s
.
draw_state
(
0
,
150
,
0
,
50
,
50
,
50
);
s
.
draw_container
(
0
,
LEVEL
*
1
,
50
,
100
);
s
.
draw_state
(
400
,
750
,
0
,
0xff
,
0xcc
,
33
);
s
.
draw_container
(
0
,
LEVEL
*
2
,
50
,
100
);
s
.
draw_container
(
0
,
LEVEL
*
3
,
50
,
100
);
s
.
draw_state
(
100
,
750
,
1
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
400
,
750
,
2
,
0xff
,
0xcc
,
33
);
s
.
draw_state
(
70
,
300
,
3
,
0xff
,
0xcc
,
33
);
s
.
end
();
s
.
end
();
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment