Sketcher/Grid: fix error in parameter function call
Sketcher/Grid: fix algorithm computing the automatic grid spacing Sketcher/Grid: forcefully redraw grid when one of its parameter is changed Sketcher/Grid: always authorize user to change grid spacing, even if 'auto spacing' is enabled Sketcher/Grid: apply a default factor of 10 for 'auto spacing' if number of subdivision is 1
This commit is contained in:
committed by
abdullahtahiriyo
parent
f486ee74a4
commit
f1bd743b1b
@@ -218,7 +218,11 @@ void GridExtensionP::computeGridSize(const Gui::View3DInventorViewer* viewer)
|
||||
|
||||
double unitMultiplier = (unitsUserSchema == 2 || unitsUserSchema == 3) ? 25.4 : (unitsUserSchema == 5 || unitsUserSchema == 7) ? 304.8 : 1;
|
||||
|
||||
computedGridValue = vp->GridSize.getValue() * unitMultiplier * pow(GridNumberSubdivision, floor(log(camMaxDimension / unitMultiplier / numberOfLines) / log(GridNumberSubdivision)));
|
||||
// If number of subdivision is 1, grid auto spacing can't work as it uses it as a factor
|
||||
// In such case, we apply a default factor of 10
|
||||
auto safeGridNumberSubdivision = GridNumberSubdivision <= 1 ? 10 : GridNumberSubdivision;
|
||||
|
||||
computedGridValue = vp->GridSize.getValue() * safeGridNumberSubdivision * unitMultiplier * pow(safeGridNumberSubdivision, floor(log(camMaxDimension / unitMultiplier / numberOfLines / vp->GridSize.getValue()) / log(safeGridNumberSubdivision)));
|
||||
|
||||
//cap the grid size
|
||||
capGridSize(computedGridValue);
|
||||
@@ -472,41 +476,49 @@ void ViewProviderGridExtension::extensionOnChanged(const App::Property* prop)
|
||||
void ViewProviderGridExtension::setGridSizePixelThreshold(int value)
|
||||
{
|
||||
pImpl->GridSizePixelThreshold = value;
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
void ViewProviderGridExtension::setGridNumberSubdivision(int value)
|
||||
{
|
||||
pImpl->GridNumberSubdivision = value;
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
void ViewProviderGridExtension::setGridLinePattern(int pattern)
|
||||
{
|
||||
pImpl->GridLinePattern = pattern;
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
void ViewProviderGridExtension::setGridDivLinePattern(int pattern)
|
||||
{
|
||||
pImpl->GridDivLinePattern = pattern;
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
void ViewProviderGridExtension::setGridLineWidth(int width)
|
||||
{
|
||||
pImpl->GridLineWidth = width;
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
void ViewProviderGridExtension::setGridDivLineWidth(int width)
|
||||
{
|
||||
pImpl->GridDivLineWidth = width;
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
void ViewProviderGridExtension::setGridLineColor(const App::Color & color)
|
||||
{
|
||||
pImpl->GridLineColor = color.getPackedValue();
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
void ViewProviderGridExtension::setGridDivLineColor(const App::Color & color)
|
||||
{
|
||||
pImpl->GridDivLineColor = color.getPackedValue();
|
||||
drawGrid(false);
|
||||
}
|
||||
|
||||
bool ViewProviderGridExtension::extensionHandleChangedPropertyType(Base::XMLReader& reader,
|
||||
|
||||
@@ -999,10 +999,6 @@ public:
|
||||
|
||||
updateCheckBoxFromProperty(gridAutoSpacing, sketchView->GridAuto);
|
||||
|
||||
auto autospacing = gridAutoSpacing->checkState() == Qt::Checked;
|
||||
|
||||
gridSizeBox->setEnabled(!autospacing);
|
||||
|
||||
gridSizeBox->setValue(sketchView->GridSize.getValue());
|
||||
}
|
||||
}
|
||||
@@ -1065,8 +1061,6 @@ protected:
|
||||
if(sketchView) {
|
||||
auto enable = (state == Qt::Checked);
|
||||
sketchView->GridAuto.setValue(enable);
|
||||
|
||||
gridSizeBox->setEnabled(!enable);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -132,12 +132,6 @@ SketcherSettingsGrid::SketcherSettingsGrid(QWidget* parent)
|
||||
ui->gridLinePattern->addItem(QIcon(px), QString(), QVariant(it->second));
|
||||
ui->gridDivLinePattern->addItem(QIcon(px), QString(), QVariant(it->second));
|
||||
}
|
||||
|
||||
ui->gridSize->setEnabled(!ui->checkBoxGridAuto->isChecked());
|
||||
|
||||
QObject::connect(ui->checkBoxGridAuto,&Gui::PrefCheckBox::stateChanged, [this](int state) {
|
||||
ui->gridSize->setEnabled(state != Qt::Checked);
|
||||
});
|
||||
}
|
||||
|
||||
SketcherSettingsGrid::~SketcherSettingsGrid()
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="gridSize">
|
||||
<property name="toolTip">
|
||||
<string>Distance between two subsequent grid lines</string>
|
||||
<string>Distance between two subsequent grid lines.
|
||||
If 'Grid Auto Spacing' is enabled, will be used as base value.</string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
@@ -121,7 +122,8 @@
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="gridSizePixelThreshold">
|
||||
<property name="toolTip">
|
||||
<string>While using 'Grid Auto Spacing' this sets a threshold in pixel to the grid spacing. The grid spacing change if it becomes smaller than this number of pixel.</string>
|
||||
<string>While using 'Grid Auto Spacing' this sets a threshold in pixel to the grid spacing.
|
||||
The grid spacing change if it becomes smaller than this number of pixel.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>3</number>
|
||||
|
||||
@@ -233,7 +233,7 @@ void ViewProviderSketch::ParameterObserver::initParameters()
|
||||
{"GridSizePixelThreshold",
|
||||
{[this](const std::string & string, [[maybe_unused]] App::Property * property){ auto v = getSketcherGeneralParameter(string, 15); Client.setGridSizePixelThreshold(v); }, nullptr }},
|
||||
{"GridNumberSubdivision",
|
||||
{[this](const std::string & string, [[maybe_unused]] App::Property * property){ auto v = getSketcherGeneralParameter(string, 10); Client.setGridSizePixelThreshold(v); }, nullptr }},
|
||||
{[this](const std::string & string, [[maybe_unused]] App::Property * property){ auto v = getSketcherGeneralParameter(string, 10); Client.setGridNumberSubdivision(v); }, nullptr }},
|
||||
{"GridLinePattern",
|
||||
{[this](const std::string & string, [[maybe_unused]] App::Property * property){ auto v = getSketcherGeneralParameter(string, 0x0f0f); Client.setGridLinePattern(v); }, nullptr }},
|
||||
{"GridDivLinePattern",
|
||||
|
||||
Reference in New Issue
Block a user