~ubuntu-branches/ubuntu/precise/mm3d/precise

« back to all changes in this revision

Viewing changes to src/implui/projectionwin.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ludovico Gardenghi
  • Date: 2008-10-21 01:00:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081021010014-65o1syy7ry430sn0
Tags: 1.3.7-1.1
* Non-maintainer upload.
* Fix FTBFS bug due to wrong Build-Depends -- still QT3 but new upstream
  moved to QT4. Removed useless dependencies on various X libraries.
  (Closes: #490331, #489838)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "texwidget.h"
29
29
#include "decalmgr.h"
30
30
 
31
 
#include "mq3compat.h"
 
31
#include <QtGui/QInputDialog>
 
32
#include <QtGui/QPushButton>
 
33
#include <QtGui/QComboBox>
 
34
#include <QtGui/QLabel>
 
35
#include <QtGui/QLineEdit>
 
36
#include <QtGui/QShortcut>
32
37
 
33
 
#include <qinputdialog.h>
34
 
#include <qpushbutton.h>
35
 
#include <qcombobox.h>
36
 
#include <qlabel.h>
37
 
#include <qlineedit.h>
38
38
#include <list>
39
39
 
40
40
using std::list;
45
45
#include "msg.h"
46
46
#include "modelstatus.h"
47
47
 
48
 
#ifdef HAVE_QT4
49
 
#include <QCloseEvent>
50
 
#endif // HAVE_QT4
51
 
 
52
48
ProjectionWin::ProjectionWin( Model * model, QWidget * parent, ViewPanel * viewPanel )
53
 
   : ProjectionWinBase( parent, "" ),
54
 
     m_accel( new QAccel(this) ),
 
49
   : QDialog( parent ),
55
50
     m_viewPanel( viewPanel ),
56
51
     m_undoCount( 0 ),
57
52
     m_redoCount( 0 ),
58
53
     m_inUndo( false ),
59
54
     m_ignoreChange( false )
60
55
{
 
56
   setupUi( this );
 
57
 
 
58
   m_material->hide();
 
59
   m_materialLabel->hide();
 
60
 
61
61
   m_textureWidget = m_textureFrame->getTextureWidget();
62
62
   m_textureWidget->setInteractive( true );
63
63
   m_textureWidget->setMouseOperation( TextureWidget::MouseRange );
69
69
   connect( m_textureWidget, SIGNAL(updateSeamDoneSignal()), this, SLOT(applyProjectionEvent()) );
70
70
   connect( m_textureWidget, SIGNAL(zoomLevelChanged(QString)), this, SLOT(zoomLevelChangedEvent(QString)) );
71
71
 
72
 
   m_accel->insertItem( QKeySequence( tr("F1", "Help Shortcut")), 0 );
73
 
   m_accel->insertItem( QKeySequence( tr("Ctrl+Z", "Undo")), 1 );
74
 
   m_accel->insertItem( QKeySequence( tr("Ctrl+Y", "Redo")), 2 );
75
 
   connect( m_accel, SIGNAL(activated(int)), this, SLOT(accelEvent(int)) );
 
72
   QShortcut * help = new QShortcut( QKeySequence( tr("F1", "Help Shortcut")), this );
 
73
   connect( help, SIGNAL(activated()), this, SLOT(helpNowEvent()) );
 
74
 
 
75
   QShortcut * undo = new QShortcut( QKeySequence( tr("CTRL+Z", "Undo shortcut")), this );
 
76
   connect( undo, SIGNAL(activated()), this, SLOT(undoEvent()) );
 
77
   QShortcut * redo = new QShortcut( QKeySequence( tr("CTRL+Y", "Redo shortcut")), this );
 
78
   connect( redo, SIGNAL(activated()), this, SLOT(redoEvent()) );
76
79
 
77
80
   // can't do this until constructor is done (because of Model::Observer interface)
78
81
   //setModel( model );
88
91
 
89
92
   if ( m_projection->count() > 0 )
90
93
   {
91
 
      int proj = m_projection->currentItem();
 
94
      int proj = m_projection->currentIndex();
92
95
      unsigned tcount = m_model->getTriangleCount();
93
96
      for ( unsigned t = 0; t < tcount; t++ )
94
97
      {
125
128
         m_redoCount = 0;
126
129
      }
127
130
 
128
 
      // FIXME need some way to re-select the projection we were looking at
 
131
      // TODO need some way to re-select the projection we were looking at
129
132
      if ( isVisible() )
130
133
      {
131
134
         int projCount = m_model->getProjectionCount();
139
142
         {
140
143
            // a change to projection itself, or a non-projection change, just 
141
144
            // re-initialize the projection display for the current projection
142
 
            int p = m_projection->currentItem();
143
 
            m_projection->changeItem( QString::fromUtf8( m_model->getProjectionName( p )), p );
144
 
            m_type->setCurrentItem( m_model->getProjectionType( p ) );
 
145
            int p = m_projection->currentIndex();
 
146
            m_projection->setItemText( p, QString::fromUtf8( m_model->getProjectionName( p )) );
 
147
            m_type->setCurrentIndex( m_model->getProjectionType( p ) );
145
148
            // TODO material/test pattern?
146
149
            addProjectionTriangles();
147
150
         }
202
205
   }
203
206
}
204
207
 
205
 
void ProjectionWin::accelEvent( int id )
 
208
void ProjectionWin::helpNowEvent()
206
209
{
207
 
   switch ( id )
208
 
   {
209
 
      case 0:
210
 
         {
211
 
            HelpWin * win = new HelpWin( "olh_projectionwin.html", true );
212
 
            win->show();
213
 
         }
214
 
         break;
215
 
      case 1:
216
 
         undoEvent();
217
 
         break;
218
 
      case 2:
219
 
         redoEvent();
220
 
         break;
221
 
   }
 
210
   HelpWin * win = new HelpWin( "olh_projectionwin.html", true );
 
211
   win->show();
222
212
}
223
213
 
224
214
void ProjectionWin::undoEvent()
252
242
      // If we are visible, setModel already did this
253
243
      initWindow();
254
244
   }
255
 
   ProjectionWinBase::show();
 
245
   QDialog::show();
256
246
}
257
247
 
