File: edit_align.cpp

package info (click to toggle)
meshlab 2022.02%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 47,348 kB
  • sloc: cpp: 536,635; ansic: 27,783; sh: 539; makefile: 36
file content (621 lines) | stat: -rw-r--r-- 20,278 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
/****************************************************************************
* 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.                                                         *
*                                                                           *
****************************************************************************/
/****************************************************************************
History
$Log: meshedit.cpp,v $
****************************************************************************/

#include "edit_align.h"
#include <common/GLExtensionsManager.h>
#include <meshlab/glarea.h>
#include <meshlab/rich_parameter_gui/richparameterlistdialog.h>
#include <wrap/qt/trackball.h>
#include "AlignPairWidget.h"
#include "AlignPairDialog.h"
#include "align/align_parameter.h"
#include <vcg/space/point_matching.h>
#include <vcg/complex/algorithms/point_matching_scale.h>

#include <QMessageBox>

using namespace vcg;

//todo: remove these orrible defs from here
//make vcg::PointMatchingScale independent
std::vector<vcg::Point3d>* vcg::PointMatchingScale::fix;
std::vector<vcg::Point3d>* vcg::PointMatchingScale::mov;
vcg::Box3d vcg::PointMatchingScale::b;

EditAlignPlugin::EditAlignPlugin()
{
    alignDialog = nullptr;
    qFont.setFamily("Helvetica");
    qFont.setPixelSize(10);

    trackball.center=Point3f(0, 0, 0);
    trackball.radius= 1;
}

QString EditAlignPlugin::info()
{
    return tr("Allows one to align different layers together.");
}

void EditAlignPlugin::suggestedRenderingData(MeshModel & /*m*/, MLRenderingData& dt)
{
	MLPerViewGLOptions opts;
	dt.get(opts);
	for (auto pr = MLRenderingData::PRIMITIVE_MODALITY(0); pr < MLRenderingData::PR_ARITY; pr = MLRenderingData::next(pr))
	{
		MLRenderingData::RendAtts atts;
		dt.get(pr, atts);

		atts[MLRenderingData::ATT_NAMES::ATT_VERTCOLOR] = false;
		if (pr == MLRenderingData::PR_SOLID)
			atts[MLRenderingData::ATT_NAMES::ATT_FACECOLOR] = false;
		dt.set(pr, atts);
	}

	opts._perpoint_fixed_color_enabled = false;
	opts._perwire_fixed_color_enabled = false;
	opts._persolid_fixed_color_enabled = false;

	opts._perpoint_mesh_color_enabled = true;
	opts._perwire_mesh_color_enabled = true;
	opts._persolid_mesh_color_enabled = true;

	dt.set(opts);

	/*switch (mode)
	{
		case ALIGN_MOVE:
		{
			_shared->setRenderingDataPerMeshView(m.id(), _gla->context(), dt);
			m.visible = false;
			break;
		}
		case ALIGN_IDLE:
		{

			MLPerViewGLOptions opts;
			dt.get(opts);
			opts._perbbox_enabled = true;
			dt.set(opts);

			_shared->setRenderingDataPerMeshView(m.id(), _gla->context(), dt);
		}
		case ALIGN_INSPECT_ARC:
		{
			break;
		}
	}*/
}

