Now the render area is sizeble. Improved icons. Improved interface

This commit is contained in:
Paolo Cignoni cignoni 2008-04-05 16:13:46 +00:00
parent 7a7f77a3fb
commit 2fe01ba98e
11 changed files with 115 additions and 155 deletions

View File

@ -51,7 +51,7 @@ const PluginInfo &EditTexturePlugin::Info()
{
static PluginInfo ai;
ai.Date=tr(__DATE__);
ai.Version = tr("0.7.3");
ai.Version = tr("0.8");
ai.Author = ("Riccardo Dini");
return ai;
}
@ -116,7 +116,6 @@ void EditTexturePlugin::mouseMoveEvent (QAction *,QMouseEvent * event, MeshModel
glFlush();
}
}
}
void EditTexturePlugin::mouseReleaseEvent(QAction *,QMouseEvent * event, MeshModel &m, GLArea * gla)
@ -176,9 +175,7 @@ void EditTexturePlugin::StartEdit(QAction * /*mode*/, MeshModel &m, GLArea *gla
CMeshO::FaceIterator ff;
for(ff = m.cm.face.begin(); ff != m.cm.face.end(); ++ff)
if(!(*ff).IsD() && (*ff).IsS()) FaceSel.push_back(&*ff);
// Reset the flag
//m.cm.face.EnableFFAdjacency();
//tri::UpdateTopology<CMeshO>::FaceFace(m.cm);
CMeshO::FaceIterator fi;
for(fi = m.cm.face.begin(); fi != m.cm.face.end(); ++fi) (*fi).ClearS();
@ -227,7 +224,7 @@ void EditTexturePlugin::EndEdit(QAction * , MeshModel &m , GLArea * )
void EditTexturePlugin::DrawXORRect(GLArea *gla)
{
/* Draw the rectangle of the selection area */
// Draw the rectangle of the selection area
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
@ -252,7 +249,7 @@ void EditTexturePlugin::DrawXORRect(GLArea *gla)
glDisable(GL_LOGIC_OP);
glPopAttrib();
glPopMatrix(); // restore modelview
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
@ -260,12 +257,10 @@ void EditTexturePlugin::DrawXORRect(GLArea *gla)
void EditTexturePlugin::InitTexture(MeshModel &m)
{
// Get the textures folder
// Get the textures name and add the tab
QString s = QString(m.fileName.c_str());
// Add the tab
for(unsigned i = 0; i < m.cm.textures.size(); i++)
widget->AddRenderArea(m.cm.textures[i].c_str(), &m, i);
vcg::Trackball tb;
}
Q_EXPORT_PLUGIN(EditTexturePlugin)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -10,5 +10,6 @@
<file>images/selarea.png</file>
<file>images/selcon.png</file>
<file>images/selpan.png</file>
<file>images/selver.png</file>
</qresource>
</RCC>

View File

@ -9,6 +9,7 @@
#define ORIGINRECT 200
#define MAX 100000
#define NOSEL -1
#define AREADIM 400
RenderArea::RenderArea(QWidget *parent, QString textureName, MeshModel *m, unsigned tnum) : QGLWidget(parent)
{
@ -23,8 +24,7 @@ RenderArea::RenderArea(QWidget *parent, QString textureName, MeshModel *m, unsig
}
textNum = tnum;
model = m;
AREADIM = 400;
// Init
oldX = 0; oldY = 0;
viewport = Point2f(0,0);
@ -131,9 +131,12 @@ void RenderArea::paintEvent(QPaintEvent *)
{
if (selected && !model->cm.face[i].IsUserBit(selBit))
glVertex3f(model->cm.face[i].WT(j).u() * AREADIM , AREADIM - (model->cm.face[i].WT(j).v() * AREADIM), 1);
else glVertex3f((oScale.x() + (model->cm.face[i].WT(j).u() - oScale.x()) * scaleX) * AREADIM - panX/zoom,
AREADIM - ((oScale.y() + (model->cm.face[i].WT(j).v() - oScale.y()) * scaleY) * AREADIM) - panY/zoom, 1);
}
else if (editMode == Scale)
glVertex3f((oScale.x() + (model->cm.face[i].WT(j).u() - oScale.x()) * scaleX) * AREADIM - panX/zoom,
AREADIM - ((oScale.y() + (model->cm.face[i].WT(j).v() - oScale.y()) * scaleY) * AREADIM) - panY/zoom, 1);
else glVertex3f((origin.x() + (cos(degree) * (model->cm.face[i].WT(j).u() - origin.x()) - sin(degree) * (model->cm.face[i].WT(j).v() - origin.y()))) * AREADIM - panX/zoom,
AREADIM - ((origin.y() + (sin(degree) * (model->cm.face[i].WT(j).u() - origin.x()) + cos(degree) * (model->cm.face[i].WT(j).v() - origin.y()))) * AREADIM) - panY/zoom, 1);
}
glEnd();
// Draw the selected faces
@ -170,7 +173,7 @@ void RenderArea::paintEvent(QPaintEvent *)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,AREADIM,AREADIM,0,-1,1);
glOrtho(0,this->width(),this->height(),0,-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
@ -179,11 +182,15 @@ void RenderArea::paintEvent(QPaintEvent *)
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
// Line and text (native Qt)
painter.drawLine(0,AREADIM,AREADIM,AREADIM);
painter.drawLine(0,AREADIM,0,0);
painter.drawText(TRANSLATE, AREADIM - TRANSLATE, QString("(%1,%2)").arg((float)-viewport.X()/AREADIM).arg((float)viewport.Y()/AREADIM));
int w = this->visibleRegion().boundingRect().width();
int h = this->visibleRegion().boundingRect().height();
painter.drawLine(0,h,w,h);
painter.drawLine(0,h,0,0);
// Calculate the coords and draw it
float c0 = (float)(w-viewport.X())/AREADIM, c1 = (float)(AREADIM - h + viewport.Y())/AREADIM;
painter.drawText(TRANSLATE, h - TRANSLATE, QString("(%1,%2)").arg((float)-viewport.X()/AREADIM).arg((float)(AREADIM - h + viewport.Y())/AREADIM));
painter.drawText(TRANSLATE, TRANSLATE*3, QString("(%1,%2)").arg((float)-viewport.X()/AREADIM).arg((float)viewport.Y()/AREADIM + 1));
painter.drawText(AREADIM - TRANSLATE*18, AREADIM - TRANSLATE, QString("(%1,%2)").arg((float)-(viewport.X()/AREADIM) + 1).arg((float)viewport.Y()/AREADIM));
painter.drawText(w - TRANSLATE*18, h - TRANSLATE, QString("(%1,%2)").arg(c0).arg(c1));
painter.drawText(TRANSLATE, TRANSLATE*6, QString("V"));
painter.drawText(AREADIM - TRANSLATE*23, AREADIM - TRANSLATE, QString("U"));
@ -281,7 +288,7 @@ void RenderArea::mousePressEvent(QMouseEvent *e)
}
}
void RenderArea::mouseReleaseEvent(QMouseEvent *e)
void RenderArea::mouseReleaseEvent(QMouseEvent *)
{
switch(mode)
{
@ -344,7 +351,7 @@ void RenderArea::mouseReleaseEvent(QMouseEvent *e)
this->update(selection);
}
}
else // Connected
else if (selectMode == Connected)
{
// <---------
}
@ -385,13 +392,15 @@ void RenderArea::mouseMoveEvent(QMouseEvent *e)
{
// Move the origin rect inside the selection area
orX = tpanX - e->x();
int tx = originR.center().x() - orX;
/*int tx = originR.center().x() - orX;
if (tx < selection.x()) orX = - selection.x() + originR.center().x();
else if (tx > selection.x() + selection.width()) orX = originR.center().x() - (selection.x() + selection.width());
*/
orY = tpanY - e->y();
int ty = originR.y() - posY - orY;
/*int ty = originR.y() - posY - orY;
if (ty < selection.y()) orY = - selection.y() + originR.center().y();
else if (ty > selection.y() + selection.height()) orY = originR.center().y() - (selection.y() + selection.height());
*/
this->update(originR);
}
else if (pressed > NOSEL && pressed < selRect.size())
@ -408,10 +417,10 @@ void RenderArea::mouseMoveEvent(QMouseEvent *e)
if (start.x() < end.x()) {x1 = start.x(); x2 = end.x();} else {x1 = end.x(); x2 = start.x();}
if (start.y() < end.y()) {y1 = start.y(); y2 = end.y();} else {y1 = end.y(); y2 = start.y();}
area = QRect(x1,y1,x2-x1,y2-y1);
if (selectMode == Area) SelectFaces();
SelectFaces();
this->update(area);
}
else
else if (selectMode == Connected)
{
// <-------
}
@ -509,7 +518,7 @@ void RenderArea::RemapClamp()
panX = 0; panY = 0; tpanX = 0; tpanY = 0; oldPX = 0; oldPY = 0;
ResetTrack(true);
this->update();
emit UpdateStat(0,0,0,0,0); // <--------
emit UpdateModel();
}
void RenderArea::RemapMod()
@ -536,7 +545,7 @@ void RenderArea::RemapMod()
panX = 0; panY = 0; tpanX = 0; tpanY = 0; oldPX = 0; oldPY = 0;
ResetTrack(true);
this->update();
emit UpdateStat(0,0,0,0,0); // <--------
emit UpdateModel();
}
void RenderArea::ChangeMode(int index)
@ -574,8 +583,10 @@ void RenderArea::ChangeMode(int index)
}
}
break;
case 3:
case 3: // For internal use... reset the selction
mode = Select;
for (unsigned i = 0; i < model->cm.face.size(); i++) model->cm.face[i].ClearUserBit(selBit);
selection = QRect();
this->setCursor(Qt::CrossCursor);
break;
}
@ -585,8 +596,21 @@ void RenderArea::ChangeMode(int index)
void RenderArea::ChangeSelectMode(int index)
{
// Change the function of the mouse selection
if (index == 0) selectMode = Area;
else selectMode = Connected;
switch(index)
{
case 0:
selectMode = Area;
break;
case 1:
selectMode = Connected;
break;
case 2:
selectMode = Vertex;
break;
default:
selectMode = Area;
break;
}
}
void RenderArea::RotateComponent(float alfa)
@ -610,7 +634,7 @@ void RenderArea::RotateComponent(float alfa)
}
}
this->update();
emit UpdateStat(0,0,0,0,0); // <--------
emit UpdateModel();
}
}
@ -629,7 +653,7 @@ void RenderArea::ScaleComponent(float percX, float percY)
}
}
this->update();
emit UpdateStat(0,0,0,0,0);
emit UpdateModel();
}
void RenderArea::UpdateUV()
@ -648,7 +672,7 @@ void RenderArea::UpdateUV()
}
panX = 0; panY = 0; tpanX = 0; tpanY = 0; oldPX = 0; oldPY = 0;
this->update();
emit UpdateStat(0,0,0,0,0); // <--------
emit UpdateModel();
}
void RenderArea::ResetTrack(bool resetViewPort)
@ -661,14 +685,6 @@ void RenderArea::ResetTrack(bool resetViewPort)
tb->track.SetTranslate(Point3f(viewport.X(), viewport.Y(), 1));
}
void RenderArea::SetDimension(int dim)
{
// Change the dimension of the control
AREADIM = dim;
// <-------- resize e cambio areadim
this->update();
}
void RenderArea::SelectFaces()
{
// Check if a face is inside the rectangle of selection and mark it

View File

@ -15,12 +15,6 @@
#define RADIUS 10
#define RECTDIM 30
#define NO_CHANGE -1
#define RESET -2
#define IGNORECMD -3
#define ENABLECMD -4
#define DISABLECMD -5
using namespace std;
class RenderArea : public QGLWidget
@ -30,7 +24,7 @@ class RenderArea : public QGLWidget
public:
enum Mode { View, Edit, Select };
enum EditMode { Scale, Rotate, NoEdit };
enum SelectMode { Area, Connected };
enum SelectMode { Area, Connected, Vertex };
RenderArea(QWidget *parent = 0, QString path = QString(), MeshModel *m = 0, unsigned textNum = 0);
~RenderArea();
@ -44,7 +38,6 @@ public:
void ChangeSelectMode(int index);
void RemapClamp();
void RemapMod();
void SetDimension(int dim);
protected:
void paintEvent(QPaintEvent *event);
@ -52,7 +45,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent*e);
void wheelEvent(QWheelEvent *event);
private:
bool antialiased; // Antialiasing
@ -77,32 +70,30 @@ private:
int panX, panY, tpanX, tpanY, oldPX, oldPY; // Temp for axis
int maxX, maxY, minX, minY; // For texCoord out of border
int selBit;
bool selected;
int selBit; // User bit: idicates if a face is selected for editing
bool selected; // Indicates if the are some selected faces
QPointF origin; // Origin for rotate editing
QRect originR;
int orX, orY;
QPoint start, end; // Selection area
QRect area;
QRect area; // Dragged rectangle
// Info for interactive editing
vector<QRect> selRect;
QRect selection;
vector<QRect> selRect; // Vector of buttons area
QRect selection; // Selection area
QPoint selStart, selEnd;
int posX, posY, rectX, rectY, oldSRX, oldSRY;
float degree, scaleX, scaleY;
int highlighted, pressed, oldDelta;
QPointF oScale;
int initVX, initVY;
float B2, Rm, Rq;
int posX, posY, rectX, rectY, oldSRX, oldSRY; // Stored value
float degree, scaleX, scaleY; // Value for edit
int highlighted, pressed, oldDelta; // Info about mouse
QPointF oScale; // Point of origin for scaling
int initVX, initVY; // Old values of viewport
float B2, Rm, Rq; // Params for line intersection
QImage rot, scal;
QImage rot, scal; // Images for buttons
int AREADIM;
float zoom;
float zoom; // Actual value of zoom
void UpdateUV();
void ResetTrack(bool reset);
@ -115,7 +106,7 @@ private:
void UpdateSelectionArea(int x, int y);
signals:
void UpdateStat(float u, float v, int faceN, int vertN, int countFace);
void UpdateModel();
};

