53 #if QT_VERSION >= 0x050000
64 savePrecisionLabel_(0),
67 saveDefaultButton_(0),
81 return QString( tr(
"Stereolithography files ( *.stl *.stla *.stlb )") );
87 return QString( tr(
"Stereolithography files ( *.stl *.stla *.stlb )") );
108 object->target(
true);
110 object->setFromFileName(_filename);
111 object->setName(object->
filename());
113 std::string filename = std::string( _filename.toUtf8() );
115 object->mesh()->request_face_normals();
117 bool loadNormals( (loadFaceNormal_ && loadFaceNormal_->isChecked()) ||
131 std::cerr <<
"Plugin FileSTL : Read error for stl mesh.\n";
132 emit deleteObject( object->
id() );
138 if (!loadNormals || !opt.face_has_normal())
139 object->
mesh()->update_normals();
141 if (object->
mesh()->has_vertex_normals())
142 object->
mesh()->update_vertex_normals();
143 if (object->
mesh()->has_halfedge_normals())
144 object->
mesh()->update_halfedge_normals();
149 emit openedFile( object->
id() );
154 emit log(
LOGERR,
"Error : Could not create new triangle mesh object.");
161 bool FileSTLPlugin::saveObject(
int _id, QString _filename)
165 emit log(
LOGERR, tr(
"saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
169 std::string filename = std::string( _filename.toUtf8() );
173 object->setFromFileName(_filename);
174 object->setName(object->
filename());
180 std::streamsize precision = 6;
181 if ( !OpenFlipper::Options::savingSettings() && saveOptions_ != 0){
183 if (!OpenFlipper::Options::nogui() && saveBinary_->isChecked())
186 if (!saveBinary_->isChecked())
187 precision = savePrecision_->value();
192 emit log(
LOGINFO, tr(
"Saved object to ") + _filename );
195 emit log(
LOGERR, tr(
"Unable to save ") + _filename );
199 emit log(
LOGERR, tr(
"Unable to save (object is not a triangle mesh type)"));
208 if (saveOptions_ == 0){
210 saveOptions_ =
new QWidget();
211 QVBoxLayout* layout =
new QVBoxLayout();
212 layout->setAlignment(Qt::AlignTop);
214 saveBinary_ =
new QCheckBox(
"Save Binary");
215 layout->addWidget(saveBinary_);
217 savePrecisionLabel_ =
new QLabel(
"Writer Precision");
218 layout->addWidget(savePrecisionLabel_);
220 savePrecision_ =
new QSpinBox();
221 savePrecision_->setMinimum(1);
222 savePrecision_->setMaximum(12);
223 savePrecision_->setValue(6);
224 layout->addWidget(savePrecision_);
226 saveDefaultButton_ =
new QPushButton(
"Make Default");
227 layout->addWidget(saveDefaultButton_);
229 saveOptions_->setLayout(layout);
231 saveBinary_->setChecked(
OpenFlipperSettings().value(
"FileSTL/Save/Binary",
false ).toBool() );
233 connect(saveBinary_, SIGNAL(clicked(
bool)), savePrecision_, SLOT(setDisabled(
bool)));
234 connect(saveDefaultButton_, SIGNAL(clicked()),
this, SLOT(
slotSaveDefault()));
245 if (loadOptions_ == 0){
247 loadOptions_ =
new QWidget();
248 QVBoxLayout* layout =
new QVBoxLayout();
249 layout->setAlignment(Qt::AlignTop);
251 loadFaceNormal_ =
new QCheckBox(
"Load Face Normals");
252 layout->addWidget(loadFaceNormal_);
254 loadFaceNormal_->setChecked(
OpenFlipperSettings().value(
"FileSTL/Load/FaceNormal",
true).toBool() );
256 loadDefaultButton_ =
new QPushButton(
"Make Default");
257 layout->addWidget(loadDefaultButton_);
259 loadOptions_->setLayout(layout);
261 connect(loadDefaultButton_, SIGNAL(clicked()),
this, SLOT(
slotLoadDefault()));
279 #if QT_VERSION < 0x050000
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
MeshT * mesh()
return a pointer to the mesh
int loadObject(QString _filename)
Loads Object as triangle mesh.
FileSTLPlugin()
Constructor.
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
QString filename() const
return the filename of the object
Type for a MeshObject containing a triangle mesh.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool getObject(int _identifier, BSplineCurveObject *&_object)
Has (r) / store (w) face normals.
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
bool dataType(DataType _type) const
Set options for reader/writer modules.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
QWidget * saveOptionsWidget(QString)
QWidget * loadOptionsWidget(QString)
void initializePlugin()
Initialize Plugin.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
int objectCount()
Get the number of available objects.
bool write_mesh(const Mesh &_mesh, const std::string &_filename, Options _opt=Options::Default, std::streamsize _precision=6)
Write a mesh to the file _filename.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
#define DATA_TRIANGLE_MESH