Developer documentation | Axl-2.5.1

axlInspectorToolCreateMiddlePoint.cpp
Go to the documentation of this file.
1 /* axlInspectorToolCreatorLine.cpp ---
2  *
3  * Author: Julien Wintz
4  * Copyright (C) 2008 - Julien Wintz, Inria.
5  * Created: Wed Mar 16 17:19:51 2011 (+0100)
6  * Version: $Id$
7  * Last-Updated: Wed Mar 16 17:38:31 2011 (+0100)
8  * By: Julien Wintz
9  * Update #: 31
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
23 
24 #include <axlCore/axlPoint.h>
25 #include <axlCore/axlLine.h>
27 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
28 #include <dtkCoreSupport/dtkAbstractProcess.h>
29 #include <dtkGuiSupport/dtkColorButton.h>
30 
31 #include <axlCore/axlDataDynamic.h>
32 #include <axlCore/axlLineCreator.h>
33 
34 #include <QtGui>
35 
36 class axlInspectorToolCreatorLinePrivate
37 {
38 public:
39  QSlider *sliderOpacity;
40  dtkColorButton *colorButton;
41  axlInspectorObjectController *controller;
42 
43  QDoubleSpinBox *spinBoxCoordinateFirst_x;
44  QDoubleSpinBox *spinBoxCoordinateFirst_y;
45  QDoubleSpinBox *spinBoxCoordinateFirst_z;
46 
47  QDoubleSpinBox *spinBoxCoordinateSecond_x;
48  QDoubleSpinBox *spinBoxCoordinateSecond_y;
49  QDoubleSpinBox *spinBoxCoordinateSecond_z;
50 };
51 
52 axlInspectorToolCreatorLine::axlInspectorToolCreatorLine(QWidget *parent) : QFrame(parent), d(new axlInspectorToolCreatorLinePrivate)
53 {
54  QVBoxLayout *layout = new QVBoxLayout(this);
55 
56 
57  QPushButton *button = new QPushButton("Create", this);
58  connect(button, SIGNAL(clicked()), this, SLOT(run()));
59 
60  layout->addWidget(new QLabel("axlInspectorToolCreatorLine", this));
61  layout->addWidget(button);
62 }
63 
65 {
66  delete d;
67 
68  d = NULL;
69 }
70 
72 {
73  d->controller = controller;
74 }
75 
77 {
78  // WARNING THESE POINT IS ONLY REFERENCED BY THE LINE : risk of memory leek when the line will be deleted
79  axlPoint *firstPoint = new axlPoint(d->spinBoxCoordinateFirst_x->value(), d->spinBoxCoordinateFirst_y->value(), d->spinBoxCoordinateFirst_z->value());
80  axlPoint *secondPoint = new axlPoint(d->spinBoxCoordinateSecond_x->value(), d->spinBoxCoordinateSecond_y->value(), d->spinBoxCoordinateSecond_z->value());
81  axlDataDynamic *dynamicLine = new axlDataDynamic();
82  axlLineCreator *lineCreator = new axlLineCreator();
83  dynamicLine->setProcess(lineCreator);
84  dynamicLine->setInput(firstPoint);
85  dynamicLine->setInput(secondPoint);
86  dynamicLine->update();
87 
88 
89  axlLine* line = dynamic_cast<axlLine *>(dynamicLine->output());
90  line->setParent(dynamicLine);
91 // axlLine* line = new axlLine(firstPoint, secondPoint);
92  line->setColor(d->colorButton->color());
93  double opacity = 1.0 - 0.01 * d->sliderOpacity->value();
94  line->setOpacity(opacity);
95  emit dataInserted(line);
96 
97 }
98 
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
Class axlLine defines 3D lines.
Definition: axlLine.h:35
void setController(axlInspectorObjectController *controller)
void dataInserted(axlAbstractData *data)
Class axlDataDynamic defines a dynamic object.
void setOpacity(const double &opacity)
void setColor(double r, double g, double b)