bool EditAlignPlugin::startEdit(MeshDocument& md, GLArea * gla, MLSceneGLSharedDataContext* cont)
{
	_md=&md;
	_gla= gla;
	_shared = cont;

	if ((_gla == NULL) || (_shared == NULL) || (md.meshNumber() < 1))
		return false;

	//mainW->addDockWidget(Qt::LeftDockWidgetArea,alignDialog);
	mode = ALIGN_IDLE;
	int numOfMeshes = _md->meshNumber();
	meshTree.clear();
	for(MeshModel& mm: _md->meshIterator()) {
		// assigns random color: if less than 50 meshes, color is truly unique, and the less meshes, the more different they will be
		// if above 50, truly unique color would generate too similar colors, so total number of unique color
		// is capped to 50 and the color reused, id that are close will have different color anyway
		if (numOfMeshes < 50)
			mm.cm.C() = Color4b::Scatter(numOfMeshes + 1, mm.id(), .2f, .7f);
		else
			mm.cm.C() = Color4b::Scatter(51, mm.id() % 50, .2f, .7f);
		mm.updateDataMask(MeshModel::MM_COLOR);
//			meshTree.nodeList.push_back(new MeshNode(mm));
		meshTree.nodeMap[mm.id()] = new MeshTreem::MeshNode(&mm);
	}

//	for(QMap<int,RenderMode>::iterator it = _gla->rendermodemap.begin();it != _gla->rendermodemap.end();++it)
//		it.value().colorMode=GLW::CMPerMesh;

	_gla->setCursor(QCursor(QPixmap(":/images/cur_align.png"),1,1));
	if (alignDialog == nullptr) {
		if (!GLExtensionsManager::initializeGLextensions_notThrowing())
			return false;

		alignDialog = new AlignDialog(_gla->window(),this);
		connect(alignDialog->ui.meshTreeParamButton,SIGNAL(clicked()),this,SLOT(meshTreeParam()));
		connect(alignDialog->ui.icpParamButton,SIGNAL(clicked()),this,SLOT(alignParam()));
		connect(alignDialog->ui.icpParamDefMMButton, SIGNAL(clicked()), this, SLOT(setAlignParamMM()));
		connect(alignDialog->ui.icpParamDefMButton, SIGNAL(clicked()), this, SLOT(setAlignParamM()));
		connect(alignDialog->ui.icpParamCurrentButton,SIGNAL(clicked()),this,SLOT(alignParamCurrent()));
		connect(alignDialog->ui.icpButton,SIGNAL(clicked()),this,SLOT(process()));
		connect(alignDialog->ui.manualAlignButton,SIGNAL(clicked()),this,SLOT(glueManual()));
		connect(alignDialog->ui.pointBasedAlignButton,SIGNAL(clicked()),this,SLOT(glueByPicking()));
		connect(alignDialog->ui.glueHereButton,SIGNAL(clicked()),this,SLOT(glueHere()));
		connect(alignDialog->ui.glueHereAllButton,SIGNAL(clicked()),this,SLOT(glueHereVisible()));
		connect(alignDialog->ui.recalcButton, SIGNAL(clicked()) , this,  SLOT(recalcCurrentArc() ) );
		connect(alignDialog->ui.hideRevealButton,  SIGNAL(clicked()) , this,  SLOT(hideRevealGluedMesh() ) );
		connect(alignDialog, SIGNAL(updateMeshSetVisibilities() ), _gla,SLOT(updateMeshSetVisibilities()));
		connect(alignDialog->ui.baseMeshButton, SIGNAL(clicked()) , this,  SLOT(setBaseMesh() ) );
		connect(alignDialog->ui.badArcButton, SIGNAL(clicked()) , this,  SLOT(selectBadArc() ) );
	}

	//alignDialog->setCurrentNode(meshTree.find(gla->mm()) );
	alignDialog->setTree(& meshTree);
	alignDialog->show();
	//alignDialog->adjustSize();
	
	connect(this, SIGNAL(suspendEditToggle()),_gla,SLOT(suspendEditToggle()) );
	connect(alignDialog, SIGNAL(closing()),_gla,SLOT(endEdit()) );
	connect(_md,SIGNAL(currentMeshChanged(int)),alignDialog,SLOT(currentMeshChanged(int)));
	suspendEditToggle();
	return true;
}

