Sketcher: Rendering order widget
This commit is contained in:
@@ -54,6 +54,8 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
|
||||
this, SLOT(setGridSize(double)));
|
||||
connect(ui->checkBoxAutoconstraints, SIGNAL(stateChanged(int)),
|
||||
this, SIGNAL(emitToggleAutoconstraints(int)));
|
||||
connect(ui->renderingOrder->model(), SIGNAL(layoutChanged()),
|
||||
this, SLOT(renderOrderChanged()));
|
||||
}
|
||||
|
||||
SketcherGeneralWidget::~SketcherGeneralWidget()
|
||||
@@ -71,6 +73,8 @@ void SketcherGeneralWidget::saveSettings()
|
||||
|
||||
hGrp->SetBool("GridSnap", ui->checkBoxGridSnap->isChecked());
|
||||
hGrp->SetBool("AutoConstraints", ui->checkBoxAutoconstraints->isChecked());
|
||||
|
||||
//not necessary to save renderOrder, as it is already stored in renderOrderChanged on every change.
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::loadSettings()
|
||||
@@ -82,6 +86,28 @@ void SketcherGeneralWidget::loadSettings()
|
||||
ui->gridSize->setToLastUsedValue();
|
||||
ui->checkBoxGridSnap->setChecked(hGrp->GetBool("GridSnap", ui->checkBoxGridSnap->isChecked()));
|
||||
ui->checkBoxAutoconstraints->setChecked(hGrp->GetBool("AutoConstraints", ui->checkBoxAutoconstraints->isChecked()));
|
||||
|
||||
ParameterGrp::handle hGrpp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
|
||||
// 1->Normal Geometry, 2->Construction, 3->External
|
||||
int topid = hGrpp->GetInt("TopRenderGeometryId",1);
|
||||
int midid = hGrpp->GetInt("MidRenderGeometryId",2);
|
||||
int lowid = hGrpp->GetInt("LowRenderGeometryId",3);
|
||||
|
||||
QListWidgetItem *newItem = new QListWidgetItem;
|
||||
newItem->setData(Qt::UserRole, QVariant(topid));
|
||||
newItem->setText( topid==1?tr("Normal Geometry"):topid==2?tr("Construction Geometry"):tr("External Geometry"));
|
||||
ui->renderingOrder->insertItem(0,newItem);
|
||||
|
||||
newItem = new QListWidgetItem;
|
||||
newItem->setData(Qt::UserRole, QVariant(midid));
|
||||
newItem->setText(midid==1?tr("Normal Geometry"):midid==2?tr("Construction Geometry"):tr("External Geometry"));
|
||||
ui->renderingOrder->insertItem(1,newItem);
|
||||
|
||||
newItem = new QListWidgetItem;
|
||||
newItem->setData(Qt::UserRole, QVariant(lowid));
|
||||
newItem->setText(lowid==1?tr("Normal Geometry"):lowid==2?tr("Construction Geometry"):tr("External Geometry"));
|
||||
ui->renderingOrder->insertItem(2,newItem);
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::toggleGridView(bool on)
|
||||
@@ -115,6 +141,20 @@ void SketcherGeneralWidget::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::renderOrderChanged()
|
||||
{
|
||||
int topid = ui->renderingOrder->item(0)->data(Qt::UserRole).toInt();
|
||||
int midid = ui->renderingOrder->item(1)->data(Qt::UserRole).toInt();
|
||||
int lowid = ui->renderingOrder->item(2)->data(Qt::UserRole).toInt();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
hGrp->SetInt("TopRenderGeometryId",topid);
|
||||
hGrp->SetInt("MidRenderGeometryId",midid);
|
||||
hGrp->SetInt("LowRenderGeometryId",lowid);
|
||||
|
||||
emitrenderOrderChanged();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
@@ -145,6 +185,11 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
this , SLOT (toggleAutoconstraints(int))
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
widget, SIGNAL(emitrenderOrderChanged()),
|
||||
this , SLOT (renderOrderChanged())
|
||||
);
|
||||
|
||||
|
||||
Gui::Selection().Attach(this);
|
||||
widget->loadSettings();
|
||||
@@ -192,4 +237,9 @@ void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller
|
||||
}
|
||||
/// @endcond DOXERR
|
||||
|
||||
void TaskSketcherGeneral::renderOrderChanged()
|
||||
{
|
||||
sketchView->updateColor();
|
||||
}
|
||||
|
||||
#include "moc_TaskSketcherGeneral.cpp"
|
||||
|
||||
@@ -55,11 +55,13 @@ Q_SIGNALS:
|
||||
void emitToggleGridSnap(int);
|
||||
void emitSetGridSize(double);
|
||||
void emitToggleAutoconstraints(int);
|
||||
void emitrenderOrderChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void toggleGridView(bool on);
|
||||
void setGridSize(double val);
|
||||
void toggleGridSnap(int state);
|
||||
void renderOrderChanged();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
@@ -88,6 +90,7 @@ public Q_SLOTS:
|
||||
void setGridSize(double val);
|
||||
void toggleGridSnap(int state);
|
||||
void toggleAutoconstraints(int state);
|
||||
void renderOrderChanged();
|
||||
|
||||
private:
|
||||
ViewProviderSketch *sketchView;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>153</width>
|
||||
<height>115</height>
|
||||
<width>194</width>
|
||||
<height>228</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -34,26 +34,26 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="gridSize">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
<property name="decimals" stdset="0">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="maximum" stdset="0">
|
||||
<double>99999999.0</double>
|
||||
</property>
|
||||
<property name="minimum" stdset="0">
|
||||
<double>0.001</double>
|
||||
</property>
|
||||
<property name="singleStep" stdset="0">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value" stdset="0">
|
||||
<double>0.0000001</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="gridSize" native="true">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
<property name="decimals" stdset="0">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="maximum" stdset="0">
|
||||
<double>99999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="minimum" stdset="0">
|
||||
<double>0.001000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep" stdset="0">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value" stdset="0">
|
||||
<double>0.000000100000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -80,16 +80,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Rendering order:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="renderingOrder">
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefQuantitySpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefQuantitySpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
||||
<connections/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -296,14 +296,18 @@ ViewProviderSketch::ViewProviderSketch()
|
||||
PointSize.setValue(4);
|
||||
|
||||
zCross=0.001f;
|
||||
zLines=0.005f;
|
||||
zConstr=0.007f; // constraint not construction
|
||||
zHighLine=0.006f;
|
||||
zPoints=0.008f;
|
||||
zHighlight=0.009f;
|
||||
zText=0.011f;
|
||||
zEdit=0.001f;
|
||||
zInfo=0.004f;
|
||||
zLowLines=0.005f;
|
||||
//zLines=0.005f; // ZLines removed in favour of 3 height groups intended for NormalLines, ConstructionLines, ExternalLines
|
||||
zMidLines=0.006f;
|
||||
zHighLines=0.007f; // Lines that are somehow selected to be in the high position (higher than other line categories)
|
||||
zHighLine=0.008f; // highlighted line (of any group)
|
||||
zConstr=0.009f; // constraint not construction
|
||||
zPoints=0.010f;
|
||||
zHighlight=0.011f;
|
||||
zText=0.011f;
|
||||
|
||||
|
||||
xInit=0;
|
||||
yInit=0;
|
||||
@@ -2453,6 +2457,17 @@ void ViewProviderSketch::updateColor(void)
|
||||
//int intGeoCount = getSketchObject()->getHighestCurveIndex() + 1;
|
||||
//int extGeoCount = getSketchObject()->getExternalGeometryCount();
|
||||
|
||||
ParameterGrp::handle hGrpp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
|
||||
// 1->Normal Geometry, 2->Construction, 3->External
|
||||
int topid = hGrpp->GetInt("TopRenderGeometryId",1);
|
||||
int midid = hGrpp->GetInt("MidRenderGeometryId",2);
|
||||
int lowid = hGrpp->GetInt("LowRenderGeometryId",3);
|
||||
|
||||
float zNormLine = (topid==1?zHighLines:midid==1?zMidLines:zLowLines);
|
||||
float zConstrLine = (topid==2?zHighLines:midid==2?zMidLines:zLowLines);
|
||||
float zExtLine = (topid==3?zHighLines:midid==3?zMidLines:zLowLines);
|
||||
|
||||
float x,y,z;
|
||||
|
||||
int j=0; // vertexindex
|
||||
@@ -2491,28 +2506,28 @@ void ViewProviderSketch::updateColor(void)
|
||||
color[i] = CurveExternalColor;
|
||||
for (int k=j; j<k+indexes; j++) {
|
||||
verts[j].getValue(x,y,z);
|
||||
verts[j] = SbVec3f(x,y,zConstr);
|
||||
verts[j] = SbVec3f(x,y,zExtLine);
|
||||
}
|
||||
}
|
||||
else if (getSketchObject()->getGeometry(GeoId)->Construction) {
|
||||
color[i] = CurveDraftColor;
|
||||
for (int k=j; j<k+indexes; j++) {
|
||||
verts[j].getValue(x,y,z);
|
||||
verts[j] = SbVec3f(x,y,zLines);
|
||||
verts[j] = SbVec3f(x,y,zConstrLine);
|
||||
}
|
||||
}
|
||||
else if (edit->FullyConstrained) {
|
||||
color[i] = FullyConstrainedColor;
|
||||
for (int k=j; j<k+indexes; j++) {
|
||||
verts[j].getValue(x,y,z);
|
||||
verts[j] = SbVec3f(x,y,zLines);
|
||||
verts[j] = SbVec3f(x,y,zLowLines);
|
||||
}
|
||||
}
|
||||
else {
|
||||
color[i] = CurveColor;
|
||||
for (int k=j; j<k+indexes; j++) {
|
||||
verts[j].getValue(x,y,z);
|
||||
verts[j] = SbVec3f(x,y,zLines);
|
||||
verts[j] = SbVec3f(x,y,zNormLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3874,7 +3889,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
|
||||
|
||||
int i=0; // setting up the line set
|
||||
for (std::vector<Base::Vector3d>::const_iterator it = Coords.begin(); it != Coords.end(); ++it,i++)
|
||||
verts[i].setValue(it->x,it->y,zLines);
|
||||
verts[i].setValue(it->x,it->y,zLowLines);
|
||||
|
||||
i=0; // setting up the indexes of the line set
|
||||
for (std::vector<unsigned int>::const_iterator it = Index.begin(); it != Index.end(); ++it,i++)
|
||||
|
||||
@@ -386,7 +386,7 @@ protected:
|
||||
static SbVec2s newCursorPos;
|
||||
|
||||
float zCross;
|
||||
float zLines;
|
||||
//float zLines;
|
||||
float zPoints;
|
||||
float zConstr;
|
||||
float zHighlight;
|
||||
@@ -394,6 +394,9 @@ protected:
|
||||
float zEdit;
|
||||
float zHighLine;
|
||||
float zInfo;
|
||||
float zLowLines;
|
||||
float zMidLines;
|
||||
float zHighLines;
|
||||
|
||||
// reference coordinates for relative operations
|
||||
double xInit,yInit;
|
||||
|
||||
Reference in New Issue
Block a user