Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
f2e29e2d
Commit
f2e29e2d
authored
11 years ago
by
Timur Pocheptsov
Browse files
Options
Downloads
Patches
Plain Diff
Comments and custom color names.
parent
2a571071
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tutorials/cocoa/flower.C
+19
-10
19 additions, 10 deletions
tutorials/cocoa/flower.C
with
19 additions
and
10 deletions
tutorials/cocoa/flower.C
+
19
−
10
View file @
f2e29e2d
//Another demo to show transparent lines with TMultiGraph
//Author: Timur Pocheptsov, 4/02/2014
//Another demo to show transparency with TMultiGraph
//(and the really interesting curve/equation). + point compression in
//TPadPainter :))
//You can see all three flowers ONLY with Cococa (transparency).
//The equation by Paul Burke: http://paulbourke.net/geometry/
#include
<cassert>
#include
<vector>
...
...
@@ -21,6 +24,7 @@ namespace {
typedef
std
::
vector
<
Double_t
>
vector_type
;
typedef
vector_type
::
size_type
size_type
;
//______________________________________________________________________
void
create_flower
(
vector_type
&
xs
,
vector_type
&
ys
,
size_type
nPoints
,
Double_t
r
)
{
assert
(
nPoints
>
100
&&
"create_flower, number of points is too small"
);
...
...
@@ -39,16 +43,18 @@ void create_flower(vector_type &xs, vector_type &ys, size_type nPoints, Double_t
}
}
}
}
//unnamed namespace.
void
flower
()
{
//0. Indices for custom colors.
Int_t
indices
[
3
]
=
{};
if
(
ROOT
::
CocoaTutorials
::
FindFreeCustomColorIndices
(
indices
)
!=
3
)
{
Error
(
"flower"
,
"failed to create custom colors"
);
return
;
}
//1. I have to create a canvas to initialize gVirtualX.
TCanvas
*
const
cnv
=
new
TCanvas
(
"Chrysanthemum"
,
"Chrysanthemum"
,
900
,
900
);
if
(
gVirtualX
&&
!
gVirtualX
->
InheritsFrom
(
"TGCocoa"
))
{
Warning
(
"flower"
,
"You can see the transparency ONLY in a pdf or png output (
\"
File
\"
->
\"
Save As
\"
->...)
\n
"
...
...
@@ -57,34 +63,37 @@ void flower()
cnv
->
cd
();
//Just to suppress a warning if compiled.
//
vector_type
xs
,
ys
;
//2. Create graphs and custom colors for each graph.
create_flower
(
xs
,
ys
,
300
,
6
);
TGraph
*
const
gr1
=
new
TGraph
(
Int_t
(
xs
.
size
()),
&
xs
[
0
],
&
ys
[
0
]);
new
TColor
(
indices
[
0
],
0
.,
0
.,
0
.
5
,
"
dark_red
"
,
0
.
7
);
new
TColor
(
indices
[
0
],
0
.,
0
.,
0
.
5
,
"
custom_blue
"
,
0
.
7
);
gr1
->
SetFillColor
(
indices
[
0
]);
gr1
->
SetName
(
"part1"
);
gr1
->
SetTitle
(
"part1"
);
create_flower
(
xs
,
ys
,
500000
,
8
);
TGraph
*
const
gr2
=
new
TGraph
(
Int_t
(
xs
.
size
()),
&
xs
[
0
],
&
ys
[
0
]);
new
TColor
(
indices
[
1
],
0
.
5
,
0
.,
0
.
5
,
"purple"
,
0
.
5
);
new
TColor
(
indices
[
1
],
0
.
5
,
0
.,
0
.
5
,
"
custom_
purple"
,
0
.
5
);
gr2
->
SetFillColor
(
indices
[
1
]);
gr2
->
SetName
(
"part2"
);
gr2
->
SetTitle
(
"part2"
);
create_flower
(
xs
,
ys
,
100000
,
1
2
);
create_flower
(
xs
,
ys
,
100000
,
1
0
);
TGraph
*
const
gr3
=
new
TGraph
(
Int_t
(
xs
.
size
()),
&
xs
[
0
],
&
ys
[
0
]);
//If you want to see the different, change 0.2 to 1 in the next call:
new
TColor
(
indices
[
2
],
1
.,
0
.,
0
.
4
,
"magenta"
,
0
.
2
);
//If you want to see the difference, change 0.2 to 1 in the next call:
new
TColor
(
indices
[
2
],
1
.,
0
.,
0
.
4
,
"custom_magenta"
,
0
.
2
);
gr3
->
SetFillColor
(
indices
[
2
]);
gr3
->
SetName
(
"part3"
);
gr3
->
SetTitle
(
"part3"
);
//The final result.
//3. Create a final multigraph.
//Otcveli, uzh davno ... nu ti ponEl.
TMultiGraph
*
const
flower
=
new
TMultiGraph
(
"Chrysanthemum"
,
"Chrysanthemum"
);
flower
->
Add
(
gr1
);
flower
->
Add
(
gr2
);
...
...
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