mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 11:26:11 +00:00
Cleaned a little bit the code.
Added combobox to select precision, not shure if it is a good idea.
This commit is contained in:
parent
99bca3f3f1
commit
5d54d16f84
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>301</width>
|
||||
<height>329</height>
|
||||
<width>275</width>
|
||||
<height>467</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -19,8 +19,8 @@
|
||||
<property name="spacing" >
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="4" column="0" colspan="2" >
|
||||
<widget class="QFrame" name="pick_frame" >
|
||||
<item row="5" column="0" colspan="2" >
|
||||
<widget class="QFrame" name="advanced_frame" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
@ -35,29 +35,141 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="pick_mode" >
|
||||
<widget class="QComboBox" name="search_mode" >
|
||||
<property name="toolTip" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">fast:</span> works better with big meshes, but can loose some vertexes when faces are not direct connected<br /><span style=" font-weight:600;">slow but accurate: </span>sholud be used with small meshes, because it finds every vertex during painting</p></body></html></string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Nearest vertex color</string>
|
||||
<string>fast</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Pixel color</string>
|
||||
<string>slow but accurate</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_pick" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Picking mode</string>
|
||||
<string>Vertex search:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QFrame" name="color_frame" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QToolButton" name="set_bw" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>10</y>
|
||||
<width>25</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="meshlab.qrc" >:/images/bw.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>15</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="switch_me" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>40</y>
|
||||
<width>25</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="meshlab.qrc" >:/images/switch.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>15</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="ColorWid" native="1" name="front" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>20</y>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="ColorWid" native="1" name="back" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<widget class="QFrame" name="pen_extra_frame" >
|
||||
<property name="frameShape" >
|
||||
@ -96,6 +208,14 @@
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2" >
|
||||
<widget class="QComboBox" name="pen_type" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>pixel</string>
|
||||
@ -106,6 +226,11 @@
|
||||
<string>percentual of bbox diagonal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>percentual of bbox height</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
@ -207,112 +332,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QFrame" name="color_frame" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="ColorWid" native="1" name="back" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="ColorWid" native="1" name="front" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>10</y>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="set_bw" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>10</y>
|
||||
<width>25</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="meshlab.qrc" >:/images/bw.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>15</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="switch_me" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>40</y>
|
||||
<width>25</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="meshlab.qrc" >:/images/switch.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>15</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QFrame" name="frame_3" >
|
||||
<property name="frameShape" >
|
||||
@ -336,7 +355,7 @@
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>70</height>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
@ -379,40 +398,6 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="pick_button" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>10</y>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Pick a color</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="meshlab.qrc" >:/images/pick.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="pen_button" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
@ -447,6 +432,113 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="pick_button" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>10</y>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Pick a color</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="meshlab.qrc" >:/images/pick.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="advanced_button" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Change advanced settings</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="meshlab.qrc" >:/images/kcontrol.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2" >
|
||||
<widget class="QFrame" name="pick_frame" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="pick_mode" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Nearest vertex color</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Pixel color</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_pick" >
|
||||
<property name="text" >
|
||||
<string>Picking mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define COLORWID_H
|
||||
|
||||
class ColorWid : public QWidget {
|
||||
protected:
|
||||
QColor bg;
|
||||
public:
|
||||
ColorWid ( QWidget * parent = 0, Qt::WindowFlags f = 0 ) :QWidget(parent,f) {}
|
||||
@ -11,5 +12,4 @@ public:
|
||||
virtual void mousePressEvent ( QMouseEvent * event );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@ -87,39 +87,63 @@ const PluginInfo &EditPaintPlugin::Info() {
|
||||
return ai;
|
||||
}
|
||||
|
||||
void EditPaintPlugin::StartEdit(QAction * /*mode*/, MeshModel &m, GLArea * parent) {
|
||||
first=true;
|
||||
pressed=false;
|
||||
//qDebug() <<"startedit"<< endl;
|
||||
tri::UpdateBounding<CMeshO>::Box(m.cm);
|
||||
if (paintbox==0) paintbox=new PaintToolbox(parent);
|
||||
//paintbox->setGeometry();
|
||||
paintbox->setVisible(true);
|
||||
//paintbox->diag=m.cm.bbox.Diag();
|
||||
//m.updateDataMask(MeshModel::MM_FACECOLOR);
|
||||
m.updateDataMask(MeshModel::MM_FACETOPO);
|
||||
//m.Enable(MeshModel::MM_FACECOLOR);
|
||||
//parent->setColorMode(vcg::GLW::CMPerVert);
|
||||
parent->getCurrentRenderMode().colorMode=vcg::GLW::CMPerVert;
|
||||
parent->mm->ioMask|=MeshModel::IOM_VERTCOLOR;
|
||||
parent->mm->ioMask|=MeshModel::IOM_VERTQUALITY;
|
||||
|
||||
LastSel.clear();
|
||||
curSel.clear();
|
||||
parent->update();
|
||||
}
|
||||
|
||||
void EditPaintPlugin::EndEdit(QAction * /*mode*/, MeshModel &/*m*/, GLArea * /*parent*/) {
|
||||
qDebug() <<"ENDEDIT"<<endl;
|
||||
if (paintbox!=0) { paintbox->setVisible(false); delete paintbox; paintbox=0; }
|
||||
}
|
||||
|
||||
void EditPaintPlugin::mousePressEvent(QAction * ac, QMouseEvent * event, MeshModel &m, GLArea * gla) {
|
||||
has_track=gla->isTrackBallVisible();
|
||||
//qDebug() << "pressStart" << endl;
|
||||
has_track=gla->isTrackBallVisible();
|
||||
gla->showTrackBall(false);
|
||||
LastSel.clear();
|
||||
first=true;
|
||||
pressed=true;
|
||||
isDragging = true;
|
||||
temporaneo.clear();
|
||||
start=event->pos();
|
||||
cur=start;
|
||||
prev=start;
|
||||
QPoint mid= QPoint(cur.x(),gla->curSiz.height()-cur.y());
|
||||
|
||||
if (paintType()==1) pen.radius=paintbox->getRadius()*0.5;
|
||||
else pen.radius=paintbox->getRadius()*m.cm.bbox.Diag()*0.01*0.5;
|
||||
|
||||
//pen.width=QPoint(paintbox->getRadius(),paintbox->getRadius());
|
||||
curSel.clear();
|
||||
curr_mouse=event->button();
|
||||
inverse_y=gla->curSiz.height()-cur.y();
|
||||
/*GLPickTri<CMeshO>::PickFace(mid.x(), mid.y(), m.cm, curSel, pen.width.x(), pen.width.y());
|
||||
qDebug() <<mid<<" trovati: "<< curSel.size() <<endl;
|
||||
curr_mouse=event->button();
|
||||
|
||||
Decorate(ac,m,gla);
|
||||
gla->update();*/
|
||||
isDragging = true;
|
||||
pressed=true;
|
||||
switch (paintbox->paintUtensil()) {
|
||||
case FILL: { return; }
|
||||
case PICK: {
|
||||
pen.painttype=paintType();
|
||||
pen.backface=paintbox->getPaintBackface();
|
||||
pen.invisible=paintbox->getPaintInvisible();
|
||||
switch (paintType()) {
|
||||
case 1: { pen.radius=paintbox->getRadius()*0.5; } break;
|
||||
case 2: { pen.radius=paintbox->getRadius()*m.cm.bbox.Diag()*0.01*0.5; } break;
|
||||
case 3: { pen.radius=paintbox->getRadius()*m.cm.bbox.DimY()*0.01*0.5; } break;
|
||||
case 4: { pen.radius=paintbox->getRadius()*0.5; } break;
|
||||
}
|
||||
curSel.clear();
|
||||
|
||||
return;
|
||||
}
|
||||
case PEN: {}
|
||||
switch (paintbox->paintUtensil()) {
|
||||
case FILL: {} break;
|
||||
case PICK: {} break;
|
||||
case PEN: {} break;
|
||||
}
|
||||
//qDebug() << "pressEnd" << endl;
|
||||
}
|
||||
@ -171,24 +195,56 @@ void EditPaintPlugin::mouseReleaseEvent (QAction *,QMouseEvent * event, MeshMod
|
||||
isDragging=false;
|
||||
}
|
||||
|
||||
void calcCoord(float x,float y,float z,double matrix[],double *xr,double *yr,double *zr) {
|
||||
inline void calcCoord(float x,float y,float z,double matrix[],double *xr,double *yr,double *zr) {
|
||||
*xr=x*matrix[0]+y*matrix[4]+z*matrix[8]+matrix[12];
|
||||
*yr=x*matrix[1]+y*matrix[5]+z*matrix[9]+matrix[13];
|
||||
*zr=x*matrix[2]+y*matrix[6]+z*matrix[10]+matrix[14];
|
||||
//cout << num.x<<" "<< num.y<<" "<< num.z<<endl;
|
||||
/*num.x=x*matrix[0]+x*matrix[1]+x*matrix[2]+matrix[12];
|
||||
num.y=y*matrix[4]+y*matrix[5]+y*matrix[6]+matrix[13];
|
||||
num.z=z*matrix[8]+z*matrix[9]+z*matrix[10]+matrix[14];*/
|
||||
//return num;
|
||||
}
|
||||
|
||||
void getInv(double orig[],double inv[]) {
|
||||
void getTranspose(double orig[],double inv[]) {
|
||||
inv[0]=orig[0]; inv[1]=orig[4]; inv[2]=orig[8]; inv[3]=orig[12];
|
||||
inv[4]=orig[1]; inv[5]=orig[5]; inv[6]=orig[9]; inv[7]=orig[13];
|
||||
inv[8]=orig[2]; inv[9]=orig[6]; inv[10]=orig[10];inv[11]=orig[14];
|
||||
inv[12]=orig[3];inv[13]=orig[7];inv[14]=orig[11]; inv[15]=orig[15];
|
||||
}
|
||||
|
||||
inline int isIn(QPointF p0,QPointF p1,float dx,float dy,float radius) {
|
||||
//qDebug() << p0 << " " << p1 << endl;
|
||||
float x0=(dx-p0.x());
|
||||
float y0=(dy-p0.y());
|
||||
float bla0=x0*x0+y0*y0;
|
||||
if (bla0<radius*radius) return 1;
|
||||
if (p0==p1) return 0;
|
||||
|
||||
float x2=(p1.x()-p0.x());
|
||||
float y2=(p1.y()-p0.y());
|
||||
//double l=sqrt(x2*x2+y2*y2);
|
||||
float l_square=x2*x2+y2*y2;
|
||||
float r=(dx-p0.x())*(p1.x()-p0.x())+(dy-p0.y())*(p1.y()-p0.y());
|
||||
//r=r/(l*l);
|
||||
r=r/l_square;
|
||||
|
||||
float px=p0.x()+r*(p1.x()-p0.x());
|
||||
float py=p0.y()+r*(p1.y()-p0.y());
|
||||
|
||||
px=px-dx;
|
||||
py=py-dy;
|
||||
|
||||
if (r>0 && r<1 && (px*px+py*py<radius*radius)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool pointInTriangle(QPointF p,QPointF a, QPointF b,QPointF c) {
|
||||
float fab=(p.y()-a.y())*(b.x()-a.x()) - (p.x()-a.x())*(b.y()-a.y());
|
||||
float fbc=(p.y()-c.y())*(a.x()-c.x()) - (p.x()-c.x())*(a.y()-c.y());
|
||||
float fca=(p.y()-b.y())*(c.x()-b.x()) - (p.x()-b.x())*(c.y()-b.y());
|
||||
if (fab*fbc>0 && fbc*fca>0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isFront(QPointF a, QPointF b, QPointF c) {
|
||||
return (b.x()-a.x())*(c.y()-a.y())-(b.y()-a.y())*(c.x()-a.x())>0;
|
||||
}
|
||||
|
||||
void EditPaintPlugin::DrawXORRect(MeshModel &m,GLArea * gla, bool doubleDraw) {
|
||||
int PEZ=18;
|
||||
@ -310,13 +366,13 @@ void EditPaintPlugin::DrawXORRect(MeshModel &m,GLArea * gla, bool doubleDraw) {
|
||||
pix_x+=da;
|
||||
pix_y+=db;
|
||||
pix_z+=dc;
|
||||
double inv_yy=old_size.y()-pix_y;
|
||||
double inv_yy=gla->curSiz.height()-pix_y;
|
||||
//circle_points[lauf]=QPoint(pix_x,inv_yy);
|
||||
//qDebug() << pix_x << " "<<pix_y << endl;
|
||||
//if (pix_z<=0 || pix_z>=1)qDebug() <<"OK: "<< pix_x << " "<<pix_y <<" pix_z: "<< pix_z<<" zz: "<<endl;
|
||||
|
||||
if ((int)pix_x>=0 && (int)pix_x<old_size.x() && (int)pix_y>=0 && (int)pix_y<old_size.y()) {
|
||||
double zz=(GLfloat)pixels[(int)(((int)pix_y)*old_size.x()+(int)pix_x)];
|
||||
if ((int)pix_x>=0 && (int)pix_x<gla->curSiz.width() && (int)pix_y>=0 && (int)pix_y<gla->curSiz.height()) {
|
||||
double zz=(GLfloat)pixels[(int)(((int)pix_y)*gla->curSiz.width()+(int)pix_x)];
|
||||
if (zz<0.99999 && zz<pix_z /*&& pix_z<1*/ && pix_z>0) {
|
||||
circle_points[lauf]=QPoint(pix_x,inv_yy);
|
||||
//lauf2=1000;
|
||||
@ -350,7 +406,7 @@ void EditPaintPlugin::DrawXORRect(MeshModel &m,GLArea * gla, bool doubleDraw) {
|
||||
//Color4b co=paintbox->getColor(curr_mouse);
|
||||
//qDebug() << co[0] << " " << co[1] << " " << co[2] << endl;
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor4d(1,1,1,0.1);
|
||||
glColor4d(1,1,1,0.13);
|
||||
for (int lauf=0; lauf<PEZ; lauf++) {
|
||||
glVertex2f(mid.x(),gla->curSiz.height()-mid.y());
|
||||
glVertex2f(circle_points[lauf].x(),circle_points[lauf].y());
|
||||
@ -381,72 +437,15 @@ void EditPaintPlugin::DrawXORRect(MeshModel &m,GLArea * gla, bool doubleDraw) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// (y2 - y1)
|
||||
// 0 = y - y1 - --------- (x - x1)
|
||||
// (x2 - x1)
|
||||
|
||||
// (Cx-Ax)(Bx-Ax) + (Cy-Ay)(By-Ay)
|
||||
//r = ------------------------------
|
||||
// L²
|
||||
|
||||
int isIn(QPointF p0,QPointF p1,float dx,float dy,float radius) {
|
||||
//qDebug() << p0 << " " << p1 << endl;
|
||||
float x0=(dx-p0.x());
|
||||
float y0=(dy-p0.y());
|
||||
float bla0=x0*x0+y0*y0;
|
||||
if (bla0<radius*radius) return 1;
|
||||
if (p0==p1) return 0;
|
||||
/*float x1=(dx-p1.x());
|
||||
float y1=(dy-p1.y());
|
||||
float bla1=x1*x1+y1*y1;
|
||||
if (bla1<radius*radius) return 1;*/
|
||||
|
||||
/*float val=dy-p0.y() -(p1.y()-p0.y())/(p1.x()-p0.x())*(dx-p0.x());
|
||||
if (fabsf(val)<radius) {
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
float x2=(p1.x()-p0.x());
|
||||
float y2=(p1.y()-p0.y());
|
||||
float l=sqrt(x2*x2+y2*y2); //TODO TOGGLE FROM HERE
|
||||
float r=(dx-p0.x())*(p1.x()-p0.x())+(dy-p0.y())*(p1.y()-p0.y());
|
||||
r=r/(l*l);
|
||||
|
||||
//float s=(p0.y()-dy)*(p1.x()-p0.x())-(p0.x()-dx)*(p1.y()-p0.y());
|
||||
//s=s/(l*l);
|
||||
|
||||
float px=p0.x()+r*(p1.x()-p0.x());
|
||||
float py=p0.y()+r*(p1.y()-p0.y());
|
||||
|
||||
px=px-dx;
|
||||
py=py-dy;
|
||||
|
||||
if (r>0 && r<1 && (px*px+py*py<radius*radius)) return 1;
|
||||
|
||||
//QPointF inver(y2,x2);
|
||||
/*
|
||||
float bla2=sqrt(sq*sq+radius*radius*4);
|
||||
if (sqrt(bla0)+sqrt(bla1)<bla2) return 1;*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pointInTriangle(QPointF p,QPointF a, QPointF b,QPointF c) {
|
||||
float fab=(p.y()-a.y())*(b.x()-a.x()) - (p.x()-a.x())*(b.y()-a.y());
|
||||
float fbc=(p.y()-c.y())*(a.x()-c.x()) - (p.x()-c.x())*(a.y()-c.y());
|
||||
float fca=(p.y()-b.y())*(c.x()-b.x()) - (p.x()-b.x())*(c.y()-b.y());
|
||||
if (fab*fbc>0 && fbc*fca>0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isFront(QPointF a, QPointF b, QPointF c) {
|
||||
return (b.x()-a.x())*(c.y()-a.y())-(b.y()-a.y())*(c.x()-a.x())>0;
|
||||
}
|
||||
|
||||
int EditPaintPlugin::paintType() { return paintbox->paintType(); }
|
||||
|
||||
void getInternFaces(MeshModel & m,vector<CMeshO::FacePointer> *actual,vector<CMeshO::VertexPointer> * risult,
|
||||
GLArea * gla,Penn &pen,QPoint &cur, QPoint &prev, QPoint&old_size, GLfloat * pixels,
|
||||
GLArea * gla,Penn &pen,QPoint &cur, QPoint &prev, GLfloat * pixels,
|
||||
double mvmatrix[16],double projmatrix[16],int viewport[4]) {
|
||||
|
||||
|
||||
@ -466,9 +465,6 @@ void getInternFaces(MeshModel & m,vector<CMeshO::FacePointer> *actual,vector<CMe
|
||||
temp_po.push_back(*fpi);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
actual->clear();
|
||||
|
||||
QPointF mid=QPointF(cur.x(),gla->curSiz.height()- cur.y());
|
||||
@ -482,7 +478,7 @@ void getInternFaces(MeshModel & m,vector<CMeshO::FacePointer> *actual,vector<CMe
|
||||
|
||||
//qDebug() << "bf: "<<backface << " inv: "<<invisible << endl;
|
||||
|
||||
if (pen.painttype==1) { // PIXEL
|
||||
if (pen.painttype==1) { /// PIXEL
|
||||
for (int lauf2=0; lauf2<temp_po.size(); lauf2++) {
|
||||
CFaceO * fac=temp_po.at(lauf2);
|
||||
bool intern=false;
|
||||
@ -491,8 +487,8 @@ void getInternFaces(MeshModel & m,vector<CMeshO::FacePointer> *actual,vector<CMe
|
||||
gluProject((fac)->V(lauf)->P()[0],(fac)->V(lauf)->P()[1],(fac)->V(lauf)->P()[2],mvmatrix,projmatrix,viewport,&tx,&ty,&tz);
|
||||
p[lauf]=QPointF(tx,ty);
|
||||
//qDebug() << "zzz: "<<(int)(((int)ty)*old_size.x()+(int)tx)<<" t: "<<tx<<" "<<ty<<" "<<tz<<endl;
|
||||
if (tx>=0 && tx<old_size.x() && ty>=0 && ty<old_size.y())
|
||||
z[lauf]=QPointF(tz,(GLfloat)pixels[(int)(((int)ty)*old_size.x()+(int)tx)]);
|
||||
if (tx>=0 && tx<viewport[2] && ty>=0 && ty<viewport[3])
|
||||
z[lauf]=QPointF(tz,(GLfloat)pixels[(int)(((int)ty)*viewport[2]+(int)tx)]);
|
||||
else z[lauf]=QPoint(1,0);
|
||||
//qDebug() << "zzz_ende"<<endl;
|
||||
//float zz;
|
||||
@ -533,7 +529,7 @@ void getInternFaces(MeshModel & m,vector<CMeshO::FacePointer> *actual,vector<CMe
|
||||
}
|
||||
}
|
||||
|
||||
} else { // PERCENTUAL
|
||||
} else { /// PERCENTUAL
|
||||
double dX, dY, dZ;
|
||||
double dX2, dY2, dZ2;
|
||||
gluUnProject ((double) mid.x(), mid.y(), 0.0, mvmatrix, projmatrix, viewport, &dX, &dY, &dZ);
|
||||
@ -584,8 +580,8 @@ void getInternFaces(MeshModel & m,vector<CMeshO::FacePointer> *actual,vector<CMe
|
||||
gluProject((fac)->V(lauf)->P()[0],(fac)->V(lauf)->P()[1],(fac)->V(lauf)->P()[2],mvmatrix,projmatrix,viewport,&tx,&ty,&tz);
|
||||
//p[lauf]=QPointF(dx,dy);
|
||||
p[lauf]=QPointF(tx,ty);
|
||||
if (tx>=0 && tx<old_size.x() && ty>=0 && ty<old_size.y())
|
||||
z[lauf]=QPointF(tz,(GLfloat)pixels[(int)(((int)ty)*old_size.x()+(int)tx)]);
|
||||
if (tx>=0 && tx<viewport[2] && ty>=0 && ty<viewport[3])
|
||||
z[lauf]=QPointF(tz,(GLfloat)pixels[(int)(((int)ty)*viewport[2]+(int)tx)]);
|
||||
else z[lauf]=QPoint(1,0);
|
||||
distance[lauf]=dz;
|
||||
//qDebug() << dx << " " << dy << " " << dz<<" "<<mid<<endl;
|
||||
@ -606,7 +602,7 @@ void getInternFaces(MeshModel & m,vector<CMeshO::FacePointer> *actual,vector<CMe
|
||||
ty=p[lauf].y();
|
||||
//QPointF poo(mid.x()*(distance[lauf])*-1.0,mid.y()*(distance[lauf])*-1.0);
|
||||
//if (isIn(poo,poo,tx,ty,/*0.08*gla->trackball.track.sca*/radius)==1) {
|
||||
//THE 2*190 should not be a constant !!!
|
||||
/** i have NO idea why it works with viewport[3]*0.88 */
|
||||
if (isIn(mid,mid_prev,tx,ty,pen.radius*scale_fac*viewport[3]*0.88/distance[lauf])==1) {
|
||||
//if (isIn(QPoint(0,0),QPoint(0,0),tx,ty,pen.radius)==1) {
|
||||
intern=true;
|
||||
@ -674,10 +670,7 @@ bool EditPaintPlugin::getFaceAtMouse(MeshModel &m,CMeshO::FacePointer& val) {
|
||||
bool EditPaintPlugin::getFacesAtMouse(MeshModel &m,vector<CMeshO::FacePointer> & val) {
|
||||
val.clear();
|
||||
QPoint mid=QPoint(cur.x(),inverse_y);
|
||||
//vector<CMeshO::FacePointer> knut;
|
||||
GLPickTri<CMeshO>::PickFace(mid.x(), mid.y(), m.cm, val,2,2);
|
||||
//qDebug() << m.cm.SimplexNumber() << endl;
|
||||
//qDebug() << val.size() << " knut"<< endl;
|
||||
return (val.size()>0);
|
||||
}
|
||||
|
||||
@ -705,7 +698,7 @@ bool EditPaintPlugin::getVertexesAtMouse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** only in decorare it is possible to obtain the correct zbuffer values and other opengl stuff */
|
||||
void EditPaintPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) {
|
||||
//qDebug()<<"startdecor"<<endl;
|
||||
//if (cur.x()==0 && cur.y()==0) return;
|
||||
@ -715,9 +708,8 @@ void EditPaintPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) {
|
||||
//worker->waitTillPause();
|
||||
first=false;
|
||||
if (pixels!=0) { free(pixels); }
|
||||
old_size=QPoint(gla->curSiz.width(),gla->curSiz.height());
|
||||
pixels=(GLfloat *)malloc(sizeof(GLfloat)*old_size.x()*old_size.y());
|
||||
glReadPixels(0,0,old_size.x(),old_size.y(),GL_DEPTH_COMPONENT,GL_FLOAT,pixels);
|
||||
pixels=(GLfloat *)malloc(sizeof(GLfloat)*gla->curSiz.width()*gla->curSiz.height());
|
||||
glReadPixels(0,0,gla->curSiz.width(),gla->curSiz.height(),GL_DEPTH_COMPONENT,GL_FLOAT,pixels);
|
||||
//worker->clear(pixels);
|
||||
//worker->setModelArea(&m,gla);
|
||||
}
|
||||
@ -756,10 +748,6 @@ void EditPaintPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) {
|
||||
|
||||
DrawXORRect(m,gla,false);
|
||||
|
||||
pen.painttype=paintType();
|
||||
pen.backface=paintbox->getPaintBackface();
|
||||
pen.invisible=paintbox->getPaintInvisible();
|
||||
|
||||
/*PaintData pa;pa.start=cur;pa.end=prev;pa.pen=pen;
|
||||
pa.color=paintbox->getColor(curr_mouse);
|
||||
pa.opac=paintbox->getOpacity();
|
||||
@ -768,12 +756,12 @@ void EditPaintPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) {
|
||||
vector<CMeshO::VertexPointer>::iterator vpo;
|
||||
vector<CMeshO::VertexPointer> newSel;
|
||||
|
||||
//curSel.clear();
|
||||
if (paintbox->searchMode()==2) curSel.clear();
|
||||
//GLPickTri<CMeshO>::PickFace(mid.x(), mid.y(), m.cm, curSel, pen.width.x(), pen.width.y());
|
||||
//CFaceO * tmp=0;
|
||||
//if (GLPickTri<CMeshO>::PickNearestFace(mid.x(), mid.y(), m.cm, tmp, pen.width.x(), pen.width.y()))
|
||||
|
||||
getInternFaces(m,&curSel,&newSel,gla,pen,cur,prev,old_size,pixels,mvmatrix,projmatrix,viewport);
|
||||
getInternFaces(m,&curSel,&newSel,gla,pen,cur,prev,pixels,mvmatrix,projmatrix,viewport);
|
||||
|
||||
int opac=paintbox->getOpacity();
|
||||
Color4b newcol=paintbox->getColor(curr_mouse);
|
||||
@ -789,37 +777,7 @@ void EditPaintPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) {
|
||||
//qDebug()<<"enddecor"<<endl;
|
||||
}
|
||||
|
||||
void EditPaintPlugin::StartEdit(QAction * /*mode*/, MeshModel &m, GLArea * parent) {
|
||||
first=true;
|
||||
pressed=false;
|
||||
//qDebug() <<"startedit"<< endl;
|
||||
//pen.radius=;
|
||||
tri::UpdateBounding<CMeshO>::Box(m.cm);
|
||||
if (paintbox==0) paintbox=new PaintToolbox(parent);
|
||||
//paintbox->setGeometry();
|
||||
paintbox->setVisible(true);
|
||||
//paintbox->diag=m.cm.bbox.Diag();
|
||||
//m.updateDataMask(MeshModel::MM_FACECOLOR);
|
||||
m.updateDataMask(MeshModel::MM_FACETOPO);
|
||||
//m.Enable(MeshModel::MM_FACECOLOR);
|
||||
//parent->setColorMode(vcg::GLW::CMPerVert);
|
||||
parent->getCurrentRenderMode().colorMode=vcg::GLW::CMPerVert;
|
||||
parent->mm->ioMask|=MeshModel::IOM_VERTCOLOR;
|
||||
parent->mm->ioMask|=MeshModel::IOM_VERTQUALITY;
|
||||
|
||||
LastSel.clear();
|
||||
curSel.clear();
|
||||
parent->update();
|
||||
}
|
||||
|
||||
void EditPaintPlugin::EndEdit(QAction * /*mode*/, MeshModel &/*m*/, GLArea * /*parent*/) {
|
||||
qDebug() <<"ENDEDIT"<<endl;
|
||||
if (paintbox!=0) { paintbox->setVisible(false); delete paintbox; paintbox=0; }
|
||||
}
|
||||
|
||||
void EditPaintPlugin::updateMe() {
|
||||
|
||||
}
|
||||
//void EditPaintPlugin::updateMe() {}
|
||||
|
||||
PaintWorker::PaintWorker() {
|
||||
nothingTodo=true;
|
||||
@ -864,7 +822,7 @@ void PaintWorker::run() {
|
||||
//}
|
||||
//qDebug() << "worker-wait-end4"<<endl;
|
||||
QPoint old_size=QPoint(gla->curSiz.width(),gla->curSiz.height());
|
||||
getInternFaces(*mesh,&curSel,&newSel,gla,data.pen,data.start,data.end,old_size,pixels,mvmatrix,projmatrix,viewport);
|
||||
getInternFaces(*mesh,&curSel,&newSel,gla,data.pen,data.start,data.end,pixels,mvmatrix,projmatrix,viewport);
|
||||
|
||||
for(vpo=newSel.begin();vpo!=newSel.end();++vpo) {
|
||||
if (!temporaneo.contains(*vpo)) {
|
||||
|
||||
@ -31,7 +31,7 @@ inline void colorize(CVertexO * vertice,const Color4b& newcol,int opac) {
|
||||
vertice->C()=orig;
|
||||
}
|
||||
|
||||
typedef enum {PEN, FILL, PICK} PaintThing;
|
||||
typedef enum {PEN, FILL, PICK, NONE} PaintThing;
|
||||
|
||||
class Penn {
|
||||
public:
|
||||
@ -52,11 +52,9 @@ struct PaintData{
|
||||
Penn pen;
|
||||
};
|
||||
|
||||
class EditPaintPlugin : public QObject, public MeshEditInterface
|
||||
{
|
||||
class EditPaintPlugin : public QObject, public MeshEditInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MeshEditInterface)
|
||||
|
||||
QList <QAction *> actionList;
|
||||
|
||||
public:
|
||||
@ -82,41 +80,31 @@ public:
|
||||
vector<CMeshO::FacePointer> LastSel;
|
||||
|
||||
private:
|
||||
//typedef enum {SMAdd, SMClear,SMSub} SelMode;
|
||||
//SelMode selMode;
|
||||
bool has_track; // to restore the trackball settings
|
||||
bool pressed; // to check in decorate if it is the first call after a mouse click
|
||||
typedef enum {SMAdd, SMClear,SMSub} SelMode;
|
||||
SelMode selMode;
|
||||
|
||||
|
||||
double mvmatrix[16];
|
||||
double projmatrix[16];
|
||||
int viewport[4];
|
||||
bool first; // same as pressed, TODO probably removable
|
||||
double mvmatrix[16]; //modelview
|
||||
double projmatrix[16]; //projection
|
||||
int viewport[4]; //viewport
|
||||
GLfloat *pixels; // the z-buffer
|
||||
int inverse_y; // gla->curSiz.height()-cur.y() TODO probably removable
|
||||
vector<CMeshO::FacePointer> tempSel; //to use when needed
|
||||
vector<CMeshO::FacePointer> curSel; //the faces i am painting on
|
||||
QHash<CVertexO *,Color4b> temporaneo; //the vertexes i am painting on
|
||||
Penn pen; //contains informations about the painting mode, color, type ...
|
||||
PaintToolbox* paintbox; //the widget with the painting stuff
|
||||
Qt::MouseButton curr_mouse; // which mouse button is selected
|
||||
|
||||
PaintWorker * worker;
|
||||
|
||||
vector<CMeshO::FacePointer> tempSel; //to use when needed
|
||||
vector<CMeshO::FacePointer> curSel; //the faces i am painting on
|
||||
QHash<CVertexO *,Color4b> temporaneo;
|
||||
Penn pen;
|
||||
QHash <long,CFaceO *> painting_at;
|
||||
|
||||
PaintToolbox* paintbox;
|
||||
Qt::MouseButton curr_mouse;
|
||||
|
||||
GLfloat *pixels;
|
||||
bool first;
|
||||
QPoint old_size;
|
||||
|
||||
int inverse_y; // gla->curSiz.height()-cur.y()
|
||||
int paintType();
|
||||
void DrawXORRect(MeshModel &m,GLArea * gla, bool doubleDraw);
|
||||
//void getInternFaces(vector<CMeshO::FacePointer> *actual,vector<CMeshO::VertexPointer> * risult, GLArea * gla);
|
||||
|
||||
bool getFaceAtMouse(MeshModel &,CMeshO::FacePointer &);
|
||||
bool getFacesAtMouse(MeshModel &,vector<CMeshO::FacePointer> &);
|
||||
bool getVertexAtMouse(MeshModel &,CMeshO::VertexPointer &);
|
||||
bool getVertexesAtMouse();
|
||||
|
||||
void fillFrom(MeshModel &,CFaceO *);
|
||||
|
||||
inline void updateMatrixes() {
|
||||
@ -143,8 +131,8 @@ private:
|
||||
return nearestInd;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void updateMe();
|
||||
//public slots:
|
||||
// void updateMe();
|
||||
};
|
||||
|
||||
class PaintWorker : public QThread{
|
||||
@ -184,13 +172,13 @@ public:
|
||||
class PaintToolbox : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
//float diag;
|
||||
PaintToolbox ( /*const QString & title,*/ QWidget * parent = 0, Qt::WindowFlags flags = 0 );
|
||||
Color4b getColor(Qt::MouseButton);
|
||||
void setColor(Color4b,Qt::MouseButton);
|
||||
void setColor(int,int,int,Qt::MouseButton mouse);
|
||||
inline double getRadius() { return ui.pen_radius->value(); }
|
||||
inline int paintType() { if (ui.pen_type->currentText()=="pixel") return 1; return 2; }
|
||||
inline int paintType() { /*if (ui.pen_type->currentText()=="pixel") return 1; return 2;*/ return ui.pen_type->currentIndex()+1; }
|
||||
inline int searchMode() { return ui.search_mode->currentIndex()+1; }
|
||||
inline int getOpacity() { return ui.deck_slider->value(); }
|
||||
inline int paintUtensil() { return paint_utensil; }
|
||||
inline bool getPaintBackface() { return ui.backface_culling->checkState()!=Qt::Unchecked; }
|
||||
@ -209,6 +197,7 @@ private slots:
|
||||
void on_pen_button_clicked();
|
||||
void on_fill_button_clicked();
|
||||
void on_pick_button_clicked();
|
||||
void on_advanced_button_clicked();
|
||||
void on_backface_culling_stateChanged(int value);
|
||||
void on_invisible_painting_stateChanged(int value);
|
||||
};
|
||||
|
||||
@ -6,5 +6,6 @@
|
||||
<file>images/bw.png</file>
|
||||
<file>images/switch.png</file>
|
||||
<file>images/pick.png</file>
|
||||
<file>images/kcontrol.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@ -41,10 +41,11 @@ PaintToolbox::PaintToolbox(/*const QString & title,*/ QWidget * parent, Qt::Wind
|
||||
ui.switch_me->setGeometry(55,10,15,15);
|
||||
ui.set_bw->setGeometry(10,45,15,15);
|
||||
QPoint p=parent->mapToGlobal(QPoint(0,0));
|
||||
setGeometry(p.x()+parent->width()-/*width()*/60,p.y(),/*width()*/100,height());
|
||||
setGeometry(p.x()+parent->width()-/*width()*/60,p.y(),/*width()*/100,/*height()*/100);
|
||||
//ui.fill_button->setEnabled(false);
|
||||
ui.pick_frame->setVisible(false);
|
||||
|
||||
ui.advanced_frame->setVisible(false);
|
||||
ui.pen_button->setChecked(true);
|
||||
}
|
||||
|
||||
Color4b PaintToolbox::getColor(Qt::MouseButton mouse) {
|
||||
@ -97,18 +98,31 @@ void PaintToolbox::on_pen_button_clicked() {
|
||||
ui.pen_frame->setVisible(true);
|
||||
ui.pen_extra_frame->setVisible(true);
|
||||
ui.pick_frame->setVisible(false);
|
||||
ui.advanced_frame->setVisible(false);
|
||||
}
|
||||
|
||||
void PaintToolbox::on_fill_button_clicked() {
|
||||
paint_utensil=FILL;
|
||||
ui.pen_frame->setVisible(true);
|
||||
ui.pen_extra_frame->setVisible(false);
|
||||
ui.pick_frame->setVisible(false);
|
||||
ui.advanced_frame->setVisible(false);
|
||||
}
|
||||
|
||||
void PaintToolbox::on_pick_button_clicked() {
|
||||
paint_utensil=PICK;
|
||||
ui.pen_frame->setVisible(false);
|
||||
ui.pen_extra_frame->setVisible(false);
|
||||
ui.pick_frame->setVisible(true);
|
||||
ui.advanced_frame->setVisible(false);
|
||||
}
|
||||
|
||||
void PaintToolbox::on_advanced_button_clicked() {
|
||||
paint_utensil=NONE;
|
||||
ui.pen_frame->setVisible(false);
|
||||
ui.pen_extra_frame->setVisible(false);
|
||||
ui.pick_frame->setVisible(false);
|
||||
ui.advanced_frame->setVisible(true);
|
||||
}
|
||||
|
||||
void PaintToolbox::setColor(Color4b newcol,Qt::MouseButton mouse) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading ui file 'PaintToolbox.ui'
|
||||
**
|
||||
** Created: Tue Jan 23 14:05:21 2007
|
||||
** Created: Wed Jan 24 14:41:01 2007
|
||||
** by: Qt User Interface Compiler version 4.2.1
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
||||
@ -30,10 +30,15 @@ class Ui_PaintToolbox
|
||||
{
|
||||
public:
|
||||
QGridLayout *gridLayout;
|
||||
QFrame *pick_frame;
|
||||
QFrame *advanced_frame;
|
||||
QGridLayout *gridLayout1;
|
||||
QComboBox *pick_mode;
|
||||
QLabel *label_pick;
|
||||
QComboBox *search_mode;
|
||||
QLabel *label_2;
|
||||
QFrame *color_frame;
|
||||
QToolButton *set_bw;
|
||||
QToolButton *switch_me;
|
||||
ColorWid *front;
|
||||
ColorWid *back;
|
||||
QFrame *pen_extra_frame;
|
||||
QGridLayout *gridLayout2;
|
||||
QCheckBox *backface_culling;
|
||||
@ -49,16 +54,16 @@ public:
|
||||
QLabel *label_penmodus;
|
||||
QComboBox *pen_modus;
|
||||
QSlider *deck_slider;
|
||||
QFrame *color_frame;
|
||||
ColorWid *back;
|
||||
ColorWid *front;
|
||||
QToolButton *set_bw;
|
||||
QToolButton *switch_me;
|
||||
QFrame *frame_3;
|
||||
QFrame *top_frame;
|
||||
QToolButton *fill_button;
|
||||
QToolButton *pick_button;
|
||||
QToolButton *pen_button;
|
||||
QToolButton *pick_button;
|
||||
QToolButton *advanced_button;
|
||||
QFrame *pick_frame;
|
||||
QGridLayout *gridLayout4;
|
||||
QComboBox *pick_mode;
|
||||
QLabel *label_pick;
|
||||
|
||||
void setupUi(QWidget *PaintToolbox)
|
||||
{
|
||||
@ -67,26 +72,60 @@ public:
|
||||
gridLayout->setSpacing(2);
|
||||
gridLayout->setMargin(2);
|
||||
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
|
||||
pick_frame = new QFrame(PaintToolbox);
|
||||
pick_frame->setObjectName(QString::fromUtf8("pick_frame"));
|
||||
pick_frame->setFrameShape(QFrame::StyledPanel);
|
||||
pick_frame->setFrameShadow(QFrame::Raised);
|
||||
gridLayout1 = new QGridLayout(pick_frame);
|
||||
advanced_frame = new QFrame(PaintToolbox);
|
||||
advanced_frame->setObjectName(QString::fromUtf8("advanced_frame"));
|
||||
advanced_frame->setFrameShape(QFrame::StyledPanel);
|
||||
advanced_frame->setFrameShadow(QFrame::Raised);
|
||||
gridLayout1 = new QGridLayout(advanced_frame);
|
||||
gridLayout1->setSpacing(6);
|
||||
gridLayout1->setMargin(9);
|
||||
gridLayout1->setObjectName(QString::fromUtf8("gridLayout1"));
|
||||
pick_mode = new QComboBox(pick_frame);
|
||||
pick_mode->setObjectName(QString::fromUtf8("pick_mode"));
|
||||
search_mode = new QComboBox(advanced_frame);
|
||||
search_mode->setObjectName(QString::fromUtf8("search_mode"));
|
||||
|
||||
gridLayout1->addWidget(pick_mode, 0, 1, 1, 1);
|
||||
gridLayout1->addWidget(search_mode, 0, 1, 1, 1);
|
||||
|
||||
label_pick = new QLabel(pick_frame);
|
||||
label_pick->setObjectName(QString::fromUtf8("label_pick"));
|
||||
label_2 = new QLabel(advanced_frame);
|
||||
label_2->setObjectName(QString::fromUtf8("label_2"));
|
||||
|
||||
gridLayout1->addWidget(label_pick, 0, 0, 1, 1);
|
||||
gridLayout1->addWidget(label_2, 0, 0, 1, 1);
|
||||
|
||||
|
||||
gridLayout->addWidget(pick_frame, 4, 0, 1, 2);
|
||||
gridLayout->addWidget(advanced_frame, 5, 0, 1, 2);
|
||||
|
||||
color_frame = new QFrame(PaintToolbox);
|
||||
color_frame->setObjectName(QString::fromUtf8("color_frame"));
|
||||
QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(0));
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(color_frame->sizePolicy().hasHeightForWidth());
|
||||
color_frame->setSizePolicy(sizePolicy);
|
||||
color_frame->setMinimumSize(QSize(70, 70));
|
||||
color_frame->setMaximumSize(QSize(16777215, 70));
|
||||
color_frame->setFrameShape(QFrame::StyledPanel);
|
||||
color_frame->setFrameShadow(QFrame::Raised);
|
||||
set_bw = new QToolButton(color_frame);
|
||||
set_bw->setObjectName(QString::fromUtf8("set_bw"));
|
||||
set_bw->setGeometry(QRect(100, 10, 25, 24));
|
||||
set_bw->setIcon(QIcon(QString::fromUtf8(":/images/bw.png")));
|
||||
set_bw->setIconSize(QSize(15, 15));
|
||||
set_bw->setAutoRaise(true);
|
||||
switch_me = new QToolButton(color_frame);
|
||||
switch_me->setObjectName(QString::fromUtf8("switch_me"));
|
||||
switch_me->setGeometry(QRect(100, 40, 25, 24));
|
||||
switch_me->setIcon(QIcon(QString::fromUtf8(":/images/switch.png")));
|
||||
switch_me->setIconSize(QSize(15, 15));
|
||||
switch_me->setAutoRaise(true);
|
||||
front = new ColorWid(color_frame);
|
||||
front->setObjectName(QString::fromUtf8("front"));
|
||||
front->setGeometry(QRect(50, 20, 40, 40));
|
||||
front->setAutoFillBackground(true);
|
||||
back = new ColorWid(color_frame);
|
||||
back->setObjectName(QString::fromUtf8("back"));
|
||||
back->setGeometry(QRect(10, 10, 40, 40));
|
||||
back->setAutoFillBackground(true);
|
||||
|
||||
gridLayout->addWidget(color_frame, 1, 0, 1, 1);
|
||||
|
||||
pen_extra_frame = new QFrame(PaintToolbox);
|
||||
pen_extra_frame->setObjectName(QString::fromUtf8("pen_extra_frame"));
|
||||
@ -113,6 +152,11 @@ public:
|
||||
|
||||
pen_type = new QComboBox(pen_extra_frame);
|
||||
pen_type->setObjectName(QString::fromUtf8("pen_type"));
|
||||
QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(0));
|
||||
sizePolicy1.setHorizontalStretch(0);
|
||||
sizePolicy1.setVerticalStretch(0);
|
||||
sizePolicy1.setHeightForWidth(pen_type->sizePolicy().hasHeightForWidth());
|
||||
pen_type->setSizePolicy(sizePolicy1);
|
||||
|
||||
gridLayout2->addWidget(pen_type, 0, 2, 1, 2);
|
||||
|
||||
@ -175,40 +219,6 @@ public:
|
||||
|
||||
gridLayout->addWidget(pen_frame, 2, 0, 1, 2);
|
||||
|
||||
color_frame = new QFrame(PaintToolbox);
|
||||
color_frame->setObjectName(QString::fromUtf8("color_frame"));
|
||||
QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(0));
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(color_frame->sizePolicy().hasHeightForWidth());
|
||||
color_frame->setSizePolicy(sizePolicy);
|
||||
color_frame->setMinimumSize(QSize(70, 70));
|
||||
color_frame->setMaximumSize(QSize(16777215, 70));
|
||||
color_frame->setFrameShape(QFrame::StyledPanel);
|
||||
color_frame->setFrameShadow(QFrame::Raised);
|
||||
back = new ColorWid(color_frame);
|
||||
back->setObjectName(QString::fromUtf8("back"));
|
||||
back->setGeometry(QRect(10, 10, 40, 40));
|
||||
back->setAutoFillBackground(true);
|
||||
front = new ColorWid(color_frame);
|
||||
front->setObjectName(QString::fromUtf8("front"));
|
||||
front->setGeometry(QRect(60, 10, 40, 40));
|
||||
front->setAutoFillBackground(true);
|
||||
set_bw = new QToolButton(color_frame);
|
||||
set_bw->setObjectName(QString::fromUtf8("set_bw"));
|
||||
set_bw->setGeometry(QRect(100, 10, 25, 24));
|
||||
set_bw->setIcon(QIcon(QString::fromUtf8(":/images/bw.png")));
|
||||
set_bw->setIconSize(QSize(15, 15));
|
||||
set_bw->setAutoRaise(true);
|
||||
switch_me = new QToolButton(color_frame);
|
||||
switch_me->setObjectName(QString::fromUtf8("switch_me"));
|
||||
switch_me->setGeometry(QRect(100, 40, 25, 24));
|
||||
switch_me->setIcon(QIcon(QString::fromUtf8(":/images/switch.png")));
|
||||
switch_me->setIconSize(QSize(15, 15));
|
||||
switch_me->setAutoRaise(true);
|
||||
|
||||
gridLayout->addWidget(color_frame, 1, 0, 1, 1);
|
||||
|
||||
frame_3 = new QFrame(PaintToolbox);
|
||||
frame_3->setObjectName(QString::fromUtf8("frame_3"));
|
||||
frame_3->setFrameShape(QFrame::StyledPanel);
|
||||
@ -218,12 +228,12 @@ public:
|
||||
|
||||
top_frame = new QFrame(PaintToolbox);
|
||||
top_frame->setObjectName(QString::fromUtf8("top_frame"));
|
||||
QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(7));
|
||||
sizePolicy1.setHorizontalStretch(0);
|
||||
sizePolicy1.setVerticalStretch(0);
|
||||
sizePolicy1.setHeightForWidth(top_frame->sizePolicy().hasHeightForWidth());
|
||||
top_frame->setSizePolicy(sizePolicy1);
|
||||
top_frame->setMinimumSize(QSize(16, 70));
|
||||
QSizePolicy sizePolicy2(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(7));
|
||||
sizePolicy2.setHorizontalStretch(0);
|
||||
sizePolicy2.setVerticalStretch(0);
|
||||
sizePolicy2.setHeightForWidth(top_frame->sizePolicy().hasHeightForWidth());
|
||||
top_frame->setSizePolicy(sizePolicy2);
|
||||
top_frame->setMinimumSize(QSize(16, 120));
|
||||
top_frame->setFrameShape(QFrame::StyledPanel);
|
||||
top_frame->setFrameShadow(QFrame::Raised);
|
||||
fill_button = new QToolButton(top_frame);
|
||||
@ -234,14 +244,6 @@ public:
|
||||
fill_button->setCheckable(true);
|
||||
fill_button->setAutoExclusive(true);
|
||||
fill_button->setAutoRaise(false);
|
||||
pick_button = new QToolButton(top_frame);
|
||||
pick_button->setObjectName(QString::fromUtf8("pick_button"));
|
||||
pick_button->setGeometry(QRect(110, 10, 48, 48));
|
||||
pick_button->setIcon(QIcon(QString::fromUtf8(":/images/pick.png")));
|
||||
pick_button->setIconSize(QSize(48, 48));
|
||||
pick_button->setCheckable(true);
|
||||
pick_button->setAutoExclusive(true);
|
||||
pick_button->setAutoRaise(false);
|
||||
pen_button = new QToolButton(top_frame);
|
||||
pen_button->setObjectName(QString::fromUtf8("pen_button"));
|
||||
pen_button->setGeometry(QRect(10, 10, 48, 48));
|
||||
@ -250,13 +252,50 @@ public:
|
||||
pen_button->setCheckable(true);
|
||||
pen_button->setAutoExclusive(true);
|
||||
pen_button->setAutoRaise(false);
|
||||
pick_button = new QToolButton(top_frame);
|
||||
pick_button->setObjectName(QString::fromUtf8("pick_button"));
|
||||
pick_button->setGeometry(QRect(110, 10, 48, 48));
|
||||
pick_button->setIcon(QIcon(QString::fromUtf8(":/images/pick.png")));
|
||||
pick_button->setIconSize(QSize(48, 48));
|
||||
pick_button->setCheckable(true);
|
||||
pick_button->setAutoExclusive(true);
|
||||
pick_button->setAutoRaise(false);
|
||||
advanced_button = new QToolButton(top_frame);
|
||||
advanced_button->setObjectName(QString::fromUtf8("advanced_button"));
|
||||
advanced_button->setGeometry(QRect(10, 60, 48, 48));
|
||||
advanced_button->setIcon(QIcon(QString::fromUtf8(":/images/kcontrol.png")));
|
||||
advanced_button->setIconSize(QSize(48, 48));
|
||||
advanced_button->setCheckable(true);
|
||||
advanced_button->setAutoExclusive(true);
|
||||
advanced_button->setAutoRaise(false);
|
||||
|
||||
gridLayout->addWidget(top_frame, 0, 0, 1, 2);
|
||||
|
||||
pick_frame = new QFrame(PaintToolbox);
|
||||
pick_frame->setObjectName(QString::fromUtf8("pick_frame"));
|
||||
pick_frame->setFrameShape(QFrame::StyledPanel);
|
||||
pick_frame->setFrameShadow(QFrame::Raised);
|
||||
gridLayout4 = new QGridLayout(pick_frame);
|
||||
gridLayout4->setSpacing(6);
|
||||
gridLayout4->setMargin(9);
|
||||
gridLayout4->setObjectName(QString::fromUtf8("gridLayout4"));
|
||||
pick_mode = new QComboBox(pick_frame);
|
||||
pick_mode->setObjectName(QString::fromUtf8("pick_mode"));
|
||||
|
||||
gridLayout4->addWidget(pick_mode, 0, 1, 1, 1);
|
||||
|
||||
label_pick = new QLabel(pick_frame);
|
||||
label_pick->setObjectName(QString::fromUtf8("label_pick"));
|
||||
|
||||
gridLayout4->addWidget(label_pick, 0, 0, 1, 1);
|
||||
|
||||
|
||||
gridLayout->addWidget(pick_frame, 4, 0, 1, 2);
|
||||
|
||||
|
||||
retranslateUi(PaintToolbox);
|
||||
|
||||
QSize size(301, 329);
|
||||
QSize size(275, 467);
|
||||
size = size.expandedTo(PaintToolbox->minimumSizeHint());
|
||||
PaintToolbox->resize(size);
|
||||
|
||||
@ -267,16 +306,23 @@ public:
|
||||
void retranslateUi(QWidget *PaintToolbox)
|
||||
{
|
||||
PaintToolbox->setWindowTitle(QApplication::translate("PaintToolbox", "Vertex Painting", 0, QApplication::UnicodeUTF8));
|
||||
pick_mode->clear();
|
||||
pick_mode->addItem(QApplication::translate("PaintToolbox", "Nearest vertex color", 0, QApplication::UnicodeUTF8));
|
||||
pick_mode->addItem(QApplication::translate("PaintToolbox", "Pixel color", 0, QApplication::UnicodeUTF8));
|
||||
label_pick->setText(QApplication::translate("PaintToolbox", "Picking mode", 0, QApplication::UnicodeUTF8));
|
||||
search_mode->clear();
|
||||
search_mode->addItem(QApplication::translate("PaintToolbox", "fast", 0, QApplication::UnicodeUTF8));
|
||||
search_mode->addItem(QApplication::translate("PaintToolbox", "slow but accurate", 0, QApplication::UnicodeUTF8));
|
||||
search_mode->setToolTip(QApplication::translate("PaintToolbox", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head><body style=\" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">fast:</span> works better with big meshes, but can loose some vertexes when faces are not direct connected<br /><span style=\" font-weight:600;\">slow but accurate: </span>sholud be used with small meshes, because it finds every vertex during painting</p></body></html>", 0, QApplication::UnicodeUTF8));
|
||||
label_2->setText(QApplication::translate("PaintToolbox", "Vertex search:", 0, QApplication::UnicodeUTF8));
|
||||
set_bw->setText(QApplication::translate("PaintToolbox", "...", 0, QApplication::UnicodeUTF8));
|
||||
switch_me->setText(QApplication::translate("PaintToolbox", "...", 0, QApplication::UnicodeUTF8));
|
||||
backface_culling->setText(QApplication::translate("PaintToolbox", "backfaces", 0, QApplication::UnicodeUTF8));
|
||||
label_pen->setText(QApplication::translate("PaintToolbox", "Pen", 0, QApplication::UnicodeUTF8));
|
||||
label->setText(QApplication::translate("PaintToolbox", "Paint on:", 0, QApplication::UnicodeUTF8));
|
||||
pen_type->clear();
|
||||
pen_type->addItem(QApplication::translate("PaintToolbox", "pixel", 0, QApplication::UnicodeUTF8));
|
||||
pen_type->addItem(QApplication::translate("PaintToolbox", "percentual of bbox diagonal", 0, QApplication::UnicodeUTF8));
|
||||
pen_type->addItem(QApplication::translate("PaintToolbox", "percentual of bbox height", 0, QApplication::UnicodeUTF8));
|
||||
invisible_painting->setText(QApplication::translate("PaintToolbox", "hidden polygons", 0, QApplication::UnicodeUTF8));
|
||||
deck_box->setToolTip(QApplication::translate("PaintToolbox", "Change the opacity of the color (this is not the opengl alpha value)", 0, QApplication::UnicodeUTF8));
|
||||
label_deck->setText(QApplication::translate("PaintToolbox", "Opacity", 0, QApplication::UnicodeUTF8));
|
||||
@ -284,14 +330,18 @@ public:
|
||||
pen_modus->clear();
|
||||
pen_modus->addItem(QApplication::translate("PaintToolbox", "Normal", 0, QApplication::UnicodeUTF8));
|
||||
deck_slider->setToolTip(QApplication::translate("PaintToolbox", "Change the opacity of the color (this is not the opengl alpha value)", 0, QApplication::UnicodeUTF8));
|
||||
set_bw->setText(QApplication::translate("PaintToolbox", "...", 0, QApplication::UnicodeUTF8));
|
||||
switch_me->setText(QApplication::translate("PaintToolbox", "...", 0, QApplication::UnicodeUTF8));
|
||||
fill_button->setToolTip(QApplication::translate("PaintToolbox", "Fill an area", 0, QApplication::UnicodeUTF8));
|
||||
fill_button->setText(QApplication::translate("PaintToolbox", "...", 0, QApplication::UnicodeUTF8));
|
||||
pick_button->setToolTip(QApplication::translate("PaintToolbox", "Pick a color", 0, QApplication::UnicodeUTF8));
|
||||
pick_button->setText(QString());
|
||||
pen_button->setToolTip(QApplication::translate("PaintToolbox", "Paint with the pen", 0, QApplication::UnicodeUTF8));
|
||||
pen_button->setText(QApplication::translate("PaintToolbox", "...", 0, QApplication::UnicodeUTF8));
|
||||
pick_button->setToolTip(QApplication::translate("PaintToolbox", "Pick a color", 0, QApplication::UnicodeUTF8));
|
||||
pick_button->setText(QString());
|
||||
advanced_button->setToolTip(QApplication::translate("PaintToolbox", "Change advanced settings", 0, QApplication::UnicodeUTF8));
|
||||
advanced_button->setText(QString());
|
||||
pick_mode->clear();
|
||||
pick_mode->addItem(QApplication::translate("PaintToolbox", "Nearest vertex color", 0, QApplication::UnicodeUTF8));
|
||||
pick_mode->addItem(QApplication::translate("PaintToolbox", "Pixel color", 0, QApplication::UnicodeUTF8));
|
||||
label_pick->setText(QApplication::translate("PaintToolbox", "Picking mode", 0, QApplication::UnicodeUTF8));
|
||||
Q_UNUSED(PaintToolbox);
|
||||
} // retranslateUi
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user