void EditAlignPlugin::decorate(MeshModel & mm, GLArea * gla)
{
	glPushAttrib(GL_ALL_ATTRIB_BITS);

	_gla = gla;
	if (mode == ALIGN_IDLE)
	{
		MLRenderingData tmp;
		MLPerViewGLOptions opts;
		tmp.get(opts);
		opts._perbbox_enabled = true;
		tmp.set(opts);
		_shared->drawAllocatedAttributesSubset(mm.id(), _gla->context(), tmp);
		if ((alignDialog != nullptr) && (alignDialog->currentArc != nullptr))
			DrawArc(alignDialog->currentArc);
	}

	if (mode == ALIGN_MOVE)
	{
		MLRenderingData dt;
		_shared->getRenderInfoPerMeshView(mm.id(), _gla->context(), dt);
		MLPerViewGLOptions opts;
		dt.get(opts);
		opts._perbbox_enabled = false;
		dt.set(opts);

		glPushMatrix();
		trackball.GetView();
		trackball.Apply();
		_shared->drawAllocatedAttributesSubset(mm.id(), _gla->context(),dt);
		glPopMatrix();
	}
	glPopAttrib();
}

void EditAlignPlugin::endEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/)
{

    // some cleaning at the end.
    qDebug("EndEdit: cleaning everything");
    meshTree.clear();

    delete alignDialog;
    alignDialog = nullptr;
}

void EditAlignPlugin::hideRevealGluedMesh()
{
  //    foreach(MeshNode *mn, meshTree.nodeList)
  for(auto ni=meshTree.nodeMap.begin();ni!=meshTree.nodeMap.end();++ni)
  { 
    MeshTreem::MeshNode *mn=ni->second;
        if(!mn->glued) mn->m->setVisible(!(mn->m->isVisible()));
  }
    alignDialog->rebuildTree();
    _gla->update();
    alignDialog->updateMeshVisibilities();
}

void EditAlignPlugin::setBaseMesh()
{
    Matrix44d oldTr = Matrix44d::Construct(_md->mm()->cm.Tr);
    Matrix44d inv = Inverse(oldTr);
    _md->mm()->cm.Tr.SetIdentity();

    //foreach(MeshNode *mn, meshTree.nodeList)
    for(auto ni=meshTree.nodeMap.begin();ni!=meshTree.nodeMap.end();++ni)
    {
        MeshTreem::MeshNode *mn=ni->second;
      if(mn->glued && (mn->m != _md->mm()) )
            mn->m->cm.Tr.Import(inv*Matrix44d::Construct(mn->m->cm.Tr));
    }

    alignDialog->rebuildTree();
    _gla->update();
}


void EditAlignPlugin::glueByPicking()
{
    if(meshTree.gluedNum()<1)
    {
        QMessageBox::warning(0,"Align tool", "Point-based aligning requires at least one glued  mesh");
        return;
    }

    //Matrix44f oldTr = md->mm()->cm.Tr;
    AlignPairDialog *dd = new AlignPairDialog(_gla,this->alignDialog);
    dd->aa->initMesh(currentNode(), &meshTree);
    dd->exec();

    if (dd->result()==QDialog::Rejected) return;

    // i picked points sono in due sistemi di riferimento.

    std::vector<Point3m>freePnt = dd->aa->freePickedPointVec;
    std::vector<Point3m>gluedPnt= dd->aa->gluedPickedPointVec;

    if( (freePnt.size() != gluedPnt.size())	|| (freePnt.size()==0) )	{
        QMessageBox::warning(0,"Align tool", "ERROR: alignment requires the same number of chosen points");
        return;
    }

    Matrix44m res;
    if ((dd != nullptr) && (dd->aa != nullptr) && (dd->aa->allowscaling))
        ComputeSimilarityMatchMatrix(gluedPnt,freePnt,res);
    else
        ComputeRigidMatchMatrix(gluedPnt,freePnt,res);

    //md->mm()->cm.Tr=res;
	currentNode()->tr() = currentNode()->tr() * res;
    QString buf;
    // for(size_t i=0;i<freePnt.size();++i)
    //		meshTree.cb(0,qUtf8Printable(buf.sprintf("%f %f %f -- %f %f %f \n",freePnt[i][0],freePnt[i][1],freePnt[i][2],gluedPnt[i][0],gluedPnt[i][1],gluedPnt[i][2])));

    assert(currentNode()->glued==false);

    currentNode()->glued=true;
    alignDialog->rebuildTree();
    _gla->update();
}


