Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
datareps
CompositeFunctionRep.cxx
Go to the documentation of this file.
1
/* -*- mode: c++ -*- */
2
14
#include "
CompositeFunctionRep.h
"
15
16
#include "
FunctionParameter.h
"
17
18
#include "
functions/FunctionBase.h
"
19
#include "
projectors/ProjectorBase.h
"
20
21
#include "
reps/LineFunctionRep.h
"
22
23
#include <algorithm>
24
25
#include <cassert>
26
27
using
std::find;
28
using
std::string;
29
using
std::vector;
30
31
using namespace
hippodraw;
32
33
CompositeFunctionRep::
34
CompositeFunctionRep
(
FunctionBase
*
function
,
DataRep
* target )
35
:
FunctionRep
( function, target )
36
{
37
m_rep
=
new
LineFunctionRep
();
38
// The above deleted in ~DataRep()
39
40
const
Color
blue (
Color::blue
);
41
m_rep
-> setColor ( blue );
42
m_rep
-> setSize ( 2 );
43
}
44
49
void
50
CompositeFunctionRep::
51
addToComposite
(
FunctionRep
* frep )
52
{
53
frep ->
setInComposite
(
true
);
54
m_func_reps
.push_back ( frep );
55
56
FunctionBase
* composite =
getFunction
();
57
FunctionBase
*
function
= frep ->
getFunction
();
58
59
composite ->
addToComposite
(
function
);
60
61
Fitter
* fitter =
getFitter
();
62
if
( fitter != 0 ) {
63
vector < int > flags =
getFixedFlags
();
// a copy
64
int
size
=
function
->
size
();
65
while
( size-- != 0 ) {
66
flags.push_back ( 0 );
67
}
68
69
setFixedFlags
( flags );
70
}
71
}
72
73
bool
74
CompositeFunctionRep::
75
isMember
(
const
FunctionRep
* rep )
76
{
77
FunctionRepList_t::iterator first
78
= find (
m_func_reps
.begin(),
m_func_reps
.end(), rep );
79
80
return
first !=
m_func_reps
.end();
81
}
82
83
void
84
CompositeFunctionRep::
85
removeFromComposite
(
FunctionRep
* frep )
86
{
87
FunctionBase
*
function
= frep ->
getFunction
();
88
FunctionBase
* composite =
getFunction
();
89
composite ->
removeFromComposite
(
function
);
90
91
FunctionRepList_t::iterator first
92
= find (
m_func_reps
.begin(),
m_func_reps
.end(), frep );
93
if
( first !=
m_func_reps
.end () ) {
94
m_func_reps
.erase ( first );
95
}
96
97
frep ->
setInComposite
(
false
);
98
}
99
100
unsigned
int
101
CompositeFunctionRep::
102
count
()
const
103
{
104
return
m_func_reps
.size ();
105
}
106
107
const
CompositeFunctionRep::FunctionRepList_t
&
108
CompositeFunctionRep::
109
getFunctionReps
()
const
110
{
111
return
m_func_reps
;
112
}
113
114
void
115
CompositeFunctionRep::
116
drawProjectedValues
(
TransformBase
* transform,
ViewBase
* view )
117
{
118
119
drawCuts
( transform, view );
120
121
const
Range
& range =
m_projector
-> getRange (
Axes::X
);
122
FunctionBase
*
function
=
getFunction
();
123
LineFunctionRep
* rep = dynamic_cast <
LineFunctionRep
* > (
m_rep
);
124
assert ( rep != 0 );
125
126
rep ->
drawProjectedValues
( range,
function
, transform, view );
127
128
setDirty
(
false
);
129
}
130
131
void
132
CompositeFunctionRep::
133
setFixedFlags
(
const
std::vector < int > & flags )
134
{
135
unsigned
int
size
=
m_func_reps
.size ();
136
vector<int>::const_iterator first = flags.begin();
137
138
for
(
unsigned
int
i = 0; i <
size
; i++ ) {
139
FunctionRep
* frep =
m_func_reps
[i];
140
vector < int > tmp = frep ->
getFixedFlags
();
// a copy
141
unsigned
int
number = tmp.size ();
142
vector<int>::const_iterator end = first + number;
143
copy ( first, end, tmp.begin() );
144
frep ->
setFixedFlags
( tmp );
145
first = end;
146
}
147
148
FunctionRep::setFixedFlags
( flags );
149
}
Generated for HippoDraw Class Library by