~ubuntu-branches/ubuntu/lucid/meshlab/lucid

« back to all changes in this revision

Viewing changes to meshlab/src/meshlabplugins/edit_phototexturing/photoTexturing.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-10-08 16:40:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091008164041-0c2ealqv8b8uc20c
Tags: 1.2.2-1
* New upstream version
* Do not build filter_isoparametrization because liblevmar dependency
  is not (yet) in Debian
* Fix compilation with gcc-4.4, thanks to Jonathan Liu for the patch
  (closes: #539544)
* rules: Add compiler variables to the qmake call (for testing with new
  GCC versions)
* io_3ds.pro: Make LIBS and INCLUDEPATH point to Debian version of lib3ds
* io_epoch.pro: Make LIBS point to Debian version of libbz2
* control:
  - Move Homepage URL to the source package section
  - Update to standards-version 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 * MeshLab                                                           o o     *
 
3
 * A versatile mesh processing toolbox                             o     o   *
 
4
 *                                                                _   O  _   *
 
5
 * Copyright(C) 2005                                                \/)\/    *
 
6
 * Visual Computing Lab                                            /\/|      *
 
7
 * ISTI - Italian National Research Council                           |      *
 
8
 *                                                                    \      *
 
9
 * All rights reserved.                                                      *
 
10
 *                                                                           *
 
11
 * This program is free software; you can redistribute it and/or modify      *   
 
12
 * it under the terms of the GNU General Public License as published by      *
 
13
 * the Free Software Foundation; either version 2 of the License, or         *
 
14
 * (at your option) any later version.                                       *
 
15
 *                                                                           *
 
16
 * This program is distributed in the hope that it will be useful,           *
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
 
19
 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
 
20
 * for more details.                                                         *
 
21
 *                                                                           *
 
22
 ****************************************************************************/
 
23
 
 
24
#include <QtGui>
 
25
 
 
26
#include <math.h>
 
27
#include <stdlib.h>
 
28
#include <meshlab/glarea.h>
 
29
#include <wrap/qt/trackball.h>
 
30
#include <PhotoTexturingWidget.h>
 
31
#include "photoTexturing.h"
 
32
 
 
33
using namespace std;
 
34
using namespace vcg;
 
35
 
 
36
/**
 
37
 * The PhotoTexturingPlugin is an edit plugin, which allows to texture a mesh using
 
38
 * a calibrated camera and a corresponding image. It is also possible to use more 
 
39
 * then one camera to generate a texture for the mesh. The texture of each individuell
 
40
 * camera can be merged with the other camera to one texture file.
 
41
 */
 
42
PhotoTexturingPlugin::PhotoTexturingPlugin() {
 
43
        qFont.setFamily("Helvetica");
 
44
        qFont.setPixelSize(10);
 
45
                
 
46
        ptDialog = NULL;
 
47
        glArea = NULL;
 
48
        // inits the PhotoTexturer
 
49
        photoTexturer = new PhotoTexturer();
 
50
}
 
51
 
 
52
const QString PhotoTexturingPlugin::Info() {
 
53
        return tr("Generates a texture for a mesh using a calibrated camera and a photo made by this camera.");
 
54
}
 
55
 
 
56
void PhotoTexturingPlugin::StartEdit(MeshModel &m, GLArea *gla)
 
57
{       
 
58
        //Creat GUI window
 
59
        if(ptDialog == NULL)
 
60
        {
 
61
                ptDialog = new PhotoTexturingWidget::PhotoTexturingWidget(this,photoTexturer,m, gla);
 
62
                //ptDialog->setWindowFlags(Qt::WindowStaysOnTopHint);
 
63
                //qDebug()<<"new PhotoTexturingDialog";
 
64
        }
 
65
        glArea = gla;
 
66
        
 
67
        //connect(this,SIGNAL(suspendEditToggle()),gla,SLOT(suspendEditToggle()));
 
68
        //emit suspendEditToggle();
 
69
        
 
70
        //show the dialog
 
71
        ptDialog->show();
 
72
}
 
73
 
 
74
void PhotoTexturingPlugin::mousePressEvent(QMouseEvent *e, MeshModel &mm, GLArea *glArea)
 
75
{
 
76
        //just passes throgh the mouse events to the GLArea
 
77
        e->accept();
 
78
        glArea->setFocus();     
 
79
        if (glArea->isDefaultTrackBall())
 
80
                glArea->trackball.MouseDown(e->x(),glArea->height()-e->y(), QT2VCG(e->button(), e->modifiers() ) );
 
81
        else glArea->trackball_light.MouseDown(e->x(),glArea->height()-e->y(), QT2VCG(e->button(), Qt::NoModifier ) );
 
82
        glArea->update();
 
83
}
 
84
 
 
85
void PhotoTexturingPlugin::mouseMoveEvent(QMouseEvent *e, MeshModel &, GLArea *glArea)
 
86
 
87
        //just passes throgh the mouse move events to the GLArea
 
88
        if(e->buttons() | Qt::LeftButton) 
 
89
        {
 
90
            if (glArea->isDefaultTrackBall()) 
 
91
                {
 
92
                glArea->trackball.MouseMove(e->x(),glArea->height()-e->y());
 
93
                //glArea->setCursorTrack(glArea->trackball.current_mode);
 
94
                }
 
95
            else glArea->trackball_light.MouseMove(e->x(),glArea->height()-e->y());
 
96
            glArea->update();
 
97
        }
 
98
}
 
99
 
 
100
// When mouse is released we set the correct mouse curson
 
101
void PhotoTexturingPlugin::mouseReleaseEvent(QMouseEvent *e, MeshModel &, GLArea *glArea)
 
102
{
 
103
          if (glArea->isDefaultTrackBall()) glArea->trackball.MouseUp(e->x(),glArea->height()-e->y(), QT2VCG(e->button(), e->modifiers() ) );
 
104
                else glArea->trackball_light.MouseUp(e->x(),glArea->height()-e->y(), QT2VCG(e->button(),e->modifiers()) );
 
105
          //glArea->setCursorTrack(glArea->trackball.current_mode);
 
106
        
 
107
        
 
108
          glArea->update();
 
109
}
 
110
 
 
111
void PhotoTexturingPlugin::EndEdit(MeshModel &/*m*/, GLArea *gla){
 
112
        //gla->reloadTexture();
 
113
        ptDialog->hide();
 
114
        //delete ptDialog;
 
115
        //ptDialog = NULL;
 
116
}