61 #include "TypeBSplineCurve.hh" 64 #include <OpenFlipper/common/BackupData.hh> 66 #include "BSplineCurveBackup.hh" 70 TypeBSplineCurvePlugin::
71 TypeBSplineCurvePlugin():
72 renderControlPolygonAction_(0),
73 renderCurveAction_(0),
74 renderCPSelectionAction_(0),
75 renderKnotSelectionAction_(0),
76 renderNoSelectionAction_(0)
89 if ( OpenFlipper::Options::gui() ){
91 QMenu* contextMenu =
new QMenu(
"Rendering");
93 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
96 renderControlPolygonAction_ =
new QAction(tr(
"Render Control Polygon"),
this);
97 renderControlPolygonAction_->setStatusTip(tr(
"Render Control Polygon"));
99 renderControlPolygonAction_->setCheckable(
true);
100 renderControlPolygonAction_->setChecked(
false);
103 renderCurveAction_ =
new QAction(tr(
"Render Curve"),
this);
104 renderCurveAction_->setStatusTip(tr(
"Render Curve"));
106 renderCurveAction_->setCheckable(
true);
107 renderCurveAction_->setChecked(
true);
109 QActionGroup* group =
new QActionGroup(
this);
110 group->setExclusive(
true);
113 renderCPSelectionAction_ =
new QAction(tr(
"Render Control Point Selection"), group);
114 renderCPSelectionAction_->setStatusTip(tr(
"Render Control Point Selection"));
116 renderCPSelectionAction_->setCheckable(
true);
117 renderCPSelectionAction_->setChecked(
true);
120 renderKnotSelectionAction_ =
new QAction(tr(
"Render Knot Selection"), group);
121 renderKnotSelectionAction_->setStatusTip(tr(
"Render Knot Selection"));
123 renderKnotSelectionAction_->setCheckable(
true);
124 renderKnotSelectionAction_->setChecked(
true);
127 renderNoSelectionAction_ =
new QAction(tr(
"Don't Render Selection"), group);
128 renderNoSelectionAction_->setStatusTip(tr(
"Don't Render Selection"));
130 renderNoSelectionAction_->setCheckable(
true);
131 renderNoSelectionAction_->setChecked(
true);
134 connect(renderControlPolygonAction_, SIGNAL(triggered()),
this, SLOT(slotRenderControlPolygon()) );
135 connect(renderCurveAction_, SIGNAL(triggered()),
this, SLOT(slotRenderCurve()) );
137 connect(group, SIGNAL(triggered(QAction*)),
this, SLOT(slotRenderSelection(QAction*)));
139 contextMenu->addAction(renderControlPolygonAction_);
140 contextMenu->addAction(renderCurveAction_);
141 contextMenu->addSeparator();
142 contextMenu->addAction(renderCPSelectionAction_);
143 contextMenu->addAction(renderKnotSelectionAction_);
144 contextMenu->addAction(renderNoSelectionAction_);
155 if ( _objectId == -1)
164 if(bsplineCurveObject != 0){
165 renderControlPolygonAction_->setChecked( bsplineCurveObject->
splineCurveNode()->render_control_polygon() );
166 renderCurveAction_->setChecked( bsplineCurveObject->
splineCurveNode()->render_bspline_curve() );
177 QVariant contextObject = renderControlPolygonAction_->data();
178 int objectId = contextObject.toInt();
189 if(bsplineCurveObject != 0){
190 bsplineCurveObject->
splineCurveNode()->render_control_polygon(renderControlPolygonAction_->isChecked());
199 QVariant contextObject = renderCurveAction_->data();
200 int objectId = contextObject.toInt();
211 if(bsplineCurveObject != 0){
212 bsplineCurveObject->
splineCurveNode()->render_bspline_curve(renderCurveAction_->isChecked());
221 QVariant contextObject = _action->data();
222 int objectId = contextObject.toInt();
233 if(bsplineCurveObject != 0){
234 if(_action == renderCPSelectionAction_) {
237 }
else if(_action == renderKnotSelectionAction_) {
240 }
else if(_action == renderNoSelectionAction_) {
250 TypeBSplineCurvePlugin::
254 setTypeIcon(
"BSplineCurve",
"BSplineCurveType.png");
279 object->target(
true);
284 object->target(
true);
288 object->target(
true);
291 QString
name =
"BSplineCurve_" + QString::number( object->
id() ) +
".bsc";
295 object->setName( f.fileName() );
298 const QColor color = OpenFlipper::Options::defaultColor();
299 const ACG::Vec4f default_color(color.redF(), color.greenF(), color.blueF(), color.alphaF());
300 object->materialNode()->set_color(default_color);
308 emit emptyObjectAdded (object->
id() );
315 void TypeBSplineCurvePlugin::generateBackup(
int _id, QString _name,
UpdateType _type ){
322 if ( splineObj != 0 ){
328 backupData = dynamic_cast< BackupData* >(object->
objectData(OBJECT_BACKUPS));
332 object->setObjectData(OBJECT_BACKUPS, backupData);
343 #if QT_VERSION < 0x050000 void slotRenderSelection(QAction *_action)
Slot triggered from context menu, if the selection rendering should be altered.
void slotRenderControlPolygon()
Slot triggered from context menu, if the control polygon should be rendered.
bool getObject(int _identifier, BSplineCurveObject *&_object)
The Menu will be shown when an object was picked.
QString getObjectinfo()
Get all Info for the Object as a string.
Abstract class that is used to store backups.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
int addEmpty()
Create an empty object.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
DLLEXPORT DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
void pluginsInitialized()
Second initialization phase.
void slotUpdateContextMenu(int _objectId)
int objectCount()
Get the number of available objects.
void storeBackup(BaseBackup *_backup)
store a backup
BSplineCurveObject * bsplineCurveObject(BaseObjectData *_object)
Cast an BaseObject to a BSplineCurveObject if possible.
ACG::SceneGraph::BSplineCurveNodeT< BSplineCurve > * splineCurveNode()
Get the scenegraph Node.
bool hasObjectData(QString _dataName)
Checks if object data with given name is available.
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
int targetCount()
Get the number of target objects.
#define DATA_BSPLINE_CURVE
QString name()
Get the backups name)
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void slotRenderCurve()
Slot triggered from context menu, if the curve should be rendered.
Class that encapsulates a backup.
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.