55 #include "TypeBSplineCurve.hh" 58 #include <OpenFlipper/common/BackupData.hh> 60 #include "BSplineCurveBackup.hh" 66 TypeBSplineCurvePlugin::
67 TypeBSplineCurvePlugin():
68 renderControlPolygonAction_(0),
69 renderCurveAction_(0),
70 renderCPSelectionAction_(0),
71 renderKnotSelectionAction_(0),
72 renderNoSelectionAction_(0)
85 if ( OpenFlipper::Options::gui() ){
87 QMenu* contextMenu =
new QMenu(
"Rendering");
89 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
92 renderControlPolygonAction_ =
new QAction(tr(
"Render Control Polygon"),
this);
93 renderControlPolygonAction_->setStatusTip(tr(
"Render Control Polygon"));
95 renderControlPolygonAction_->setCheckable(
true);
96 renderControlPolygonAction_->setChecked(
false);
99 renderCurveAction_ =
new QAction(tr(
"Render Curve"),
this);
100 renderCurveAction_->setStatusTip(tr(
"Render Curve"));
102 renderCurveAction_->setCheckable(
true);
103 renderCurveAction_->setChecked(
true);
105 QActionGroup* group =
new QActionGroup(
this);
106 group->setExclusive(
true);
109 renderCPSelectionAction_ =
new QAction(tr(
"Render Control Point Selection"), group);
110 renderCPSelectionAction_->setStatusTip(tr(
"Render Control Point Selection"));
112 renderCPSelectionAction_->setCheckable(
true);
113 renderCPSelectionAction_->setChecked(
true);
116 renderKnotSelectionAction_ =
new QAction(tr(
"Render Knot Selection"), group);
117 renderKnotSelectionAction_->setStatusTip(tr(
"Render Knot Selection"));
119 renderKnotSelectionAction_->setCheckable(
true);
120 renderKnotSelectionAction_->setChecked(
true);
123 renderNoSelectionAction_ =
new QAction(tr(
"Don't Render Selection"), group);
124 renderNoSelectionAction_->setStatusTip(tr(
"Don't Render Selection"));
126 renderNoSelectionAction_->setCheckable(
true);
127 renderNoSelectionAction_->setChecked(
true);
130 connect(renderControlPolygonAction_, SIGNAL(triggered()),
this, SLOT(slotRenderControlPolygon()) );
131 connect(renderCurveAction_, SIGNAL(triggered()),
this, SLOT(slotRenderCurve()) );
133 connect(group, SIGNAL(triggered(QAction*)),
this, SLOT(slotRenderSelection(QAction*)));
135 contextMenu->addAction(renderControlPolygonAction_);
136 contextMenu->addAction(renderCurveAction_);
137 contextMenu->addSeparator();
138 contextMenu->addAction(renderCPSelectionAction_);
139 contextMenu->addAction(renderKnotSelectionAction_);
140 contextMenu->addAction(renderNoSelectionAction_);
151 if ( _objectId == -1)
160 if(bsplineCurveObject != 0){
161 renderControlPolygonAction_->setChecked( bsplineCurveObject->
splineCurveNode()->render_control_polygon() );
162 renderCurveAction_->setChecked( bsplineCurveObject->
splineCurveNode()->render_bspline_curve() );
173 QVariant contextObject = renderControlPolygonAction_->data();
174 int objectId = contextObject.toInt();
185 if(bsplineCurveObject != 0){
186 bsplineCurveObject->
splineCurveNode()->render_control_polygon(renderControlPolygonAction_->isChecked());
195 QVariant contextObject = renderCurveAction_->data();
196 int objectId = contextObject.toInt();
207 if(bsplineCurveObject != 0){
208 bsplineCurveObject->
splineCurveNode()->render_bspline_curve(renderCurveAction_->isChecked());
217 QVariant contextObject = _action->data();
218 int objectId = contextObject.toInt();
229 if(bsplineCurveObject != 0){
230 if(_action == renderCPSelectionAction_) {
233 }
else if(_action == renderKnotSelectionAction_) {
236 }
else if(_action == renderNoSelectionAction_) {
246 TypeBSplineCurvePlugin::
250 setTypeIcon(
"BSplineCurve",
"BSplineCurveType.png");
275 object->target(
true);
280 object->target(
true);
284 object->target(
true);
287 QString
name =
"BSplineCurve_" + QString::number( object->
id() ) +
".bsc";
291 object->setName( f.fileName() );
294 const QColor color = OpenFlipper::Options::defaultColor();
295 const ACG::Vec4f default_color(color.redF(), color.greenF(), color.blueF(), color.alphaF());
296 object->materialNode()->set_color(default_color);
304 emit emptyObjectAdded (object->
id() );
311 void TypeBSplineCurvePlugin::generateBackup(
int _id, QString _name,
UpdateType _type ){
318 if ( splineObj != 0 ){
324 backupData = dynamic_cast< BackupData* >(object->
objectData(OBJECT_BACKUPS));
328 object->setObjectData(OBJECT_BACKUPS, backupData);
int addEmpty()
Create an empty object.
BSplineCurveObject * bsplineCurveObject(BaseObjectData *_object)
Cast an BaseObject to a BSplineCurveObject if possible.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
int objectCount()
Get the number of available objects.
void pluginsInitialized()
Second initialization phase.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void storeBackup(BaseBackup *_backup)
store a backup
QString name()
Get the backups name)
DLLEXPORT DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
Abstract class that is used to store backups.
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
#define DATA_BSPLINE_CURVE
void slotRenderControlPolygon()
Slot triggered from context menu, if the control polygon should be rendered.
int targetCount()
Get the number of target objects.
ACG::SceneGraph::BSplineCurveNodeT< BSplineCurve > * splineCurveNode()
Get the scenegraph Node.
void slotRenderSelection(QAction *_action)
Slot triggered from context menu, if the selection rendering should be altered.
Class that encapsulates a backup.
void slotUpdateContextMenu(int _objectId)
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.
void slotRenderCurve()
Slot triggered from context menu, if the curve should be rendered.
bool hasObjectData(QString _dataName)
Checks if object data with given name is available.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
QString getObjectinfo()
Get all Info for the Object as a string.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )