From 5d4844fbf08140657bad92b60bd7db8d8950942e Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Thu, 23 Oct 2008 12:34:56 +0000 Subject: [PATCH] renamed ***Dialog to ***Widget using MeshlabEditDockWidget as parent class --- ...ingDialog.cpp => PhotoTexturingWidget.cpp} | 69 +++-- ...xturingDialog.h => PhotoTexturingWidget.h} | 20 +- .../ui/photoTexturingDialog.ui | 246 ----------------- .../ui/photoTexturingWidget.ui | 251 ++++++++++++++++++ 4 files changed, 307 insertions(+), 279 deletions(-) rename src/meshlabplugins/edit_phototexturing/{PhotoTexturingDialog.cpp => PhotoTexturingWidget.cpp} (80%) rename src/meshlabplugins/edit_phototexturing/{PhotoTexturingDialog.h => PhotoTexturingWidget.h} (85%) delete mode 100644 src/meshlabplugins/edit_phototexturing/ui/photoTexturingDialog.ui create mode 100644 src/meshlabplugins/edit_phototexturing/ui/photoTexturingWidget.ui diff --git a/src/meshlabplugins/edit_phototexturing/PhotoTexturingDialog.cpp b/src/meshlabplugins/edit_phototexturing/PhotoTexturingWidget.cpp similarity index 80% rename from src/meshlabplugins/edit_phototexturing/PhotoTexturingDialog.cpp rename to src/meshlabplugins/edit_phototexturing/PhotoTexturingWidget.cpp index 31ecf862e..9af224e36 100644 --- a/src/meshlabplugins/edit_phototexturing/PhotoTexturingDialog.cpp +++ b/src/meshlabplugins/edit_phototexturing/PhotoTexturingWidget.cpp @@ -24,21 +24,24 @@ #include #include #include -#include +#include #include #include #include -PhotoTexturingDialog::PhotoTexturingDialog(MeshEditInterface* plugin, PhotoTexturer* texturer,MeshModel &m,GLArea *gla): QDialog() { - +PhotoTexturingWidget::PhotoTexturingWidget(MeshEditInterface* plugin, PhotoTexturer* texturer,MeshModel &m,GLArea *gla): MeshlabEditDockWidget(gla) { + connect(this,SIGNAL(updateGLAreaTextures()),gla,SLOT(updateTexture())); connect(this,SIGNAL(setGLAreaTextureMode(vcg::GLW::TextureMode)),gla,SLOT(setTextureMode(vcg::GLW::TextureMode))); connect(this,SIGNAL(updateMainWindowMenus()),gla,SIGNAL(updateMainWindowMenus())); ptPlugin = plugin; photoTexturer = texturer; - PhotoTexturingDialog::ui.setupUi(this); - + PhotoTexturingWidget::ui.setupUi(this); + this->setWidget(ui.main_frame); + this->setFeatures(QDockWidget::AllDockWidgetFeatures); + this->setAllowedAreas(Qt::LeftDockWidgetArea); + this->setFloating(true); mesh = &m; glarea = gla; @@ -58,6 +61,8 @@ PhotoTexturingDialog::PhotoTexturingDialog(MeshEditInterface* plugin, PhotoTextu connect(ui.assignImagePushButton, SIGNAL(clicked()),this,SLOT(assignImage())); connect(ui.calculateTexturesPushButton, SIGNAL(clicked()),this,SLOT(calculateTextures())); connect(ui.combineTexturesPushButton, SIGNAL(clicked()),this,SLOT(combineTextures())); + connect(ui.unprojectTexturePushButton, SIGNAL(clicked()),this,SLOT(unprojectTextures())); + connect(ui.textureListWidget, SIGNAL(itemClicked(QListWidgetItem* )),this,SLOT(selectCurrentTexture())); connect(ui.applyPushButton, SIGNAL(clicked()),this,SLOT(apply())); @@ -71,31 +76,30 @@ PhotoTexturingDialog::PhotoTexturingDialog(MeshEditInterface* plugin, PhotoTextu } -PhotoTexturingDialog::~PhotoTexturingDialog(){ +PhotoTexturingWidget::~PhotoTexturingWidget(){ } -void PhotoTexturingDialog::loadConfigurationFile(){ +void PhotoTexturingWidget::loadConfigurationFile(){ QString filename = QFileDialog::getOpenFileName(this,tr("Select Configuration File"),".", "*.ptcfg"); ui.calibrationFileLineEdit->setText(filename); photoTexturer->loadConfigurationFile(filename); update(); } -void PhotoTexturingDialog::saveConfigurationFile(){ +void PhotoTexturingWidget::saveConfigurationFile(){ QString filename = QFileDialog::getSaveFileName(this,tr("Select Configuration File"),".", "*.ptcfg"); ui.calibrationFileLineEdit->setText(filename); photoTexturer->saveConfigurationFile(filename); } -void PhotoTexturingDialog::addCamera(){ - //QString filename = QFileDialog::getOpenFileName(this,tr("Select Calibration File"),".", "Cameras (*.tsai *.kai)"); - QString filename = QFileDialog::getOpenFileName(this,tr("Select Calibration File"),".", "Cameras (*.tsai)"); +void PhotoTexturingWidget::addCamera(){ + QString filename = QFileDialog::getOpenFileName(this,tr("Select Calibration File"),".", "Cameras (*.cam)"); photoTexturer->addCamera(filename); update(); ui.cameraTableWidget->selectRow(ui.cameraTableWidget->rowCount()-1); } -void PhotoTexturingDialog::removeCamera(){ +void PhotoTexturingWidget::removeCamera(){ //int selectedRow = ui.cameraTableWidget->sel QList list = ui.cameraTableWidget->selectedItems(); if (list.size()>0){ @@ -108,7 +112,7 @@ void PhotoTexturingDialog::removeCamera(){ } -void PhotoTexturingDialog::update(){ +void PhotoTexturingWidget::update(){ int rowcount = photoTexturer->cameras.size(); ui.cameraTableWidget->setRowCount((rowcount)); int i; @@ -138,13 +142,20 @@ void PhotoTexturingDialog::update(){ if (vcg::tri::HasPerFaceAttribute(mesh->cm,PhotoTexturer::ORIGINALUVTEXTURECOORDS) && vcg::tri::HasPerFaceAttribute(mesh->cm,PhotoTexturer::CAMERAUVTEXTURECOORDS)){ + ui.unprojectTexturePushButton->setDisabled(false); + }else{ + ui.unprojectTexturePushButton->setDisabled(true); + } + + if (vcg::tri::HasPerFaceAttribute(mesh->cm,PhotoTexturer::CAMERAUVTEXTURECOORDS)){ ui.combineTexturesPushButton->setDisabled(false); }else{ ui.combineTexturesPushButton->setDisabled(true); } + } -void PhotoTexturingDialog::assignImage(){ +void PhotoTexturingWidget::assignImage(){ QString filename = QFileDialog::getOpenFileName(this,tr("Select Image File"),".", "Images (*.png *.jpg *.bmp)"); QList list = ui.cameraTableWidget->selectedItems(); if (list.size()>0){ @@ -156,7 +167,7 @@ void PhotoTexturingDialog::assignImage(){ } } -void PhotoTexturingDialog::calculateTextures(){ +void PhotoTexturingWidget::calculateTextures(){ photoTexturer->calculateMeshTextureForAllCameras(mesh); glarea->update(); update(); @@ -166,15 +177,25 @@ void PhotoTexturingDialog::calculateTextures(){ updateMainWindowMenus(); } -void PhotoTexturingDialog::selectCurrentTexture(){ +void PhotoTexturingWidget::selectCurrentTexture(){ int icam = ui.textureListWidget->currentRow(); photoTexturer->applyTextureToMesh(mesh,icam); setGLAreaTextureMode(vcg::GLW::TMPerWedgeMulti); + updateMainWindowMenus(); glarea->update(); } -void PhotoTexturingDialog::combineTextures(){ +void PhotoTexturingWidget::combineTextures(){ + photoTexturer->combineTextures(mesh); + setGLAreaTextureMode(vcg::GLW::TMPerWedgeMulti); + updateMainWindowMenus(); + glarea->update(); + + +} + +void PhotoTexturingWidget::unprojectTextures(){ FilterParameterSet combineParamSet; combineParamSet.addInt("width",1024,"Image width:",""); combineParamSet.addInt("height",1024,"Image height:",""); @@ -194,30 +215,30 @@ void PhotoTexturingDialog::combineTextures(){ GenericParamDialog ad(this,&combineParamSet,"Texture Baking Parameters"); int result=ad.exec(); if (result == 1){ - photoTexturer->combineTextures(mesh,combineParamSet.getInt("width"),combineParamSet.getInt("height"),combineParamSet.getInt("edgeStretchingPasses"),combineParamSet.getBool("enable_angle_map"),combineParamSet.getInt("angle_map_weight"),combineParamSet.getInt("angle_map_sharpness"),combineParamSet.getFloat("min_angle"),combineParamSet.getBool("enable_distance_map"),combineParamSet.getInt("distance_map_weight")); + photoTexturer->unprojectTextures(mesh,combineParamSet.getInt("width"),combineParamSet.getInt("height"),combineParamSet.getInt("edgeStretchingPasses"),combineParamSet.getBool("enable_angle_map"),combineParamSet.getInt("angle_map_weight"),combineParamSet.getInt("angle_map_sharpness"),combineParamSet.getFloat("min_angle"),combineParamSet.getBool("enable_distance_map"),combineParamSet.getInt("distance_map_weight")); } update(); } -void PhotoTexturingDialog::apply(){ +void PhotoTexturingWidget::apply(){ } -void PhotoTexturingDialog::close(){ +void PhotoTexturingWidget::close(){ //glarea->endEdit(); //ptPlugin->EndEdit(NULL,NULL,NULL); } -void PhotoTexturingDialog::cancel(){ +void PhotoTexturingWidget::cancel(){ photoTexturer->restoreOriginalTextureCoordinates(mesh); glarea->update(); } -void PhotoTexturingDialog::exportCamerasToMaxScript(){ +void PhotoTexturingWidget::exportCamerasToMaxScript(){ QString filename = QFileDialog::getSaveFileName(this,tr("Select MaxScript File"),".", "*.ms"); photoTexturer->exportMaxScript(filename,mesh); } -void PhotoTexturingDialog::convertToTsaiCamera(){ - QString filename = QFileDialog::getSaveFileName(this,tr("Select Tsai Calibration File"),".", "*.tsai"); +void PhotoTexturingWidget::convertToTsaiCamera(){ + QString filename = QFileDialog::getSaveFileName(this,tr("Select Tsai Calibration File"),".", "*.cam"); QList list = ui.cameraTableWidget->selectedItems(); bool optimize; diff --git a/src/meshlabplugins/edit_phototexturing/PhotoTexturingDialog.h b/src/meshlabplugins/edit_phototexturing/PhotoTexturingWidget.h similarity index 85% rename from src/meshlabplugins/edit_phototexturing/PhotoTexturingDialog.h rename to src/meshlabplugins/edit_phototexturing/PhotoTexturingWidget.h index bde1d5b2c..695210802 100644 --- a/src/meshlabplugins/edit_phototexturing/PhotoTexturingDialog.h +++ b/src/meshlabplugins/edit_phototexturing/PhotoTexturingWidget.h @@ -21,25 +21,26 @@ * * ****************************************************************************/ -#ifndef PHOTOTEXTURINGDIALOG_H_ -#define PHOTOTEXTURINGDIALOG_H_ +#ifndef PHOTOTEXTURINGWIDGET_H_ +#define PHOTOTEXTURINGWIDGET_H_ -#include +#include #include #include #include +#include //#include #include -#include "ui_photoTexturingDialog.h" +#include "ui_photoTexturingWidget.h" -class PhotoTexturingDialog: public QDialog, Ui::photoTexturingDialog{ +class PhotoTexturingWidget: public MeshlabEditDockWidget, Ui::photoTexturingWidget{ Q_OBJECT private: MeshModel *mesh; GLArea *glarea; - Ui::photoTexturingDialog ui; + Ui::photoTexturingWidget ui; MeshEditInterface *ptPlugin; PhotoTexturer *photoTexturer; @@ -67,14 +68,15 @@ private slots: void calculateTextures(); void selectCurrentTexture(); void combineTextures(); + void unprojectTextures(); void apply(); void close(); void cancel(); public: - PhotoTexturingDialog(MeshEditInterface*, PhotoTexturer*,MeshModel &m, GLArea *gla); - ~PhotoTexturingDialog(); + PhotoTexturingWidget(MeshEditInterface*, PhotoTexturer*,MeshModel &m, GLArea *gla); + ~PhotoTexturingWidget(); }; -#endif /*PHOTOTEXTURINGDIALOG_H_*/ +#endif /*PHOTOTEXTURINGWIDGET_H_*/ diff --git a/src/meshlabplugins/edit_phototexturing/ui/photoTexturingDialog.ui b/src/meshlabplugins/edit_phototexturing/ui/photoTexturingDialog.ui deleted file mode 100644 index 0ca48703b..000000000 --- a/src/meshlabplugins/edit_phototexturing/ui/photoTexturingDialog.ui +++ /dev/null @@ -1,246 +0,0 @@ - - photoTexturingDialog - - - - 0 - 0 - 580 - 360 - - - - - 0 - 0 - - - - - 580 - 360 - - - - - 580 - 360 - - - - Photo texturing - - - - - 10 - 0 - 561 - 351 - - - - - - - - 0 - 0 - - - - Cameras: - - - false - - - false - - - - - 390 - 20 - 161 - 221 - - - - - 6 - - - 0 - - - - - Textures: - - - - - - - - - - Calculate UV Coords. - - - - - - - Combine Textures - - - - - - - - - 10 - 20 - 377 - 221 - - - - - - - - 0 - 0 - - - - QAbstractItemView::SelectRows - - - 2 - - - - Camera - - - - - Texture - - - - - - - - 6 - - - - - Add Camera - - - - - - - Remove Camera - - - - - - - Assign Image - - - - - - - Convert to Tsai - - - - - - - - - - - - - - - Photo texturing Configuration File: - - - - - - - - - - - - Load - - - - - - - Save - - - - - - - export to MaxScript - - - - - - - - - - - - - Apply Texture to Mesh - - - - - - - Restore Original Texture - - - - - - - Close - - - - - - - - - - - diff --git a/src/meshlabplugins/edit_phototexturing/ui/photoTexturingWidget.ui b/src/meshlabplugins/edit_phototexturing/ui/photoTexturingWidget.ui new file mode 100644 index 000000000..8e9b839ed --- /dev/null +++ b/src/meshlabplugins/edit_phototexturing/ui/photoTexturingWidget.ui @@ -0,0 +1,251 @@ + + photoTexturingWidget + + + + 0 + 0 + 627 + 422 + + + + Photo Texturing + + + + + 10 + 10 + 611 + 371 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 591 + 351 + + + + + + + + 0 + 0 + + + + Cameras: + + + false + + + false + + + + + 420 + 20 + 161 + 221 + + + + + 6 + + + 0 + + + + + Textures: + + + + + + + + + + Calculate UV Coords. + + + + + + + Combine Textures + + + + + + + Unproject Texture + + + + + + + + + 40 + 20 + 377 + 221 + + + + + + + + 0 + 0 + + + + QAbstractItemView::SelectRows + + + 2 + + + + Camera + + + + + Texture + + + + + + + + 6 + + + + + Add Camera + + + + + + + Remove Camera + + + + + + + Assign Image + + + + + + + Convert to Tsai + + + + + + + + + + + + + + + Photo texturing Configuration File: + + + + + + + + + + + + Load + + + + + + + Save + + + + + + + export to MaxScript + + + + + + + + + + + + + Apply Texture to Mesh + + + + + + + Restore Original Texture + + + + + + + Close + + + + + + + + + + + +