258
248
void ProjectionWin::initWindow()
283
273
      {
284
274
         for ( unsigned p = 0; p < pcount; p++ )
285
275
         {
286
 
            m_projection->insertItem( QString::fromUtf8( m_model->getProjectionName(p) ), p );
 
276
            m_projection->insertItem( p, QString::fromUtf8( m_model->getProjectionName(p) ) );
287
277
         }
288
278
 
289
279
         bool found = false;
293
283
            if ( m_model->isProjectionSelected( p ) )
294
284
            {
295
285
               found = true;
296
 
               m_projection->setCurrentItem( p );
 
286
               m_projection->setCurrentIndex( p );
297
287
               projectionIndexChangedEvent( p );
298
288
               break;
299
289
            }
309
299
                  int p = m_model->getTriangleProjection( t );
310
300
                  if ( p >= 0 )
311
301
                  {
312
 
                     m_projection->setCurrentItem( p );
 
302
                     m_projection->setCurrentIndex( p );
313
303
                     projectionIndexChangedEvent( p );
314
304
                     break;
315
305
                  }
344
334
   {
345
335
      m_model->setProjectionType( p, type );
346
336
      //m_model->applyProjection( p );
347
 
      operationComplete( tr( "Set Projection Type", "operation complete" ).utf8() );
 
337
      operationComplete( tr( "Set Projection Type", "operation complete" ).toUtf8() );
348
338
   }
349
339
 
350
340
   refreshProjectionDisplay();
363
353
      }
364
354
   }
365
355
   m_model->applyProjection( p );
366
 
   operationComplete( tr( "Set Triangle Projection", "operation complete" ).utf8() );
 
356
   operationComplete( tr( "Set Triangle Projection", "operation complete" ).toUtf8() );
367
357
   refreshProjectionDisplay();
368
358
}
369
359
 
377
367
         m_model->setTriangleProjection( t, -1 );
378
368
      }
379
369
   }
380
 
   operationComplete( tr( "Set Triangle Projection", "operation complete" ).utf8() );
 
370
   operationComplete( tr( "Set Triangle Projection", "operation complete" ).toUtf8() );
381
371
   refreshProjectionDisplay();
382
372
}
383
373
 
395
385
void ProjectionWin::applyProjectionEvent()
396
386
{
397
387
   applyProjection();
398
 
   operationComplete( tr("Apply Projection", "operation complete").utf8() );
 
388
   operationComplete( tr("Apply Projection", "operation complete").toUtf8() );
399
389
}
400
390
 
401
391
void ProjectionWin::resetClickedEvent()
403
393
   int p = getSelectedProjection();
404
394
 
405
395
   m_model->setProjectionRange( p, 0.0, 0.0, 1.0, 1.0 );
406
 
   operationComplete( tr( "Reset UV Coordinates", "operation complete" ).utf8() );
 
396
   operationComplete( tr( "Reset UV Coordinates", "operation complete" ).toUtf8() );
407
397
   addProjectionTriangles();
408
398
   //applyProjectionEvent();
409
399
}
415
405
   if ( p >= 0 )
416
406
   {
417
407
      bool ok = false;
418
 
      QString projName = QInputDialog::getText( tr("Rename projection", "window title"), tr("Enter new point name:"), QLineEdit::Normal, QString::fromUtf8( m_model->getProjectionName( p )), &ok );
 
408
      QString projName = QInputDialog::getText( this, tr("Rename projection", "window title"), tr("Enter new point name:"), QLineEdit::Normal, QString::fromUtf8( m_model->getProjectionName( p )), &ok );
419
409
      if ( ok )
420
410
      {
421
 
         m_model->setProjectionName( p, projName.utf8() );
422
 
         m_projection->changeItem( projName, p );
423
 
         operationComplete( tr( "Rename Projection", "operation complete" ).utf8() );
 
411
         m_model->setProjectionName( p, projName.toUtf8() );
 
412
         m_projection->setItemText( p, projName );
 
413
         operationComplete( tr( "Rename Projection", "operation complete" ).toUtf8() );
424
414
      }
425
415
   }
426
416
}
428
418
void ProjectionWin::projectionIndexChangedEvent( int newIndex )
429
419
{
430
420
   int type = m_model->getProjectionType( newIndex );
431
 
   m_type->setCurrentItem( type );
 
421
   m_type->setCurrentIndex( type );
432
422
 
433
423
   double uv[4] = { 0, 0, 0, 0 };
434
424
   m_model->getProjectionRange( newIndex, 
441
431
 
442
432
void ProjectionWin::zoomChangeEvent()
443
433
{
444
 
   double zoom = atof( m_zoomInput->text().latin1() );
 
434
   double zoom = atof( m_zoomInput->text().toLatin1() );
445
435
   if ( zoom < 0.00001 )
446
436
   {
447
437
      zoom = 1;
491
481
{
492
482
   if ( m_projection->count() > 0 )
493
483
   {
494
 
      return m_projection->currentItem();
 
484
      return m_projection->currentIndex();
495
485
   }
496
486
   return -1;
497
487
}