void EditAlignPlugin::glueManual()
{
    assert(currentNode()->glued==false);
    
	if ((_md == nullptr) || (_md->mm() == nullptr) || (_gla == nullptr) || (_gla->mvc() == nullptr))
		return;

	MeshModel *mm=_md->mm();

	static QString oldLabelButton;
    Matrix44f tran,mtran, tmp;
	
    switch(mode)
    {
		case ALIGN_IDLE:
		{
			emit suspendEditToggle();
			mode = ALIGN_MOVE;
			mm->setVisible(false);
			trackball.Reset();
			trackball.center.Import(mm->cm.trBB().Center());
			trackball.radius = mm->cm.trBB().Diag() / 2.0;
			toggleButtons();
			oldLabelButton = alignDialog->ui.manualAlignButton->text();
			alignDialog->ui.manualAlignButton->setText("Accept Transformation");
			break;
		}

		case ALIGN_MOVE:  // stop manual alignment and freeze the mesh
		{
			emit suspendEditToggle();
			mode = ALIGN_IDLE;
			toggleButtons();
			tran.SetTranslate(trackball.center);
			mtran.SetTranslate(-trackball.center);
			tmp.Import(mm->cm.Tr);
			mm->cm.Tr.Import((tran)* trackball.track.Matrix()*(mtran)* tmp);
			mm->setVisible(true);
			alignDialog->ui.manualAlignButton->setText(oldLabelButton);
			currentNode()->glued = true;
			alignDialog->rebuildTree();
			break;
		}
		default : assert("entered in the GlueManual slot in the wrong state"==nullptr);
	}

    _gla->update();
}

void EditAlignPlugin:: alignParamCurrent()
{
    assert(currentArc());

    RichParameterList alignParamSet;
    QString titleString=QString("Current Arc (%1 -> %2) Alignment Parameters").arg(currentArc()->MovName).arg(currentArc()->FixName);
    AlignParameter::AlignPairParamToRichParameterSet(currentArc()->ap, alignParamSet);

	RichParameterListDialog ad(alignDialog, alignParamSet, titleString);
    ad.setWindowFlags(Qt::Dialog);
    ad.setWindowModality(Qt::WindowModal);
    int result=ad.exec();
    if(result != QDialog::Accepted) return;

    // Dialog accepted. get back the values
    AlignParameter::RichParameterSetToAlignPairParam(alignParamSet, currentArc()->ap);
}

void EditAlignPlugin:: meshTreeParam()
{
  RichParameterList  meshTreeParamSet;
  AlignParameter::MeshTreeParamToRichParameterSet(defaultMTP, meshTreeParamSet);
  RichParameterListDialog ad(alignDialog, meshTreeParamSet, "Default Alignment Parameters");
  ad.setWindowFlags(Qt::Dialog);
  ad.setWindowModality(Qt::WindowModal);
  int result=ad.exec();
  if(result != QDialog::Accepted) return;
  // Dialog accepted. get back the values
  AlignParameter::RichParameterSetToMeshTreeParam(meshTreeParamSet, defaultMTP);

}

void EditAlignPlugin:: alignParam()
{
    RichParameterList alignParamSet;
    AlignParameter::AlignPairParamToRichParameterSet(defaultAP, alignParamSet);
	RichParameterListDialog ad(alignDialog, alignParamSet, "Default Alignment Parameters");
    ad.setWindowFlags(Qt::Dialog);
    ad.setWindowModality(Qt::WindowModal);
    int result=ad.exec();
    if(result != QDialog::Accepted) return;
    // Dialog accepted. get back the values
    AlignParameter::RichParameterSetToAlignPairParam(alignParamSet, defaultAP);
}

void EditAlignPlugin::setAlignParamMM()
{
	defaultAP.SampleNum = 2000;
	defaultAP.MinDistAbs = 10.0;
	defaultAP.TrgDistAbs = 0.005;
	defaultAP.MaxIterNum = 75;
	defaultAP.ReduceFactorPerc = 0.8;
	defaultAP.PassHiFilter = 0.75;
	defaultAP.MatchMode = AlignPair::Param::MMRigid;
	QMessageBox::warning(0, "Align tool", "ICP Default Parameters set for MILLIMETERS");
}

