renamed ***Dialog to ***Widget

using MeshlabEditDockWidget as parent class
This commit is contained in:
Paolo Cignoni cignoni 2008-10-23 12:34:56 +00:00
parent def9db7ece
commit 5d4844fbf0
4 changed files with 307 additions and 279 deletions

View File

@ -24,21 +24,24 @@
#include <QList>
#include <QListWidgetItem>
#include <QListWidget>
#include <PhotoTexturingDialog.h>
#include <PhotoTexturingWidget.h>
#include <meshlab/mainwindow.h>
#include <wrap/gl/trimesh.h>
#include <meshlab/stdpardialog.h>
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 <QTableWidgetItem*>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 <QTableWidgetItem*>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 <QTableWidgetItem*>list = ui.cameraTableWidget->selectedItems();
bool optimize;

View File

@ -21,25 +21,26 @@
* *
****************************************************************************/
#ifndef PHOTOTEXTURINGDIALOG_H_
#define PHOTOTEXTURINGDIALOG_H_
#ifndef PHOTOTEXTURINGWIDGET_H_
#define PHOTOTEXTURINGWIDGET_H_
#include <QDialog>
#include <QDockWidget>
#include <meshlab/meshmodel.h>
#include <meshlab/interfaces.h>
#include <wrap/gl/trimesh.h>
#include <meshlab/meshlabeditdockwidget.h>
//#include <photoTexturing.h>
#include <src/PhotoTexturer.h>
#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_*/

View File

@ -1,246 +0,0 @@
<ui version="4.0" >
<class>photoTexturingDialog</class>
<widget class="QDialog" name="photoTexturingDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>580</width>
<height>360</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>580</width>
<height>360</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>580</width>
<height>360</height>
</size>
</property>
<property name="windowTitle" >
<string>Photo texturing</string>
</property>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>10</x>
<y>0</y>
<width>561</width>
<height>351</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Cameras:</string>
</property>
<property name="flat" >
<bool>false</bool>
</property>
<property name="checkable" >
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>390</x>
<y>20</y>
<width>161</width>
<height>221</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Textures:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="textureListWidget" />
</item>
<item>
<widget class="QPushButton" name="calculateTexturesPushButton" >
<property name="text" >
<string>Calculate UV Coords.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="combineTexturesPushButton" >
<property name="text" >
<string>Combine Textures</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>377</width>
<height>221</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QTableWidget" name="cameraTableWidget" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="columnCount" >
<number>2</number>
</property>
<column>
<property name="text" >
<string>Camera</string>
</property>
</column>
<column>
<property name="text" >
<string>Texture</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="addCameraPushButton" >
<property name="text" >
<string>Add Camera</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeCameraPushButton" >
<property name="text" >
<string>Remove Camera</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="assignImagePushButton" >
<property name="text" >
<string>Assign Image</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="convertToTsaiCameraPushButton" >
<property name="text" >
<string>Convert to Tsai</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Photo texturing Configuration File:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLineEdit" name="calibrationFileLineEdit" />
</item>
<item>
<widget class="QPushButton" name="configurationLoadPushButton" >
<property name="text" >
<string>Load</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="configurationSavePushButton" >
<property name="text" >
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="exportToMaxScriptPushButton" >
<property name="text" >
<string>export to MaxScript</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="applyPushButton" >
<property name="text" >
<string>Apply Texture to Mesh</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelPushButton" >
<property name="text" >
<string>Restore Original Texture</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closePushButton" >
<property name="text" >
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,251 @@
<ui version="4.0" >
<class>photoTexturingWidget</class>
<widget class="QWidget" name="photoTexturingWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>627</width>
<height>422</height>
</rect>
</property>
<property name="windowTitle" >
<string>Photo Texturing</string>
</property>
<widget class="QFrame" name="main_frame" >
<property name="geometry" >
<rect>
<x>10</x>
<y>10</y>
<width>611</width>
<height>371</height>
</rect>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>10</x>
<y>10</y>
<width>591</width>
<height>351</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Cameras:</string>
</property>
<property name="flat" >
<bool>false</bool>
</property>
<property name="checkable" >
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget_2" >
<property name="geometry" >
<rect>
<x>420</x>
<y>20</y>
<width>161</width>
<height>221</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Textures:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="textureListWidget" />
</item>
<item>
<widget class="QPushButton" name="calculateTexturesPushButton" >
<property name="text" >
<string>Calculate UV Coords.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="combineTexturesPushButton" >
<property name="text" >
<string>Combine Textures</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="unprojectTexturePushButton" >
<property name="text" >
<string>Unproject Texture</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_3" >
<property name="geometry" >
<rect>
<x>40</x>
<y>20</y>
<width>377</width>
<height>221</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QTableWidget" name="cameraTableWidget" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="columnCount" >
<number>2</number>
</property>
<column>
<property name="text" >
<string>Camera</string>
</property>
</column>
<column>
<property name="text" >
<string>Texture</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="addCameraPushButton" >
<property name="text" >
<string>Add Camera</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeCameraPushButton" >
<property name="text" >
<string>Remove Camera</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="assignImagePushButton" >
<property name="text" >
<string>Assign Image</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="convertToTsaiCameraPushButton" >
<property name="text" >
<string>Convert to Tsai</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Photo texturing Configuration File:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLineEdit" name="calibrationFileLineEdit" />
</item>
<item>
<widget class="QPushButton" name="configurationLoadPushButton" >
<property name="text" >
<string>Load</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="configurationSavePushButton" >
<property name="text" >
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="exportToMaxScriptPushButton" >
<property name="text" >
<string>export to MaxScript</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="applyPushButton" >
<property name="text" >
<string>Apply Texture to Mesh</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelPushButton" >
<property name="text" >
<string>Restore Original Texture</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closePushButton" >
<property name="text" >
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>