mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-16 01:24:36 +00:00
new mesh attribute dialog working, textures are saved when saving a mesh
This commit is contained in:
parent
d8e6343fd5
commit
1a0fc3bb49
@ -130,6 +130,18 @@ std::list<std::string> MeshModel::loadTextures(
|
||||
return unloadedTextures;
|
||||
}
|
||||
|
||||
void MeshModel::saveTextures(
|
||||
const QString& basePath,
|
||||
GLLogStream* log,
|
||||
CallBackPos* cb)
|
||||
{
|
||||
for (const std::string& tname : cm.textures){
|
||||
meshlab::saveImage(
|
||||
basePath + "/" + QString::fromStdString(tname.substr(1)),
|
||||
textures.at(tname), log, cb);
|
||||
}
|
||||
}
|
||||
|
||||
QImage MeshModel::getTexture(const std::string& tn) const
|
||||
{
|
||||
auto it = textures.find(tn);
|
||||
@ -160,6 +172,22 @@ void MeshModel::setTexture(std::string name, const QImage& txt)
|
||||
it->second = txt;
|
||||
}
|
||||
|
||||
void MeshModel::changeTextureName(
|
||||
const std::string& oldName,
|
||||
std::string newName)
|
||||
{
|
||||
auto mit = textures.find(oldName);
|
||||
auto tit = std::find(cm.textures.begin(), cm.textures.end(), oldName);
|
||||
if (mit != textures.end() && tit != cm.textures.end()){
|
||||
if (newName.front() != ':')
|
||||
newName = ":" + newName;
|
||||
*tit = newName;
|
||||
|
||||
textures[newName] = mit->second;
|
||||
textures.erase(mit);
|
||||
}
|
||||
}
|
||||
|
||||
int MeshModel::io2mm(int single_iobit)
|
||||
{
|
||||
switch(single_iobit)
|
||||
|
||||
@ -168,11 +168,13 @@ public:
|
||||
bool isVisible() const { return visible; }
|
||||
|
||||
std::list<std::string> loadTextures(GLLogStream* log = nullptr, vcg::CallBackPos* cb = nullptr);
|
||||
void saveTextures(const QString& basePath, GLLogStream* log = nullptr, vcg::CallBackPos* cb = nullptr);
|
||||
|
||||
QImage getTexture(const std::string& tn) const;
|
||||
void clearTextures();
|
||||
void addTexture(std::string name, const QImage& txt);
|
||||
void setTexture(std::string name, const QImage& txt);
|
||||
void changeTextureName(const std::string& oldName, std::string newName);
|
||||
|
||||
// This function is roughly equivalent to the updateDataMask,
|
||||
// but it takes in input a mask coming from a filetype instead of a filter requirement (like topology etc)
|
||||
|
||||
@ -39,7 +39,7 @@ void IOPluginContainer::pushIOPlugin(IOPlugin* iIO)
|
||||
}
|
||||
}
|
||||
|
||||
//add input raster formats to inputFormatMap
|
||||
//add input image formats to inputFormatMap
|
||||
for (const FileFormat& ff : iIO->importImageFormats()){
|
||||
for (const QString& currentExtension : ff.extensions) {
|
||||
if (! inputImageFormatToPluginMap.contains(currentExtension.toLower())) {
|
||||
@ -47,6 +47,15 @@ void IOPluginContainer::pushIOPlugin(IOPlugin* iIO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//add input raster formats to inputFormatMap
|
||||
for (const FileFormat& ff : iIO->exportImageFormats()){
|
||||
for (const QString& currentExtension : ff.extensions) {
|
||||
if (! outputImageFormatToPluginMap.contains(currentExtension.toLower())) {
|
||||
outputImageFormatToPluginMap.insert(currentExtension.toLower(), iIO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IOPluginContainer::eraseIOPlugin(IOPlugin* iIO)
|
||||
|
||||
@ -32,66 +32,197 @@ SaveMeshAttributesDialog::SaveMeshAttributesDialog(
|
||||
MeshModel *m,
|
||||
int capability,
|
||||
int defaultBits,
|
||||
RichParameterList *_parSet,
|
||||
const RichParameterList& additionalSaveParams,
|
||||
GLArea* glar):
|
||||
QDialog(parent),
|
||||
ui(new Ui::SaveMeshAttributesDialog),
|
||||
m(m),
|
||||
mask(0),
|
||||
capability(capability),
|
||||
defaultBits(defaultBits),
|
||||
parSet(_parSet),
|
||||
mask(0),
|
||||
additionalSaveParametrs(additionalSaveParams),
|
||||
glar(glar)
|
||||
{
|
||||
ui = new Ui::SaveMeshAttributesDialog();
|
||||
InitDialog();
|
||||
}
|
||||
ui->setupUi(this);
|
||||
|
||||
void SaveMeshAttributesDialog::InitDialog()
|
||||
{
|
||||
SaveMeshAttributesDialog::ui->setupUi(this);
|
||||
connect(ui->okButton, SIGNAL(clicked()), this, SLOT(SlotOkButton()));
|
||||
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(SlotCancelButton()));
|
||||
connect(ui->renametextureButton,SIGNAL(clicked()),this,SLOT(SlotRenameTexture()));
|
||||
connect(ui->listTextureName,SIGNAL(itemSelectionChanged()),this,SLOT(SlotSelectionTextureName()));
|
||||
connect(ui->AllButton,SIGNAL(clicked()),this,SLOT(SlotSelectionAllButton()));
|
||||
connect(ui->NoneButton,SIGNAL(clicked()),this,SLOT(SlotSelectionNoneButton()));
|
||||
ui->renametextureButton->setDisabled(true);
|
||||
|
||||
stdParFrame = new RichParameterListFrame(*parSet, this,glar);
|
||||
additionalParametersFrame = new RichParameterListFrame(additionalSaveParametrs, this,glar);
|
||||
QVBoxLayout *vbox = new QVBoxLayout(this);
|
||||
vbox->addWidget(stdParFrame);
|
||||
vbox->addWidget(additionalParametersFrame);
|
||||
ui->saveParBox->setLayout(vbox);
|
||||
QFileInfo fi(m->fullName());
|
||||
this->setWindowTitle("Choose Saving Options for: '"+ fi.baseName() +"'");
|
||||
// Show the additional parameters only for formats that have some.
|
||||
if(parSet->isEmpty()) ui->saveParBox->hide();
|
||||
else ui->saveParBox->show();
|
||||
if(additionalSaveParametrs.isEmpty())
|
||||
ui->saveParBox->hide();
|
||||
else
|
||||
ui->saveParBox->show();
|
||||
//all - none
|
||||
ui->AllButton->setChecked(true);
|
||||
//ui->NoneButton->setChecked(true);
|
||||
|
||||
SetTextureName();
|
||||
SetMaskCapability();
|
||||
if( m->cm.textures.size() == 0 )
|
||||
{
|
||||
ui->check_iom_wedgtexcoord->setDisabled(true);
|
||||
ui->check_iom_wedgtexcoord->setChecked(false);
|
||||
}
|
||||
|
||||
textureNames.reserve(m->cm.textures.size());
|
||||
for(const std::string& tname : m->cm.textures)
|
||||
{
|
||||
textureNames.push_back(tname.substr(1));
|
||||
QString item(tname.substr(1).c_str());
|
||||
ui->listTextureName->addItem(item);
|
||||
}
|
||||
setMaskCapability();
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::SetTextureName()
|
||||
SaveMeshAttributesDialog::~SaveMeshAttributesDialog()
|
||||
{
|
||||
if( m->cm.textures.size() == 0 )
|
||||
{
|
||||
ui->check_iom_wedgtexcoord->setDisabled(true);
|
||||
ui->check_iom_wedgtexcoord->setChecked(false);
|
||||
}
|
||||
|
||||
for(unsigned int i=0;i<m->cm.textures.size();i++)
|
||||
{
|
||||
QString item(m->cm.textures[i].c_str());
|
||||
ui->listTextureName->addItem(item);
|
||||
}
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int SaveMeshAttributesDialog::GetNewMask()
|
||||
void SaveMeshAttributesDialog::selectAllPossibleBits()
|
||||
{
|
||||
return this->mask;
|
||||
on_AllButton_clicked();
|
||||
updateMask();
|
||||
}
|
||||
|
||||
int SaveMeshAttributesDialog::getNewMask() const
|
||||
{
|
||||
return this->mask;
|
||||
}
|
||||
|
||||
RichParameterList SaveMeshAttributesDialog::getNewAdditionalSaveParameters() const
|
||||
{
|
||||
return additionalSaveParametrs;
|
||||
}
|
||||
|
||||
std::vector<std::string> SaveMeshAttributesDialog::getTextureNames() const
|
||||
{
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_okButton_clicked()
|
||||
{
|
||||
updateMask();
|
||||
additionalParametersFrame->writeValuesOnParameterList(additionalSaveParametrs);
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_cancelButton_clicked()
|
||||
{
|
||||
mask=-1;
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_check_help_stateChanged(int)
|
||||
{
|
||||
additionalParametersFrame->toggleHelp();
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_renametextureButton_clicked()
|
||||
{
|
||||
int row = ui->listTextureName->currentRow();
|
||||
ChangeTextureNameDialog dialog(this, textureNames[row].c_str());
|
||||
dialog.exec();
|
||||
std::string newtexture = dialog.GetTextureName();
|
||||
dialog.close();
|
||||
if(newtexture.size()>0) {
|
||||
textureNames[row] = newtexture;
|
||||
ui->listTextureName->currentItem()->setText(newtexture.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_listTextureName_itemSelectionChanged()
|
||||
{
|
||||
ui->renametextureButton->setDisabled(false);
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_AllButton_clicked()
|
||||
{
|
||||
//vert
|
||||
ui->check_iom_vertquality->setChecked(ui->check_iom_vertquality->isEnabled());
|
||||
ui->check_iom_vertflags->setChecked(ui->check_iom_vertflags->isEnabled());
|
||||
ui->check_iom_vertcolor->setChecked(ui->check_iom_vertcolor->isEnabled());
|
||||
ui->check_iom_verttexcoord->setChecked(ui->check_iom_verttexcoord->isEnabled());
|
||||
ui->check_iom_vertnormal->setChecked(ui->check_iom_vertnormal->isEnabled());
|
||||
ui->check_iom_vertradius->setChecked(ui->check_iom_vertradius->isEnabled());
|
||||
|
||||
//face
|
||||
ui->check_iom_facequality->setChecked(ui->check_iom_facequality->isEnabled());
|
||||
ui->check_iom_faceflags->setChecked(ui->check_iom_faceflags->isEnabled());
|
||||
ui->check_iom_facenormal->setChecked(ui->check_iom_facenormal->isEnabled());
|
||||
ui->check_iom_facecolor->setChecked(ui->check_iom_facecolor->isEnabled());
|
||||
|
||||
//wedg
|
||||
ui->check_iom_wedgcolor->setChecked(ui->check_iom_wedgcolor->isEnabled());
|
||||
ui->check_iom_wedgtexcoord->setChecked(ui->check_iom_wedgtexcoord->isEnabled());
|
||||
ui->check_iom_wedgnormal->setChecked(ui->check_iom_wedgnormal->isEnabled());
|
||||
|
||||
//camera
|
||||
ui->check_iom_camera->setChecked(ui->check_iom_camera->isEnabled());
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_NoneButton_clicked()
|
||||
{
|
||||
//vert
|
||||
ui->check_iom_vertquality->setChecked(false);
|
||||
ui->check_iom_vertflags->setChecked(false);
|
||||
ui->check_iom_vertcolor->setChecked(false);
|
||||
ui->check_iom_verttexcoord->setChecked(false);
|
||||
ui->check_iom_vertnormal->setChecked(false);
|
||||
ui->check_iom_vertradius->setChecked(false);
|
||||
|
||||
//face
|
||||
ui->check_iom_facequality->setChecked(false);
|
||||
ui->check_iom_faceflags->setChecked(false);
|
||||
ui->check_iom_facenormal->setChecked(false);
|
||||
ui->check_iom_facecolor->setChecked(false);
|
||||
|
||||
//wedg
|
||||
ui->check_iom_wedgcolor->setChecked(false);
|
||||
ui->check_iom_wedgtexcoord->setChecked(false);
|
||||
ui->check_iom_wedgnormal->setChecked(false);
|
||||
|
||||
//camera
|
||||
ui->check_iom_camera->setChecked(false);
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::setMaskCapability()
|
||||
{
|
||||
//vert
|
||||
checkAndEnable(ui->check_iom_vertquality, vcg::tri::io::Mask::IOM_VERTQUALITY, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_vertflags, vcg::tri::io::Mask::IOM_VERTFLAGS, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_vertcolor, vcg::tri::io::Mask::IOM_VERTCOLOR, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_verttexcoord, vcg::tri::io::Mask::IOM_VERTTEXCOORD, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_vertnormal, vcg::tri::io::Mask::IOM_VERTNORMAL, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_vertradius, vcg::tri::io::Mask::IOM_VERTRADIUS, capability, defaultBits);
|
||||
|
||||
// point cloud fix: if a point cloud, probably you'd want to save vertex normals
|
||||
if ((m->cm.fn == 0) && (m->cm.en == 0))
|
||||
ui->check_iom_vertnormal->setChecked(true);
|
||||
|
||||
//face
|
||||
checkAndEnable(ui->check_iom_facequality, vcg::tri::io::Mask::IOM_FACEQUALITY, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_faceflags, vcg::tri::io::Mask::IOM_FACEFLAGS, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_facecolor, vcg::tri::io::Mask::IOM_FACECOLOR, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_facenormal, vcg::tri::io::Mask::IOM_FACENORMAL, capability, defaultBits );
|
||||
|
||||
//wedge
|
||||
checkAndEnable(ui->check_iom_wedgcolor, vcg::tri::io::Mask::IOM_WEDGCOLOR, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_wedgtexcoord, vcg::tri::io::Mask::IOM_WEDGTEXCOORD, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_wedgnormal, vcg::tri::io::Mask::IOM_WEDGNORMAL, capability, defaultBits );
|
||||
|
||||
checkAndEnable(ui->check_iom_polygonal, vcg::tri::io::Mask::IOM_BITPOLYGONAL, capability, defaultBits );
|
||||
|
||||
//camera THIS ONE HAS TO BE CORRECTED !!!!
|
||||
//bool camval = m->cm.shot.IsValid();
|
||||
//int res = capability & vcg::tri::io::Mask::IOM_CAMERA;
|
||||
ui->check_iom_camera->setDisabled( ((capability & vcg::tri::io::Mask::IOM_CAMERA)==0) || (m->cm.shot.IsValid() == false));
|
||||
ui->check_iom_camera->setChecked ( ((capability & vcg::tri::io::Mask::IOM_CAMERA)!=0) && (m->cm.shot.IsValid()));
|
||||
|
||||
if(capability == 0)
|
||||
ui->NoneButton->setChecked(true);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -100,194 +231,63 @@ int SaveMeshAttributesDialog::GetNewMask()
|
||||
- this->defaultBit
|
||||
|
||||
|
||||
setDisabled(true): uncheckable
|
||||
setDisabled(false) : checkable
|
||||
setDisabled(true): uncheckable
|
||||
setDisabled(false) : checkable
|
||||
|
||||
true : when the information is not present or in the Capability or in the MeshModel Mask
|
||||
false : when the information is present in the Capability and in the Mask MeshModel
|
||||
true : when the information is not present or in the Capability or in the MeshModel Mask
|
||||
false : when the information is present in the Capability and in the Mask MeshModel
|
||||
|
||||
setChecked(true) : checked
|
||||
setChecked(false): unchecked
|
||||
setChecked(true) : checked
|
||||
setChecked(false): unchecked
|
||||
|
||||
true : the information is present both in the Capability and the MeshModel Mask
|
||||
false : otherwise.
|
||||
true : the information is present both in the Capability and the MeshModel Mask
|
||||
false : otherwise.
|
||||
|
||||
*/
|
||||
bool SaveMeshAttributesDialog::shouldBeChecked(int bit, int /*capabilityBits*/, int defaultBits)
|
||||
void SaveMeshAttributesDialog::checkAndEnable(QCheckBox *qcb,int bit, int capabilityBits, int defaultBits)
|
||||
{
|
||||
if(!m->hasDataMask(MeshModel::io2mm(bit))) return false;
|
||||
//if( (bit & meshBits) == 0 ) return false;
|
||||
if( (bit & defaultBits) == 0 ) return false;
|
||||
return true;
|
||||
qcb->setEnabled(shouldBeEnabled (bit,capabilityBits, defaultBits) );
|
||||
qcb->setChecked(shouldBeChecked (bit,capabilityBits, defaultBits) );
|
||||
}
|
||||
|
||||
bool SaveMeshAttributesDialog::shouldBeEnabled(int iobit, int capabilityBits, int /*defaultBits*/)
|
||||
{
|
||||
if( (iobit & capabilityBits) == 0 ) return false;
|
||||
int mmbit = MeshModel::io2mm(iobit);
|
||||
if(!m->hasDataMask(mmbit)) return false;
|
||||
return true;
|
||||
if( (iobit & capabilityBits) == 0 ) return false;
|
||||
int mmbit = MeshModel::io2mm(iobit);
|
||||
if(!m->hasDataMask(mmbit)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::checkAndEnable(QCheckBox *qcb,int bit, int capabilityBits, int defaultBits)
|
||||
bool SaveMeshAttributesDialog::shouldBeChecked(int bit, int /*capabilityBits*/, int defaultBits)
|
||||
{
|
||||
qcb->setEnabled(shouldBeEnabled (bit,capabilityBits, defaultBits) );
|
||||
qcb->setChecked(shouldBeChecked (bit,capabilityBits, defaultBits) );
|
||||
if(!m->hasDataMask(MeshModel::io2mm(bit))) return false;
|
||||
//if( (bit & meshBits) == 0 ) return false;
|
||||
if( (bit & defaultBits) == 0 ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::SetMaskCapability()
|
||||
{
|
||||
//vert
|
||||
checkAndEnable(ui->check_iom_vertquality, vcg::tri::io::Mask::IOM_VERTQUALITY, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_vertflags, vcg::tri::io::Mask::IOM_VERTFLAGS, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_vertcolor, vcg::tri::io::Mask::IOM_VERTCOLOR, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_verttexcoord, vcg::tri::io::Mask::IOM_VERTTEXCOORD, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_vertnormal, vcg::tri::io::Mask::IOM_VERTNORMAL, capability, defaultBits);
|
||||
checkAndEnable(ui->check_iom_vertradius, vcg::tri::io::Mask::IOM_VERTRADIUS, capability, defaultBits);
|
||||
|
||||
// point cloud fix: if a point cloud, probably you'd want to save vertex normals
|
||||
if ((m->cm.fn == 0) && (m->cm.en == 0))
|
||||
ui->check_iom_vertnormal->setChecked(true);
|
||||
|
||||
//face
|
||||
checkAndEnable(ui->check_iom_facequality, vcg::tri::io::Mask::IOM_FACEQUALITY, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_faceflags, vcg::tri::io::Mask::IOM_FACEFLAGS, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_facecolor, vcg::tri::io::Mask::IOM_FACECOLOR, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_facenormal, vcg::tri::io::Mask::IOM_FACENORMAL, capability, defaultBits );
|
||||
|
||||
//wedge
|
||||
checkAndEnable(ui->check_iom_wedgcolor, vcg::tri::io::Mask::IOM_WEDGCOLOR, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_wedgtexcoord, vcg::tri::io::Mask::IOM_WEDGTEXCOORD, capability, defaultBits );
|
||||
checkAndEnable(ui->check_iom_wedgnormal, vcg::tri::io::Mask::IOM_WEDGNORMAL, capability, defaultBits );
|
||||
|
||||
checkAndEnable(ui->check_iom_polygonal, vcg::tri::io::Mask::IOM_BITPOLYGONAL, capability, defaultBits );
|
||||
|
||||
//camera THIS ONE HAS TO BE CORRECTED !!!!
|
||||
//bool camval = m->cm.shot.IsValid();
|
||||
//int res = capability & vcg::tri::io::Mask::IOM_CAMERA;
|
||||
ui->check_iom_camera->setDisabled( ((capability & vcg::tri::io::Mask::IOM_CAMERA)==0) || (m->cm.shot.IsValid() == false));
|
||||
ui->check_iom_camera->setChecked ( ((capability & vcg::tri::io::Mask::IOM_CAMERA)!=0) && (m->cm.shot.IsValid()));
|
||||
|
||||
if(capability == 0)
|
||||
ui->NoneButton->setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
void SaveMeshAttributesDialog::updateMask()
|
||||
{
|
||||
int newmask = 0;
|
||||
int newmask = 0;
|
||||
|
||||
if( ui->check_iom_vertflags->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTFLAGS;}
|
||||
if( ui->check_iom_vertcolor->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTCOLOR;}
|
||||
if( ui->check_iom_vertquality->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTQUALITY;}
|
||||
if( ui->check_iom_verttexcoord->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;}
|
||||
if( ui->check_iom_vertnormal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTNORMAL;}
|
||||
if( ui->check_iom_vertradius->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTRADIUS;}
|
||||
if( ui->check_iom_vertflags->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTFLAGS;}
|
||||
if( ui->check_iom_vertcolor->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTCOLOR;}
|
||||
if( ui->check_iom_vertquality->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTQUALITY;}
|
||||
if( ui->check_iom_verttexcoord->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;}
|
||||
if( ui->check_iom_vertnormal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTNORMAL;}
|
||||
if( ui->check_iom_vertradius->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_VERTRADIUS;}
|
||||
|
||||
if( ui->check_iom_faceflags->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACEFLAGS;}
|
||||
if( ui->check_iom_facecolor->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACECOLOR;}
|
||||
if( ui->check_iom_facequality->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACEQUALITY;}
|
||||
if( ui->check_iom_facenormal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACENORMAL;}
|
||||
if( ui->check_iom_faceflags->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACEFLAGS;}
|
||||
if( ui->check_iom_facecolor->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACECOLOR;}
|
||||
if( ui->check_iom_facequality->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACEQUALITY;}
|
||||
if( ui->check_iom_facenormal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_FACENORMAL;}
|
||||
|
||||
if( ui->check_iom_wedgcolor->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_WEDGCOLOR;}
|
||||
if( ui->check_iom_wedgtexcoord->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_WEDGTEXCOORD;}
|
||||
if( ui->check_iom_wedgnormal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_WEDGNORMAL;}
|
||||
if( ui->check_iom_wedgcolor->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_WEDGCOLOR;}
|
||||
if( ui->check_iom_wedgtexcoord->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_WEDGTEXCOORD;}
|
||||
if( ui->check_iom_wedgnormal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_WEDGNORMAL;}
|
||||
|
||||
if( ui->check_iom_camera->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_CAMERA;}
|
||||
if( ui->check_iom_polygonal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_BITPOLYGONAL;}
|
||||
if( ui->check_iom_camera->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_CAMERA;}
|
||||
if( ui->check_iom_polygonal->isChecked() ) { newmask |= vcg::tri::io::Mask::IOM_BITPOLYGONAL;}
|
||||
|
||||
for(unsigned int i=0;i<m->cm.textures.size();i++)
|
||||
m->cm.textures[i] = ui->listTextureName->item(i)->text().toStdString();
|
||||
this->mask=newmask;
|
||||
}
|
||||
|
||||
//slot
|
||||
void SaveMeshAttributesDialog::SlotOkButton()
|
||||
{
|
||||
updateMask();
|
||||
stdParFrame->writeValuesOnParameterList(*parSet);
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::SlotCancelButton()
|
||||
{
|
||||
this->mask=-1;
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::SlotRenameTexture()
|
||||
{
|
||||
int row = ui->listTextureName->currentRow();
|
||||
ChangeTextureNameDialog dialog(this,m->cm.textures[row].c_str());
|
||||
dialog.exec();
|
||||
std::string newtexture = dialog.GetTextureName();
|
||||
dialog.close();
|
||||
if(newtexture.size()>0)
|
||||
{
|
||||
QStringList lists = QString(newtexture.c_str()).split('/');
|
||||
(ui->listTextureName->currentItem())->setText(lists[lists.size()-1]);
|
||||
}
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::SlotSelectionTextureName()
|
||||
{
|
||||
ui->renametextureButton->setDisabled(false);
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::SlotSelectionAllButton()
|
||||
{
|
||||
//vert
|
||||
ui->check_iom_vertquality->setChecked(ui->check_iom_vertquality->isEnabled());
|
||||
ui->check_iom_vertflags->setChecked(ui->check_iom_vertflags->isEnabled());
|
||||
ui->check_iom_vertcolor->setChecked(ui->check_iom_vertcolor->isEnabled());
|
||||
ui->check_iom_verttexcoord->setChecked(ui->check_iom_verttexcoord->isEnabled());
|
||||
ui->check_iom_vertnormal->setChecked(ui->check_iom_vertnormal->isEnabled());
|
||||
ui->check_iom_vertradius->setChecked(ui->check_iom_vertradius->isEnabled());
|
||||
|
||||
//face
|
||||
ui->check_iom_facequality->setChecked(ui->check_iom_facequality->isEnabled());
|
||||
ui->check_iom_faceflags->setChecked(ui->check_iom_faceflags->isEnabled());
|
||||
ui->check_iom_facenormal->setChecked(ui->check_iom_facenormal->isEnabled());
|
||||
ui->check_iom_facecolor->setChecked(ui->check_iom_facecolor->isEnabled());
|
||||
|
||||
//wedg
|
||||
ui->check_iom_wedgcolor->setChecked(ui->check_iom_wedgcolor->isEnabled());
|
||||
ui->check_iom_wedgtexcoord->setChecked(ui->check_iom_wedgtexcoord->isEnabled());
|
||||
ui->check_iom_wedgnormal->setChecked(ui->check_iom_wedgnormal->isEnabled());
|
||||
|
||||
//camera
|
||||
ui->check_iom_camera->setChecked(ui->check_iom_camera->isEnabled());
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::SlotSelectionNoneButton()
|
||||
{
|
||||
//vert
|
||||
ui->check_iom_vertquality->setChecked(false);
|
||||
ui->check_iom_vertflags->setChecked(false);
|
||||
ui->check_iom_vertcolor->setChecked(false);
|
||||
ui->check_iom_verttexcoord->setChecked(false);
|
||||
ui->check_iom_vertnormal->setChecked(false);
|
||||
ui->check_iom_vertradius->setChecked(false);
|
||||
|
||||
//face
|
||||
ui->check_iom_facequality->setChecked(false);
|
||||
ui->check_iom_faceflags->setChecked(false);
|
||||
ui->check_iom_facenormal->setChecked(false);
|
||||
ui->check_iom_facecolor->setChecked(false);
|
||||
|
||||
//wedg
|
||||
ui->check_iom_wedgcolor->setChecked(false);
|
||||
ui->check_iom_wedgtexcoord->setChecked(false);
|
||||
ui->check_iom_wedgnormal->setChecked(false);
|
||||
|
||||
//camera
|
||||
ui->check_iom_camera->setChecked(false);
|
||||
}
|
||||
|
||||
void SaveMeshAttributesDialog::on_check_help_stateChanged(int)
|
||||
{
|
||||
stdParFrame->toggleHelp();
|
||||
}
|
||||
|
||||
SaveMeshAttributesDialog::~SaveMeshAttributesDialog()
|
||||
{
|
||||
delete ui;
|
||||
this->mask=newmask;
|
||||
}
|
||||
|
||||
@ -50,37 +50,49 @@ class SaveMeshAttributesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SaveMeshAttributesDialog(QWidget *parent, MeshModel *m, int capability, int defaultBits, RichParameterList *par,GLArea* glar = NULL);
|
||||
SaveMeshAttributesDialog(
|
||||
QWidget* parent,
|
||||
MeshModel* m,
|
||||
int capability,
|
||||
int defaultBits,
|
||||
const RichParameterList& additionalSaveParams,
|
||||
GLArea* glar = NULL);
|
||||
~SaveMeshAttributesDialog();
|
||||
|
||||
void InitDialog();
|
||||
void SetTextureName();
|
||||
int GetNewMask();
|
||||
void SetMaskCapability();
|
||||
void updateMask();
|
||||
|
||||
public slots:
|
||||
void selectAllPossibleBits();
|
||||
|
||||
int getNewMask() const;
|
||||
RichParameterList getNewAdditionalSaveParameters() const;
|
||||
std::vector<std::string> getTextureNames() const;
|
||||
|
||||
private slots:
|
||||
void on_okButton_clicked();
|
||||
void on_cancelButton_clicked();
|
||||
void on_check_help_stateChanged(int);
|
||||
void SlotOkButton();
|
||||
void SlotCancelButton();
|
||||
void SlotRenameTexture();
|
||||
void SlotSelectionTextureName();
|
||||
void SlotSelectionNoneButton();
|
||||
void SlotSelectionAllButton();
|
||||
void on_renametextureButton_clicked();
|
||||
void on_listTextureName_itemSelectionChanged();
|
||||
void on_AllButton_clicked();
|
||||
void on_NoneButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::SaveMeshAttributesDialog* ui;
|
||||
MeshModel *m;
|
||||
int mask;
|
||||
int type;
|
||||
int capability;
|
||||
int defaultBits;
|
||||
RichParameterList *parSet;
|
||||
RichParameterListFrame *stdParFrame;
|
||||
GLArea* glar;
|
||||
|
||||
void setMaskCapability();
|
||||
void checkAndEnable(QCheckBox *qcb,int bit, int capabilityBits, int defaultBits);
|
||||
bool shouldBeEnabled(int bit, int capabilityBits, int defaultBits);
|
||||
bool shouldBeChecked(int bit, int capabilityBits, int defaultBits);
|
||||
void updateMask();
|
||||
|
||||
Ui::SaveMeshAttributesDialog* ui;
|
||||
MeshModel *m;
|
||||
const int capability;
|
||||
const int defaultBits;
|
||||
|
||||
int mask;
|
||||
|
||||
RichParameterList additionalSaveParametrs;
|
||||
std::vector<std::string> textureNames;
|
||||
|
||||
RichParameterListFrame *additionalParametersFrame;
|
||||
GLArea* glar;
|
||||
};//end class
|
||||
|
||||
#endif
|
||||
|
||||
@ -2704,15 +2704,22 @@ bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPo
|
||||
|
||||
pCurrentIOPlugin->initSaveParameter(extension,*(mod),savePar);
|
||||
|
||||
SaveMeshAttributesDialog maskDialog(this,mod,capability,defaultBits,&savePar,this->GLA());
|
||||
SaveMeshAttributesDialog maskDialog(this, mod, capability, defaultBits, savePar, this->GLA());
|
||||
if (!saveAllPossibleAttributes)
|
||||
maskDialog.exec();
|
||||
else
|
||||
{
|
||||
maskDialog.SlotSelectionAllButton();
|
||||
maskDialog.updateMask();
|
||||
//this is horrible: creating a dialog object but then not showing the
|
||||
//dialog.. And using it just to select all the possible options..
|
||||
//to be removed soon
|
||||
maskDialog.selectAllPossibleBits();
|
||||
}
|
||||
int mask = maskDialog.getNewMask();
|
||||
savePar = maskDialog.getNewAdditionalSaveParameters();
|
||||
std::vector<std::string> textureNames = maskDialog.getTextureNames();
|
||||
for (unsigned int i = 0; i < mod->cm.textures.size(); ++i){
|
||||
mod->changeTextureName(mod->cm.textures[i], textureNames[i]);
|
||||
}
|
||||
int mask = maskDialog.GetNewMask();
|
||||
if (!saveAllPossibleAttributes)
|
||||
{
|
||||
maskDialog.close();
|
||||
@ -2729,6 +2736,8 @@ bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPo
|
||||
|
||||
try {
|
||||
pCurrentIOPlugin->save(extension, fileName, *mod ,mask,savePar,QCallBack);
|
||||
QFileInfo finfo(fileName);
|
||||
mod->saveTextures(finfo.absolutePath(), &meshDoc()->Log, QCallBack);
|
||||
GLA()->Logf(GLLogStream::SYSTEM, "Saved Mesh %s in %i msec", qUtf8Printable(fileName), tt.elapsed());
|
||||
mod->setFileName(fileName);
|
||||
QSettings settings;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user