void EditAlignPlugin::setAlignParamM()
{
	defaultAP.SampleNum = 2000;
	defaultAP.MinDistAbs = 0.3;
	defaultAP.TrgDistAbs = 0.0005;
	defaultAP.MaxIterNum = 75;
	defaultAP.ReduceFactorPerc = 0.8;
	defaultAP.PassHiFilter = 0.75;
	defaultAP.MatchMode = AlignPair::Param::MMRigid;
	QMessageBox::warning(nullptr, "Align tool", "ICP Default Parameters set for METERS");
}

void EditAlignPlugin::glueHere()
{
    MeshTreem::MeshNode *mn=currentNode();
    if(mn->glued)
      meshTree.deleteResult(mn);

    mn->glued = !mn->glued;
    alignDialog->rebuildTree();
}

void EditAlignPlugin::glueHereVisible()
{
  for(auto ni=meshTree.nodeMap.begin();ni!=meshTree.nodeMap.end();++ni)
//    foreach(MeshNode *mn, meshTree.nodeList)
      if(ni->second->m->isVisible()) ni->second->glued=true;

    alignDialog->rebuildTree();
}

void EditAlignPlugin::selectBadArc()
{
  float maxErr=0;
  AlignPair::Result *worseArc=0;
  for(auto li=meshTree.resultList.begin();li!=meshTree.resultList.end();++li)
  {
    if(li->err > maxErr)
    {
      maxErr=li->err;
      worseArc=&*li;
    }
  }
  if(worseArc)
    alignDialog->setCurrentArc(worseArc);
}


void EditAlignPlugin::process()
{
    if(meshTree.gluedNum()<2)
    {
        QMessageBox::warning(nullptr,"Align tool", "ICP Process can only work when at least two layers have been glued");
        return;
    }
    alignDialog->setEnabled(false);
    meshTree.Process(defaultAP, defaultMTP);
    alignDialog->rebuildTree();
    _gla->update();
    alignDialog->setEnabled(true);
}

void EditAlignPlugin::recalcCurrentArc()
{
    assert(currentArc());

    alignDialog->setEnabled(false);
    meshTree.ProcessArc(currentArc()->FixName,currentArc()->MovName,*currentArc(),currentArc()->ap);
    meshTree.ProcessGlobal(currentArc()->ap);
    AlignPair::Result *recomputedArc = currentArc();
    alignDialog->rebuildTree();
    alignDialog->setCurrentArc(recomputedArc);
    alignDialog->setEnabled(true);
    _gla->update();
}


void EditAlignPlugin::mousePressEvent(QMouseEvent *e, MeshModel &, GLArea * )
{
    if(mode==ALIGN_MOVE)
    {
        trackball.MouseDown(e->x(),_gla->height()-e->y(), QT2VCG(e->button(), e->modifiers() ) );
        _gla->update();
    }
}

void EditAlignPlugin::mouseMoveEvent(QMouseEvent *e, MeshModel &, GLArea * )
{
    if(mode==ALIGN_MOVE)
    {
        trackball.MouseMove(e->x(),_gla->height()-e->y() );
        _gla->update();
    }

}

void EditAlignPlugin::mouseReleaseEvent(QMouseEvent * e, MeshModel &/*m*/, GLArea * )
{
    if(mode==ALIGN_MOVE)
    {
        trackball.MouseUp(e->x(),_gla->height()-e->y(), QT2VCG(e->button(), e->modifiers() ) );
        _gla->update();
    }
}