View File

@ -29,7 +29,7 @@ void TextureEditor::AddRenderArea(QString texture, MeshModel *m, unsigned index)
QTabBar *t = new QTabBar(ui.tabWidget);
RenderArea *ra= new RenderArea(t, texture, m, index);
ra->setGeometry(MARGIN,MARGIN,400,400);
ra->setGeometry(MARGIN,MARGIN,MAXW,MAXH);
ui.tabWidget->addTab(t, name);
if (countPage == 1)
{
@ -38,7 +38,7 @@ void TextureEditor::AddRenderArea(QString texture, MeshModel *m, unsigned index)
ra->show();
}
countPage++;
QObject::connect(ra, SIGNAL(UpdateStat(float,float,int,int, int)),this, SLOT(UpStat(float,float,int,int, int)));
QObject::connect(ra, SIGNAL(UpdateModel()),this, SLOT(UpdateModel()));
}
@ -51,10 +51,9 @@ void TextureEditor::AddEmptyRenderArea()
ra->show();
}
void TextureEditor::UpStat(float u, float v, int faceN, int vertN, int countFace)
void TextureEditor::UpdateModel()
{
// Manage the update of the controls from RenderArea to the editor, also enable/disable controls
// <----- TODO
// Update the mesh after an edit
area->update();
}
@ -91,7 +90,7 @@ void TextureEditor::on_connectedButton_clicked()
ResetLayout();
((RenderArea*)ui.tabWidget->currentWidget()->childAt(MARGIN,MARGIN))->ChangeMode(2);
((RenderArea*)ui.tabWidget->currentWidget()->childAt(MARGIN,MARGIN))->ChangeSelectMode(1);
ui.moveButton->setChecked(true);
ui.connectedButton->setChecked(true);
}
void TextureEditor::on_selectButton_clicked()
@ -102,16 +101,12 @@ void TextureEditor::on_selectButton_clicked()
ui.selectButton->setChecked(true);
}
void TextureEditor::on_optimizeButton_clicked()
void TextureEditor::on_vertexButton_clicked()
{
ResetLayout();
ui.optimizeButton->setChecked(true);
}
void TextureEditor::on_optionButton_clicked()
{
ResetLayout();
ui.optionButton->setChecked(true);
((RenderArea*)ui.tabWidget->currentWidget()->childAt(MARGIN,MARGIN))->ChangeMode(2);
((RenderArea*)ui.tabWidget->currentWidget()->childAt(MARGIN,MARGIN))->ChangeSelectMode(2);
ui.vertexButton->setChecked(true);
}
void TextureEditor::on_clampButton_clicked()
@ -129,7 +124,7 @@ void TextureEditor::ResetLayout()
// uncheck all the buttons
ui.connectedButton->setChecked(false);
ui.moveButton->setChecked(false);
ui.optionButton->setChecked(false);
ui.selectButton->setChecked(false);
ui.optimizeButton->setChecked(false);
ui.vertexButton->setChecked(false);
}

