edit_referencing ready for testing

This commit is contained in:
Marco Callieri mcallieri 2014-02-10 16:47:31 +00:00
parent dcddd826fc
commit 067fdc4ddc
4 changed files with 65 additions and 166 deletions

View File

@ -66,70 +66,6 @@ void EditReferencingPlugin::mouseReleaseEvent(QMouseEvent * event, MeshModel &/*
{
gla->update();
cur=event->pos();
//haveToPick=true;
// DEBUG DEBUG
/*
vector<vcg::Point3d> FixP;
vector<vcg::Point3d> 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; Pind<MovP.size(); Pind++)
{
TrError = (FixP[Pind] - (Mtrasf * MovP[Pind])).Norm();
this->Log(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; pindex<pointID.size(); pindex++)
{
if(pointID[pindex] == newname)
alreadyThere=true;
}
}
while(alreadyThere);
usePoint.push_back(new bool(true));
pointID.push_back(newname);
@ -761,6 +657,20 @@ void EditReferencingPlugin::applyMatrix()
newMat.Import(transfMatrix);
glArea->mm()->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();
}

View File

@ -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<bool> usePoint;
std::vector<QString> pointID;

View File

@ -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;
}

View File

@ -65,20 +65,6 @@
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -112,17 +98,17 @@
</column>
<column>
<property name="text">
<string>X (picked)</string>
<string>X (mov)</string>
</property>
</column>
<column>
<property name="text">
<string>Y (picked)</string>
<string>Y (mov)</string>
</property>
</column>
<column>
<property name="text">
<string>Z (picked)</string>
<string>Z (mov)</string>
</property>
</column>
<column>
@ -163,14 +149,14 @@
<item>
<widget class="QPushButton" name="addLine">
<property name="text">
<string>Add Point</string>
<string>Add New Point</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delLine">
<property name="text">
<string>Delete Point</string>
<string>Delete Current Point</string>
</property>
</widget>
</item>
@ -191,30 +177,36 @@
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="pickCurrent">
<property name="text">
<string>Pick Current</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="exportToFile">
<property name="text">
<string>Export to File</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="loadFromFile">
<property name="text">
<string>Load From File</string>
<string>Load Reference Points From File</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="exportToFile">
<property name="text">
<string>Export all Referencing Data to file...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pickCurrent">
<property name="text">
<string>Pick current point on MOVING</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="buttonPickRef">
<property name="text">
<string>DEBUG</string>
<string>Pick current point on REFERENCE</string>
</property>
</widget>
</item>
@ -231,7 +223,7 @@
<item row="0" column="0">
<widget class="QCheckBox" name="cbAllowScaling">
<property name="text">
<string>Allow Scaling</string>
<string>Allow UNIFORM Scaling</string>
</property>
</widget>
</item>