// this function toggles on and off all the buttons (according to the "modal" states of the interface),
// do not confuse it with the updatebuttons function of the alignDialog class.
void EditAlignPlugin::toggleButtons()
{
    switch(mode)
    {
    case	ALIGN_MOVE:
        alignDialog->ui.manualAlignButton->setEnabled(true);
		alignDialog->ui.glueHereButton->setEnabled(false);
		alignDialog->ui.glueHereAllButton->setEnabled(false);
		alignDialog->ui.pointBasedAlignButton->setEnabled(false);
		alignDialog->ui.baseMeshButton->setEnabled(false);
		alignDialog->ui.hideRevealButton->setEnabled(false);
		alignDialog->ui.icpButton->setEnabled(false);
		alignDialog->ui.icpParamButton->setEnabled(false);
		alignDialog->ui.icpParamDefMMButton->setEnabled(false);
		alignDialog->ui.icpParamDefMButton->setEnabled(false);
		alignDialog->ui.meshTreeParamButton->setEnabled(false);
		alignDialog->ui.badArcButton->setEnabled(false);
		alignDialog->ui.icpParamCurrentButton->setEnabled(false);
		alignDialog->ui.recalcButton->setEnabled(false);
        alignDialog->ui.alignTreeWidget->setEnabled(false);

        break;
    case	ALIGN_IDLE:
        alignDialog->ui.manualAlignButton->setEnabled(true);
		alignDialog->ui.glueHereButton->setEnabled(true);
		alignDialog->ui.glueHereAllButton->setEnabled(true);
		alignDialog->ui.pointBasedAlignButton->setEnabled(true);
		alignDialog->ui.baseMeshButton->setEnabled(true);
		alignDialog->ui.hideRevealButton->setEnabled(true);
		alignDialog->ui.icpButton->setEnabled(true);
		alignDialog->ui.icpParamButton->setEnabled(true);
		alignDialog->ui.icpParamDefMMButton->setEnabled(true);
		alignDialog->ui.icpParamDefMButton->setEnabled(true);
		alignDialog->ui.meshTreeParamButton->setEnabled(true);
		alignDialog->ui.badArcButton->setEnabled(true);
		alignDialog->ui.icpParamCurrentButton->setEnabled(true);
		alignDialog->ui.recalcButton->setEnabled(true);
		alignDialog->ui.alignTreeWidget->setEnabled(true);
		alignDialog->updateButtons();
        break;
    }
}

void EditAlignPlugin::DrawArc(vcg::AlignPair::Result *A )
{
    unsigned int i;
    AlignPair::Result &r=*A;
    MeshTreem::MeshNode *fix=meshTree.find(r.FixName);
    MeshTreem::MeshNode *mov=meshTree.find(r.MovName);
    //int mov=FindMesh(r.MovName);
    double nl=2.0*(*fix).bbox().Diag()/100.0;
    glPushAttrib(GL_ENABLE_BIT );

    glDisable(GL_LIGHTING);

    glPushMatrix();
    glMultMatrix(fix->tr());
    glPointSize(5.0f);
    glColor3f(1,0,0);
    glBegin(GL_POINTS);
    for(i=0;i<r.Pfix.size();i++) glVertex(r.Pfix[i]);
    glEnd();
    glPointSize(1.0f);
    //glColor((*fix).mi.c);
    if(r.Nfix.size()==r.Pfix.size())
    {
        glBegin(GL_LINES);
        for(i=0;i<r.Pfix.size();i++) {
            glVertex(r.Pfix[i]);
            glVertex(r.Pfix[i]+r.Nfix[i]*nl);
        }
        glEnd();
    }

    glPopMatrix();
    glPushMatrix();
    glMultMatrix(mov->tr());

    glPointSize(5.0f);
    glColor3f(0,0,1);
    glBegin(GL_POINTS);
    for(i=0;i<r.Pmov.size();i++) glVertex(r.Pmov[i]);
    glEnd();
    glPointSize(1.0f);
    //glColor((*mov).mi.c);
    if(r.Nmov.size()==r.Pmov.size())
    {
        glBegin(GL_LINES);
        for(i=0;i<r.Pmov.size();i++) {
            glVertex(r.Pmov[i]);
            glVertex(r.Pmov[i]+r.Nmov[i]*nl);
        }
        glEnd();
    }
    glPopMatrix();
    /*
    // Now Draw the histogram

    int HSize = ViewPort[2]-100;
    r.H.glDraw(Point4i(20,80,HSize,100),dlFont,r.as.I[0].MinDistAbs,1);
    */
    glPopAttrib();

}