mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-17 10:04:38 +00:00
Added option for individual tile saving in snapshot for combining into very very large images...
This commit is contained in:
parent
ab2e0276ec
commit
8407cd23f8
@ -155,23 +155,35 @@ void GLArea::initializeGL()
|
||||
|
||||
void GLArea::pasteTile()
|
||||
{
|
||||
QString outfile;
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT);
|
||||
QImage tileBuffer=grabFrameBuffer(true).mirrored(false,true);
|
||||
if(ss.tiledSave)
|
||||
{
|
||||
outfile=QString("%1/%2_%3-%4.png")
|
||||
.arg(ss.outdir)
|
||||
.arg(ss.basename)
|
||||
.arg(tileCol,2,10,QChar('0'))
|
||||
.arg(tileRow,2,10,QChar('0'));
|
||||
tileBuffer.mirrored(false,true).save(outfile,"PNG");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (snapBuffer.isNull())
|
||||
snapBuffer = QImage(tileBuffer.width() * ss.resolution, tileBuffer.height() * ss.resolution, tileBuffer.format());
|
||||
|
||||
if (snapBuffer.isNull())
|
||||
snapBuffer = QImage(tileBuffer.width() * ss.resolution, tileBuffer.height() * ss.resolution, tileBuffer.format());
|
||||
uchar *snapPtr = snapBuffer.bits() + (tileBuffer.bytesPerLine() * tileCol) + ((totalCols * tileRow) * tileBuffer.numBytes());
|
||||
uchar *tilePtr = tileBuffer.bits();
|
||||
|
||||
uchar *snapPtr = snapBuffer.bits() + (tileBuffer.bytesPerLine() * tileCol) + ((totalCols * tileRow) * tileBuffer.numBytes());
|
||||
uchar *tilePtr = tileBuffer.bits();
|
||||
|
||||
for (int y=0; y < tileBuffer.height(); y++)
|
||||
{
|
||||
memcpy((void*) snapPtr, (void*) tilePtr, tileBuffer.bytesPerLine());
|
||||
snapPtr+=tileBuffer.bytesPerLine() * totalCols;
|
||||
tilePtr+=tileBuffer.bytesPerLine();
|
||||
}
|
||||
|
||||
tileCol++;
|
||||
for (int y=0; y < tileBuffer.height(); y++)
|
||||
{
|
||||
memcpy((void*) snapPtr, (void*) tilePtr, tileBuffer.bytesPerLine());
|
||||
snapPtr+=tileBuffer.bytesPerLine() * totalCols;
|
||||
tilePtr+=tileBuffer.bytesPerLine();
|
||||
}
|
||||
}
|
||||
tileCol++;
|
||||
|
||||
if (tileCol >= totalCols)
|
||||
{
|
||||
@ -180,31 +192,28 @@ void GLArea::pasteTile()
|
||||
|
||||
if (tileRow >= totalRows)
|
||||
{
|
||||
QString outfile;
|
||||
|
||||
if(ss.snapAllLayers)
|
||||
{
|
||||
outfile=QString("%1/%2%3_L%4.png")
|
||||
.arg(ss.outdir)
|
||||
.arg(ss.basename)
|
||||
.arg(ss.counter,2,10,QChar('0'))
|
||||
.arg(currSnapLayer,2,10,QChar('0'));
|
||||
}
|
||||
else
|
||||
{
|
||||
outfile=QString("%1/%2%3_L%4.png")
|
||||
.arg(ss.outdir).arg(ss.basename)
|
||||
.arg(ss.counter,2,10,QChar('0'))
|
||||
.arg(currSnapLayer,2,10,QChar('0'));
|
||||
} else {
|
||||
outfile=QString("%1/%2%3.png")
|
||||
.arg(ss.outdir)
|
||||
.arg(ss.basename)
|
||||
.arg(ss.counter++,2,10,QChar('0'));
|
||||
.arg(ss.outdir).arg(ss.basename)
|
||||
.arg(ss.counter++,2,10,QChar('0'));
|
||||
}
|
||||
bool ret = (snapBuffer.mirrored(false,true)).save(outfile,"PNG");
|
||||
if (ret) log->Logf(GLLogStream::SYSTEM, "Snapshot saved to %s",outfile.toLocal8Bit().constData());
|
||||
else log->Logf(GLLogStream::WARNING,"Error saving %s",outfile.toLocal8Bit().constData());
|
||||
|
||||
if(!ss.tiledSave)
|
||||
{
|
||||
bool ret = (snapBuffer.mirrored(false,true)).save(outfile,"PNG");
|
||||
if (ret) log->Logf(GLLogStream::SYSTEM, "Snapshot saved to %s",outfile.toLocal8Bit().constData());
|
||||
else log->Logf(GLLogStream::WARNING,"Error saving %s",outfile.toLocal8Bit().constData());
|
||||
}
|
||||
takeSnapTile=false;
|
||||
snapBuffer=QImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
glPopAttrib();
|
||||
}
|
||||
@ -588,7 +597,6 @@ void GLArea::displayHelp(QPainter *painter)
|
||||
void GLArea::saveSnapshot()
|
||||
{
|
||||
// snap all layers
|
||||
totalSnapLayer= meshDoc->meshList.size();
|
||||
currSnapLayer=0;
|
||||
|
||||
// number of subparts
|
||||
@ -597,32 +605,25 @@ void GLArea::saveSnapshot()
|
||||
|
||||
if(ss.snapAllLayers)
|
||||
{
|
||||
|
||||
while(currSnapLayer<totalSnapLayer)
|
||||
while(currSnapLayer<meshDoc->meshList.size())
|
||||
{
|
||||
tileRow=tileCol=0;
|
||||
|
||||
qDebug("Snapping layer %i",currSnapLayer);
|
||||
meshDoc->setCurrentMesh(currSnapLayer);
|
||||
for(int i=0; i<totalSnapLayer; i++)
|
||||
{
|
||||
if(i==currSnapLayer)
|
||||
addMeshSetVisibility(i,true);
|
||||
else
|
||||
addMeshSetVisibility(i,false);
|
||||
foreach(MeshModel *mp,meshDoc->meshList) {
|
||||
meshSetVisibility(mp,false);
|
||||
}
|
||||
meshSetVisibility(mm(),true);
|
||||
|
||||
takeSnapTile=true;
|
||||
update();
|
||||
repaint();
|
||||
currSnapLayer++;
|
||||
}
|
||||
|
||||
//cleanup
|
||||
for(int i=0; i<totalSnapLayer; i++)
|
||||
{
|
||||
addMeshSetVisibility(i,true);
|
||||
foreach(MeshModel *mp,meshDoc->meshList) {
|
||||
meshSetVisibility(mp,true);
|
||||
}
|
||||
|
||||
ss.counter++;
|
||||
}
|
||||
else
|
||||
@ -1214,9 +1215,10 @@ void GLArea::updateRasterSetVisibilities()
|
||||
}
|
||||
}
|
||||
|
||||
void GLArea::addMeshSetVisibility(int meshId, bool visibility)
|
||||
void GLArea::meshSetVisibility(MeshModel *mp, bool visibility)
|
||||
{
|
||||
meshVisibilityMap.insert(meshId,visibility);
|
||||
mp->visible=visibility;
|
||||
meshVisibilityMap[mp->id()]=visibility;
|
||||
}
|
||||
|
||||
void GLArea::addRasterSetVisibility(int rasterId, bool visibility)
|
||||
|
||||
@ -55,6 +55,7 @@ public:
|
||||
int resolution;
|
||||
bool transparentBackground;
|
||||
bool snapAllLayers;
|
||||
bool tiledSave; // if true all the tiles are saved as separated files and not joined.
|
||||
|
||||
SnapshotSetting()
|
||||
{
|
||||
@ -64,6 +65,7 @@ public:
|
||||
resolution=1;
|
||||
transparentBackground=true;
|
||||
snapAllLayers=false;
|
||||
tiledSave=false;
|
||||
};
|
||||
};
|
||||
|
||||
@ -296,7 +298,7 @@ public:
|
||||
QMap<int, bool> rasterVisibilityMap;
|
||||
|
||||
// Add an entry in the mesh visibility map
|
||||
void addMeshSetVisibility(int meshId, bool visibility);
|
||||
void meshSetVisibility(MeshModel *mp, bool visibility);
|
||||
|
||||
// Add an entry in the raster visibility map
|
||||
void addRasterSetVisibility(int rasterId, bool visibility);
|
||||
@ -315,7 +317,7 @@ private:
|
||||
enum AnimMode { AnimNone, AnimSpin, AnimInterp};
|
||||
AnimMode animMode;
|
||||
int tileCol, tileRow, totalCols, totalRows; // snapshot: total number of subparts and current subpart rendered
|
||||
int totalSnapLayer, currSnapLayer; // snapshot: total number of layers and current layer rendered
|
||||
int currSnapLayer; // snapshot: total number of layers and current layer rendered
|
||||
void setCursorTrack(vcg::TrackMode *tm);
|
||||
|
||||
//-----------Raster support----------------------------
|
||||
|
||||
@ -98,17 +98,14 @@ void LayerDialog::meshItemClicked (QTreeWidgetItem * item , int col)
|
||||
// Very useful for comparing meshes
|
||||
|
||||
if(QApplication::keyboardModifiers() == Qt::ControlModifier)
|
||||
foreach(MeshModel *mp, md->meshList)
|
||||
{
|
||||
mp->visible=false;
|
||||
mw->GLA()->addMeshSetVisibility(mp->id(), mp->visible);
|
||||
foreach(MeshModel *mp, md->meshList)
|
||||
{
|
||||
mw->GLA()->meshSetVisibility(mp, false);
|
||||
}
|
||||
}
|
||||
|
||||
if(md->getMesh(clickedId)->visible) md->getMesh(clickedId)->visible = false;
|
||||
else md->getMesh(clickedId)->visible = true;
|
||||
|
||||
//Update current GLArea visibility
|
||||
mw->GLA()->addMeshSetVisibility(md->getMesh(clickedId)->id(), md->getMesh(clickedId)->visible);
|
||||
//Toggle visibility of current mesh
|
||||
mw->GLA()->meshSetVisibility(md->getMesh(clickedId), !md->getMesh(clickedId)->visible);
|
||||
} break;
|
||||
case 1 :
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ SnapshotSetting SaveSnapshotDialog::getValues()
|
||||
settings.resolution=ui->resolutionSpinBox->value();
|
||||
settings.transparentBackground=ui->backgroundCheckBox->isChecked();
|
||||
settings.snapAllLayers=ui->alllayersCheckBox->isChecked();
|
||||
settings.tiledSave=ui->tiledSaveCheckBox->isChecked();
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>552</width>
|
||||
<height>192</height>
|
||||
<width>616</width>
|
||||
<height>225</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -115,6 +115,16 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="tiledSaveCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>If checked, save each image independently, allowing to later combine the saved images into a very very large image</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tiled Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user