From 29d23b06b89f798e458f13267cdabedff548c8e3 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Fri, 2 Dec 2005 17:40:26 +0000 Subject: [PATCH] added dialog obj exporter. --- src/meshlabplugins/meshio/savemaskdialog.cpp | 144 ++++++++++++++++++ src/meshlabplugins/meshio/savemaskdialog.h | 63 ++++++++ src/meshlabplugins/meshio/ui_savemask.h | 150 +++++++++++++++++++ 3 files changed, 357 insertions(+) create mode 100644 src/meshlabplugins/meshio/savemaskdialog.cpp create mode 100644 src/meshlabplugins/meshio/savemaskdialog.h create mode 100644 src/meshlabplugins/meshio/ui_savemask.h diff --git a/src/meshlabplugins/meshio/savemaskdialog.cpp b/src/meshlabplugins/meshio/savemaskdialog.cpp new file mode 100644 index 000000000..3ceb97f58 --- /dev/null +++ b/src/meshlabplugins/meshio/savemaskdialog.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +* MeshLab o o * +* An extendible mesh processor o o * +* _ O _ * +* Copyright(C) 2005, 2006 \/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +/**************************************************************************** + History + + $Log$ + Revision 1.1 2005/12/02 17:40:26 fmazzant + added dialog obj exporter. + + +*****************************************************************************/ + +#include "savemaskdialog.h" +#include +#include +#include + +SaveMaskDialog::SaveMaskDialog(QWidget *parent): QDialog(parent) +{ + SaveMaskDialog::ui.setupUi(this); + connect(ui.okButton, SIGNAL(clicked()), this, SLOT(SlotOkButton())); + connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(SlotCancelButton())); +} + +//slot +void SaveMaskDialog::SlotOkButton() +{ + Mask mymask; + mymask.binary = SaveMaskDialog::ui.binaryButton->isChecked(); + mymask.faces = SaveMaskDialog::ui.faceCheck->isChecked(); + mymask.normal = SaveMaskDialog::ui.normalCheck->isChecked(); + mymask.texture = SaveMaskDialog::ui.textureCheck->isChecked(); + mymask.vertexs = SaveMaskDialog::ui.vertexCheck->isChecked(); + mymask.colorV = SaveMaskDialog::ui.vertexCheck->isChecked(); + mymask.material = SaveMaskDialog::ui.vertexCheck->isChecked(); + if(WriteMask(&mymask)) + accept(); + else + QMessageBox::warning(new QWidget(),"Error","Parameters not valid!"); +} + +void SaveMaskDialog::SlotCancelButton() +{ + +} + + + +//member +bool SaveMaskDialog::ReadMask() +{ + Mask mask; + std::ifstream in("./mask.ini"); + if (in.fail()){return false;} + std::string line; + std::getline(in, line, '\n'); + bool ok = false; + + if(line.size()==Mask::args) + { + mask.binary = QString(line.at(0)).toInt(&ok, 10); + mask.faces = QString(line.at(1)).toInt(&ok, 10); + mask.normal = QString(line.at(2)).toInt(&ok, 10); + mask.texture = QString(line.at(3)).toInt(&ok, 10); + mask.vertexs = QString(line.at(4)).toInt(&ok, 10); + mask.colorV = QString(line.at(5)).toInt(&ok, 10); + mask.material = QString(line.at(6)).toInt(&ok, 10); + } + else + { + mask.binary = 0; + mask.faces = 0; + mask.normal = 0; + mask.texture = 0; + mask.vertexs = 0; + mask.colorV = 0; + mask.material = 0; + } + + SaveMaskDialog::ui.binaryButton->setChecked((bool)mask.binary); + SaveMaskDialog::ui.asciiButton->setChecked(!((bool)mask.binary)); + SaveMaskDialog::ui.faceCheck->setChecked((bool)mask.faces); + SaveMaskDialog::ui.normalCheck->setChecked((bool)mask.normal); + SaveMaskDialog::ui.textureCheck->setChecked((bool)mask.texture); + SaveMaskDialog::ui.vertexCheck->setChecked((bool)mask.vertexs); + SaveMaskDialog::ui.colorVertexCheck->setChecked((bool)mask.colorV); + SaveMaskDialog::ui.materialCheck->setChecked((bool)mask.material); + + in.close(); + return true; +} + + +//static +Mask SaveMaskDialog::GetMask() +{ + Mask mask; + std::ifstream in("./mask.ini"); + if (in.fail()){return mask;} + std::string line; + std::getline(in, line, '\n'); + bool ok = false; + mask.binary = QString(line.at(0)).toInt(&ok, 10); + mask.faces = QString(line.at(1)).toInt(&ok, 10); + mask.normal = QString(line.at(2)).toInt(&ok, 10); + mask.texture = QString(line.at(3)).toInt(&ok, 10); + mask.vertexs = QString(line.at(4)).toInt(&ok, 10); + mask.colorV = QString(line.at(5)).toInt(&ok, 10); + mask.material = QString(line.at(6)).toInt(&ok, 10); + return mask; +} + +bool SaveMaskDialog::WriteMask(Mask *mask) +{ + std::ofstream out("./mask.ini"); + if (out.fail()){return false;} + out << mask->binary << mask->faces << mask->normal << mask->texture << mask->vertexs << mask->colorV << mask->material << std::endl; + out.close(); + return true; +} +int SaveMaskDialog::MaskToInt(Mask *mask) +{ + return -1; +} \ No newline at end of file diff --git a/src/meshlabplugins/meshio/savemaskdialog.h b/src/meshlabplugins/meshio/savemaskdialog.h new file mode 100644 index 000000000..52e4d2833 --- /dev/null +++ b/src/meshlabplugins/meshio/savemaskdialog.h @@ -0,0 +1,63 @@ +/**************************************************************************** +* MeshLab o o * +* An extendible mesh processor o o * +* _ O _ * +* Copyright(C) 2005, 2006 \/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +/**************************************************************************** + History + + $Log$ + Revision 1.1 2005/12/02 17:40:26 fmazzant + added dialog obj exporter. + + +*****************************************************************************/ + +#include "ui_savemask.h" +struct Mask +{ + int vertexs;//salva i vertici 1, non li salva 0 + int faces;//salva le facce 1, non li salva 0 + int texture;//salva le texture 1, non li salva 0 + int normal;//salva le normali 1, non li salva 0 + int binary;//salva in binario 1, salva in ascii 0 + int colorV;//salva colore vertici 1, non li salva 0 + int material;//salva il materiale 1, non lo salva 0 + const static int args = 7; +}; + +class SaveMaskDialog : public QDialog +{ + Q_OBJECT +public: + SaveMaskDialog(QWidget *parent); + bool ReadMask(); + + static Mask GetMask(); + static bool WriteMask(Mask *mask); + static int MaskToInt(Mask *mask); //converte la Mask nell'intero definito come maschera. + +private slots: + void SlotOkButton(); + void SlotCancelButton(); + +private: + Ui::Dialog ui; +}; \ No newline at end of file diff --git a/src/meshlabplugins/meshio/ui_savemask.h b/src/meshlabplugins/meshio/ui_savemask.h new file mode 100644 index 000000000..0d44098be --- /dev/null +++ b/src/meshlabplugins/meshio/ui_savemask.h @@ -0,0 +1,150 @@ +#ifndef UI_SAVEMASK_H +#define UI_SAVEMASK_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Ui_Dialog +{ +public: + QWidget *horizontalLayout; + QWidget *layoutWidget; + QWidget *widget; + QWidget *widget_2; + QWidget *widget_3; + QGroupBox *groupBox_2; + QVBoxLayout *vboxLayout; + QRadioButton *binaryButton; + QRadioButton *asciiButton; + QPushButton *okButton; + QPushButton *cancelButton; + QGroupBox *groupBox_3; + QGridLayout *gridLayout; + QCheckBox *faceCheck; + QCheckBox *normalCheck; + QCheckBox *materialCheck; + QCheckBox *textureCheck; + QCheckBox *vertexCheck; + QCheckBox *colorVertexCheck; + + void setupUi(QDialog *Dialog) + { + Dialog->setObjectName(QString::fromUtf8("Dialog")); + Dialog->resize(QSize(357, 150).expandedTo(Dialog->minimumSizeHint())); + horizontalLayout = new QWidget(Dialog); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + horizontalLayout->setGeometry(QRect(20, 150, 361, 31)); + layoutWidget = new QWidget(Dialog); + layoutWidget->setObjectName(QString::fromUtf8("layoutWidget")); + layoutWidget->setGeometry(QRect(20, 250, 351, 33)); + widget = new QWidget(Dialog); + widget->setObjectName(QString::fromUtf8("widget")); + widget->setGeometry(QRect(10, 10, 341, 241)); + widget_2 = new QWidget(Dialog); + widget_2->setObjectName(QString::fromUtf8("widget_2")); + widget_2->setGeometry(QRect(11, 94, 339, 125)); + widget_3 = new QWidget(Dialog); + widget_3->setObjectName(QString::fromUtf8("widget_3")); + widget_3->setGeometry(QRect(11, 225, 339, 25)); + groupBox_2 = new QGroupBox(Dialog); + groupBox_2->setObjectName(QString::fromUtf8("groupBox_2")); + groupBox_2->setGeometry(QRect(250, 0, 95, 78)); + vboxLayout = new QVBoxLayout(groupBox_2); + vboxLayout->setSpacing(6); + vboxLayout->setMargin(8); + vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); + binaryButton = new QRadioButton(groupBox_2); + binaryButton->setObjectName(QString::fromUtf8("binaryButton")); + + vboxLayout->addWidget(binaryButton); + + asciiButton = new QRadioButton(groupBox_2); + asciiButton->setObjectName(QString::fromUtf8("asciiButton")); + + vboxLayout->addWidget(asciiButton); + + okButton = new QPushButton(Dialog); + okButton->setObjectName(QString::fromUtf8("okButton")); + okButton->setGeometry(QRect(250, 90, 101, 23)); + cancelButton = new QPushButton(Dialog); + cancelButton->setObjectName(QString::fromUtf8("cancelButton")); + cancelButton->setGeometry(QRect(250, 120, 101, 23)); + groupBox_3 = new QGroupBox(Dialog); + groupBox_3->setObjectName(QString::fromUtf8("groupBox_3")); + groupBox_3->setGeometry(QRect(10, 0, 231, 141)); + gridLayout = new QGridLayout(groupBox_3); + gridLayout->setSpacing(6); + gridLayout->setMargin(8); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + faceCheck = new QCheckBox(groupBox_3); + faceCheck->setObjectName(QString::fromUtf8("faceCheck")); + + gridLayout->addWidget(faceCheck, 2, 1, 1, 1); + + normalCheck = new QCheckBox(groupBox_3); + normalCheck->setObjectName(QString::fromUtf8("normalCheck")); + + gridLayout->addWidget(normalCheck, 2, 0, 1, 1); + + materialCheck = new QCheckBox(groupBox_3); + materialCheck->setObjectName(QString::fromUtf8("materialCheck")); + + gridLayout->addWidget(materialCheck, 0, 1, 1, 1); + + textureCheck = new QCheckBox(groupBox_3); + textureCheck->setObjectName(QString::fromUtf8("textureCheck")); + + gridLayout->addWidget(textureCheck, 1, 1, 1, 1); + + vertexCheck = new QCheckBox(groupBox_3); + vertexCheck->setObjectName(QString::fromUtf8("vertexCheck")); + + gridLayout->addWidget(vertexCheck, 0, 0, 1, 1); + + colorVertexCheck = new QCheckBox(groupBox_3); + colorVertexCheck->setObjectName(QString::fromUtf8("colorVertexCheck")); + + gridLayout->addWidget(colorVertexCheck, 1, 0, 1, 1); + + retranslateUi(Dialog); + QObject::connect(cancelButton, SIGNAL(clicked()), Dialog, SLOT(reject())); + QObject::connect(okButton, SIGNAL(clicked()), Dialog, SLOT(accept())); + + QMetaObject::connectSlotsByName(Dialog); + } // setupUi + + void retranslateUi(QDialog *Dialog) + { + Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8)); + groupBox_2->setTitle(QApplication::translate("Dialog", "Type Save", 0, QApplication::UnicodeUTF8)); + binaryButton->setText(QApplication::translate("Dialog", "Binary Obj", 0, QApplication::UnicodeUTF8)); + asciiButton->setText(QApplication::translate("Dialog", "ASCII Obj", 0, QApplication::UnicodeUTF8)); + okButton->setText(QApplication::translate("Dialog", "OK", 0, QApplication::UnicodeUTF8)); + cancelButton->setText(QApplication::translate("Dialog", "Cancel", 0, QApplication::UnicodeUTF8)); + groupBox_3->setTitle(QApplication::translate("Dialog", "Information Save", 0, QApplication::UnicodeUTF8)); + faceCheck->setText(QApplication::translate("Dialog", "Faces", 0, QApplication::UnicodeUTF8)); + normalCheck->setText(QApplication::translate("Dialog", "Normals Vertex", 0, QApplication::UnicodeUTF8)); + materialCheck->setText(QApplication::translate("Dialog", "Materials", 0, QApplication::UnicodeUTF8)); + textureCheck->setText(QApplication::translate("Dialog", "Texture Coords", 0, QApplication::UnicodeUTF8)); + vertexCheck->setText(QApplication::translate("Dialog", "Vertexs", 0, QApplication::UnicodeUTF8)); + colorVertexCheck->setText(QApplication::translate("Dialog", "Vertexs Color", 0, QApplication::UnicodeUTF8)); + Q_UNUSED(Dialog); + } // retranslateUi + +}; + +namespace Ui { + class Dialog: public Ui_Dialog {}; +} // namespace Ui + +#endif // UI_SAVEMASK_H