mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-15 00:54:38 +00:00
first working draft
it simply outputs an image with model rendered from the current camera with creases highlighted
This commit is contained in:
parent
c5785d22b2
commit
2079824513
@ -98,7 +98,7 @@ void PluginManager::loadPlugins(RichParameterSet& defaultGlobal)
|
||||
else
|
||||
{
|
||||
QPluginLoader loader(absfilepath);
|
||||
QObject *plugin = loader.instance();
|
||||
QObject *plugin = loader.instance();
|
||||
if (plugin)
|
||||
{
|
||||
pluginsLoaded.push_back(fileName);
|
||||
|
||||
@ -34,4 +34,3 @@ CADtexturingControl::CADtexturingControl(QWidget * parent, Qt::WindowFlags flags
|
||||
void CADtexturingControl::on_renderEdges(){
|
||||
emit(renderEdgesClicked());
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#include <QUndoStack>
|
||||
#include <QUndoGroup>
|
||||
#include <QFileDialog>
|
||||
#include <ui_CADtexturingControl.h>
|
||||
#include <generatedfiles/ui_CADtexturingControl.h>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ $Log: meshedit.cpp,v $
|
||||
#include<wrap/qt/gl_label.h>
|
||||
#include<wrap/gl/shot.h>
|
||||
#include <wrap/glw/glw.h>
|
||||
#include<vcg/complex/algorithms/update/flag.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
@ -89,12 +90,6 @@ void CADtexturingEditPlugin::renderEdges(GLArea * gla){
|
||||
|
||||
glViewport(0, 0, winsize, winsize);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(90, 1.0, 0.1, 100); // SISTEMARE NEAR E FAR
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
ctx.bindReadDrawFramebuffer(hFramebuffer);
|
||||
GLW_CHECK_GL_READ_DRAW_FRAMEBUFFER_STATUS;
|
||||
|
||||
@ -102,52 +97,64 @@ void CADtexturingEditPlugin::renderEdges(GLArea * gla){
|
||||
MLSceneGLSharedDataContext::PerMeshRenderingDataMap dt;
|
||||
shared->getRenderInfoPerMeshView(gla->context(), dt);
|
||||
|
||||
for (int i = 0; i < meshmodel->cm.vert.size(); ++i){
|
||||
CMeshO::CoordType p = meshmodel->cm.vert[i].cP();
|
||||
|
||||
QImage image(int(width), int(height), QImage::Format_ARGB32);
|
||||
QImage image(int(width), int(height), QImage::Format_ARGB32);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glViewport(0, 0, winsize, winsize);
|
||||
glPushMatrix();
|
||||
glViewport(0, 0, winsize, winsize);
|
||||
glPushMatrix();
|
||||
|
||||
/* set camera*/
|
||||
GlShot<Shotm>::SetView(gla->mvc()->meshDoc.rm()->shot, 1, 100);
|
||||
|
||||
/* set camera*/
|
||||
GlShot<Shotm>::SetView(gla->mvc()->meshDoc.rm()->shot, 1, 10000);
|
||||
|
||||
/**/
|
||||
/**/
|
||||
|
||||
{
|
||||
MLSceneGLSharedDataContext* datacont = gla->mvc()->sharedDataContext();
|
||||
if (datacont == NULL)
|
||||
return;
|
||||
{
|
||||
MLSceneGLSharedDataContext* datacont = gla->mvc()->sharedDataContext();
|
||||
if (datacont == NULL)
|
||||
return;
|
||||
|
||||
foreach(MeshModel * mp, gla->md()->meshList){
|
||||
MLRenderingData curr;
|
||||
datacont->getRenderInfoPerMeshView(mp->id(), gla->context(), curr);
|
||||
MLPerViewGLOptions opts;
|
||||
curr.get(opts);
|
||||
//if (curr.get(opts) == false)
|
||||
// throw MLException(QString("GLArea: invalid MLPerViewGLOptions"));
|
||||
//gla->setLightingColors(opts);
|
||||
foreach(MeshModel * mp, gla->md()->meshList){
|
||||
MLRenderingData curr;
|
||||
datacont->getRenderInfoPerMeshView(mp->id(), gla->context(), curr);
|
||||
MLPerViewGLOptions opts;
|
||||
curr.get(opts);
|
||||
//if (curr.get(opts) == false)
|
||||
// throw MLException(QString("GLArea: invalid MLPerViewGLOptions"));
|
||||
//gla->setLightingColors(opts);
|
||||
|
||||
|
||||
if (opts._back_face_cull)
|
||||
glEnable(GL_CULL_FACE);
|
||||
else
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_CULL_FACE);
|
||||
datacont->setMeshTransformationMatrix(mp->id(), mp->cm.Tr);
|
||||
|
||||
|
||||
if (mp->cm.fn){
|
||||
glPolygonMode(GL_FRONT, GL_FILL);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0, 1);
|
||||
drawer.DrawFill<vcg::GLW::NormalMode::NMNone,vcg::GLW::ColorMode::CMPerMesh,vcg::GLW::TextureMode::TMNone>();
|
||||
glEnable(GL_LIGHTING);
|
||||
glCullFace(GL_BACK);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
drawer.DrawWirePolygonal<vcg::GLW::NormalMode::NMNone, vcg::GLW::ColorMode::CMNone>();
|
||||
|
||||
datacont->setMeshTransformationMatrix(mp->id(), mp->cm.Tr);
|
||||
|
||||
if (mp->cm.fn)
|
||||
datacont->draw(mp->id(), gla->context());
|
||||
}
|
||||
}
|
||||
|
||||
glReadPixels(0, 0, 3 * winsize, 2 * winsize, GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
|
||||
|
||||
image.rgbSwapped().mirrored().save("pano_" + QString().setNum(i) + ".jpg");
|
||||
}
|
||||
|
||||
GlShot<Shotm>::UnsetView();
|
||||
|
||||
glReadPixels(0, 0, winsize, winsize, GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
|
||||
|
||||
image.rgbSwapped().mirrored().save("edges.jpg");
|
||||
|
||||
ctx.unbindReadDrawFramebuffer();
|
||||
ctx.release();
|
||||
glViewport(vp[0], vp[1], vp[2], vp[3]);
|
||||
@ -258,5 +265,19 @@ bool CADtexturingEditPlugin::StartEdit(MeshModel & m , GLArea * gla, MLSceneGLSh
|
||||
|
||||
QObject::connect(control, SIGNAL(renderEdgesClicked()), this, SLOT(on_renderEdges()));
|
||||
drawEdgesTrigger = false;
|
||||
|
||||
m.updateDataMask(MeshModel::MM_FACEFACETOPO);
|
||||
vcg::tri::UpdateFlags<CMeshO>::FaceFauxSignedCrease(m.cm, -M_PI*0.5, M_PI*0.5);
|
||||
drawer.m = &m.cm;
|
||||
m.cm.C().SetGrayShade(0.5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CADtexturingEditPlugin::EndEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/){
|
||||
|
||||
dock->setVisible(false);
|
||||
delete control;
|
||||
delete dock;
|
||||
|
||||
};
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include <meshlab/glarea.h>
|
||||
#include <common/interfaces.h>
|
||||
#include "CADtexturingControl.h"
|
||||
#include <wrap/gl/trimesh.h>
|
||||
|
||||
class CADtexturingEditPlugin : public QObject, public MeshEditInterface
|
||||
{
|
||||
@ -41,7 +42,7 @@ public:
|
||||
static const QString Info();
|
||||
|
||||
bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/);
|
||||
void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/){};
|
||||
void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/);
|
||||
void Decorate(MeshModel &/*m*/, GLArea * /*parent*/, QPainter *p);
|
||||
void Decorate (MeshModel &/*m*/, GLArea * ){};
|
||||
void mousePressEvent(QMouseEvent *, MeshModel &, GLArea * ) {};
|
||||
@ -50,6 +51,7 @@ public:
|
||||
void keyReleaseEvent(QKeyEvent *, MeshModel &, GLArea *);
|
||||
|
||||
void renderEdges(GLArea *gla);
|
||||
vcg::GlTrimesh<CMeshO> drawer;
|
||||
|
||||
private:
|
||||
bool drawEdgesTrigger;
|
||||
|
||||
@ -5,7 +5,8 @@ HEADERS = edit_CADtexturing_factory.h \
|
||||
CADtexturingedit.h
|
||||
|
||||
SOURCES = edit_CADtexturing_factory.cpp \
|
||||
CADtexturingedit.cpp
|
||||
CADtexturingedit.cpp \
|
||||
CADtexturingControl.cpp
|
||||
|
||||
TARGET = CADtexturingedit
|
||||
|
||||
|
||||
82
src/plugins_experimental/edit_panosample/QualityChecker.ui
Normal file
82
src/plugins_experimental/edit_panosample/QualityChecker.ui
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QualityChecker</class>
|
||||
<widget class="QDockWidget" name="QualityChecker">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>567</width>
|
||||
<height>403</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Quality Checker</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<widget class="QPushButton" name="createImageSpacePushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>50</y>
|
||||
<width>121</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Take Views</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="comparePushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>80</y>
|
||||
<width>121</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Compare </string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="useCurrentLayerPushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>121</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string extracomment="Use the vertices in the current mesh layer as sampling points for taking model shots"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use Current Layer </string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<action name="actionCreateImageSpace">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>createImageSpace</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="edit_paint.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
BIN
src/plugins_experimental/edit_panosample/Resource.aps
Normal file
BIN
src/plugins_experimental/edit_panosample/Resource.aps
Normal file
Binary file not shown.
BIN
src/plugins_experimental/edit_panosample/Resource.rc
Normal file
BIN
src/plugins_experimental/edit_panosample/Resource.rc
Normal file
Binary file not shown.
BIN
src/plugins_experimental/edit_panosample/bitmap1.bmp
Normal file
BIN
src/plugins_experimental/edit_panosample/bitmap1.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
105
src/plugins_experimental/edit_panosample/cloneview.h
Normal file
105
src/plugins_experimental/edit_panosample/cloneview.h
Normal file
@ -0,0 +1,105 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* An extendible mesh processor o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005, 2009 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CLONEVIEW_H_
|
||||
#define CLONEVIEW_H_
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsItem>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class CloneView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private :
|
||||
QPointF last_pos;
|
||||
QPointF start_pos;
|
||||
|
||||
QGraphicsItem * crosshair;
|
||||
|
||||
public :
|
||||
QGraphicsItem * scenegroup;
|
||||
|
||||
CloneView(QWidget * parent) : QGraphicsView(parent)
|
||||
{
|
||||
setDragMode(QGraphicsView::NoDrag); setMouseTracking(false);
|
||||
}
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent * event) {
|
||||
start_pos = QPointF(event->pos());
|
||||
last_pos.setX(event->pos().x()); last_pos.setY(event->pos().y());
|
||||
|
||||
if (event->buttons() == Qt::RightButton)
|
||||
emit positionReset();
|
||||
}
|
||||
|
||||
virtual void mouseMoveEvent ( QMouseEvent * event)
|
||||
{
|
||||
if (!(event->buttons() & Qt::LeftButton)) return;
|
||||
QGraphicsItem * item = itemAt(event->pos());
|
||||
if (item != NULL)
|
||||
if (!crosshair->isAncestorOf(item)) item->moveBy(event->pos().x() - last_pos.x(), event->pos().y() - last_pos.y());
|
||||
last_pos.setX(event->pos().x()); last_pos.setY(event->pos().y());
|
||||
// emit positionChanged(last_pos.x() - start_pos.x(), last_pos.y() - start_pos.y());
|
||||
}
|
||||
|
||||
virtual void mouseReleaseEvent ( QMouseEvent *)
|
||||
{
|
||||
emit positionChanged(last_pos.x() - start_pos.x(), last_pos.y() - start_pos.y());
|
||||
}
|
||||
|
||||
virtual void wheelEvent(QWheelEvent *)
|
||||
{
|
||||
//ignore or move..
|
||||
}
|
||||
|
||||
virtual void setScene(QGraphicsScene * scene)
|
||||
{
|
||||
QGraphicsView::setScene(scene);
|
||||
QList<QGraphicsItem*> gil;
|
||||
scenegroup = scene->createItemGroup(gil);
|
||||
crosshair = new QGraphicsItemGroup(scenegroup);
|
||||
crosshair->setZValue(2);
|
||||
QPen pen;
|
||||
pen.setWidth(3);
|
||||
pen.setColor(QColor(qRgb(255, 255, 255)));
|
||||
QGraphicsItem * p = scene->addLine(0, 8, 0, -8, pen);
|
||||
p->setParentItem(crosshair);
|
||||
QGraphicsItem * c = scene->addLine(8, 0, -8, 0, pen);
|
||||
c->setParentItem(p); p = c;
|
||||
pen.setWidth(1);
|
||||
pen.setColor(QColor(qRgb(0, 0, 0)));
|
||||
c = scene->addLine(0, 8, 0, -8, pen);
|
||||
c->setParentItem(p); p = c;
|
||||
c = scene->addLine(8, 0, -8, 0, pen);
|
||||
c->setParentItem(p); p = c;
|
||||
}
|
||||
|
||||
signals:
|
||||
void positionChanged(double x, double y);
|
||||
void positionReset();
|
||||
|
||||
};
|
||||
|
||||
#endif /*CLONEVIEW_H_*/
|
||||
49
src/plugins_experimental/edit_panosample/colorframe.h
Normal file
49
src/plugins_experimental/edit_panosample/colorframe.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef COLORFRAME_H_
|
||||
#define COLORFRAME_H_
|
||||
|
||||
#include <QFrame>
|
||||
#include <QColorDialog>
|
||||
|
||||
/*
|
||||
*A simple widget that displays a color and allows the
|
||||
* user to choose a new one with a QColorDialog
|
||||
*/
|
||||
class Colorframe : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Colorframe(QWidget * parent, Qt::WindowFlags flags = 0) : QFrame(parent, flags){}
|
||||
|
||||
virtual void mousePressEvent ( QMouseEvent *)
|
||||
{
|
||||
QPalette palette = Colorframe::palette();
|
||||
QColor temp = palette.color(QPalette::Normal, QPalette::Window);
|
||||
temp = QColorDialog::getColor(temp);
|
||||
if (temp.isValid()){
|
||||
setColor(temp);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
QColor getColor(){return Colorframe::palette().color(QPalette::Normal, QPalette::Window);}
|
||||
|
||||
public slots:
|
||||
|
||||
void setColor(QColor c)
|
||||
{
|
||||
QPalette palette = Colorframe::palette();
|
||||
palette.setColor(QPalette::Normal, QPalette::Window, c);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Window, c);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Window, c);
|
||||
setPalette(palette);
|
||||
update();
|
||||
emit colorChanged(c);
|
||||
}
|
||||
|
||||
signals:
|
||||
void colorChanged(QColor c);
|
||||
|
||||
};
|
||||
|
||||
#endif /*COLORFRAME_H_*/
|
||||
267
src/plugins_experimental/edit_panosample/edit_panosample.cpp
Normal file
267
src/plugins_experimental/edit_panosample/edit_panosample.cpp
Normal file
@ -0,0 +1,267 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* A versatile mesh processing toolbox o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#include "edit_panosample.h"
|
||||
|
||||
#include <vcg/math/perlin_noise.h>
|
||||
#include <wrap/glw/glw.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
using namespace glw;
|
||||
|
||||
EditPanosamplePlugin::EditPanosamplePlugin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EditPanosamplePlugin::~EditPanosamplePlugin() {}
|
||||
|
||||
const QString EditPanosamplePlugin::Info() {
|
||||
return tr("Improved Painting");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EditPanosamplePlugin::StartEdit(MeshModel & m, GLArea * parent, MLSceneGLSharedDataContext* /*cont*/)
|
||||
{
|
||||
glarea = parent;
|
||||
meshmodel = &m;
|
||||
|
||||
GLenum err = glewInit();
|
||||
if (err != GLEW_OK)
|
||||
return false;
|
||||
|
||||
dock1 = new QDockWidget(parent->window());
|
||||
this->qualitychecker = new QualityChecker(dock1);
|
||||
//dock->setAllowedAreas(Qt::NoDockWidgetArea);
|
||||
//dock->setWidget(paintbox);
|
||||
//QPoint p = parent->mapToGlobal(QPoint(0, 0));
|
||||
//dock->setGeometry(5 + p.x(), p.y() + 5, paintbox->width(), parent->height() - 10);
|
||||
//dock->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||
dock1->setFloating(true);
|
||||
dock1->setVisible(true);
|
||||
|
||||
|
||||
QObject::connect(qualitychecker, SIGNAL(createImageSpaceClicked()), this, SLOT(on_createImageSpace()));
|
||||
|
||||
QObject::connect(qualitychecker, SIGNAL(layerChosenChanged), this, SLOT(on_layerChosenChanged()));
|
||||
|
||||
|
||||
createImageSpaceTrigger = false;
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void EditPanosamplePlugin::EndEdit(MeshModel &/* m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/)
|
||||
{
|
||||
glarea->setMouseTracking(false);
|
||||
delete dock1;
|
||||
}
|
||||
|
||||
void EditPanosamplePlugin::mousePressEvent(QMouseEvent * event, MeshModel &, GLArea * gla)
|
||||
{
|
||||
gla->update();
|
||||
}
|
||||
|
||||
void EditPanosamplePlugin::mouseMoveEvent(QMouseEvent* event, MeshModel & m, GLArea * gla)
|
||||
{
|
||||
if (gla == NULL)
|
||||
return;
|
||||
|
||||
gla->update();
|
||||
}
|
||||
|
||||
void EditPanosamplePlugin::mouseReleaseEvent(QMouseEvent * event, MeshModel &, GLArea * gla)
|
||||
{
|
||||
gla->updateAllSiblingsGLAreas();
|
||||
}
|
||||
|
||||
|
||||
void EditPanosamplePlugin::drawScene(GLArea * gla){
|
||||
MLSceneGLSharedDataContext* datacont = gla->mvc()->sharedDataContext();
|
||||
if (datacont == NULL)
|
||||
return;
|
||||
|
||||
foreach(MeshModel * mp, gla->md()->meshList){
|
||||
MLRenderingData curr;
|
||||
datacont->getRenderInfoPerMeshView(mp->id(), gla->context(), curr);
|
||||
MLPerViewGLOptions opts;
|
||||
curr.get(opts);
|
||||
//if (curr.get(opts) == false)
|
||||
// throw MLException(QString("GLArea: invalid MLPerViewGLOptions"));
|
||||
//gla->setLightingColors(opts);
|
||||
|
||||
|
||||
if (opts._back_face_cull)
|
||||
glEnable(GL_CULL_FACE);
|
||||
else
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
datacont->setMeshTransformationMatrix(mp->id(), mp->cm.Tr);
|
||||
|
||||
if(mp->cm.fn)
|
||||
datacont->draw(mp->id(), gla->context());
|
||||
}
|
||||
}
|
||||
|
||||
void EditPanosamplePlugin::panoRender(GLArea * gla){
|
||||
int winsize = 512;
|
||||
int width = winsize * 3;
|
||||
int height = winsize * 2;
|
||||
|
||||
|
||||
glarea = gla;
|
||||
if (gla->mvc() == NULL)
|
||||
return;
|
||||
MLSceneGLSharedDataContext* shared = gla->mvc()->sharedDataContext();
|
||||
if (shared == NULL)
|
||||
return;
|
||||
|
||||
Context ctx;
|
||||
ctx.acquire();
|
||||
|
||||
RenderbufferHandle hDepth = createRenderbuffer(ctx, GL_DEPTH_COMPONENT24, width, height);
|
||||
Texture2DHandle hColor = createTexture2D(ctx, GL_RGBA8, width, height, GL_RGBA, GL_UNSIGNED_BYTE);
|
||||
FramebufferHandle hFramebuffer = createFramebuffer(ctx, renderbufferTarget(hDepth), texture2DTarget(hColor));
|
||||
|
||||
GLint vp[4];
|
||||
glGetIntegerv(GL_VIEWPORT, vp);
|
||||
|
||||
glViewport(0, 0, winsize, winsize);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(90, 1.0, 0.1, 100); // SISTEMARE NEAR E FAR
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
ctx.bindReadDrawFramebuffer(hFramebuffer);
|
||||
GLW_CHECK_GL_READ_DRAW_FRAMEBUFFER_STATUS;
|
||||
|
||||
|
||||
MLSceneGLSharedDataContext::PerMeshRenderingDataMap dt;
|
||||
shared->getRenderInfoPerMeshView(gla->context(), dt);
|
||||
|
||||
for (int i = 0; i < meshmodel->cm.vert.size(); ++i){
|
||||
CMeshO::CoordType p = meshmodel->cm.vert[i].cP();
|
||||
|
||||
QImage image(int(width), int(height), QImage::Format_ARGB32);
|
||||
|
||||
|
||||
//*** Z+
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glViewport(0, 0, winsize, winsize);
|
||||
glPushMatrix();
|
||||
gluLookAt(p.X(), p.Y(), p.Z(), p.X(), p.Y(), p.Z() + 1, 0, 1, 0);
|
||||
drawScene(gla);
|
||||
glPopMatrix();
|
||||
|
||||
//*** X-
|
||||
glViewport(winsize, 0, winsize, winsize);
|
||||
glPushMatrix();
|
||||
glViewport(winsize, 0, winsize, winsize);
|
||||
gluLookAt(p.X(), p.Y(), p.Z(), p.X()-1, p.Y(), p.Z() , 0, 1, 0);
|
||||
drawScene(gla);
|
||||
glPopMatrix();
|
||||
|
||||
//*** Z-
|
||||
glViewport(winsize * 2, 0, winsize, winsize);
|
||||
glPushMatrix();
|
||||
gluLookAt(p.X(), p.Y(), p.Z(), p.X(), p.Y(), p.Z() - 1, 0, 1, 0);
|
||||
drawScene(gla);
|
||||
glPopMatrix();
|
||||
|
||||
//*** Y+
|
||||
glViewport(0, winsize, winsize, winsize);
|
||||
glPushMatrix();
|
||||
gluLookAt(p.X(), p.Y(), p.Z(), p.X(), p.Y()+ 1, p.Z() , 0, 0, 1);
|
||||
drawScene(gla);
|
||||
glPopMatrix();
|
||||
|
||||
//*** X+
|
||||
glViewport(winsize, winsize, winsize, winsize);
|
||||
glPushMatrix();
|
||||
gluLookAt(p.X(), p.Y(), p.Z(), p.X() + 1, p.Y(), p.Z(), 0, 0, 1);
|
||||
drawScene(gla);
|
||||
glPopMatrix();
|
||||
|
||||
//*** Y-
|
||||
glViewport(winsize * 2, winsize, winsize, winsize);
|
||||
glPushMatrix();
|
||||
gluLookAt(p.X(), p.Y(), p.Z(), p.X(), p.Y() - 1, p.Z(), 0, 0, 1);
|
||||
drawScene(gla);
|
||||
glPopMatrix();
|
||||
|
||||
glReadPixels(0, 0, 3 * winsize, 2 * winsize, GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
|
||||
|
||||
image.rgbSwapped().mirrored().save("pano_"+QString().setNum(i)+".jpg");
|
||||
}
|
||||
ctx.unbindReadDrawFramebuffer();
|
||||
ctx.release();
|
||||
glViewport(vp[0], vp[1], vp[2], vp[3]);
|
||||
return;
|
||||
|
||||
}
|
||||
/**
|
||||
* Since only on a Decorate call it is possible to obtain correct values
|
||||
* from OpenGL, all operations are performed during the execution of this
|
||||
* method and not where mouse events are processed.
|
||||
*
|
||||
*/
|
||||
void EditPanosamplePlugin::Decorate(MeshModel &m, GLArea * gla)
|
||||
{
|
||||
if (createImageSpaceTrigger){
|
||||
panoRender(gla);
|
||||
createImageSpaceTrigger = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditPanosamplePlugin::on_createImageSpace(){
|
||||
createImageSpaceTrigger = true;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditPanosamplePlugin::on_layerChosenChanged(){
|
||||
createImageSpaceTrigger = true;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request an async repainting of the glarea
|
||||
*
|
||||
* This slot is connected to undo and redo
|
||||
*/
|
||||
void EditPanosamplePlugin::update()
|
||||
{
|
||||
glarea->update();
|
||||
glarea->updateAllSiblingsGLAreas();
|
||||
}
|
||||
|
||||
87
src/plugins_experimental/edit_panosample/edit_panosample.h
Normal file
87
src/plugins_experimental/edit_panosample/edit_panosample.h
Normal file
@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* A versatile mesh processing toolbox o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef EDITPAINT_H
|
||||
#define EDITPAINT_H
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <QObject>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include <meshlab/glarea.h>
|
||||
#include <common/interfaces.h>
|
||||
#include <wrap/gl/pick.h>
|
||||
|
||||
#include "qualitychecker.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* EditPanosample plugin main class (MeshEditing plugin)
|
||||
*/
|
||||
class EditPanosamplePlugin : public QObject, public MeshEditInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MeshEditInterface)
|
||||
|
||||
public:
|
||||
EditPanosamplePlugin();
|
||||
virtual ~EditPanosamplePlugin();
|
||||
|
||||
static const QString Info();
|
||||
|
||||
bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/);
|
||||
void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/);
|
||||
void Decorate(MeshModel &/*m*/, GLArea * /*parent*/);
|
||||
void mousePressEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea *);
|
||||
void mouseMoveEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea *);
|
||||
void mouseReleaseEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea *);
|
||||
|
||||
|
||||
signals:
|
||||
void setSelectionRendering(bool);
|
||||
|
||||
public slots:
|
||||
void update();
|
||||
void on_createImageSpace();
|
||||
void on_layerChosenChanged();
|
||||
|
||||
//void runPanoSample();
|
||||
//void setSamplePoints();
|
||||
private:
|
||||
bool createImageSpaceTrigger;
|
||||
|
||||
|
||||
void panoRender(GLArea * gla);
|
||||
void drawScene(GLArea * gla);
|
||||
|
||||
std::vector<QImage> panoramas;
|
||||
QDockWidget* dock1;
|
||||
QualityChecker * qualitychecker;
|
||||
MeshModel * meshmodel;
|
||||
|
||||
GLArea * glarea;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
16
src/plugins_experimental/edit_panosample/edit_panosample.pro
Normal file
16
src/plugins_experimental/edit_panosample/edit_panosample.pro
Normal file
@ -0,0 +1,16 @@
|
||||
include (../../shared.pri)
|
||||
|
||||
HEADERS = edit_panosample_factory.h \
|
||||
cloneview.h \
|
||||
colorframe.h \
|
||||
paintbox.h \
|
||||
edit_panosample.h
|
||||
|
||||
SOURCES = edit_panosample_factory.cpp \
|
||||
../../meshlab/ml_selection_buffers.cpp \
|
||||
paintbox.cpp \
|
||||
edit_panosample.cpp \
|
||||
|
||||
TARGET = edit_panosample
|
||||
RESOURCES = edit_paint.qrc
|
||||
FORMS = paintbox.ui
|
||||
@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* A versatile mesh processing toolbox o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005-2008 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include "edit_panosample_factory.h"
|
||||
#include "edit_panosample.h"
|
||||
|
||||
EditPanosampleFactory::EditPanosampleFactory()
|
||||
{
|
||||
editPanosample = new QAction(QIcon(":/images/paintbrush-22.png"), "Z-painting", this);
|
||||
|
||||
actionList << editPanosample;
|
||||
|
||||
foreach(QAction *editAction, actionList)
|
||||
editAction->setCheckable(true);
|
||||
}
|
||||
|
||||
//gets a list of actions available from this plugin
|
||||
QList<QAction *> EditPanosampleFactory::actions() const
|
||||
{
|
||||
return actionList;
|
||||
}
|
||||
|
||||
//get the edit tool for the given action
|
||||
MeshEditInterface* EditPanosampleFactory::getMeshEditInterface(QAction *action)
|
||||
{
|
||||
if (action == editPanosample)
|
||||
{
|
||||
return new EditPanosamplePlugin();
|
||||
} else assert(0); //should never be asked for an action that isnt here
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QString EditPanosampleFactory::getEditToolDescription(QAction *)
|
||||
{
|
||||
return EditPanosamplePlugin::Info();
|
||||
}
|
||||
|
||||
MESHLAB_PLUGIN_NAME_EXPORTER(EditPanosampleFactory)
|
||||
@ -0,0 +1,56 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* A versatile mesh processing toolbox o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005-2008 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef EditPanosampleFactoryPLUGIN_H
|
||||
#define EditPanosamplePLUGIN_H
|
||||
#include <QObject>
|
||||
|
||||
#include <common/interfaces.h>
|
||||
|
||||
class EditPanosampleFactory : public QObject, public MeshEditInterfaceFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
MESHLAB_PLUGIN_IID_EXPORTER(MESH_EDIT_INTERFACE_FACTORY_IID)
|
||||
Q_INTERFACES(MeshEditInterfaceFactory)
|
||||
|
||||
public:
|
||||
EditPanosampleFactory();
|
||||
virtual ~EditPanosampleFactory() { delete editPanosample; }
|
||||
|
||||
//gets a list of actions available from this plugin
|
||||
virtual QList<QAction *> actions() const;
|
||||
|
||||
//get the edit tool for the given action
|
||||
virtual MeshEditInterface* getMeshEditInterface(QAction *);
|
||||
|
||||
//get the description for the given action
|
||||
virtual QString getEditToolDescription(QAction *);
|
||||
|
||||
private:
|
||||
QList <QAction *> actionList;
|
||||
|
||||
QAction *editPanosample;
|
||||
};
|
||||
|
||||
#endif
|
||||
BIN
src/plugins_experimental/edit_panosample/images/icon_align.png
Normal file
BIN
src/plugins_experimental/edit_panosample/images/icon_align.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
2040
src/plugins_experimental/edit_panosample/paintbox.ui
Normal file
2040
src/plugins_experimental/edit_panosample/paintbox.ui
Normal file
File diff suppressed because it is too large
Load Diff
50
src/plugins_experimental/edit_panosample/qualitychecker.cpp
Normal file
50
src/plugins_experimental/edit_panosample/qualitychecker.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* A versatile mesh processing toolbox o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include "qualitychecker.h"
|
||||
#include <QFileDialog>
|
||||
|
||||
QualityChecker::QualityChecker(QWidget * parent, Qt::WindowFlags flags) : QDockWidget(parent, flags)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
//QObject::connect(clone_source_view, SIGNAL(positionChanged(double, double)), this, SLOT(movePixmapDelta(double, double)));
|
||||
//QObject::connect(clone_source_view, SIGNAL(positionReset()), this, SLOT(resetPixmapDelta()));
|
||||
|
||||
QObject::connect(this->createImageSpacePushButton, SIGNAL(clicked()), this, SLOT(on_createImageSpace()));
|
||||
QObject::connect(this->createImageSpacePushButton, SIGNAL(clicked()), this, SLOT(on_compare()));
|
||||
QObject::connect(this->useCurrentLayerPushButton, SIGNAL(clicked()), this, SLOT(on_layerChosen()));
|
||||
comparePushButton->setVisible(false);
|
||||
}
|
||||
|
||||
void QualityChecker::on_createImageSpace(){
|
||||
emit(createImageSpaceClicked());
|
||||
}
|
||||
|
||||
void QualityChecker::on_compare(){
|
||||
emit(compareClicked());
|
||||
}
|
||||
|
||||
void QualityChecker::on_layerChosen(){
|
||||
emit(layerChosenChanged());
|
||||
}
|
||||
66
src/plugins_experimental/edit_panosample/qualitychecker.h
Normal file
66
src/plugins_experimental/edit_panosample/qualitychecker.h
Normal file
@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* A versatile mesh processing toolbox o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005 \/)\/ *
|
||||
* 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. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QUALITYCHECKER_H_
|
||||
#define QUALITYCHECKER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <vcg/math/base.h>
|
||||
#include <GL/glew.h>
|
||||
#include <QHash>
|
||||
#include <QUndoStack>
|
||||
#include <QUndoGroup>
|
||||
#include "ui_qualitychecker.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class manages the user interface and is concerned
|
||||
* with emitting appropriate signals. It should not be
|
||||
* concerned with the application logic in any way.
|
||||
*/
|
||||
class QualityChecker : public QDockWidget, private Ui::QualityChecker
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
QualityChecker(QWidget * parent = 0, Qt::WindowFlags flags = 0);
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
void createImageSpaceClicked();
|
||||
void compareClicked();
|
||||
void layerChosenChanged();
|
||||
|
||||
public slots :
|
||||
void on_compare();
|
||||
void on_createImageSpace();
|
||||
void on_layerChosen();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
BIN
src/plugins_experimental/edit_panosample/resource.h
Normal file
BIN
src/plugins_experimental/edit_panosample/resource.h
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user