Changeset View
Changeset View
Standalone View
Standalone View
objects/line_imp.cc
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 93 | { | |||
---|---|---|---|---|---|
95 | l << I18N_NOOP( "Slope" ); | 95 | l << I18N_NOOP( "Slope" ); | ||
96 | l << I18N_NOOP( "Equation" ); | 96 | l << I18N_NOOP( "Equation" ); | ||
97 | assert( l.size() == AbstractLineImp::numberOfProperties() ); | 97 | assert( l.size() == AbstractLineImp::numberOfProperties() ); | ||
98 | return l; | 98 | return l; | ||
99 | } | 99 | } | ||
100 | 100 | | |||
101 | int SegmentImp::numberOfProperties() const | 101 | int SegmentImp::numberOfProperties() const | ||
102 | { | 102 | { | ||
103 | return Parent::numberOfProperties() + 5; | 103 | return Parent::numberOfProperties() + 6; | ||
104 | } | 104 | } | ||
105 | 105 | | |||
106 | const QByteArrayList SegmentImp::propertiesInternalNames() const | 106 | const QByteArrayList SegmentImp::propertiesInternalNames() const | ||
107 | { | 107 | { | ||
108 | QByteArrayList s = Parent::propertiesInternalNames(); | 108 | QByteArrayList s = Parent::propertiesInternalNames(); | ||
109 | s << "length"; | 109 | s << "length"; | ||
110 | s << "mid-point"; | 110 | s << "mid-point"; | ||
111 | s << "golden-point"; | ||||
111 | s << "support"; | 112 | s << "support"; | ||
112 | s << "end-point-A"; | 113 | s << "end-point-A"; | ||
113 | s << "end-point-B"; | 114 | s << "end-point-B"; | ||
114 | assert( s.size() == SegmentImp::numberOfProperties() ); | 115 | assert( s.size() == SegmentImp::numberOfProperties() ); | ||
115 | return s; | 116 | return s; | ||
116 | } | 117 | } | ||
117 | 118 | | |||
118 | const QByteArrayList SegmentImp::properties() const | 119 | const QByteArrayList SegmentImp::properties() const | ||
119 | { | 120 | { | ||
120 | QByteArrayList s = Parent::properties(); | 121 | QByteArrayList s = Parent::properties(); | ||
121 | s << I18N_NOOP( "Length" ); | 122 | s << I18N_NOOP( "Length" ); | ||
122 | s << I18N_NOOP( "Mid Point" ); | 123 | s << I18N_NOOP( "Mid Point" ); | ||
124 | s << I18N_NOOP( "Golden Ratio Point" ); | ||||
123 | s << I18N_NOOP( "Support Line" ); | 125 | s << I18N_NOOP( "Support Line" ); | ||
124 | s << I18N_NOOP( "First End Point" ); | 126 | s << I18N_NOOP( "First End Point" ); | ||
125 | s << I18N_NOOP( "Second End Point" ); | 127 | s << I18N_NOOP( "Second End Point" ); | ||
126 | assert( s.size() == SegmentImp::numberOfProperties() ); | 128 | assert( s.size() == SegmentImp::numberOfProperties() ); | ||
127 | return s; | 129 | return s; | ||
128 | } | 130 | } | ||
129 | 131 | | |||
130 | const ObjectImpType* SegmentImp::impRequirementForProperty( int which ) const | 132 | const ObjectImpType* SegmentImp::impRequirementForProperty( int which ) const | ||
131 | { | 133 | { | ||
132 | if ( which < Parent::numberOfProperties() ) | 134 | if ( which < Parent::numberOfProperties() ) | ||
133 | return Parent::impRequirementForProperty( which ); | 135 | return Parent::impRequirementForProperty( which ); | ||
134 | else return SegmentImp::stype(); | 136 | else return SegmentImp::stype(); | ||
135 | } | 137 | } | ||
136 | 138 | | |||
137 | const char* SegmentImp::iconForProperty( int which ) const | 139 | const char* SegmentImp::iconForProperty( int which ) const | ||
138 | { | 140 | { | ||
139 | int pnum = 0; | 141 | int pnum = 0; | ||
140 | if ( which < Parent::numberOfProperties() ) | 142 | if ( which < Parent::numberOfProperties() ) | ||
141 | return Parent::iconForProperty( which ); | 143 | return Parent::iconForProperty( which ); | ||
142 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 144 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
143 | return "distance"; // length | 145 | return "distance"; // length | ||
144 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 146 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
145 | return "segment_midpoint"; // mid point | 147 | return "segment_midpoint"; // mid point | ||
146 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 148 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
149 | return "segment_golden_point"; // golden ratio point | ||||
150 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||||
147 | return ""; // support line | 151 | return ""; // support line | ||
148 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 152 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
149 | return "endpoint1"; // mid point | 153 | return "endpoint1"; // mid point | ||
150 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 154 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
151 | return "endpoint2"; // mid point | 155 | return "endpoint2"; // mid point | ||
152 | else assert( false ); | 156 | else assert( false ); | ||
153 | return ""; | 157 | return ""; | ||
154 | } | 158 | } | ||
155 | 159 | | |||
156 | ObjectImp* SegmentImp::property( int which, const KigDocument& w ) const | 160 | ObjectImp* SegmentImp::property( int which, const KigDocument& w ) const | ||
157 | { | 161 | { | ||
158 | int pnum = 0; | 162 | int pnum = 0; | ||
159 | 163 | | |||
160 | if ( which < Parent::numberOfProperties() ) | 164 | if ( which < Parent::numberOfProperties() ) | ||
161 | return Parent::property( which, w ); | 165 | return Parent::property( which, w ); | ||
162 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 166 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
163 | return new DoubleImp( mdata.dir().length() ); | 167 | return new DoubleImp( mdata.dir().length() ); | ||
164 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 168 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
165 | return new PointImp( ( mdata.a + mdata.b ) / 2 ); | 169 | return new PointImp( ( mdata.a + mdata.b ) / 2 ); | ||
166 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 170 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
171 | return new PointImp( mdata.a + (sqrt(5) - 1) / 2 * (mdata.b - mdata.a) ); | ||||
172 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||||
167 | return new LineImp( mdata.a, mdata.b ); | 173 | return new LineImp( mdata.a, mdata.b ); | ||
168 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 174 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
169 | return new PointImp( mdata.a ); | 175 | return new PointImp( mdata.a ); | ||
170 | else if ( which == Parent::numberOfProperties() + pnum++ ) | 176 | else if ( which == Parent::numberOfProperties() + pnum++ ) | ||
171 | return new PointImp( mdata.b ); | 177 | return new PointImp( mdata.b ); | ||
172 | else assert( false ); | 178 | else assert( false ); | ||
173 | return new InvalidImp; | 179 | return new InvalidImp; | ||
174 | } | 180 | } | ||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |