Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
ba4acffd
Commit
ba4acffd
authored
13 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
basic 2D Log10 graphs
parent
00aa7781
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Graphics/drawGraph2d.cpp
+59
-46
59 additions, 46 deletions
Graphics/drawGraph2d.cpp
with
59 additions
and
46 deletions
Graphics/drawGraph2d.cpp
+
59
−
46
View file @
ba4acffd
...
@@ -153,6 +153,12 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
...
@@ -153,6 +153,12 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
xmin
=
data
->
getTime
(
0
);
xmin
=
data
->
getTime
(
0
);
xmax
=
data
->
getTime
(
data
->
getNumTimeSteps
()
-
1
);
xmax
=
data
->
getTime
(
data
->
getNumTimeSteps
()
-
1
);
}
}
if
(
opt
->
scaleType
==
PViewOptions
::
Logarithmic
)
for
(
unsigned
int
i
=
0
;
i
<
y
.
size
();
i
++
)
for
(
unsigned
int
j
=
0
;
j
<
y
[
i
].
size
();
j
++
)
y
[
i
][
j
]
=
log10
(
y
[
i
][
j
]);
return
true
;
return
true
;
}
}
...
@@ -164,8 +170,6 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
...
@@ -164,8 +170,6 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
if
(
!
opt
->
axes
)
return
;
if
(
!
opt
->
axes
)
return
;
char
label
[
1024
];
// total font height
// total font height
double
font_h
=
drawContext
::
global
()
->
getStringHeight
()
?
double
font_h
=
drawContext
::
global
()
->
getStringHeight
()
?
drawContext
::
global
()
->
getStringHeight
()
:
1
;
drawContext
::
global
()
->
getStringHeight
()
:
1
;
...
@@ -196,29 +200,30 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
...
@@ -196,29 +200,30 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
glEnd
();
glEnd
();
// y label
// y label
std
::
string
label
=
data
->
getName
();
if
(
opt
->
type
==
PViewOptions
::
Plot2D
||
if
(
opt
->
type
==
PViewOptions
::
Plot2D
||
opt
->
type
==
PViewOptions
::
Plot2DSpace
){
opt
->
type
==
PViewOptions
::
Plot2DSpace
){
int
nt
=
data
->
getNumTimeSteps
();
int
nt
=
data
->
getNumTimeSteps
();
if
((
opt
->
showTime
==
1
&&
nt
>
1
)
||
opt
->
showTime
==
2
){
if
((
opt
->
showTime
==
1
&&
nt
>
1
)
||
opt
->
showTime
==
2
){
char
tmp
[
256
];
char
tmp
[
256
];
sprintf
(
tmp
,
opt
->
format
.
c_str
(),
data
->
getTime
(
opt
->
timeStep
));
sprintf
(
tmp
,
opt
->
format
.
c_str
(),
data
->
getTime
(
opt
->
timeStep
));
sprintf
(
label
,
"%s (%s)"
,
data
->
getName
().
c_str
(),
tmp
)
;
label
+=
std
::
string
(
" ("
)
+
tmp
+
")"
;
}
}
else
if
((
opt
->
showTime
==
3
&&
nt
>
1
)
||
opt
->
showTime
==
4
){
else
if
((
opt
->
showTime
==
3
&&
nt
>
1
)
||
opt
->
showTime
==
4
){
sprintf
(
label
,
"%s (%d)"
,
data
->
getName
().
c_str
(),
opt
->
timeStep
);
char
tmp
[
256
];
sprintf
(
tmp
,
"%d"
,
opt
->
timeStep
);
label
+=
std
::
string
(
" ("
)
+
tmp
+
")"
;
}
}
else
sprintf
(
label
,
"%s"
,
data
->
getName
().
c_str
());
}
}
else
if
(
opt
->
scaleType
==
PViewOptions
::
Logarithmic
)
sprintf
(
label
,
"%s"
,
data
->
getName
().
c_str
())
;
label
=
"Log10 "
+
label
;
glRasterPos2d
(
xleft
,
ytop
+
font_h
+
tic
);
glRasterPos2d
(
xleft
,
ytop
+
font_h
+
tic
);
ctx
->
drawStringCenter
(
label
);
ctx
->
drawStringCenter
(
label
.
c_str
()
);
// x label
// x label
sprintf
(
label
,
"%s"
,
opt
->
axesLabel
[
0
]
.
c_str
())
;
label
=
opt
->
axesLabel
[
0
];
glRasterPos2d
(
xleft
+
width
/
2
,
ytop
-
height
-
2
*
font_h
-
2
*
tic
);
glRasterPos2d
(
xleft
+
width
/
2
,
ytop
-
height
-
2
*
font_h
-
2
*
tic
);
ctx
->
drawStringCenter
(
label
);
ctx
->
drawStringCenter
(
label
.
c_str
()
);
// y tics and horizontal grid
// y tics and horizontal grid
if
(
opt
->
nbIso
>
0
){
if
(
opt
->
nbIso
>
0
){
...
@@ -253,10 +258,11 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
...
@@ -253,10 +258,11 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
}
}
}
}
if
(
opt
->
showScale
){
if
(
opt
->
showScale
){
sprintf
(
label
,
opt
->
format
.
c_str
(),
(
i
==
nb
)
?
opt
->
tmpMin
:
char
tmp
[
256
];
sprintf
(
tmp
,
opt
->
format
.
c_str
(),
(
i
==
nb
)
?
opt
->
tmpMin
:
(
opt
->
tmpMax
-
i
*
dv
));
(
opt
->
tmpMax
-
i
*
dv
));
glRasterPos2d
(
xleft
-
2
*
tic
,
ytop
-
i
*
dy
-
font_a
/
3.
);
glRasterPos2d
(
xleft
-
2
*
tic
,
ytop
-
i
*
dy
-
font_a
/
3.
);
ctx
->
drawStringRight
(
label
);
ctx
->
drawStringRight
(
tmp
);
}
}
}
}
}
}
...
@@ -265,9 +271,10 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
...
@@ -265,9 +271,10 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
if
(
opt
->
axesTics
[
0
]
>
0
){
if
(
opt
->
axesTics
[
0
]
>
0
){
int
nb
=
opt
->
axesTics
[
0
];
int
nb
=
opt
->
axesTics
[
0
];
if
(
opt
->
axes
){
if
(
opt
->
axes
){
sprintf
(
label
,
opt
->
axesFormat
[
0
].
c_str
(),
-
M_PI
*
1.e-4
);
char
tmp
[
256
];
if
((
nb
-
1
)
*
drawContext
::
global
()
->
getStringWidth
(
label
)
>
width
)
sprintf
(
tmp
,
opt
->
axesFormat
[
0
].
c_str
(),
-
M_PI
*
1.e-4
);
nb
=
(
int
)(
width
/
drawContext
::
global
()
->
getStringWidth
(
label
))
+
1
;
if
((
nb
-
1
)
*
drawContext
::
global
()
->
getStringWidth
(
tmp
)
>
width
)
nb
=
(
int
)(
width
/
drawContext
::
global
()
->
getStringWidth
(
tmp
))
+
1
;
}
}
if
(
nb
==
1
)
nb
++
;
if
(
nb
==
1
)
nb
++
;
...
@@ -299,13 +306,14 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
...
@@ -299,13 +306,14 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
CTX
::
instance
()
->
print
.
epsLineWidthFactor
));
CTX
::
instance
()
->
print
.
epsLineWidthFactor
));
}
}
char
tmp
[
256
];
if
(
nb
==
1
)
if
(
nb
==
1
)
sprintf
(
label
,
opt
->
axesFormat
[
0
].
c_str
(),
xmin
);
sprintf
(
tmp
,
opt
->
axesFormat
[
0
].
c_str
(),
xmin
);
else
else
sprintf
(
label
,
opt
->
axesFormat
[
0
].
c_str
(),
sprintf
(
tmp
,
opt
->
axesFormat
[
0
].
c_str
(),
xmin
+
i
*
(
xmax
-
xmin
)
/
(
double
)(
nb
-
1
));
xmin
+
i
*
(
xmax
-
xmin
)
/
(
double
)(
nb
-
1
));
glRasterPos2d
(
xleft
+
i
*
dx
,
ybot
-
font_h
-
tic
);
glRasterPos2d
(
xleft
+
i
*
dx
,
ybot
-
font_h
-
tic
);
ctx
->
drawStringCenter
(
label
);
ctx
->
drawStringCenter
(
tmp
);
}
}
}
}
}
}
...
@@ -421,6 +429,11 @@ static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop,
...
@@ -421,6 +429,11 @@ static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop,
opt
->
tmpMax
=
data
->
getMax
();
opt
->
tmpMax
=
data
->
getMax
();
}
}
if
(
opt
->
scaleType
==
PViewOptions
::
Logarithmic
){
opt
->
tmpMin
=
log10
(
opt
->
tmpMin
);
opt
->
tmpMax
=
log10
(
opt
->
tmpMax
);
}
std
::
vector
<
double
>
x
;
std
::
vector
<
double
>
x
;
std
::
vector
<
std
::
vector
<
double
>
>
y
;
std
::
vector
<
std
::
vector
<
double
>
>
y
;
double
xmin
,
xmax
;
double
xmin
,
xmax
;
...
...
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