1 /****************************************************************************
2 * MeshLab                                                           o o     *
3 * A versatile mesh processing toolbox                             o     o   *
4 *                                                                _   O  _   *
5 * Copyright(C) 2005                                                \/)\/    *
6 * Visual Computing Lab                                            /\/|      *
7 * ISTI - Italian National Research Council                           |      *
8 *                                                                    \      *
9 * All rights reserved.                                                      *
10 *                                                                           *
11 * This program is free software; you can redistribute it and/or modify      *
12 * it under the terms of the GNU General Public License as published by      *
13 * the Free Software Foundation; either version 2 of the License, or         *
14 * (at your option) any later version.                                       *
15 *                                                                           *
16 * This program is distributed in the hope that it will be useful,           *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
20 * for more details.                                                         *
21 *                                                                           *
22 ****************************************************************************/
23 
24 #include "ml_rendering_actions.h"
25 #include <wrap/qt/col_qt_convert.h>
26 #include <QObject>
27 #include <QString>
28 #include <common/meshmodel.h>
29 
MLRenderingAction(QObject * parent)30 MLRenderingAction::MLRenderingAction( QObject* parent )
31     :QAction(parent)
32 {
33     setCheckable(true);
34     setChecked(false);
35     setMeshId(-1);
36 }
37 
MLRenderingAction(int meshid,QObject * parent)38 MLRenderingAction::MLRenderingAction(int meshid,QObject* parent )
39     :QAction(parent)
40 {
41     setCheckable(true);
42     setChecked(false);
43     setMeshId(meshid);
44 }
45 
meshId() const46 int MLRenderingAction::meshId() const
47 {
48     bool isvalidid = false;
49     return data().toInt(&isvalidid);
50 }
51 
52 
setMeshId(int meshid)53 void MLRenderingAction::setMeshId(int meshid)
54 {
55     setData(QVariant(meshid));
56 }
57 
isSameType(const MLRenderingAction & act) const58 bool MLRenderingAction::isSameType(const MLRenderingAction& act) const
59 {
60 	return (metaObject()->className() == act.metaObject()->className());
61 }
62 
isRenderingDataEnabled(MLRenderingData::PRIMITIVE_MODALITY pm,MLRenderingData::ATT_NAMES att,const MLRenderingData & rd) const63 bool MLRenderingAction::isRenderingDataEnabled( MLRenderingData::PRIMITIVE_MODALITY pm,MLRenderingData::ATT_NAMES att,const MLRenderingData& rd ) const
64 {
65     MLRenderingData::RendAtts atts;
66     rd.get(pm,atts);
67     return atts[att];
68 }
69 
MLRenderingBBoxAction(QObject * parent)70 MLRenderingBBoxAction::MLRenderingBBoxAction( QObject* parent)
71     :MLRenderingAction(parent)
72 {
73     setIcon(QIcon(":/images/bbox.png"));
74     setText(QString("Bounding Box"));
75 }
76 
MLRenderingBBoxAction(int meshid,QObject * parent)77 MLRenderingBBoxAction::MLRenderingBBoxAction( int meshid,QObject* parent)
78     :MLRenderingAction(meshid,parent)
79 {
80     setIcon(QIcon(":/images/bbox.png"));
81     setText(QString("Bounding Box"));
82 }
83 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)84 void MLRenderingBBoxAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
85 {
86 	sisteract = new MLRenderingBBoxAction(meshId(), par);
87 }
88 
updateRenderingData(MLRenderingData & rd)89 void MLRenderingBBoxAction::updateRenderingData(MLRenderingData& rd)
90 {
91     MLPerViewGLOptions opts;
92     bool valid = rd.get(opts);
93     if (valid)
94     {
95         opts._perbbox_enabled = isChecked();
96         rd.set(opts);
97     }
98 }
99 
isRenderingDataEnabled(const MLRenderingData & rd) const100 bool MLRenderingBBoxAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
101 {
102     MLPerViewGLOptions opts;
103     bool valid = rd.get(opts);
104     return (valid && opts._perbbox_enabled);
105 }
106 
MLRenderingPointsAction(QObject * parent)107 MLRenderingPointsAction::MLRenderingPointsAction( QObject* parent)
108     :MLRenderingAction(parent)
109 {
110     setIcon(QIcon(":/images/points.png"));
111     setText(QString("Points"));
112 }
113 
MLRenderingPointsAction(int meshid,QObject * parent)114 MLRenderingPointsAction::MLRenderingPointsAction( int meshid,QObject* parent)
115     :MLRenderingAction(meshid, parent)
116 {
117     setIcon(QIcon(":/images/points.png"));
118     setText(QString("Points"));
119 }
120 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)121 void MLRenderingPointsAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
122 {
123 	sisteract = new MLRenderingPointsAction(meshId(), par);
124 }
125 
updateRenderingData(MLRenderingData & rd)126 void MLRenderingPointsAction::updateRenderingData(MLRenderingData& rd )
127 {
128     rd.set(MLRenderingData::PR_POINTS,isChecked());
129 }
130 
isRenderingDataEnabled(const MLRenderingData & rd) const131 bool MLRenderingPointsAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
132 {
133     return rd.isPrimitiveActive(MLRenderingData::PR_POINTS);
134 }
135 
MLRenderingWireAction(QObject * parent)136 MLRenderingWireAction::MLRenderingWireAction(QObject* parent)
137     :MLRenderingAction(parent)
138 {
139     setIcon(QIcon(":/images/wire.png"));
140     setText(QString("Wireframe"));
141 }
142 
MLRenderingWireAction(int meshid,QObject * parent)143 MLRenderingWireAction::MLRenderingWireAction(int meshid,QObject* parent)
144     :MLRenderingAction(meshid,parent)
145 {
146     setIcon(QIcon(":/images/wire.png"));
147     setText(QString("Wireframe"));
148 }
149 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)150 void MLRenderingWireAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
151 {
152 	sisteract = new MLRenderingWireAction(meshId(), par);
153 }
154 
updateRenderingData(MLRenderingData & rd)155 void MLRenderingWireAction::updateRenderingData(MLRenderingData& rd )
156 {
157 	MLPerViewGLOptions opts;
158 	bool valid = rd.get(opts);
159 	if (valid)
160 	{
161 		opts._peredge_wire_enabled = isChecked();
162 		rd.set(opts);
163 	}
164 }
165 
isRenderingDataEnabled(const MLRenderingData & rd) const166 bool MLRenderingWireAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
167 {
168 	MLPerViewGLOptions opts;
169 	bool valid = rd.get(opts);
170 	return (valid && opts._peredge_wire_enabled);
171 }
172 
MLRenderingSolidAction(QObject * parent)173 MLRenderingSolidAction::MLRenderingSolidAction( QObject* parent )
174     :MLRenderingAction(parent)
175 {
176     setIcon(QIcon(":/images/smooth.png"));
177     setText(QString("Fill"));
178 }
179 
MLRenderingSolidAction(int meshid,QObject * parent)180 MLRenderingSolidAction::MLRenderingSolidAction( int meshid,QObject* parent )
181     :MLRenderingAction(meshid,parent)
182 {
183     setIcon(QIcon(":/images/smooth.png"));
184     setText(QString("Fill"));
185 }
186 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)187 void MLRenderingSolidAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
188 {
189 	sisteract = new MLRenderingSolidAction(meshId(), par);
190 }
191 
updateRenderingData(MLRenderingData & rd)192 void MLRenderingSolidAction::updateRenderingData( MLRenderingData& rd )
193 {
194     rd.set(MLRenderingData::PR_SOLID,isChecked());
195 }
196 
isRenderingDataEnabled(const MLRenderingData & rd) const197 bool MLRenderingSolidAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
198 {
199     return rd.isPrimitiveActive(MLRenderingData::PR_SOLID);
200 }
201 
MLRenderingFauxEdgeWireAction(QObject * parent)202 MLRenderingFauxEdgeWireAction::MLRenderingFauxEdgeWireAction( QObject* parent )
203     :MLRenderingAction(parent)
204 {
205     setText(QString("Edges Wireframe"));
206 }
207 
MLRenderingFauxEdgeWireAction(int meshid,QObject * parent)208 MLRenderingFauxEdgeWireAction::MLRenderingFauxEdgeWireAction( int meshid,QObject* parent )
209     :MLRenderingAction(meshid,parent)
210 {
211     setText(QString("Edges Wireframe"));
212 }
213 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)214 void MLRenderingFauxEdgeWireAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
215 {
216 	sisteract = new MLRenderingFauxEdgeWireAction(meshId(), par);
217 }
218 
updateRenderingData(MLRenderingData & rd)219 void MLRenderingFauxEdgeWireAction::updateRenderingData( MLRenderingData& rd )
220 {
221 	MLPerViewGLOptions opts;
222 	bool valid = rd.get(opts);
223 	if (valid)
224 	{
225 		opts._peredge_fauxwire_enabled = isChecked();
226 		rd.set(opts);
227 	}
228 }
229 
isRenderingDataEnabled(const MLRenderingData & rd) const230 bool MLRenderingFauxEdgeWireAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
231 {
232 	MLPerViewGLOptions opts;
233 	bool valid = rd.get(opts);
234 	return (valid && opts._peredge_fauxwire_enabled);
235 }
236 
isVisibleConditionValid(MeshModel * mm) const237 bool MLRenderingFauxEdgeWireAction::isVisibleConditionValid( MeshModel* mm) const
238 {
239     return mm->hasDataMask(MeshModel::MM_POLYGONAL);
240 }
241 
MLRenderingPerFaceNormalAction(QObject * parent)242 MLRenderingPerFaceNormalAction::MLRenderingPerFaceNormalAction( QObject* parent)
243     :MLRenderingAction(parent)
244 {
245     setText(QString("Face"));
246 	setIcon(QIcon(":/images/flat.png"));
247 }
248 
MLRenderingPerFaceNormalAction(int meshid,QObject * parent)249 MLRenderingPerFaceNormalAction::MLRenderingPerFaceNormalAction( int meshid,QObject* parent)
250     :MLRenderingAction(meshid, parent)
251 {
252     setText(QString("Face"));
253 	setIcon(QIcon(":/images/flat.png"));
254 }
255 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)256 void MLRenderingPerFaceNormalAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
257 {
258 	sisteract = new MLRenderingPerFaceNormalAction(meshId(), par);
259 }
260 
updateRenderingData(MLRenderingData & rd)261 void MLRenderingPerFaceNormalAction::updateRenderingData(MLRenderingData& rd )
262 {
263     rd.set(MLRenderingData::PR_SOLID,MLRenderingData::ATT_NAMES::ATT_FACENORMAL,isChecked());
264 }
265 
isRenderingDataEnabled(const MLRenderingData & rd) const266 bool MLRenderingPerFaceNormalAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
267 {
268     return MLRenderingAction::isRenderingDataEnabled(MLRenderingData::PR_SOLID,MLRenderingData::ATT_NAMES::ATT_FACENORMAL,rd);
269 }
270 
isVisibleConditionValid(MeshModel * mm) const271 bool MLRenderingPerFaceNormalAction::isVisibleConditionValid(MeshModel* mm) const
272 {
273 	if (mm == NULL)
274 		return false;
275 	return mm->hasDataMask(MeshModel::MM_FACENORMAL);
276 }
277 
MLRenderingPerVertexNormalAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject * parent)278 MLRenderingPerVertexNormalAction::MLRenderingPerVertexNormalAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject* parent)
279     :MLRenderingAction(parent),_pm(pm)
280 {
281     setText(QString("Vert"));
282 	setIcon(QIcon(":/images/smooth.png"));
283 }
284 
MLRenderingPerVertexNormalAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject * parent)285 MLRenderingPerVertexNormalAction::MLRenderingPerVertexNormalAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject* parent)
286     :MLRenderingAction(meshid,parent),_pm(pm)
287 {
288     setText(QString("Vert"));
289 	setIcon(QIcon(":/images/smooth.png"));
290 }
291 
switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)292 void MLRenderingPerVertexNormalAction::switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)
293 {
294 	_pm = pr;
295 }
296 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)297 void MLRenderingPerVertexNormalAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
298 {
299 	sisteract = new MLRenderingPerVertexNormalAction(_pm, meshId(), par);
300 }
301 
updateRenderingData(MLRenderingData & rd)302 void MLRenderingPerVertexNormalAction::updateRenderingData(MLRenderingData& rd )
303 {
304     rd.set(_pm,MLRenderingData::ATT_NAMES::ATT_VERTNORMAL,isChecked());
305 }
306 
isRenderingDataEnabled(const MLRenderingData & rd) const307 bool MLRenderingPerVertexNormalAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
308 {
309     return MLRenderingAction::isRenderingDataEnabled(_pm,MLRenderingData::ATT_NAMES::ATT_VERTNORMAL,rd);
310 }
311 
isVisibleConditionValid(MeshModel * mm) const312 bool MLRenderingPerVertexNormalAction::isVisibleConditionValid(MeshModel* mm) const
313 {
314 	if (mm == NULL)
315 		return false;
316 	return mm->hasDataMask(MeshModel::MM_VERTNORMAL);
317 }
318 
MLRenderingPerVertTextCoordAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject * parent)319 MLRenderingPerVertTextCoordAction::MLRenderingPerVertTextCoordAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject* parent)
320     :MLRenderingAction(-1,parent),_pm(pm)
321 {
322     setText(QString("Enabled"));
323 }
324 
MLRenderingPerVertTextCoordAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject * parent)325 MLRenderingPerVertTextCoordAction::MLRenderingPerVertTextCoordAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject* parent)
326     :MLRenderingAction(meshid,parent),_pm(pm)
327 {
328     setText(QString("Enabled"));
329 }
330 
switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)331 void MLRenderingPerVertTextCoordAction::switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)
332 {
333 	_pm = pr;
334 }
335 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)336 void MLRenderingPerVertTextCoordAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
337 {
338 	sisteract = new MLRenderingPerVertTextCoordAction(_pm,meshId(), par);
339 }
340 
updateRenderingData(MLRenderingData & rd)341 void MLRenderingPerVertTextCoordAction::updateRenderingData(MLRenderingData& rd )
342 {
343     rd.set(_pm,MLRenderingData::ATT_NAMES::ATT_VERTTEXTURE,isChecked());
344 }
345 
isRenderingDataEnabled(const MLRenderingData & rd) const346 bool MLRenderingPerVertTextCoordAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
347 {
348     return MLRenderingAction::isRenderingDataEnabled(_pm,MLRenderingData::ATT_NAMES::ATT_VERTTEXTURE,rd);
349 }
350 
isVisibleConditionValid(MeshModel * mm) const351 bool MLRenderingPerVertTextCoordAction::isVisibleConditionValid( MeshModel* mm) const
352 {
353     return mm->hasDataMask(MeshModel::MM_VERTTEXCOORD);
354 }
355 
MLRenderingPerWedgeTextCoordAction(QObject * parent)356 MLRenderingPerWedgeTextCoordAction::MLRenderingPerWedgeTextCoordAction(QObject* parent)
357     :MLRenderingAction(parent)
358 {
359 	setText(QString("Wedge Text"));
360 	setIcon(QIcon(":/images/text_color.png"));
361 }
362 
MLRenderingPerWedgeTextCoordAction(int meshid,QObject * parent)363 MLRenderingPerWedgeTextCoordAction::MLRenderingPerWedgeTextCoordAction(int meshid,QObject* parent)
364     :MLRenderingAction(meshid,parent)
365 {
366 	setText(QString("Wedge Text"));
367 	setIcon(QIcon(":/images/text_color.png"));
368 }
369 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)370 void MLRenderingPerWedgeTextCoordAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
371 {
372 	sisteract = new MLRenderingPerWedgeTextCoordAction(meshId(), par);
373 }
374 
updateRenderingData(MLRenderingData & rd)375 void MLRenderingPerWedgeTextCoordAction::updateRenderingData(MLRenderingData& rd )
376 {
377     rd.set(MLRenderingData::PR_SOLID,MLRenderingData::ATT_NAMES::ATT_WEDGETEXTURE,isChecked());
378 }
379 
isRenderingDataEnabled(const MLRenderingData & rd) const380 bool MLRenderingPerWedgeTextCoordAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
381 {
382     return MLRenderingAction::isRenderingDataEnabled(MLRenderingData::PR_SOLID,MLRenderingData::ATT_NAMES::ATT_WEDGETEXTURE,rd);
383 }
384 
isVisibleConditionValid(MeshModel * mm) const385 bool MLRenderingPerWedgeTextCoordAction::isVisibleConditionValid( MeshModel* mm) const
386 {
387     return mm->hasDataMask(MeshModel::MM_WEDGTEXCOORD);
388 }
389 
MLRenderingDoubleLightingAction(QObject * parent)390 MLRenderingDoubleLightingAction::MLRenderingDoubleLightingAction( QObject* parent)
391     :MLRenderingAction(parent)
392 {
393     setText(QString("Double"));
394 }
395 
MLRenderingDoubleLightingAction(int meshid,QObject * parent)396 MLRenderingDoubleLightingAction::MLRenderingDoubleLightingAction( int meshid,QObject* parent)
397     :MLRenderingAction(meshid,parent)
398 {
399     setText(QString("Double"));
400 }
401 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)402 void MLRenderingDoubleLightingAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
403 {
404 	sisteract = new MLRenderingDoubleLightingAction(meshId(), par);
405 }
406 
updateRenderingData(MLRenderingData & rd)407 void MLRenderingDoubleLightingAction::updateRenderingData(MLRenderingData& rd )
408 {
409     MLPerViewGLOptions opts;
410     bool valid = rd.get(opts);
411     if (valid)
412     {
413         opts._double_side_lighting = isChecked();
414         rd.set(opts);
415     }
416 }
417 
isRenderingDataEnabled(const MLRenderingData & rd) const418 bool MLRenderingDoubleLightingAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
419 {
420     MLPerViewGLOptions opts;
421     bool valid = rd.get(opts);
422     return (valid && opts._double_side_lighting);
423 }
424 
MLRenderingSingleLightingAction(QObject * parent)425 MLRenderingSingleLightingAction::MLRenderingSingleLightingAction(QObject* parent)
426 	:MLRenderingAction(parent)
427 {
428 	setText(QString("Single"));
429 }
430 
MLRenderingSingleLightingAction(int meshid,QObject * parent)431 MLRenderingSingleLightingAction::MLRenderingSingleLightingAction(int meshid, QObject* parent)
432 	: MLRenderingAction(meshid, parent)
433 {
434 	setText(QString("Single"));
435 }
436 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)437 void MLRenderingSingleLightingAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
438 {
439 	sisteract = new MLRenderingSingleLightingAction(meshId(), par);
440 }
441 
updateRenderingData(MLRenderingData & rd)442 void MLRenderingSingleLightingAction::updateRenderingData(MLRenderingData& rd)
443 {
444 	MLPerViewGLOptions opts;
445 	bool valid = rd.get(opts);
446 	if (valid)
447 	{
448 		opts._single_side_lighting = isChecked();
449 		rd.set(opts);
450 	}
451 }
452 
isRenderingDataEnabled(const MLRenderingData & rd) const453 bool MLRenderingSingleLightingAction::isRenderingDataEnabled(const MLRenderingData& rd) const
454 {
455 	MLPerViewGLOptions opts;
456 	bool valid = rd.get(opts);
457 	return (valid && opts._single_side_lighting);
458 }
459 
MLRenderingFancyLightingAction(QObject * parent)460 MLRenderingFancyLightingAction::MLRenderingFancyLightingAction( QObject* parent)
461     :MLRenderingAction(parent)
462 {
463     setText(QString("Fancy"));
464 }
465 
MLRenderingFancyLightingAction(int meshid,QObject * parent)466 MLRenderingFancyLightingAction::MLRenderingFancyLightingAction( int meshid,QObject* parent)
467     :MLRenderingAction(meshid,parent)
468 {
469     setText(QString("Fancy"));
470 }
471 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)472 void MLRenderingFancyLightingAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
473 {
474 	sisteract = new MLRenderingFancyLightingAction(meshId(), par);
475 }
476 
updateRenderingData(MLRenderingData & rd)477 void MLRenderingFancyLightingAction::updateRenderingData(MLRenderingData& rd )
478 {
479     MLPerViewGLOptions opts;
480     bool valid = rd.get(opts);
481     if (valid)
482     {
483         opts._fancy_lighting = isChecked();
484         rd.set(opts);
485     }
486 }
487 
isRenderingDataEnabled(const MLRenderingData & rd) const488 bool MLRenderingFancyLightingAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
489 {
490     MLPerViewGLOptions opts;
491     bool valid = rd.get(opts);
492     return (valid && opts._fancy_lighting);
493 }
494 
MLRenderingNoShadingAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject * parent)495 MLRenderingNoShadingAction::MLRenderingNoShadingAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject* parent)
496     :MLRenderingAction(parent),_pm(pm)
497 {
498     //setIcon(QIcon(":/images/lighton.png"));
499     setText(QString("None"));
500     setToolTip(QString("Light on/off"));
501 }
502 
MLRenderingNoShadingAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject * parent)503 MLRenderingNoShadingAction::MLRenderingNoShadingAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject* parent)
504     :MLRenderingAction(meshid,parent),_pm(pm)
505 {
506     //setIcon(QIcon(":/images/lighton.png"));
507     setText(QString("None"));
508     setToolTip(QString("Light on/off"));
509 }
510 
switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)511 void MLRenderingNoShadingAction::switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)
512 {
513 	_pm = pr;
514 }
515 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)516 void MLRenderingNoShadingAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
517 {
518 	sisteract = new MLRenderingNoShadingAction(_pm,meshId(), par);
519 }
520 
updateRenderingData(MLRenderingData & rd)521 void MLRenderingNoShadingAction::updateRenderingData(MLRenderingData& rd )
522 {
523     MLPerViewGLOptions opts;
524     bool valid = rd.get(opts);
525 
526     if (valid)
527     {
528         switch (_pm)
529         {
530             case (MLRenderingData::PR_POINTS):
531                 {
532                     opts._perpoint_noshading = isChecked();
533                     break;
534                 }
535             case (MLRenderingData::PR_WIREFRAME_TRIANGLES):
536             case (MLRenderingData::PR_WIREFRAME_EDGES):
537                 {
538                     opts._perwire_noshading = isChecked();
539                     break;
540                 }
541             case (MLRenderingData::PR_SOLID):
542                 {
543                     opts._persolid_noshading = isChecked();
544                     break;
545                 }
546             default:
547                 break;
548         }
549         rd.set(opts);
550     }
551 }
552 
isRenderingDataEnabled(const MLRenderingData & rd) const553 bool MLRenderingNoShadingAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
554 {
555     MLPerViewGLOptions opts;
556     bool valid = rd.get(opts);
557     if (valid)
558     {
559         switch (_pm)
560         {
561             case (MLRenderingData::PR_POINTS):
562                 {
563                     return opts._perpoint_noshading;
564                 }
565             case (MLRenderingData::PR_WIREFRAME_TRIANGLES):
566             case (MLRenderingData::PR_WIREFRAME_EDGES):
567                 {
568                     return opts._perwire_noshading;
569                 }
570             case (MLRenderingData::PR_SOLID):
571                 {
572                     return opts._persolid_noshading;
573                 }
574             default:
575                 break;
576         }
577     }
578     return false;
579 }
580 
MLRenderingFaceCullAction(QObject * parent)581 MLRenderingFaceCullAction::MLRenderingFaceCullAction( QObject* parent)
582     :MLRenderingAction(parent)
583 {
584     setText(QString("Cull"));
585 }
586 
MLRenderingFaceCullAction(int meshid,QObject * parent)587 MLRenderingFaceCullAction::MLRenderingFaceCullAction( int meshid,QObject* parent)
588     :MLRenderingAction(meshid,parent)
589 {
590     setText(QString("Cull"));
591 }
592 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)593 void MLRenderingFaceCullAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
594 {
595 	sisteract = new MLRenderingFaceCullAction(meshId(), par);
596 }
597 
updateRenderingData(MLRenderingData & rd)598 void MLRenderingFaceCullAction::updateRenderingData(MLRenderingData& rd )
599 {
600     MLPerViewGLOptions opts;
601     bool valid = rd.get(opts);
602     if (valid)
603     {
604         opts._back_face_cull = isChecked();
605         rd.set(opts);
606     }
607 }
608 
isRenderingDataEnabled(const MLRenderingData & rd) const609 bool MLRenderingFaceCullAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
610 {
611     MLPerViewGLOptions opts;
612     bool valid = rd.get(opts);
613     return (valid && opts._back_face_cull);
614 }
615 
MLRenderingPerMeshColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject * parent)616 MLRenderingPerMeshColorAction::MLRenderingPerMeshColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject* parent)
617     :MLRenderingAction(-1,parent),_pm(pm)
618 {
619     setText(QString("Mesh"));
620 }
621 
MLRenderingPerMeshColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject * parent)622 MLRenderingPerMeshColorAction::MLRenderingPerMeshColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject* parent)
623     :MLRenderingAction(meshid,parent),_pm(pm)
624 {
625     setText(QString("Mesh"));
626 }
627 
switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)628 void MLRenderingPerMeshColorAction::switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)
629 {
630 	_pm = pr;
631 }
632 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)633 void MLRenderingPerMeshColorAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
634 {
635 	sisteract = new MLRenderingPerMeshColorAction(_pm,meshId(), par);
636 }
637 
updateRenderingData(MLRenderingData & rd)638 void MLRenderingPerMeshColorAction::updateRenderingData(MLRenderingData& rd)
639 {
640     MLPerViewGLOptions opts;
641     bool valid = rd.get(opts);
642     if (valid)
643     {
644         switch (_pm)
645         {
646             case (MLRenderingData::PR_POINTS):
647                 {
648                     opts._perpoint_mesh_color_enabled = isChecked();
649                     break;
650                 }
651             case (MLRenderingData::PR_WIREFRAME_TRIANGLES):
652             case (MLRenderingData::PR_WIREFRAME_EDGES):
653                 {
654                     opts._perwire_mesh_color_enabled = isChecked();
655                     break;
656                 }
657             case (MLRenderingData::PR_SOLID):
658                 {
659                     opts._persolid_mesh_color_enabled = isChecked();
660                     break;
661                 }
662             default:
663                 break;
664         }
665         rd.set(opts);
666     }
667 }
668 
isRenderingDataEnabled(const MLRenderingData & rd) const669 bool MLRenderingPerMeshColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
670 {
671     MLPerViewGLOptions opts;
672     bool valid = rd.get(opts);
673     if (valid)
674     {
675         switch (_pm)
676         {
677             case (MLRenderingData::PR_POINTS):
678                 {
679                     return opts._perpoint_mesh_color_enabled;
680 
681                 }
682             case (MLRenderingData::PR_WIREFRAME_TRIANGLES):
683             case (MLRenderingData::PR_WIREFRAME_EDGES):
684                 {
685                     return opts._perwire_mesh_color_enabled;
686 
687                 }
688             case (MLRenderingData::PR_SOLID):
689                 {
690                     return opts._persolid_mesh_color_enabled;
691                 }
692             default:
693                 break;
694         }
695     }
696     return false;
697 }
698 
setColor(const QColor & col)699 void MLRenderingPerMeshColorAction::setColor( const QColor& col )
700 {
701     _col = vcg::ColorConverter::ToColor4b(col);
702 }
703 
setColor(const vcg::Color4b & col)704 void MLRenderingPerMeshColorAction::setColor( const vcg::Color4b& col )
705 {
706     _col = col;
707 }
708 
getColor()709 vcg::Color4b& MLRenderingPerMeshColorAction::getColor()
710 {
711     return _col;
712 }
713 
MLRenderingPerVertexColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject * parent)714 MLRenderingPerVertexColorAction::MLRenderingPerVertexColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject* parent)
715     :MLRenderingAction(-1,parent),_pm(pm)
716 {
717     setText(QString("Vert"));
718 	setIcon(QIcon(":/images/vert_color.png"));
719 }
720 
MLRenderingPerVertexColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject * parent)721 MLRenderingPerVertexColorAction::MLRenderingPerVertexColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject* parent)
722     :MLRenderingAction(meshid,parent),_pm(pm)
723 {
724     setText(QString("Vert"));
725 	setIcon(QIcon(":/images/vert_color.png"));
726 }
727 
switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)728 void MLRenderingPerVertexColorAction::switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)
729 {
730 	_pm = pr;
731 }
732 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)733 void MLRenderingPerVertexColorAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
734 {
735 	sisteract = new MLRenderingPerVertexColorAction(_pm, meshId(), par);
736 }
737 
updateRenderingData(MLRenderingData & rd)738 void MLRenderingPerVertexColorAction::updateRenderingData(MLRenderingData& rd )
739 {
740     rd.set(_pm,MLRenderingData::ATT_NAMES::ATT_VERTCOLOR,isChecked());
741 }
742 
isRenderingDataEnabled(const MLRenderingData & rd) const743 bool MLRenderingPerVertexColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
744 {
745     return MLRenderingAction::isRenderingDataEnabled(_pm,MLRenderingData::ATT_NAMES::ATT_VERTCOLOR,rd);
746 }
747 
isVisibleConditionValid(MeshModel * mm) const748 bool MLRenderingPerVertexColorAction::isVisibleConditionValid(MeshModel* mm) const
749 {
750 	if (mm == NULL)
751 		return false;
752 	return mm->hasDataMask(MeshModel::MM_VERTCOLOR);
753 }
754 
MLRenderingPerFaceColorAction(QObject * parent)755 MLRenderingPerFaceColorAction::MLRenderingPerFaceColorAction(QObject* parent)
756     :MLRenderingAction(parent)
757 {
758     setText(QString("Face"));
759 	setIcon(QIcon(":/images/face_color.png"));
760 }
761 
MLRenderingPerFaceColorAction(int meshid,QObject * parent)762 MLRenderingPerFaceColorAction::MLRenderingPerFaceColorAction(int meshid,QObject* parent)
763     :MLRenderingAction(meshid,parent)
764 {
765     setText(QString("Face"));
766 	setIcon(QIcon(":/images/face_color.png"));
767 }
768 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)769 void MLRenderingPerFaceColorAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
770 {
771 	sisteract = new MLRenderingPerFaceColorAction(meshId(), par);
772 }
773 
updateRenderingData(MLRenderingData & rd)774 void MLRenderingPerFaceColorAction::updateRenderingData(MLRenderingData& rd )
775 {
776    rd.set(MLRenderingData::PR_SOLID,MLRenderingData::ATT_NAMES::ATT_FACECOLOR,isChecked());
777 }
778 
isRenderingDataEnabled(const MLRenderingData & rd) const779 bool MLRenderingPerFaceColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
780 {
781     return MLRenderingAction::isRenderingDataEnabled(MLRenderingData::PR_SOLID,MLRenderingData::ATT_NAMES::ATT_FACECOLOR,rd);
782 }
783 
isVisibleConditionValid(MeshModel * mm) const784 bool MLRenderingPerFaceColorAction::isVisibleConditionValid( MeshModel* mm) const
785 {
786 	if (mm == NULL)
787 		return false;
788     return mm->hasDataMask(MeshModel::MM_FACECOLOR);
789 }
790 
791 
MLRenderingUserDefinedGeneralColorAction(QObject * parent)792 MLRenderingUserDefinedGeneralColorAction::MLRenderingUserDefinedGeneralColorAction(QObject* parent)
793 	:MLRenderingAction(parent)
794 {
795 }
796 
MLRenderingUserDefinedGeneralColorAction(int meshid,QObject * parent)797 MLRenderingUserDefinedGeneralColorAction::MLRenderingUserDefinedGeneralColorAction(int meshid, QObject* parent)
798 	:MLRenderingAction(meshid,parent)
799 {
800 }
801 
MLRenderingUserDefinedGeneralColorAction(MLRenderingUserDefinedGeneralColorAction * origin,QObject * par)802 MLRenderingUserDefinedGeneralColorAction::MLRenderingUserDefinedGeneralColorAction(MLRenderingUserDefinedGeneralColorAction* origin, QObject * par)
803 	:MLRenderingAction(origin->meshId(),par)
804 {
805 	setColor(origin->getColor());
806 }
807 
setColor(const vcg::Color4b & col)808 void MLRenderingUserDefinedGeneralColorAction::setColor(const vcg::Color4b& col)
809 {
810 	_coluser = col;
811 }
812 
setColor(const QColor & col)813 void MLRenderingUserDefinedGeneralColorAction::setColor(const QColor& col)
814 {
815 	_coluser = vcg::ColorConverter::ToColor4b(col);
816 }
817 
getColor()818 vcg::Color4b& MLRenderingUserDefinedGeneralColorAction::getColor()
819 {
820 	return _coluser;
821 }
822 
823 
MLRenderingUserDefinedColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,QObject * parent)824 MLRenderingUserDefinedColorAction::MLRenderingUserDefinedColorAction( MLRenderingData::PRIMITIVE_MODALITY pm,QObject* parent )
825     :MLRenderingUserDefinedGeneralColorAction(-1,parent),_pm(pm)
826 {
827     setText(QString("User-Def"));
828 }
829 
MLRenderingUserDefinedColorAction(MLRenderingData::PRIMITIVE_MODALITY pm,int meshid,QObject * parent)830 MLRenderingUserDefinedColorAction::MLRenderingUserDefinedColorAction( MLRenderingData::PRIMITIVE_MODALITY pm,int meshid, QObject* parent )
831     : MLRenderingUserDefinedGeneralColorAction(meshid,parent),_pm(pm)
832 {
833     setText(QString("User-Def"));
834 }
835 
MLRenderingUserDefinedColorAction(MLRenderingUserDefinedColorAction * origin,QObject * par)836 MLRenderingUserDefinedColorAction::MLRenderingUserDefinedColorAction(MLRenderingUserDefinedColorAction* origin, QObject * par)
837 	: MLRenderingUserDefinedGeneralColorAction(origin->meshId(),par)
838 {
839 	setText(origin->text());
840 	_pm = origin->_pm;
841 }
842 
switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)843 void MLRenderingUserDefinedColorAction::switchPrimitive(MLRenderingData::PRIMITIVE_MODALITY pr)
844 {
845 	_pm = pr;
846 }
847 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)848 void MLRenderingUserDefinedColorAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
849 {
850 	sisteract = new MLRenderingUserDefinedColorAction(this,par);
851 }
852 
updateRenderingData(MLRenderingData & rd)853 void MLRenderingUserDefinedColorAction::updateRenderingData( MLRenderingData& rd )
854 {
855     MLPerViewGLOptions opts;
856     bool valid = rd.get(opts);
857     if (valid)
858     {
859         switch (_pm)
860         {
861             case (MLRenderingData::PR_POINTS):
862                 {
863                     opts._perpoint_fixed_color_enabled = isChecked();
864                     opts._perpoint_fixed_color = _coluser;
865                     break;
866                 }
867             case (MLRenderingData::PR_WIREFRAME_TRIANGLES):
868             case (MLRenderingData::PR_WIREFRAME_EDGES):
869                 {
870                     opts._perwire_fixed_color_enabled = isChecked();
871                     opts._perwire_fixed_color = _coluser;
872                     break;
873                 }
874             case (MLRenderingData::PR_SOLID):
875                 {
876                     opts._persolid_fixed_color_enabled = isChecked();
877                     opts._persolid_fixed_color = _coluser;
878                     break;
879                 }
880             default:
881                 break;
882         }
883         rd.set(opts);
884     }
885 }
886 
isRenderingDataEnabled(const MLRenderingData & rd) const887 bool MLRenderingUserDefinedColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
888 {
889     MLPerViewGLOptions opts;
890     bool valid = rd.get(opts);
891     if (valid)
892     {
893         switch (_pm)
894         {
895             case (MLRenderingData::PR_POINTS):
896                 {
897                     return opts._perpoint_fixed_color_enabled;
898                 }
899             case (MLRenderingData::PR_WIREFRAME_TRIANGLES):
900             case (MLRenderingData::PR_WIREFRAME_EDGES):
901                 {
902                     return opts._perwire_fixed_color_enabled;
903 
904                 }
905             case (MLRenderingData::PR_SOLID):
906                 {
907                     return opts._persolid_fixed_color_enabled;
908                 }
909             default:
910                 break;
911         }
912     }
913     return false;
914 }
915 
readColor(const MLRenderingData & rd,vcg::Color4b & col)916 void MLRenderingUserDefinedColorAction::readColor(const MLRenderingData& rd, vcg::Color4b& col)
917 {
918 	MLPerViewGLOptions opts;
919 	bool valid = rd.get(opts);
920 	if (valid)
921 	{
922 		switch (_pm)
923 		{
924 			case (MLRenderingData::PR_POINTS):
925 				{
926 					col = opts._perpoint_fixed_color;
927 					break;
928 				}
929 			case (MLRenderingData::PR_WIREFRAME_TRIANGLES):
930 			case (MLRenderingData::PR_WIREFRAME_EDGES):
931 				{
932 					col = opts._perwire_fixed_color;
933 					break;
934 				}
935 			case (MLRenderingData::PR_SOLID):
936 				{
937 					col = opts._persolid_fixed_color;
938 					break;
939 				}
940 			default:
941 				break;
942 		}
943 	}
944 }
945 
MLRenderingSelectionAction(QObject * parent)946 MLRenderingSelectionAction::MLRenderingSelectionAction( QObject* parent )
947     :MLRenderingAction(-1,parent)
948 {
949     setIcon(QIcon(":/images/selected.png"));
950     setText(QString("Selection"));
951 }
952 
MLRenderingSelectionAction(int meshid,QObject * parent)953 MLRenderingSelectionAction::MLRenderingSelectionAction( int meshid,QObject* parent )
954     :MLRenderingAction(meshid,parent)
955 {
956     setIcon(QIcon(":/images/selected.png"));
957     setText(QString("Selection"));
958 }
959 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)960 void MLRenderingSelectionAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
961 {
962 	sisteract = new MLRenderingSelectionAction(meshId(), par);
963 }
964 
updateRenderingData(MLRenderingData & rd)965 void MLRenderingSelectionAction::updateRenderingData( MLRenderingData& rd )
966 {
967     MLPerViewGLOptions opts;
968     bool valid = rd.get(opts);
969     if (valid)
970     {
971         opts._sel_enabled = isChecked();
972         rd.set(opts);
973     }
974 }
975 
isRenderingDataEnabled(const MLRenderingData & rd) const976 bool MLRenderingSelectionAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
977 {
978     MLPerViewGLOptions opts;
979     bool valid = rd.get(opts);
980     return (valid && opts._sel_enabled);
981 }
982 
MLRenderingPointsDotAction(QObject * parent)983 MLRenderingPointsDotAction::MLRenderingPointsDotAction( QObject* parent )
984     :MLRenderingAction(-1,parent)
985 {
986     setText("Dot");
987 }
988 
MLRenderingPointsDotAction(int meshid,QObject * parent)989 MLRenderingPointsDotAction::MLRenderingPointsDotAction( int meshid,QObject* parent )
990     :MLRenderingAction(meshid,parent)
991 {
992     setText("Dot");
993 }
994 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)995 void MLRenderingPointsDotAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
996 {
997 	sisteract = new MLRenderingPointsDotAction(meshId(), par);
998 }
999 
updateRenderingData(MLRenderingData & rd)1000 void MLRenderingPointsDotAction::updateRenderingData( MLRenderingData& rd )
1001 {
1002     MLPerViewGLOptions opts;
1003     bool valid = rd.get(opts);
1004     if (valid)
1005     {
1006         opts._perpoint_dot_enabled = isChecked();
1007         rd.set(opts);
1008     }
1009 }
1010 
isRenderingDataEnabled(const MLRenderingData & rd) const1011 bool MLRenderingPointsDotAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1012 {
1013     MLPerViewGLOptions opts;
1014     bool valid = rd.get(opts);
1015     return (valid && opts._perpoint_dot_enabled);
1016 }
1017 
MLRenderingVertSelectionAction(QObject * parent)1018 MLRenderingVertSelectionAction::MLRenderingVertSelectionAction( QObject* parent )
1019     :MLRenderingAction(-1,parent)
1020 {
1021     setText("Vert Selection");
1022 
1023 }
1024 
MLRenderingVertSelectionAction(int meshid,QObject * parent)1025 MLRenderingVertSelectionAction::MLRenderingVertSelectionAction( int meshid,QObject* parent )
1026     :MLRenderingAction(meshid,parent)
1027 {
1028     setText("Vert Selection");
1029 }
1030 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1031 void MLRenderingVertSelectionAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1032 {
1033 	sisteract = new MLRenderingVertSelectionAction(meshId(), par);
1034 }
1035 
updateRenderingData(MLRenderingData & rd)1036 void MLRenderingVertSelectionAction::updateRenderingData( MLRenderingData& rd )
1037 {
1038     MLPerViewGLOptions opts;
1039     bool valid = rd.get(opts);
1040     if (valid)
1041     {
1042         opts._vertex_sel = isChecked();
1043         rd.set(opts);
1044     }
1045 }
1046 
isRenderingDataEnabled(const MLRenderingData & rd) const1047 bool MLRenderingVertSelectionAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1048 {
1049     MLPerViewGLOptions opts;
1050     bool valid = rd.get(opts);
1051     return (valid && opts._vertex_sel);
1052 }
1053 
MLRenderingFaceSelectionAction(QObject * parent)1054 MLRenderingFaceSelectionAction::MLRenderingFaceSelectionAction( QObject* parent )
1055     :MLRenderingAction(-1,parent)
1056 {
1057     setText("Face Selection");
1058 
1059 }
1060 
MLRenderingFaceSelectionAction(int meshid,QObject * parent)1061 MLRenderingFaceSelectionAction::MLRenderingFaceSelectionAction( int meshid,QObject* parent )
1062     :MLRenderingAction(meshid,parent)
1063 {
1064     setText("Face Selection");
1065 }
1066 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1067 void MLRenderingFaceSelectionAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1068 {
1069 	sisteract = new MLRenderingFaceSelectionAction(meshId(), par);
1070 }
1071 
updateRenderingData(MLRenderingData & rd)1072 void MLRenderingFaceSelectionAction::updateRenderingData( MLRenderingData& rd )
1073 {
1074     MLPerViewGLOptions opts;
1075     bool valid = rd.get(opts);
1076     if (valid)
1077     {
1078         opts._face_sel = isChecked();
1079         rd.set(opts);
1080     }
1081 }
1082 
isRenderingDataEnabled(const MLRenderingData & rd) const1083 bool MLRenderingFaceSelectionAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1084 {
1085     MLPerViewGLOptions opts;
1086     bool valid = rd.get(opts);
1087     return (valid && opts._face_sel);
1088 }
1089 
MLRenderingBBoxPerMeshColorAction(QObject * parent)1090 MLRenderingBBoxPerMeshColorAction::MLRenderingBBoxPerMeshColorAction( QObject* parent )
1091     :MLRenderingAction(-1,parent)
1092 {
1093     setText("Mesh");
1094 }
1095 
MLRenderingBBoxPerMeshColorAction(int meshid,QObject * parent)1096 MLRenderingBBoxPerMeshColorAction::MLRenderingBBoxPerMeshColorAction( int meshid,QObject* parent )
1097     :MLRenderingAction(meshid,parent)
1098 {
1099     setText("Mesh");
1100 }
1101 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1102 void MLRenderingBBoxPerMeshColorAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1103 {
1104 	sisteract = new MLRenderingBBoxPerMeshColorAction(meshId(), par);
1105 }
1106 
updateRenderingData(MLRenderingData & rd)1107 void MLRenderingBBoxPerMeshColorAction::updateRenderingData( MLRenderingData& rd )
1108 {
1109     MLPerViewGLOptions opts;
1110     bool valid = rd.get(opts);
1111     if (valid)
1112     {
1113         opts._perbbox_mesh_color_enabled = isChecked();
1114         rd.set(opts);
1115     }
1116 }
1117 
isRenderingDataEnabled(const MLRenderingData & rd) const1118 bool MLRenderingBBoxPerMeshColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1119 {
1120     MLPerViewGLOptions opts;
1121     bool valid = rd.get(opts);
1122     if (valid)
1123         return opts._perbbox_mesh_color_enabled;
1124     return false;
1125 }
1126 
setColor(const QColor & col)1127 void MLRenderingBBoxPerMeshColorAction::setColor( const QColor& col )
1128 {
1129     _col = vcg::ColorConverter::ToColor4b(col);
1130 }
1131 
setColor(const vcg::Color4b & col)1132 void MLRenderingBBoxPerMeshColorAction::setColor( const vcg::Color4b& col )
1133 {
1134     _col = col;
1135 }
1136 
MLRenderingBBoxUserDefinedColorAction(QObject * parent)1137 MLRenderingBBoxUserDefinedColorAction::MLRenderingBBoxUserDefinedColorAction( QObject* parent )
1138     :MLRenderingUserDefinedGeneralColorAction(-1,parent)
1139 {
1140     setText("User-Def");
1141 }
1142 
MLRenderingBBoxUserDefinedColorAction(int meshid,QObject * parent)1143 MLRenderingBBoxUserDefinedColorAction::MLRenderingBBoxUserDefinedColorAction( int meshid,QObject* parent )
1144     : MLRenderingUserDefinedGeneralColorAction(meshid,parent)
1145 {
1146     setText("User-Def");
1147 }
1148 
MLRenderingBBoxUserDefinedColorAction(MLRenderingBBoxUserDefinedColorAction * origin,QObject * par)1149 MLRenderingBBoxUserDefinedColorAction::MLRenderingBBoxUserDefinedColorAction(MLRenderingBBoxUserDefinedColorAction* origin, QObject * par)
1150 	: MLRenderingUserDefinedGeneralColorAction(origin->meshId(), par)
1151 {
1152 	setText(origin->text());
1153 	_coluser = origin->_coluser;
1154 }
1155 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1156 void MLRenderingBBoxUserDefinedColorAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1157 {
1158 	sisteract = new MLRenderingBBoxUserDefinedColorAction(this, par);
1159 }
1160 
updateRenderingData(MLRenderingData & rd)1161 void MLRenderingBBoxUserDefinedColorAction::updateRenderingData( MLRenderingData& rd )
1162 {
1163     MLPerViewGLOptions opts;
1164     bool valid = rd.get(opts);
1165     if (valid)
1166     {
1167         opts._perbbox_fixed_color_enabled = isChecked();
1168         opts._perbbox_fixed_color = _coluser;
1169         rd.set(opts);
1170     }
1171 }
1172 
isRenderingDataEnabled(const MLRenderingData & rd) const1173 bool MLRenderingBBoxUserDefinedColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1174 {
1175     MLPerViewGLOptions opts;
1176     bool valid = rd.get(opts);
1177     if (valid)
1178         return opts._perbbox_fixed_color_enabled;
1179     return false;
1180 }
1181 
readColor(const MLRenderingData & rd,vcg::Color4b & col)1182 void MLRenderingBBoxUserDefinedColorAction::readColor(const MLRenderingData& rd, vcg::Color4b& col)
1183 {
1184 	MLPerViewGLOptions opts;
1185 	bool valid = rd.get(opts);
1186 	if (valid)
1187 		col = opts._perbbox_fixed_color;
1188 }
1189 
MLRenderingEdgeDecoratorAction(QObject * parent)1190 MLRenderingEdgeDecoratorAction::MLRenderingEdgeDecoratorAction( QObject* parent )
1191     :MLRenderingAction(-1,parent)
1192 {
1193     setIcon(QIcon(":/images/border.png"));
1194     setText("Edge Decorators");
1195 }
1196 
MLRenderingEdgeDecoratorAction(int meshid,QObject * parent)1197 MLRenderingEdgeDecoratorAction::MLRenderingEdgeDecoratorAction( int meshid,QObject* parent )
1198     :MLRenderingAction(meshid,parent)
1199 {
1200     setIcon(QIcon(":/images/border.png"));
1201     setText("Edge Decorators");
1202 }
1203 
1204 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1205 void MLRenderingEdgeDecoratorAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1206 {
1207 	sisteract = new MLRenderingEdgeDecoratorAction(meshId(), par);
1208 }
1209 
updateRenderingData(MLRenderingData & rd)1210 void MLRenderingEdgeDecoratorAction::updateRenderingData( MLRenderingData& rd )
1211 {
1212     MLPerViewGLOptions opts;
1213     bool valid = rd.get(opts);
1214     if (valid)
1215     {
1216         opts._peredge_extra_enabled = isChecked();
1217         rd.set(opts);
1218     }
1219 }
1220 
isRenderingDataEnabled(const MLRenderingData & rd) const1221 bool MLRenderingEdgeDecoratorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1222 {
1223     MLPerViewGLOptions opts;
1224     bool valid = rd.get(opts);
1225     if (valid)
1226         return opts._peredge_extra_enabled;
1227     return false;
1228 }
1229 
MLRenderingEdgeBoundaryAction(QObject * parent)1230 MLRenderingEdgeBoundaryAction::MLRenderingEdgeBoundaryAction( QObject* parent )
1231     :MLRenderingAction(-1,parent)
1232 {
1233      setText("Edges Boundary");
1234 }
1235 
MLRenderingEdgeBoundaryAction(int meshid,QObject * parent)1236 MLRenderingEdgeBoundaryAction::MLRenderingEdgeBoundaryAction( int meshid,QObject* parent )
1237     :MLRenderingAction(meshid,parent)
1238 {
1239      setText("Edges Boundary");
1240 }
1241 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1242 void MLRenderingEdgeBoundaryAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1243 {
1244 	sisteract = new MLRenderingEdgeBoundaryAction(meshId(), par);
1245 }
1246 
updateRenderingData(MLRenderingData & rd)1247 void MLRenderingEdgeBoundaryAction::updateRenderingData( MLRenderingData& rd )
1248 {
1249     MLPerViewGLOptions opts;
1250     bool valid = rd.get(opts);
1251     if (valid)
1252     {
1253         opts._peredge_edgeboundary_enabled = isChecked();
1254         rd.set(opts);
1255     }
1256 }
1257 
isRenderingDataEnabled(const MLRenderingData & rd) const1258 bool MLRenderingEdgeBoundaryAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1259 {
1260     MLPerViewGLOptions opts;
1261     bool valid = rd.get(opts);
1262     if (valid)
1263         return opts._peredge_edgeboundary_enabled;
1264     return false;
1265 }
1266 
MLRenderingFaceBoundaryAction(QObject * parent)1267 MLRenderingFaceBoundaryAction::MLRenderingFaceBoundaryAction( QObject* parent )
1268     :MLRenderingAction(-1,parent)
1269 {
1270     setText("Faces Boundary");
1271 }
1272 
MLRenderingFaceBoundaryAction(int meshid,QObject * parent)1273 MLRenderingFaceBoundaryAction::MLRenderingFaceBoundaryAction( int meshid,QObject* parent )
1274     :MLRenderingAction(meshid,parent)
1275 {
1276     setText("Faces Boundary");
1277 }
1278 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1279 void MLRenderingFaceBoundaryAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1280 {
1281 	sisteract = new MLRenderingFaceBoundaryAction(meshId(), par);
1282 }
1283 
updateRenderingData(MLRenderingData & rd)1284 void MLRenderingFaceBoundaryAction::updateRenderingData( MLRenderingData& rd )
1285 {
1286     MLPerViewGLOptions opts;
1287     bool valid = rd.get(opts);
1288     if (valid)
1289     {
1290         opts._peredge_faceboundary_enabled = isChecked();
1291         rd.set(opts);
1292     }
1293 }
1294 
isRenderingDataEnabled(const MLRenderingData & rd) const1295 bool MLRenderingFaceBoundaryAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1296 {
1297     MLPerViewGLOptions opts;
1298     bool valid = rd.get(opts);
1299     if (valid)
1300         return opts._peredge_faceboundary_enabled;
1301     return false;
1302 }
1303 
MLRenderingEdgeManifoldAction(QObject * parent)1304 MLRenderingEdgeManifoldAction::MLRenderingEdgeManifoldAction( QObject* parent )
1305     :MLRenderingAction(-1,parent)
1306 {
1307     setText("No 2-Manifold Edges Decorator");
1308 }
1309 
MLRenderingEdgeManifoldAction(int meshid,QObject * parent)1310 MLRenderingEdgeManifoldAction::MLRenderingEdgeManifoldAction( int meshid,QObject* parent )
1311     :MLRenderingAction(meshid,parent)
1312 {
1313     setText("No 2-Manifold Edges Decorator");
1314 }
1315 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1316 void MLRenderingEdgeManifoldAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1317 {
1318 	sisteract = new MLRenderingEdgeManifoldAction(meshId(), par);
1319 }
1320 
updateRenderingData(MLRenderingData & rd)1321 void MLRenderingEdgeManifoldAction::updateRenderingData( MLRenderingData& rd )
1322 {
1323     MLPerViewGLOptions opts;
1324     bool valid = rd.get(opts);
1325     if (valid)
1326     {
1327         opts._peredge_edgemanifold_enabled = isChecked();
1328         rd.set(opts);
1329     }
1330 }
1331 
isRenderingDataEnabled(const MLRenderingData & rd) const1332 bool MLRenderingEdgeManifoldAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1333 {
1334     MLPerViewGLOptions opts;
1335     bool valid = rd.get(opts);
1336     if (valid)
1337         return opts._peredge_edgemanifold_enabled;
1338     return false;
1339 }
1340 
MLRenderingVertManifoldAction(QObject * parent)1341 MLRenderingVertManifoldAction::MLRenderingVertManifoldAction( QObject* parent )
1342     :MLRenderingAction(-1,parent)
1343 {
1344     setText("No 2-Manifold Vertices Decorator");
1345 }
1346 
MLRenderingVertManifoldAction(int meshid,QObject * parent)1347 MLRenderingVertManifoldAction::MLRenderingVertManifoldAction( int meshid,QObject* parent )
1348     :MLRenderingAction(meshid,parent)
1349 {
1350     setText("No 2-Manifold Vertices Decorator");
1351 }
1352 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1353 void MLRenderingVertManifoldAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1354 {
1355 	sisteract = new MLRenderingVertManifoldAction(meshId(), par);
1356 }
1357 
updateRenderingData(MLRenderingData & rd)1358 void MLRenderingVertManifoldAction::updateRenderingData( MLRenderingData& rd )
1359 {
1360     MLPerViewGLOptions opts;
1361     bool valid = rd.get(opts);
1362     if (valid)
1363     {
1364         opts._peredge_vertmanifold_enabled = isChecked();
1365         rd.set(opts);
1366     }
1367 }
1368 
isRenderingDataEnabled(const MLRenderingData & rd) const1369 bool MLRenderingVertManifoldAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1370 {
1371     MLPerViewGLOptions opts;
1372     bool valid = rd.get(opts);
1373     if (valid)
1374         return opts._peredge_vertmanifold_enabled;
1375     return false;
1376 }
1377 
MLRenderingTexBorderAction(QObject * parent)1378 MLRenderingTexBorderAction::MLRenderingTexBorderAction( QObject* parent )
1379     :MLRenderingAction(-1,parent)
1380 {
1381     setText("Texture Borders Decorator");
1382 }
1383 
MLRenderingTexBorderAction(int meshid,QObject * parent)1384 MLRenderingTexBorderAction::MLRenderingTexBorderAction( int meshid,QObject* parent )
1385     :MLRenderingAction(meshid,parent)
1386 {
1387     setText("Texture Borders Decorator");
1388 }
1389 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1390 void MLRenderingTexBorderAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1391 {
1392 	sisteract = new MLRenderingTexBorderAction(meshId(), par);
1393 }
1394 
updateRenderingData(MLRenderingData & rd)1395 void MLRenderingTexBorderAction::updateRenderingData( MLRenderingData& rd )
1396 {
1397     MLPerViewGLOptions opts;
1398     bool valid = rd.get(opts);
1399     if (valid)
1400     {
1401         opts._peredge_text_boundary_enabled = isChecked();
1402         rd.set(opts);
1403     }
1404 }
1405 
isRenderingDataEnabled(const MLRenderingData & rd) const1406 bool MLRenderingTexBorderAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1407 {
1408     MLPerViewGLOptions opts;
1409     bool valid = rd.get(opts);
1410     if (valid)
1411         return opts._peredge_text_boundary_enabled;
1412     return false;
1413 }
1414 
MLRenderingDotAction(QObject * parent)1415 MLRenderingDotAction::MLRenderingDotAction( QObject* parent )
1416     :MLRenderingAction(-1,parent)
1417 {
1418     setText("Dot Decorator");
1419 }
1420 
MLRenderingDotAction(int meshid,QObject * parent)1421 MLRenderingDotAction::MLRenderingDotAction( int meshid,QObject* parent )
1422     :MLRenderingAction(meshid,parent)
1423 {
1424     setText("Dot Decorator");
1425 }
1426 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1427 void MLRenderingDotAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1428 {
1429 	sisteract = new MLRenderingDotAction(meshId(), par);
1430 }
1431 
updateRenderingData(MLRenderingData & rd)1432 void MLRenderingDotAction::updateRenderingData( MLRenderingData& rd )
1433 {
1434     MLPerViewGLOptions opts;
1435     bool valid = rd.get(opts);
1436     if (valid)
1437     {
1438         opts._perpoint_dot_enabled = isChecked();
1439         rd.set(opts);
1440     }
1441 }
1442 
isRenderingDataEnabled(const MLRenderingData & rd) const1443 bool MLRenderingDotAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1444 {
1445     MLPerViewGLOptions opts;
1446     bool valid = rd.get(opts);
1447     if (valid)
1448         return opts._perpoint_dot_enabled;
1449     return false;
1450 }
1451 
MLRenderingPointsSizeAction(QObject * parent)1452 MLRenderingPointsSizeAction::MLRenderingPointsSizeAction( QObject* parent )
1453     :MLRenderingFloatAction(-1,parent)
1454 {
1455     setText("Point Size");
1456 }
1457 
MLRenderingPointsSizeAction(int meshid,QObject * parent)1458 MLRenderingPointsSizeAction::MLRenderingPointsSizeAction( int meshid,QObject* parent )
1459     :MLRenderingFloatAction(meshid,parent)
1460 {
1461     setText("Point Size");
1462 }
1463 
MLRenderingPointsSizeAction(MLRenderingPointsSizeAction * origin,QObject * parent)1464 MLRenderingPointsSizeAction::MLRenderingPointsSizeAction(MLRenderingPointsSizeAction* origin, QObject* parent)
1465 	:MLRenderingFloatAction(origin->meshId(),parent)
1466 {
1467 	setText(origin->text());
1468 	_value = origin->_value;
1469 }
1470 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1471 void MLRenderingPointsSizeAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1472 {
1473 	sisteract = new MLRenderingPointsSizeAction(this, par);
1474 }
1475 
updateRenderingData(MLRenderingData & rd)1476 void MLRenderingPointsSizeAction::updateRenderingData( MLRenderingData& rd )
1477 {
1478     MLPerViewGLOptions opts;
1479     bool valid = rd.get(opts);
1480     if (valid)
1481     {
1482         opts._perpoint_pointsize = _value;
1483         rd.set(opts);
1484     }
1485 }
1486 
isRenderingDataEnabled(const MLRenderingData &) const1487 bool MLRenderingPointsSizeAction::isRenderingDataEnabled( const MLRenderingData& /*rd*/ ) const
1488 {
1489     return true;
1490 }
1491 
getValueFromRenderingData(const MLRenderingData & rd) const1492 float MLRenderingPointsSizeAction::getValueFromRenderingData( const MLRenderingData& rd ) const
1493 {
1494     MLPerViewGLOptions opts;
1495     bool valid = rd.get(opts);
1496     if (valid)
1497     {
1498         return opts._perpoint_pointsize;
1499     }
1500     return 0.0f;
1501 }
1502 
MLRenderingWireWidthAction(QObject * parent)1503 MLRenderingWireWidthAction::MLRenderingWireWidthAction( QObject* parent )
1504     :MLRenderingFloatAction(-1,parent)
1505 {
1506     setText("Edge Width");
1507 }
1508 
MLRenderingWireWidthAction(int meshid,QObject * parent)1509 MLRenderingWireWidthAction::MLRenderingWireWidthAction( int meshid,QObject* parent )
1510     :MLRenderingFloatAction(meshid,parent)
1511 {
1512     setText("Edge Width");
1513 }
1514 
MLRenderingWireWidthAction(MLRenderingWireWidthAction * origin,QObject * parent)1515 MLRenderingWireWidthAction::MLRenderingWireWidthAction(MLRenderingWireWidthAction* origin, QObject* parent)
1516 :MLRenderingFloatAction(origin->meshId(), parent)
1517 {
1518 	setText(origin->text());
1519 	_value = origin->_value;
1520 }
1521 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1522 void MLRenderingWireWidthAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1523 {
1524 	sisteract = new MLRenderingWireWidthAction(this, par);
1525 }
1526 
updateRenderingData(MLRenderingData & rd)1527 void MLRenderingWireWidthAction::updateRenderingData( MLRenderingData& rd )
1528 {
1529     MLPerViewGLOptions opts;
1530     bool valid = rd.get(opts);
1531     if (valid)
1532     {
1533         opts._perwire_wirewidth = _value;
1534         rd.set(opts);
1535     }
1536 }
1537 
isRenderingDataEnabled(const MLRenderingData &) const1538 bool MLRenderingWireWidthAction::isRenderingDataEnabled( const MLRenderingData& /*rd*/ ) const
1539 {
1540     return true;
1541 }
1542 
getValueFromRenderingData(const MLRenderingData & rd) const1543 float MLRenderingWireWidthAction::getValueFromRenderingData( const MLRenderingData& rd ) const
1544 {
1545     MLPerViewGLOptions opts;
1546     bool valid = rd.get(opts);
1547     if (valid)
1548     {
1549         return opts._perwire_wirewidth;
1550     }
1551     return 0.0f;
1552 }
1553 
MLRenderingFloatAction(QObject * parent)1554 MLRenderingFloatAction::MLRenderingFloatAction( QObject* parent )
1555     :MLRenderingAction(-1,parent)
1556 {
1557 
1558 
1559 }
1560 
MLRenderingFloatAction(int meshid,QObject * parent)1561 MLRenderingFloatAction::MLRenderingFloatAction(int meshid, QObject* parent )
1562     :MLRenderingAction(meshid,parent)
1563 {
1564 
1565 
1566 }
1567 
MLRenderingBBoxQuotedInfoAction(QObject * parent)1568 MLRenderingBBoxQuotedInfoAction::MLRenderingBBoxQuotedInfoAction( QObject* parent )
1569     :MLRenderingAction(-1,parent)
1570 {
1571 
1572 }
1573 
MLRenderingBBoxQuotedInfoAction(int meshid,QObject * parent)1574 MLRenderingBBoxQuotedInfoAction::MLRenderingBBoxQuotedInfoAction( int meshid,QObject* parent )
1575     :MLRenderingAction(meshid,parent)
1576 {
1577 
1578 }
1579 
createSisterAction(MLRenderingAction * & sisteract,QObject * par)1580 void MLRenderingBBoxQuotedInfoAction::createSisterAction(MLRenderingAction *& sisteract, QObject * par)
1581 {
1582 	sisteract = new MLRenderingBBoxQuotedInfoAction(meshId(), par);
1583 }
1584 
updateRenderingData(MLRenderingData & rd)1585 void MLRenderingBBoxQuotedInfoAction::updateRenderingData( MLRenderingData& rd )
1586 {
1587     MLPerViewGLOptions opts;
1588     bool valid = rd.get(opts);
1589     if (valid)
1590     {
1591         opts._perbbox_quoted_info_enabled = isChecked();
1592         rd.set(opts);
1593     }
1594 }
1595 
isRenderingDataEnabled(const MLRenderingData & rd) const1596 bool MLRenderingBBoxQuotedInfoAction::isRenderingDataEnabled( const MLRenderingData& rd ) const
1597 {
1598     MLPerViewGLOptions opts;
1599     bool valid = rd.get(opts);
1600     if (valid)
1601         return opts._perbbox_quoted_info_enabled;
1602     return false;
1603 }
1604 
MLRenderingGlobalAction(const QString & text,const QIcon & icon,QObject * par)1605 MLRenderingGlobalAction::MLRenderingGlobalAction(const QString& text, const QIcon& icon, QObject* par)
1606 	:QAction(QIcon(icon),text,par)
1607 {
1608 
1609 }
1610 
addMainAction(MLRenderingAction * act)1611 void MLRenderingGlobalAction::addMainAction(MLRenderingAction* act)
1612 {
1613 	_mainactions.push_back(act);
1614 }
1615 
addRelatedAction(MLRenderingAction * act)1616 void MLRenderingGlobalAction::addRelatedAction(MLRenderingAction* act)
1617 {
1618 	_relatedactions.push_back(act);
1619 }
1620 
mainActions()1621 QList<MLRenderingAction*>& MLRenderingGlobalAction::mainActions()
1622 {
1623 	return _mainactions;
1624 }
1625 
relatedActions()1626 QList<MLRenderingAction*>& MLRenderingGlobalAction::relatedActions()
1627 {
1628 	return _relatedactions;
1629 }
1630