View File

@ -8,6 +8,8 @@
#include "renderarea.h"
#define MARGIN 5
#define MAXW 1400
#define MAXH 1000
using namespace std;
@ -36,18 +38,15 @@ private:
private slots:
void on_connectedButton_clicked();
void on_optimizeButton_clicked();
void on_moveButton_clicked();
void on_selectButton_clicked();
void on_optionButton_clicked();
void on_vertexButton_clicked();
void on_clampButton_clicked();
void on_modulusButton_clicked();
public slots:
void UpStat(float u, float v, int faceN, int vertN, int countFace);
void UpdateModel();
signals:
void updateUV(float u, float v);
};
#endif // TEXTUREEDITOR_H

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>443</width>
<height>748</height>
<width>439</width>
<height>686</height>
</rect>
</property>
<property name="windowTitle" >
@ -43,6 +43,19 @@
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="moveButton" >
<property name="sizePolicy" >
@ -100,7 +113,7 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>Allow the selection of face inside a dragged area</string>
<string>Allow the selection of faces inside a dragged area</string>
</property>
<property name="text" >
<string/>
@ -176,7 +189,7 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="optimizeButton" >
<widget class="QPushButton" name="vertexButton" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
@ -185,8 +198,20 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Allow the selection of vertexes inside a dragged area</string>
</property>
<property name="text" >
<string>Optimize</string>
<string/>
</property>
<property name="icon" >
<iconset resource="meshlab.qrc" >:/images/selver.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable" >
<bool>true</bool>
@ -206,24 +231,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="optionButton" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Option</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -353,50 +360,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxOption" >
<property name="title" >
<string> Options </string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="2" >
<widget class="QSpinBox" name="spinBox_2" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Color:</string>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QSpinBox" name="spinBox_3" />
</item>
<item row="0" column="1" >
<widget class="QSpinBox" name="spinBox" />
</item>
<item row="0" column="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />