diff --git a/src/plugins_experimental/edit_referencing/edit_referencing.cpp b/src/plugins_experimental/edit_referencing/edit_referencing.cpp index 2616d0342..a76428d79 100644 --- a/src/plugins_experimental/edit_referencing/edit_referencing.cpp +++ b/src/plugins_experimental/edit_referencing/edit_referencing.cpp @@ -66,70 +66,6 @@ void EditReferencingPlugin::mouseReleaseEvent(QMouseEvent * event, MeshModel &/* { gla->update(); cur=event->pos(); - //haveToPick=true; - - // DEBUG DEBUG -/* - vector FixP; - vector MovP; - Matrix44d Mtrasf; - vcg::Point3d newp; - - FixP.clear(); - newp = Point3d(-25.19000, 89.52376, 0.0); - FixP.push_back(newp); - newp = Point3d(35.97340, 21.47749, 1.0); - FixP.push_back(newp); - newp = Point3d(0.00000, 0.00000, 5.0); - FixP.push_back(newp); - newp = Point3d(-58.22760, 68.19291, 2.0); - FixP.push_back(newp); - newp = Point3d(-24.87419, 29.90908, 1.0); - FixP.push_back(newp); - newp = Point3d(8.98064, 46.20274, 2.0); - FixP.push_back(newp); - newp = Point3d(-34.08825, 59.46381, -3.0); - FixP.push_back(newp); - newp = Point3d(14.83746, 28.60058, -1.0); - FixP.push_back(newp); - - newp = Point3d(38.97, -45.4012, 0.0); - MovP.push_back(newp); - newp = Point3d(-52.9811, -39.7094, 1.0); - MovP.push_back(newp); - newp = Point3d(-42.0136, 0.259092, 5.0); - MovP.push_back(newp); - newp = Point3d(47.047, -7.04106, 2.0); - MovP.push_back(newp); - newp = Point3d(-3.1936, -3.69573, 1.0); - MovP.push_back(newp); - newp = Point3d(-16.494, -38.3969, 2.0); - MovP.push_back(newp); - newp = Point3d(23.9654, -17.6361, -3.0); - MovP.push_back(newp); - newp = Point3d(-32.6295, -29.9274, -1.0); - MovP.push_back(newp); - - ComputeRigidMatchMatrix(FixP, MovP, Mtrasf); - - this->Log(GLLogStream::FILTER, "MATRIX:"); - this->Log(GLLogStream::FILTER, "%f, %f, %f, %f",Mtrasf[0][0],Mtrasf[0][1],Mtrasf[0][2],Mtrasf[0][3]); - this->Log(GLLogStream::FILTER, "%f, %f, %f, %f",Mtrasf[1][0],Mtrasf[1][1],Mtrasf[1][2],Mtrasf[1][3]); - this->Log(GLLogStream::FILTER, "%f, %f, %f, %f",Mtrasf[2][0],Mtrasf[2][1],Mtrasf[2][2],Mtrasf[2][3]); - this->Log(GLLogStream::FILTER, "%f, %f, %f, %f",Mtrasf[3][0],Mtrasf[3][1],Mtrasf[3][2],Mtrasf[3][3]); - - this->Log(GLLogStream::FILTER, " "); - this->Log(GLLogStream::FILTER, "errors:"); - - float TrError=0; - for(int Pind=0; PindLog(GLLogStream::FILTER, "%d: %f",Pind,TrError); - } -*/ - - } void EditReferencingPlugin::Decorate(MeshModel &m, GLArea * gla, QPainter *p) @@ -186,7 +122,7 @@ void EditReferencingPlugin::Decorate(MeshModel &m, GLArea * gla, QPainter *p) glVertex3f(currpoint[0], currpoint[1], currpoint[2]+lineLen); glEnd(); - buf = pointID[pindex] + " (picked)"; + buf = pointID[pindex] + " (moving)"; vcg::glLabel::render(p,currpoint,buf); @@ -207,7 +143,7 @@ void EditReferencingPlugin::Decorate(MeshModel &m, GLArea * gla, QPainter *p) glVertex3f(currpoint[0], currpoint[1], currpoint[2]+lineLen); glEnd(); - buf = pointID[pindex] + " (ref)"; + buf = pointID[pindex] + " (reference)"; vcg::glLabel::render(p,currpoint,buf); if(validMatrix) @@ -229,7 +165,7 @@ void EditReferencingPlugin::Decorate(MeshModel &m, GLArea * gla, QPainter *p) glVertex3f(currpoint[0], currpoint[1], currpoint[2]+lineLen); glEnd(); - buf = pointID[pindex] + " (trasf)"; + buf = pointID[pindex] + " (transformed)"; vcg::glLabel::render(p,currpoint,buf); } } @@ -239,63 +175,11 @@ void EditReferencingPlugin::Decorate(MeshModel &m, GLArea * gla, QPainter *p) glPopAttrib(); } - if(curFacePtr) - { - glPushMatrix(); - glMultMatrix(m.cm.Tr); - glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LINE_BIT | GL_DEPTH_BUFFER_BIT); - glLineWidth(2.0f); - glDepthFunc(GL_ALWAYS); - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - - glDisable(GL_LIGHTING); - glColor(Color4b::DarkRed); - glBegin(GL_LINE_LOOP); - glVertex(curFacePtr->P(0)); - glVertex(curFacePtr->P(1)); - glVertex(curFacePtr->P(2)); - glEnd(); - - glDepthMask(GL_TRUE); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - glColor(Color4b::Red); - glBegin(GL_LINE_LOOP); - glVertex(curFacePtr->P(0)); - glVertex(curFacePtr->P(1)); - glVertex(curFacePtr->P(2)); - glEnd(); - - drawFace(curFacePtr,m,gla,p); - - glPopAttrib(); - glPopMatrix(); - } -} - -void EditReferencingPlugin::drawFace(CMeshO::FacePointer fp, MeshModel &m, GLArea *gla, QPainter *p) -{ - QString buf = QString("f%1\n (%3 %4 %5)").arg(tri::Index(m.cm,fp)).arg(tri::Index(m.cm,fp->V(0))).arg(tri::Index(m.cm,fp->V(1))).arg(tri::Index(m.cm,fp->V(2))); - Point3f c=Barycenter(*fp); - vcg::glLabel::render(p,c,buf); - for(int i=0;i<3;++i) - { - buf =QString("\nv%1:%2 (%3 %4 %5)").arg(i).arg(fp->V(i) - &m.cm.vert[0]).arg(fp->P(i)[0]).arg(fp->P(i)[1]).arg(fp->P(i)[2]); - if( m.hasDataMask(MeshModel::MM_VERTQUALITY) ) - buf +=QString(" - Q(%1)").arg(fp->V(i)->Q()); - if( m.hasDataMask(MeshModel::MM_WEDGTEXCOORD) ) - buf +=QString("- uv(%1 %2) id:%3").arg(fp->WT(i).U()).arg(fp->WT(i).V()).arg(fp->WT(i).N()); - if( m.hasDataMask(MeshModel::MM_VERTTEXCOORD) ) - buf +=QString("- uv(%1 %2) id:%3").arg(fp->V(i)->T().U()).arg(fp->V(i)->T().V()).arg(fp->V(i)->T().N()); - vcg::glLabel::render(p,fp->V(i)->P(),buf); - } } bool EditReferencingPlugin::StartEdit(MeshModel &m, GLArea *gla) { qDebug("EDIT_REFERENCING: StartEdit: setup all"); - curFacePtr=0; glArea=gla; @@ -349,6 +233,9 @@ void EditReferencingPlugin::EndEdit(MeshModel &/*m*/, GLArea *gla) void EditReferencingPlugin::addNewPoint() { status_error = ""; + int pindex; + bool alreadyThere; + QString newname; // i do not want to have too many refs if(usePoint.size() > MAX_REFPOINTS) @@ -357,9 +244,18 @@ void EditReferencingPlugin::addNewPoint() return; } - QString newname = "P" + QString::number(lastname++); - // I should check the name is really new... hehe :) + do + { + alreadyThere = false; + newname = "PP" + QString::number(lastname++); + for(pindex=0; pindexmm()->cm.Tr = newMat * glArea->mm()->cm.Tr; + if(referencingDialog->ui->cbApplyToAll->checkState() == Qt::Checked) + { + foreach(MeshModel *mmp, glArea->md()->meshList) + { + if(mmp->visible) + { + mmp->cm.Tr = newMat * glArea->mm()->cm.Tr; + } + } + } + else + { + glArea->mm()->cm.Tr = newMat * glArea->mm()->cm.Tr; + } + glArea->update(); } diff --git a/src/plugins_experimental/edit_referencing/edit_referencing.h b/src/plugins_experimental/edit_referencing/edit_referencing.h index b4e1b1b06..c4b73d814 100644 --- a/src/plugins_experimental/edit_referencing/edit_referencing.h +++ b/src/plugins_experimental/edit_referencing/edit_referencing.h @@ -52,12 +52,8 @@ public: void mouseMoveEvent(QMouseEvent *, MeshModel &, GLArea * ) {}; void mouseReleaseEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * ); - void drawFace(CMeshO::FacePointer fp,MeshModel &m, GLArea *gla, QPainter *p); - QPoint cur; QFont qFont; - bool haveToPick; - CMeshO::FacePointer curFacePtr; // the dialog edit_referencingDialog *referencingDialog; @@ -65,9 +61,6 @@ public: // used to draw over the rendering GLArea *glArea; - //the place where the mouse was clicked - QPoint currentMousePosition; - //referencing data std::vector usePoint; std::vector pointID; diff --git a/src/plugins_experimental/edit_referencing/edit_referencingDialog.cpp b/src/plugins_experimental/edit_referencing/edit_referencingDialog.cpp index 27cded44d..0d2124656 100644 --- a/src/plugins_experimental/edit_referencing/edit_referencingDialog.cpp +++ b/src/plugins_experimental/edit_referencing/edit_referencingDialog.cpp @@ -29,10 +29,11 @@ void edit_referencingDialog::closeEvent(QCloseEvent *event) void edit_referencingDialog::updateTable() { + this->referencingPlugin->status_error = ""; this->ui->tableWidget->clear(); this->ui->tableWidget->setRowCount(this->referencingPlugin->usePoint.size()); - this->ui->tableWidget->setHorizontalHeaderLabels(QString("Active; ID ;X (picked);Y (picked);Z (picked);X (ref);Y (ref);Z (ref);Error").split(";")); + this->ui->tableWidget->setHorizontalHeaderLabels(QString("Active; ID ;X (mov);Y (mov);Z (mov);X (ref);Y (ref);Z (ref);Error").split(";")); this->ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection); this->ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); @@ -89,6 +90,7 @@ void edit_referencingDialog::updateTable() void edit_referencingDialog::on_tableWidget_itemChanged(QTableWidgetItem *item) { + this->referencingPlugin->status_error = ""; // an item in the table has changed int rowInd = this->ui->tableWidget->currentRow(); int colInd = this->ui->tableWidget->currentColumn(); @@ -191,6 +193,7 @@ void edit_referencingDialog::on_tableWidget_itemChanged(QTableWidgetItem *item) void edit_referencingDialog::on_tableWidget_cellDoubleClicked(int row, int column) { + this->referencingPlugin->status_error = ""; // only significative for forst column, to toggle between active<->inactive if(column == 0) { @@ -214,6 +217,7 @@ void edit_referencingDialog::on_tableWidget_cellDoubleClicked(int row, int colum void edit_referencingDialog::on_tableWidget_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) { + this->referencingPlugin->status_error = ""; this->referencingPlugin->glArea->update(); return; } diff --git a/src/plugins_experimental/edit_referencing/edit_referencingDialog.ui b/src/plugins_experimental/edit_referencing/edit_referencingDialog.ui index dad8fd139..eea3917b6 100644 --- a/src/plugins_experimental/edit_referencing/edit_referencingDialog.ui +++ b/src/plugins_experimental/edit_referencing/edit_referencingDialog.ui @@ -65,20 +65,6 @@ 5 - - - - PushButton - - - - - - - PushButton - - - @@ -112,17 +98,17 @@ - X (picked) + X (mov) - Y (picked) + Y (mov) - Z (picked) + Z (mov) @@ -163,14 +149,14 @@ - Add Point + Add New Point - Delete Point + Delete Current Point @@ -191,30 +177,36 @@ 5 - - - Pick Current - - - - - - - Export to File - - - - - Load From File + Load Reference Points From File + + + false + + + false + + + Export all Referencing Data to file... + + + + + + + Pick current point on MOVING + + + + - DEBUG + Pick current point on REFERENCE @@ -231,7 +223,7 @@ - Allow Scaling + Allow UNIFORM Scaling