| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include "qg_dlgoptionsdrawing.h" |
| |
|
| | #include <QMessageBox> |
| | #include <QListView> |
| | #include <QMenu> |
| | #include <QStandardItemModel> |
| | #include <cfloat> |
| |
|
| | #include "lc_dimstyletovariablesmapper.h" |
| | #include "lc_defaults.h" |
| | #include "lc_dimstyleitem.h" |
| | #include "lc_dimstylepreviewgraphicview.h" |
| | #include "lc_dimstylepreviewpanel.h" |
| | #include "lc_dimstylesexporter.h" |
| | #include "lc_dimstyleslistmodel.h" |
| | #include "lc_dimstylestreemodel.h" |
| | #include "lc_dlgdimstylemanager.h" |
| | #include "lc_dlgnewcustomvariable.h" |
| | #include "lc_dlgnewdimstyle.h" |
| | #include "lc_inputtextdialog.h" |
| | #include "qc_applicationwindow.h" |
| | #include "rs_debug.h" |
| | #include "rs_filterdxfrw.h" |
| | #include "rs_font.h" |
| | #include "rs_math.h" |
| | #include "rs_settings.h" |
| | #include "rs_units.h" |
| | #include "rs_vector.h" |
| |
|
| | #define $ENABLE_LEGACY_DIMENSIONS_TAB |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | QG_DlgOptionsDrawing::QG_DlgOptionsDrawing(QWidget* parent) |
| | : LC_Dialog(parent, "OptionsDrawing") |
| | , m_listPrec1(std::make_unique<QStringList>()) |
| | ,m_paperScene{new QGraphicsScene(parent)} |
| | ,m_spacing{std::make_unique<RS_Vector>()}{ |
| | setupUi(this); |
| |
|
| | connect(tabWidget, &QTabWidget::currentChanged, this, &QG_DlgOptionsDrawing::onTabCurrentChanged); |
| |
|
| | connectPaperTab(); |
| | connectUnitTab(); |
| | connectGridTab(); |
| |
|
| | #ifdef ENABLE_LEGACY_DIMENSIONS_TAB |
| | _to_remove_ConnectLegacyDimsTab(); |
| | #else |
| | tabWidget->removeTab(3); |
| | #endif |
| |
|
| | connectPointsTab(); |
| | connectUserVarsTab(); |
| |
|
| | tabWidget->setCurrentIndex(0); |
| | init(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onTabCurrentChanged(int index) { |
| | if (index == 3) { |
| | if (m_previewView != nullptr) { |
| | m_previewView->zoomAuto(); |
| | } |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::connectPointsTab() { |
| | connect(rbRelSize, &QRadioButton::toggled, this, &QG_DlgOptionsDrawing::onRelSizeToggled); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::connectUserVarsTab() { |
| | connect(pbCustomVarAdd, &QPushButton::clicked, this, &QG_DlgOptionsDrawing::onCustomVariableAdd); |
| | connect(pbCustomVarDelete, &QPushButton::clicked, this, &QG_DlgOptionsDrawing::onCustomVariableDelete); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::_to_remove_ConnectLegacyDimsTab() { |
| | connect(cbDimLUnit, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateDimLengthPrecision); |
| | connect(cbDimAUnit, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateDimAnglePrecision); |
| | connect(cbDimFxLon, &QCheckBox::toggled, this, &QG_DlgOptionsDrawing::onDimFxLonToggled); |
| | } |
| |
|
| | |
| | |
| | |
| | QG_DlgOptionsDrawing::~QG_DlgOptionsDrawing(){ |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::connectPaperTab() { |
| | connect(cbPaperFormat, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updatePaperSize); |
| | connect(lePaperWidth, &QLineEdit::textChanged, this, &QG_DlgOptionsDrawing::updatePaperPreview); |
| | connect(lePaperHeight, &QLineEdit::textChanged, this, &QG_DlgOptionsDrawing::updatePaperPreview); |
| | connect(rbLandscape, &QRadioButton::toggled, this, &QG_DlgOptionsDrawing::onLandscapeToggled); |
| | connect(leMarginTop, &QLineEdit::textChanged, this, &QG_DlgOptionsDrawing::updatePaperPreview); |
| | connect(leMarginBottom, &QLineEdit::textChanged, this, &QG_DlgOptionsDrawing::updatePaperPreview); |
| | connect(leMarginRight, &QLineEdit::textChanged, this, &QG_DlgOptionsDrawing::updatePaperPreview); |
| | connect(leMarginLeft, &QLineEdit::textChanged, this, &QG_DlgOptionsDrawing::updatePaperPreview); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::connectUnitTab() { |
| | connect(cbUnit, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateUnitsPreview); |
| | connect(cbLengthFormat, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateLengthPrecision); |
| | connect(cbLengthFormat, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateUnitsPreview); |
| | connect(cbLengthPrecision, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateUnitsPreview); |
| | connect(cbAngleFormat, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateAnglePrecision); |
| | connect(cbAngleFormat, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateUnitsPreview); |
| | connect(cbAnglePrecision, &QComboBox::activated, this, &QG_DlgOptionsDrawing::updateUnitsPreview); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::connectGridTab() { |
| | connect(rbIsoLeft, &QCheckBox::toggled, this, &QG_DlgOptionsDrawing::disableXSpacing); |
| | connect(rbIsoRight, &QCheckBox::toggled, this, &QG_DlgOptionsDrawing::disableXSpacing); |
| | connect(rbIsoTop, &QCheckBox::toggled, this, &QG_DlgOptionsDrawing::disableXSpacing); |
| | connect(rbOrthogonalGrid, &QCheckBox::toggled, this, &QG_DlgOptionsDrawing::enableXSpacing); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::languageChange(){ |
| | retranslateUi(this); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::init() { |
| | m_graphic = nullptr; |
| |
|
| | |
| | for (int i=0; i<=8; i++) |
| | *m_listPrec1 << QString("%1").arg(0.0,0,'f', i); |
| |
|
| | |
| | for (int i=RS2::None; i<RS2::LastUnit; i++) { |
| | cbUnit->addItem(RS_Units::unitToString(static_cast<RS2::Unit>(i))); |
| | } |
| |
|
| | fillLinearUnitsCombobox(cbLengthFormat); |
| | fillAngleUnitsCombobox(cbAngleFormat); |
| | #ifdef ENABLE_LEGACY_DIMENSIONS_TAB |
| | fillLinearUnitsCombobox(cbDimLUnit); |
| | fillAngleUnitsCombobox(cbDimAUnit); |
| | #endif |
| |
|
| | |
| | for (RS2::PaperFormat i = RS2::FirstPaperFormat; RS2::NPageFormat > i; i = static_cast<RS2::PaperFormat>(i + 1)) { |
| | cbPaperFormat->addItem( RS_Units::paperFormatToString( i)); |
| | } |
| | |
| | gvPaperPreview->setScene(m_paperScene); |
| | gvPaperPreview->setBackgroundBrush(this->palette().color(QPalette::Window)); |
| | #ifdef ENABLE_LEGACY_DIMENSIONS_TAB |
| | cbDimTxSty->init(); |
| | #endif |
| | } |
| |
|
| | #define TO_MM(v) RS_Units::convert(v, RS2::Millimeter, unit) |
| |
|
| | void QG_DlgOptionsDrawing::prepareDimStyleItems(QList<LC_DimStyleItem*> &items) { |
| | QString defaultDimStyleName = m_graphic->getDefaultDimStyleName(); |
| | LC_DimStyle* styleThatIsDefault = m_graphic->getDimStyleByName(defaultDimStyleName); |
| | QMap<QString, int> usages; |
| | auto dimStylesList = m_graphic->getDimStyleList(); |
| | auto dimStyles = dimStylesList->getStylesList(); |
| | collectStylesUsage(usages); |
| |
|
| | for (const auto dimStyle : *dimStyles) { |
| | LC_DimStyle* ds = dimStyle->getCopy(); |
| | int usageCount = usages.value(dimStyle->getName(), 0); |
| | auto item = new LC_DimStyleItem(ds, usageCount, styleThatIsDefault == dimStyle); |
| | items << item; |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupDimStylesTab() { |
| | m_previewView = LC_DimStylePreviewGraphicView::init(this, m_graphic, RS2::EntityUnknown); |
| |
|
| | auto* layout = new QVBoxLayout(gbDimStylesPreview); |
| | layout->setContentsMargins(0, 0, 0, 0); |
| |
|
| | gbDimStylesPreview->setLayout(layout); |
| | layout->addWidget(m_previewView); |
| |
|
| | auto previewToolbar = new LC_DimStylePreviewPanel(gbDimStylesPreview); |
| | previewToolbar->setGraphicView(m_previewView); |
| |
|
| | layout->addWidget(previewToolbar); |
| | layout->addWidget(m_previewView, 10); |
| |
|
| | QList<LC_DimStyleItem*> items; |
| | prepareDimStyleItems(items); |
| |
|
| | auto* model = new LC_DimStyleTreeModel(this, items, true); |
| | lvDimStyles->setModel(model); |
| |
|
| | updateActiveStyleLabel(model); |
| |
|
| | expandStylesTree(); |
| |
|
| | connect(tbDimNew, &QToolButton::clicked, this, &QG_DlgOptionsDrawing::onDimStyleNew); |
| | connect(tbDimEdit, &QToolButton::clicked, this, &QG_DlgOptionsDrawing::onDimStyleEdit); |
| | connect(tbDimRename, &QToolButton::clicked, this, &QG_DlgOptionsDrawing::onDimStyleRename); |
| | connect(tbDimRemove, &QToolButton::clicked, this, &QG_DlgOptionsDrawing::onDimStyleRemove); |
| | connect(tbDimExport, &QToolButton::clicked, this, &QG_DlgOptionsDrawing::onDimStyleExport); |
| | connect(tbDimImport, &QToolButton::clicked, this, &QG_DlgOptionsDrawing::onDimStyleImport); |
| | connect(tbDimDefault, &QToolButton::clicked, this, &QG_DlgOptionsDrawing::onDimStyleSetDefault); |
| |
|
| | bool autoRaiseButtons = LC_GET_ONE_BOOL("Widgets", "DockWidgetsFlatIcons", true); |
| | tbDimNew->setAutoRaise(autoRaiseButtons); |
| | tbDimEdit->setAutoRaise(autoRaiseButtons); |
| | tbDimRename->setAutoRaise(autoRaiseButtons); |
| | tbDimRemove->setAutoRaise(autoRaiseButtons); |
| | tbDimExport->setAutoRaise(autoRaiseButtons); |
| | tbDimImport->setAutoRaise(autoRaiseButtons); |
| | tbDimDefault->setAutoRaise(autoRaiseButtons); |
| |
|
| | lvDimStyles->setContextMenuPolicy(Qt::CustomContextMenu); |
| |
|
| | connect(lvDimStyles->selectionModel(), &QItemSelectionModel::currentChanged, this, |
| | &QG_DlgOptionsDrawing::onDimCurrentChanged); |
| |
|
| | QModelIndex indexOfSelected = model->index(0, 0, QModelIndex()); |
| | lvDimStyles->setCurrentIndex(indexOfSelected); |
| |
|
| | connect(lvDimStyles, &QListView::customContextMenuRequested, this, |
| | &QG_DlgOptionsDrawing::onDimStylesListMenuRequested); |
| | connect(lvDimStyles, &QListView::doubleClicked, this, &QG_DlgOptionsDrawing::onDimStyleDoubleClick); |
| |
|
| | |
| | |
| |
|
| | dbDimEmbeddArrowBlocks->setVisible(false); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::collectStylesUsage(QMap<QString, int>& map) { |
| | for (RS_Entity* e : m_graphic->getEntityList()) { |
| | auto entityType = e->rtti(); |
| | if (!e->isUndone() && RS2::isDimensionalEntity(entityType)) { |
| | auto* dim = dynamic_cast<RS_Dimension*>(e); |
| | QString styleName = dim->getStyle(); |
| |
|
| | auto dimStyleForNameAndType = m_graphic->getDimStyleByName(styleName, entityType); |
| | if (dimStyleForNameAndType != nullptr) { |
| | QString resolvedStyleName = dimStyleForNameAndType->getName(); |
| | int value = map.value(resolvedStyleName, 0); |
| | value++; |
| | map[resolvedStyleName] = value; |
| | } |
| | else { |
| | |
| | } |
| | } |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupMetaTab() { |
| | QString title = m_graphic->getVariableString("$TITLE", ""); |
| | QString subject = m_graphic->getVariableString("$SUBJECT", ""); |
| | QString author = m_graphic->getVariableString("$AUTHOR", ""); |
| | QString keywords = m_graphic->getVariableString("$KEYWORDS", ""); |
| | QString comments = m_graphic->getVariableString("$COMMENTS", ""); |
| |
|
| | leMetaTitle->setText(title); |
| | leMetaSubject->setText(subject); |
| | leMetaAuthor->setText(author); |
| | leMetaKeywords->setText(keywords); |
| | leMetaComments->setText(comments); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupUserREditor(QLineEdit* edit, const QString &key) { |
| | double rval = m_graphic->getVariableDouble(key, 0.0); |
| | QString val = QString::number(rval, 'g', 12); |
| | edit->setText(val); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupUserTab() { |
| | sbUserI1->setValue(m_graphic->getVariableInt("$USERI1", 0)); |
| | sbUserI2->setValue(m_graphic->getVariableInt("$USERI2", 0)); |
| | sbUserI3->setValue(m_graphic->getVariableInt("$USERI3", 0)); |
| | sbUserI4->setValue(m_graphic->getVariableInt("$USERI4", 0)); |
| | sbUserI5->setValue(m_graphic->getVariableInt("$USERI5", 0)); |
| |
|
| | setupUserREditor(leUserR1, "$USERR1"); |
| | setupUserREditor(leUserR2, "$USERR2"); |
| | setupUserREditor(leUserR3, "$USERR3"); |
| | setupUserREditor(leUserR4, "$USERR4"); |
| | setupUserREditor(leUserR5, "$USERR5"); |
| |
|
| | twCustomVars->setColumnCount(2); |
| | twCustomVars->setHorizontalHeaderLabels({tr("Name"), tr("Value")}); |
| |
|
| | auto customVars = m_graphic->getCustomProperties(); |
| | int row = 0; |
| | QHashIterator<QString,RS_Variable> it(customVars); |
| | while (it.hasNext()){ |
| | it.next(); |
| | QString key = it.key(); |
| | QString value = it.value().getString(); |
| | twCustomVars->insertRow(row); |
| | auto keyItem = new QTableWidgetItem(key); |
| | keyItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); |
| | twCustomVars->setItem(row,0, keyItem); |
| | twCustomVars->setItem(row,1, new QTableWidgetItem(value)); |
| | row++; |
| | } |
| | if (row == 0) { |
| | pbCustomVarDelete->setEnabled(false); |
| | } |
| | |
| | twCustomVars->horizontalHeader()->setStretchLastSection(true); |
| | twCustomVars->setSelectionBehavior(QAbstractItemView::SelectRows); |
| | twCustomVars->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); |
| | twCustomVars->setSortingEnabled(true); |
| | twCustomVars->verticalHeader()->hide(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onCustomVariableAdd([[maybe_unused]]bool checked) { |
| | LC_DlgNewCustomVariable dlg(this); |
| | QStringList propertyNames; |
| | int rowCount = twCustomVars->rowCount(); |
| | for (int row = 0; row < rowCount; row++) { |
| | QString propertyName = twCustomVars->item(row, 0)->text(); |
| | propertyNames.push_back(propertyName); |
| | } |
| | dlg.setPropertyNames(&propertyNames); |
| | if (dlg.exec() == QDialog::Accepted) { |
| | QString propertyName = dlg.getPropertyName(); |
| | QString propertyValue = dlg.getPropertyValue(); |
| | int rowCount = twCustomVars->rowCount(); |
| | twCustomVars->insertRow(rowCount); |
| | twCustomVars->setItem(rowCount,0, new QTableWidgetItem(propertyName)); |
| | twCustomVars->setItem(rowCount,1, new QTableWidgetItem(propertyValue)); |
| | pbCustomVarDelete->setEnabled(true); |
| | } |
| | |
| | |
| | |
| | twCustomVars->update(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onCustomVariableDelete([[maybe_unused]]bool checked) { |
| | int row = twCustomVars->currentRow(); |
| | if (row >= 0) { |
| | QString propertyName = twCustomVars->item(row, 0)->text(); |
| | int response = QMessageBox::warning( |
| | this, |
| | tr("Delete Custom Property"), |
| | tr("Are you sure you'd like to delete property [%1]?").arg(propertyName), |
| | QMessageBox::Yes | QMessageBox::No, QMessageBox::No |
| | ); |
| |
|
| | if (response != QMessageBox::Yes) { |
| | return; |
| | } |
| | twCustomVars->removeRow(row); |
| | } |
| | if (twCustomVars->rowCount() == 0) { |
| | pbCustomVarDelete->setEnabled(false); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleDoubleClick() { |
| | onDimStyleEdit(false); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::reject() { |
| | if (m_hasImportantModificationsToAskOnCancel) { |
| | int response = QMessageBox::warning( |
| | this, |
| | tr("Drawing Options"), |
| | tr("Settings were changed. Are you sure you'd like to skip saving changes (so they will not be saved)?"), |
| | QMessageBox::Yes | QMessageBox::No, QMessageBox::No |
| | ); |
| |
|
| | if (response != QMessageBox::Yes) { |
| | return; |
| | } |
| | } |
| | LC_Dialog::reject(); |
| | } |
| |
|
| | LC_DimStyleTreeModel* QG_DlgOptionsDrawing::getDimStylesModel() { |
| | return dynamic_cast<LC_DimStyleTreeModel*>(lvDimStyles->model()); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStylesListMenuRequested(const QPoint& pos) { |
| | auto* contextMenu = new QMenu(this); |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | QModelIndex index = lvDimStyles->indexAt(pos); |
| | using ActionMemberFunc = void (QG_DlgOptionsDrawing::*)(bool); |
| | const auto addActionFunc = [this, &contextMenu](const QString& iconName, const QString& name, ActionMemberFunc func) |
| | { |
| | contextMenu->addAction(QIcon(":/icons/" + iconName + ".lci"), name, this, func); |
| | }; |
| |
|
| | if (index.isValid()) { |
| | auto* model = getDimStylesModel(); |
| | LC_DimStyleItem* item = model->getItemForIndex(index); |
| | if (!item->isActive() && item->isBaseStyle()) { |
| | addActionFunc("dim_default", tr("&Set as Active"), &QG_DlgOptionsDrawing::onDimStyleSetDefault); |
| | } |
| |
|
| | addActionFunc("add", tr("&Create Style"), &QG_DlgOptionsDrawing::onDimStyleNew); |
| | contextMenu->addSeparator(); |
| | addActionFunc("attributes", tr("&Edit Style"), &QG_DlgOptionsDrawing::onDimStyleEdit); |
| |
|
| | if (item->isNotUsedInDrawing()) { |
| | if (item->isBaseStyle()) { |
| | addActionFunc("rename_active_block", tr("&Rename Style"), &QG_DlgOptionsDrawing::onDimStyleRename); |
| | } |
| | addActionFunc("remove", tr("&Delete Style"), &QG_DlgOptionsDrawing::onDimStyleRemove); |
| | } |
| |
|
| | contextMenu->addSeparator(); |
| | addActionFunc("export", tr("E&xport Styles"), &QG_DlgOptionsDrawing::onDimStyleExport); |
| | addActionFunc("import", tr("&Import Styles"), &QG_DlgOptionsDrawing::onDimStyleImport); |
| | } |
| | else { |
| | addActionFunc("add", tr("&Create Style"), &QG_DlgOptionsDrawing::onDimStyleNew); |
| | addActionFunc("import", tr("&Import Styles"), &QG_DlgOptionsDrawing::onDimStyleImport); |
| | } |
| | contextMenu->exec(QCursor::pos()); |
| | delete contextMenu; |
| | } |
| |
|
| | QString QG_DlgOptionsDrawing::askForUniqueDimStyleName(const QString &caption, const QString &prompt, const QString &defaultText) { |
| | bool ok; |
| | bool styleNameNotUnique = false; |
| | QString styleName = ""; |
| | QString value = defaultText; |
| | auto* model = getDimStylesModel(); |
| | int i = 1; |
| | do { |
| | styleName = LC_InputTextDialog::getText(this, caption,prompt, {}, true, value, &ok); |
| | styleName = styleName.trimmed(); |
| | if (ok) { |
| | auto foundStyle = model->findByName(styleName); |
| | styleNameNotUnique = foundStyle != nullptr; |
| | if (styleNameNotUnique) { |
| | value = styleName+"_"+QString::number(i); |
| | i++; |
| | } |
| | } |
| | else { |
| | return ""; |
| | } |
| | } |
| | while (styleNameNotUnique); |
| | return styleName; |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleNew([[maybe_unused]]bool checked) { |
| | QModelIndex selectedItemIndex = getSelectedDimStyleIndex(); |
| | auto* model = getDimStylesModel(); |
| | LC_DimStyleItem* defaultItem = nullptr; |
| | if (selectedItemIndex.isValid()) { |
| | defaultItem = model->getItemForIndex(selectedItemIndex); |
| | } |
| | else { |
| | defaultItem = model->getActiveStyleItem(); |
| | if (defaultItem == nullptr) { |
| | defaultItem = model->getStandardItem(); |
| | } |
| | } |
| |
|
| | QString newStyleName = ""; |
| | LC_DlgNewDimStyle dlgNewDimStyle(this); |
| | QList<LC_DimStyleItem*> styleItems; |
| | model->collectAllStyleItems(styleItems); |
| | dlgNewDimStyle.setup(defaultItem, styleItems); |
| | if (dlgNewDimStyle.exec() == Accepted) { |
| | newStyleName = dlgNewDimStyle.getStyleName(); |
| | auto styleItemBaseOn = dlgNewDimStyle.getBaseDimStyle(); |
| | RS2::EntityType newDimType = dlgNewDimStyle.getDimensionType(); |
| |
|
| | doCreateDimStyle(newStyleName, model, styleItemBaseOn, newDimType); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::expandStylesTree() { |
| | lvDimStyles->expandAll(); |
| | lvDimStyles->setItemsExpandable(false); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::doCreateDimStyle(const QString &newStyleName, LC_DimStyleTreeModel* model, LC_DimStyleItem* styleItemBasedOn, RS2::EntityType newDimType) { |
| | QApplication::setOverrideCursor(Qt::WaitCursor); |
| | auto originalStyle = styleItemBasedOn->dimStyle(); |
| |
|
| | |
| | LC_DimStyle* styleCopyToEdit = originalStyle->getCopy(); |
| | styleCopyToEdit->setName(newStyleName); |
| | styleCopyToEdit->setFromVars(false); |
| | styleCopyToEdit->resetFlags(true); |
| |
|
| | LC_DlgDimStyleManager dimStyleManager(this, styleCopyToEdit, m_graphic, newDimType); |
| |
|
| | |
| | QList<LC_DimStyleItem*> itemsMatchedStyle; |
| | model->collectAllItemsForStyle(styleCopyToEdit, &itemsMatchedStyle); |
| | for (auto dsi: itemsMatchedStyle) { |
| | auto styleToAdd = dsi->dimStyle(); |
| | if (styleToAdd->getName() != newStyleName) { |
| | dimStyleManager.addDimStyle(styleToAdd); |
| | } |
| | } |
| |
|
| | dimStyleManager.setWindowTitle(tr("Style to Create - ") + LC_DimStyleItem::getDisplayDimStyleName(styleCopyToEdit)); |
| | QApplication::restoreOverrideCursor(); |
| | dimStyleManager.refreshPreview(); |
| |
|
| | if (dimStyleManager.exec() == QDialog::Accepted) { |
| | auto item = new LC_DimStyleItem(styleCopyToEdit, 0, false); |
| | model->addItem(item); |
| | expandStylesTree(); |
| | updateDimStylePreview(originalStyle, model); |
| | m_hasImportantModificationsToAskOnCancel = true; |
| | } |
| | else { |
| | delete styleCopyToEdit; |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleEdit([[maybe_unused]]bool checked) { |
| | QModelIndex selectedItemIndex = getSelectedDimStyleIndex(); |
| | if (selectedItemIndex.isValid()) { |
| | auto model = getDimStylesModel(); |
| | LC_DimStyleItem* itemToEdit = model->getItemForIndex(selectedItemIndex); |
| |
|
| | auto originalStyleToEdit = itemToEdit->dimStyle(); |
| |
|
| | QString baseName = itemToEdit->baseName(); |
| | RS2::EntityType dimType = itemToEdit->forDimensionType(); |
| |
|
| | LC_DimStyle* styleCopyToEdit = originalStyleToEdit->getCopy(); |
| |
|
| | if (dimType != RS2::EntityUnknown) { |
| | |
| | auto baseStyleItem = model->findByName(baseName); |
| | if (baseStyleItem != nullptr) { |
| | LC_DimStyle* baseStyle = baseStyleItem->dimStyle(); |
| | if (baseStyle != nullptr) { |
| | styleCopyToEdit->mergeWith(baseStyle, LC_DimStyle::ModificationAware::UNSET, LC_DimStyle::ModificationAware::SET); |
| | } |
| | } |
| | } |
| |
|
| | QApplication::setOverrideCursor(Qt::WaitCursor); |
| | LC_DlgDimStyleManager dimStyleManager(this, styleCopyToEdit, m_graphic, dimType); |
| | QList<LC_DimStyleItem*> itemsMatchedStyle; |
| | model->collectItemsForBaseStyleName(baseName, &itemsMatchedStyle); |
| | for (auto dsi: itemsMatchedStyle) { |
| | auto styleToAdd = dsi->dimStyle(); |
| | if (itemToEdit != dsi){ |
| | dimStyleManager.addDimStyle(styleToAdd); |
| | } |
| | } |
| |
|
| | dimStyleManager.refreshPreview(); |
| | dimStyleManager.setWindowTitle(tr("Dimension style editing - ") + LC_DimStyleItem::getDisplayDimStyleName(originalStyleToEdit)); |
| | QApplication::restoreOverrideCursor(); |
| |
|
| | if (dimStyleManager.exec() == QDialog::Accepted) { |
| | styleCopyToEdit->copyTo(originalStyleToEdit); |
| | m_hasImportantModificationsToAskOnCancel = true; |
| | updateDimStylePreview(originalStyleToEdit, model); |
| | }; |
| | delete styleCopyToEdit; |
| | } |
| | } |
| |
|
| | QModelIndex QG_DlgOptionsDrawing::getSelectedDimStyleIndex() { |
| | return lvDimStyles->selectionModel()->currentIndex(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleRename([[maybe_unused]]bool checked) { |
| | QModelIndex selectedItemIndex = getSelectedDimStyleIndex(); |
| | if (selectedItemIndex.isValid()) { |
| | auto* model = getDimStylesModel(); |
| | LC_DimStyleItem* item = model->getItemForIndex(selectedItemIndex); |
| | if (item->isBaseStyle() && item->isNotUsedInDrawing()) { |
| | auto style = item->dimStyle(); |
| | QString originalStyleName = style->getName(); |
| | QString styleName = askForUniqueDimStyleName(tr("Rename Dimension Style"), |
| | tr("Enter new unique name of dimension style (was \"%1\"):").arg(originalStyleName), originalStyleName); |
| | if (!styleName.isEmpty()) { |
| | item->setNewBaseName(styleName); |
| | } |
| | model->emitDataChanged(); |
| | expandStylesTree(); |
| | m_hasImportantModificationsToAskOnCancel = true; |
| | } |
| | } |
| | } |
| |
|
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleRemove([[maybe_unused]]bool checked) { |
| | QModelIndex selectedItemIndex = getSelectedDimStyleIndex(); |
| | if (selectedItemIndex.isValid()) { |
| | auto* model = getDimStylesModel(); |
| | LC_DimStyleItem* item = model->getItemForIndex(selectedItemIndex); |
| | int itemsCount = model->itemsCount(); |
| | if (itemsCount == 1) { |
| | QMessageBox msgBox(QMessageBox::Critical, |
| | tr("Removing Dimension Style"), |
| | tr("Can't delete last dimension style. At least one should be present! "), |
| | QMessageBox::Ok); |
| | return; |
| | } |
| |
|
| | if (item->usageCount() == 0) { |
| | QString styleName = item->dimStyle()->getName(); |
| | bool allowRemoval = false; |
| |
|
| | if (item->childCount() > 0) { |
| | bool hasUsedChildren = item->hasUsedChildren(); |
| | if (hasUsedChildren) { |
| | QMessageBox msgBox(QMessageBox::Critical, |
| | tr("Removing Dimension Style"), |
| | tr("Can't delete dimension style as it's children is used in drawing. Only unused style may be deleted."), |
| | QMessageBox::Ok); |
| | allowRemoval = false; |
| | } |
| | else { |
| | QMessageBox msgBox(QMessageBox::Warning, |
| | tr("Removing Dimension Style"), |
| | tr("Are you sure you want to remove the dimension style \"%1\" together with child styles?").arg(styleName), |
| | QMessageBox::Yes | QMessageBox::No); |
| | allowRemoval = msgBox.exec() == QMessageBox::Yes; |
| | } |
| | } |
| | else { |
| | QMessageBox msgBox(QMessageBox::Warning, |
| | tr("Removing Dimension Style"), |
| | tr("Are you sure you want to remove the dimension style \"%1\"?").arg(styleName), |
| | QMessageBox::Yes | QMessageBox::No); |
| | allowRemoval = msgBox.exec() == QMessageBox::Yes; |
| | } |
| |
|
| | if (allowRemoval) { |
| | model->removeItem(item); |
| | expandStylesTree(); |
| | m_hasImportantModificationsToAskOnCancel = true; |
| | } |
| | } |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleExport([[maybe_unused]]bool checked) { |
| | LC_DimStylesExporter exporter; |
| | |
| | auto model = getDimStylesModel(); |
| | QList<LC_DimStyleItem*> dimStyleItems; |
| | model->collectAllStyleItems(dimStyleItems); |
| | exporter.exportStyles(this, dimStyleItems, m_graphic->getFilename()); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleImport([[maybe_unused]]bool checked) { |
| | LC_DimStylesExporter exporter; |
| | QList<LC_DimStyle*> items; |
| | if (exporter.importStyles(this, items)) { |
| | auto model = getDimStylesModel(); |
| | model->mergeWith(items); |
| | items.clear(); |
| | QModelIndex selectedItemIndex = getSelectedDimStyleIndex(); |
| | LC_DimStyleItem* itemToRefresh{nullptr}; |
| | if (selectedItemIndex.isValid()) { |
| | itemToRefresh = model->getItemForIndex(selectedItemIndex); |
| | } |
| | else{ |
| | itemToRefresh = model->getStandardItem(); |
| | } |
| | m_hasImportantModificationsToAskOnCancel= true; |
| | updateDimStylePreview(itemToRefresh->dimStyle(), model); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::updateActiveStyleLabel(LC_DimStyleTreeModel* model) { |
| | auto activeStyleItem = model->getActiveStyleItem(); |
| | QString styleName = ""; |
| | if (activeStyleItem != nullptr){ |
| | styleName = activeStyleItem->baseName(); |
| | } |
| | lblActiveStyle->setText(styleName); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimStyleSetDefault([[maybe_unused]]bool checked) { |
| | QModelIndex selectedItemIndex = getSelectedDimStyleIndex(); |
| | if (selectedItemIndex.isValid()) { |
| | auto model = getDimStylesModel(); |
| | model->setActiveStyleItem(selectedItemIndex); |
| | expandStylesTree(); |
| | updateActiveStyleLabel(model); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::updateActionButtons(LC_DimStyleItem* item) { |
| | auto model = getDimStylesModel(); |
| | int itemsCount = model->itemsCount(); |
| | tbDimDefault->setEnabled(!item->isActive() && item->isBaseStyle()); |
| | bool notUsed = item->isNotUsedInDrawing(); |
| | tbDimRemove->setEnabled(itemsCount > 1 && notUsed); |
| | |
| | tbDimRename->setEnabled(item->isBaseStyle() && notUsed); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimCurrentChanged(const QModelIndex ¤t, [[maybe_unused]]const QModelIndex &previous){ |
| | if (current.isValid()) { |
| | auto model = getDimStylesModel(); |
| | LC_DimStyleItem* item = model->getItemForIndex(current); |
| | updateActionButtons(item); |
| | updateDimStylePreview(item->dimStyle(), model); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::updateDimStylePreview(LC_DimStyle* dimStyle, LC_DimStyleTreeModel* model) const { |
| | m_previewView->setDimStyle(dimStyle); |
| | QList<LC_DimStyleItem*> itemsMatchedStyle; |
| | model->collectAllItemsForStyle(dimStyle, &itemsMatchedStyle); |
| | QString dimStyleName = dimStyle->getName(); |
| | for (auto dsi: itemsMatchedStyle) { |
| | auto styleToAdd = dsi->dimStyle(); |
| | if (styleToAdd->getName() != dimStyleName) { |
| | m_previewView->addDimStyle(styleToAdd); |
| | } |
| | } |
| | m_previewView->updateDims(); |
| | m_previewView->refresh(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupPointsTab() { |
| | |
| | int pdmode = m_graphic->getVariableInt("$PDMODE", LC_DEFAULTS_PDMode); |
| | double pdsize = m_graphic->getVariableDouble("$PDSIZE", LC_DEFAULTS_PDSize); |
| |
|
| | |
| | switch (pdmode) { |
| | case DXF_FORMAT_PDMode_CentreDot: |
| | default: |
| | bDot->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_CentreBlank: |
| | bBlank->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_CentrePlus: |
| | bPlus->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_CentreCross: |
| | bCross->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_CentreTick: |
| | bTick->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreDot): |
| | bDotCircle->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreBlank): |
| | bBlankCircle->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentrePlus): |
| | bPlusCircle->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreCross): |
| | bCrossCircle->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreTick): |
| | bTickCircle->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreDot): |
| | bDotSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreBlank): |
| | bBlankSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentrePlus): |
| | bPlusSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreCross): |
| | bCrossSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreTick): |
| | bTickSquare->setChecked(true); |
| | break; |
| |
|
| | case DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreDot): |
| | bDotCircleSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreBlank): |
| | bBlankCircleSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentrePlus): |
| | bPlusCircleSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreCross): |
| | bCrossCircleSquare->setChecked(true); |
| | break; |
| | case DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreTick): |
| | bTickCircleSquare->setChecked(true); |
| | break; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | if (pdsize <= 0.0) |
| | rbRelSize->setChecked(true); |
| | else |
| | rbAbsSize->setChecked(true); |
| | lePointSize->setText(QString::number(pdsize >= 0.0 ? pdsize : -pdsize)); |
| |
|
| | |
| | updateLPtSzUnits(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupSplinesTab() { |
| | |
| | int splinesegs = m_graphic->getVariableInt("$SPLINESEGS", 8); |
| | |
| | cbSplineSegs->setEditText(QString("%1").arg(splinesegs)); |
| |
|
| | RS_DEBUG->print("QG_DlgOptionsDrawing::setGraphic: splinesegs is: %d", |
| | splinesegs); |
| | int lineCaps = m_graphic->getGraphicVariableInt("$ENDCAPS", 1); |
| | cbLineCap->setCurrentIndex(lineCaps); |
| |
|
| | int joinStyle = m_graphic->getGraphicVariableInt("$JOINSTYLE", 1); |
| | cbLineJoin ->setCurrentIndex(joinStyle); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupGridTab() { |
| | |
| | cbGridOn->setChecked(m_graphic->isGridOn()); |
| | bool isometricGrid = m_graphic->isIsometricGrid(); |
| | if (isometricGrid){ |
| | rbOrthogonalGrid ->setChecked(false); |
| | RS2::IsoGridViewType chType = m_graphic->getIsoView(); |
| | switch (chType) { |
| | case RS2::IsoLeft: |
| | rbIsoLeft->setChecked(true); |
| | break; |
| | case RS2::IsoTop: |
| | rbIsoTop->setChecked(true); |
| | break; |
| | case RS2::IsoRight: |
| | rbIsoRight->setChecked(true); |
| | break; |
| | default: |
| | break; |
| | } |
| | } |
| | else{ |
| | rbOrthogonalGrid->setChecked(true); |
| | } |
| |
|
| | *m_spacing = m_graphic->getVariableVector("$GRIDUNIT", |
| | {0.0, 0.0}); |
| |
|
| | cbXSpacing->setEditText(QString("%1").arg(m_spacing->x)); |
| | cbYSpacing->setEditText(QString("%1").arg(m_spacing->y)); |
| |
|
| | if (cbXSpacing->currentText() == "0") { |
| | cbXSpacing->setEditText(tr("auto")); |
| | } |
| | if (cbYSpacing->currentText() == "0") { |
| | cbYSpacing->setEditText(tr("auto")); |
| | } |
| | LC_GROUP("Appearance"); |
| | { |
| | bool state = LC_GET_BOOL("ScaleGrid"); |
| | lGridStateScaling->setText(state? tr("ON"): tr("OFF")); |
| |
|
| | state = LC_GET_BOOL("UnitlessGrid"); |
| | lGridStateUnitless->setText(state? tr("ON"): tr("OFF")); |
| |
|
| | state = LC_GET_BOOL("GridDraw"); |
| | lGridStateDrawGrid->setText(state? tr("ON"): tr("OFF")); |
| |
|
| | state = LC_GET_BOOL("metaGridDraw"); |
| | lGridStateDrawMetaGrid->setText(state? tr("ON"): tr("OFF")); |
| | } |
| |
|
| | cbXSpacing->setEnabled(cbGridOn->isChecked() && rbOrthogonalGrid->isChecked()); |
| | cbYSpacing->setEnabled(cbGridOn->isChecked()); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupPaperTab() { |
| | |
| | bool landscape; |
| | RS2::PaperFormat format = m_graphic->getPaperFormat(&landscape); |
| | RS_DEBUG->print("QG_DlgOptionsDrawing::setGraphic: paper format is: %d", (int) format); |
| | cbPaperFormat->setCurrentIndex((int) format); |
| |
|
| | |
| | rbLandscape->blockSignals(true); |
| | if (landscape) { |
| | rbLandscape->setChecked(true); |
| | } else { |
| | rbPortrait->setChecked(true); |
| | } |
| | rbLandscape->blockSignals(false); |
| | if (format == RS2::Custom) { |
| | RS_Vector s = m_graphic->getPaperSize(); |
| | auto widthStr = QString("%1").setNum(s.x, 'g', 5); |
| | auto heightStr = QString("%1").setNum(s.y, 'g', 5); |
| |
|
| | lePaperWidth->blockSignals(true); |
| | lePaperHeight->blockSignals(true); |
| | lePaperWidth->setText(widthStr); |
| | lePaperHeight->setText(heightStr); |
| | lePaperWidth->blockSignals(false); |
| | lePaperHeight->blockSignals(false); |
| |
|
| | lePaperWidth->setEnabled(true); |
| | lePaperHeight->setEnabled(true); |
| | } else { |
| | lePaperWidth->setEnabled(false); |
| | lePaperHeight->setEnabled(false); |
| | } |
| |
|
| | |
| | bool block = true; |
| | leMarginLeft->blockSignals(block); |
| | leMarginRight->blockSignals(block); |
| | leMarginTop->blockSignals(block); |
| | leMarginBottom->blockSignals(block); |
| |
|
| | leMarginLeft->setText(QString::number(m_graphic->getMarginLeftInUnits())); |
| | leMarginTop->setText(QString::number(m_graphic->getMarginTopInUnits())); |
| | leMarginRight->setText(QString::number(m_graphic->getMarginRightInUnits())); |
| | leMarginBottom->setText(QString::number(m_graphic->getMarginBottomInUnits())); |
| |
|
| | block = false; |
| | leMarginLeft->blockSignals(block); |
| | leMarginRight->blockSignals(block); |
| | leMarginTop->blockSignals(block); |
| | leMarginBottom->blockSignals(block); |
| |
|
| | updatePaperSize(); |
| | updateUnitLabels(); |
| | updatePaperPreview(); |
| |
|
| | |
| | sbPagesNumH->setValue(m_graphic->getPagesNumHoriz()); |
| | sbPagesNumV->setValue(m_graphic->getPagesNumVert()); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::_toRemoveSetupLegacyDimsTab(RS2::LinearFormat& linearFormat, int lunits, int luprec, int aunits, int auprec) { |
| | |
| | auto unit = static_cast<RS2::Unit>(cbUnit->currentIndex()); |
| |
|
| | |
| | double dimfactor = m_graphic->getVariableDouble("$DIMLFAC", 1.0); |
| | cbDimFactor->setEditText(QString("%1").arg(dimfactor)); |
| |
|
| | |
| | double dimscale = m_graphic->getVariableDouble("$DIMSCALE", 1.0); |
| | cbDimScale->setEditText(QString("%1").arg(dimscale)); |
| |
|
| | double dimtxt = m_graphic->getVariableDouble("$DIMTXT", TO_MM(2.5)); |
| | cbDimTextHeight->setEditText(QString("%1").arg(dimtxt)); |
| |
|
| | |
| | double dimexe = m_graphic->getVariableDouble("$DIMEXE", TO_MM(1.25)); |
| | cbDimExe->setEditText(QString("%1").arg(dimexe)); |
| |
|
| | |
| | double dimexo = m_graphic->getVariableDouble("$DIMEXO", TO_MM(0.625)); |
| | cbDimExo->setEditText(QString("%1").arg(dimexo)); |
| |
|
| | |
| | double dimgap = m_graphic->getVariableDouble("$DIMGAP", TO_MM(0.625)); |
| | cbDimGap->setEditText(QString("%1").arg(dimgap)); |
| |
|
| |
|
| | |
| | double dimasz = m_graphic->getVariableDouble("$DIMASZ", TO_MM(2.5)); |
| | cbDimAsz->setEditText(QString("%1").arg(dimasz)); |
| |
|
| | |
| | double dimtsz = m_graphic->getVariableDouble("$DIMTSZ", 0.); |
| | cbDimTsz->setEditText(QString("%1").arg(dimtsz)); |
| | |
| | int dimtih = m_graphic->getVariableInt("$DIMTIH", 0); |
| | cbDimTih->setCurrentIndex(dimtih); |
| | |
| | cbDimClrT->init(true, false); |
| | cbDimClrE->init(true, false); |
| | cbDimClrD->init(true, false); |
| | cbDimLwD->init(true, false); |
| | cbDimLwE->init(true, false); |
| | |
| | double dimfxl = m_graphic->getVariableDouble("$DIMFXL",TO_MM(1.0)); |
| | cbDimFxL->setValue(dimfxl); |
| | int dimfxlon = m_graphic->getVariableInt("$DIMFXLON", 0); |
| | if (dimfxlon > 0) { |
| | cbDimFxL->setEnabled(true); |
| | cbDimFxLon->setChecked(true); |
| | } else { |
| | cbDimFxL->setEnabled(false); |
| | cbDimFxLon->setChecked(false); |
| | } |
| | int dimlwd = m_graphic->getVariableInt("$DIMLWD", -2); |
| | |
| | RS2::LineWidth lineWidth = RS2::intToLineWidth(dimlwd); |
| | cbDimLwD->setWidth(lineWidth); |
| | int dimlwe = m_graphic->getVariableInt("$DIMLWE", -2); |
| | cbDimLwE->setWidth(RS2::intToLineWidth(dimlwe)); |
| | |
| |
|
| |
|
| | |
| | int dimlunit = m_graphic->getVariableInt("$DIMLUNIT", lunits); |
| | cbDimLUnit->setCurrentIndex(dimlunit - 1); |
| |
|
| | |
| | int dimdec = m_graphic->getVariableInt("$DIMDEC", luprec); |
| |
|
| | linearFormat = linearFormatFromUI(cbDimLUnit->currentIndex()); |
| | updateLengthPrecisionCombobox(linearFormat, cbDimDec); |
| | cbDimDec->setCurrentIndex(dimdec); |
| | |
| | int dimzin = m_graphic->getVariableInt("$DIMZIN", 1); |
| | cbDimZin->setLinear(); |
| | cbDimZin->setData(dimzin); |
| |
|
| | |
| | int dimaunit = m_graphic->getVariableInt("$DIMAUNIT", aunits); |
| | cbDimAUnit->setCurrentIndex(dimaunit); |
| |
|
| | |
| | int dimadec = m_graphic->getVariableInt("$DIMADEC", auprec); |
| | updateAnglePrecisionCombobox(angleFormatFromUI(dimaunit), cbDimADec); |
| | cbDimADec->setCurrentIndex(dimadec); |
| | |
| | int dimazin = m_graphic->getVariableInt("$DIMAZIN", 0); |
| | |
| | cbDimAZin->setData(dimazin); |
| |
|
| | int dimclrd = m_graphic->getVariableInt("$DIMCLRD", 0); |
| | int dimclre = m_graphic->getVariableInt("$DIMCLRE", 0); |
| | int dimclrt = m_graphic->getVariableInt("$DIMCLRT", 0); |
| | cbDimClrD->setColor(RS_FilterDXFRW::numberToColor(dimclrd)); |
| | cbDimClrE->setColor(RS_FilterDXFRW::numberToColor(dimclre)); |
| | cbDimClrT->setColor(RS_FilterDXFRW::numberToColor(dimclrt)); |
| |
|
| | QString dimtxsty = m_graphic->getVariableString("$DIMTXSTY", "standard"); |
| | cbDimTxSty->setFont(dimtxsty); |
| | int dimdsep = m_graphic->getVariableInt("$DIMDSEP", 0); |
| | (dimdsep == 44) ? cbDimDSep->setCurrentIndex(1) : cbDimDSep->setCurrentIndex(0); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::setGraphic(RS_Graphic *g) { |
| | m_graphic = g; |
| |
|
| | if (m_graphic == nullptr) { |
| | RS_DEBUG->print(" QG_DlgOptionsDrawing::setGraphic(nullptr)\n"); |
| | return; |
| | } |
| |
|
| | |
| | int insunits = m_graphic->getVariableInt("$INSUNITS", 0); |
| | cbUnit->setCurrentIndex(cbUnit->findText( |
| | RS_Units::unitToString(RS_FilterDXFRW::numberToUnit(insunits)))); |
| |
|
| | |
| | int lunits = m_graphic->getVariableInt("$LUNITS", 2); |
| | cbLengthFormat->setCurrentIndex(lunits - 1); |
| |
|
| | |
| | int luprec = m_graphic->getVariableInt("$LUPREC", 4); |
| |
|
| | RS2::LinearFormat linearFormat = linearFormatFromUI(cbLengthFormat->currentIndex()); |
| | updateLengthPrecisionCombobox(linearFormat, cbLengthPrecision); |
| | cbLengthPrecision->setCurrentIndex(luprec); |
| |
|
| | |
| | int aunits = m_graphic->getVariableInt("$AUNITS", 0); |
| | cbAngleFormat->setCurrentIndex(aunits); |
| |
|
| | |
| | int auprec = m_graphic->getVariableInt("$AUPREC", 2); |
| | updateAnglePrecisionCombobox(angleFormatFromUI(aunits), cbAnglePrecision); |
| | cbAnglePrecision->setCurrentIndex(auprec); |
| |
|
| | |
| | double baseAngle = m_graphic->getAnglesBase(); |
| | leAngleBaseZero->setText(QString("%1").arg(RS_Math::rad2deg(baseAngle))); |
| |
|
| | bool anglesAreCounterClockwise = m_graphic->areAnglesCounterClockWise(); |
| | rbAngleBasePositive->setChecked(anglesAreCounterClockwise); |
| | rbAngleBaseNegative->setChecked(!anglesAreCounterClockwise); |
| |
|
| | setupGridTab(); |
| |
|
| | #ifdef ENABLE_LEGACY_DIMENSIONS_TAB |
| | _toRemoveSetupLegacyDimsTab(linearFormat, lunits, luprec, aunits, auprec); |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | setupPaperTab(); |
| | setupPointsTab(); |
| | setupSplinesTab(); |
| | setupDimStylesTab(); |
| | setupMetaTab(); |
| | setupUserTab(); |
| | setupVariablesTab(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::setupVariablesTab(){ |
| | QHash<QString, RS_Variable>vars = m_graphic->getVariableDict(); |
| | tabVariables->setRowCount(vars.count()); |
| | QHash<QString, RS_Variable>::iterator it = vars.begin(); |
| | int row = 0; |
| | while (it != vars.end()) { |
| | QString name = it.key(); |
| | if (name.startsWith("$")){ |
| | name = name.mid(1); |
| | } |
| | auto *nameItem = new QTableWidgetItem(name); |
| | tabVariables->setItem(row, 0, nameItem); |
| |
|
| | auto* codeItem = new QTableWidgetItem(QString("%1").arg(it.value().getCode())); |
| | tabVariables->setItem(row, 1, codeItem); |
| |
|
| | QString str = ""; |
| | switch (it.value().getType()) { |
| | case RS2::VariableVoid: |
| | tabVariables->setItem(row, 2, new QTableWidgetItem(tr("VOID"))); |
| | break; |
| | case RS2::VariableInt: |
| | tabVariables->setItem(row, 2, new QTableWidgetItem(tr("INT"))); |
| | str = QString("%1").arg(it.value().getInt()); |
| | break; |
| | case RS2::VariableDouble: |
| | tabVariables->setItem(row, 2, new QTableWidgetItem(tr("DOUBLE"))); |
| | str = QString("%1").arg(it.value().getDouble()); |
| | break; |
| | case RS2::VariableString: |
| | tabVariables->setItem(row, 2, new QTableWidgetItem(tr("STRING"))); |
| | str = QString("%1").arg(it.value().getString()); |
| | break; |
| | case RS2::VariableVector: |
| | tabVariables->setItem(row, 2, new QTableWidgetItem(tr("VECTOR"))); |
| | str = QString("%1/%2") |
| | .arg(it.value().getVector().x) |
| | .arg(it.value().getVector().y); |
| | if (RS_FilterDXFRW::isVariableTwoDimensional(it.key())==false) { |
| | str+= QString("/%1").arg(it.value().getVector().z); |
| | } |
| | break; |
| | } |
| | auto *valueItem = new QTableWidgetItem(str); |
| | tabVariables->setItem(row, 3, valueItem); |
| | row++; |
| | ++it; |
| | } |
| | tabVariables->sortByColumn(0, Qt::SortOrder::AscendingOrder); |
| | tabVariables->setSortingEnabled(true); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::_toRemove_validateDimsOld() { |
| | |
| | bool ok1 = true; |
| | double oldValue = m_graphic->getVariableDouble("$DIMTXT", 1.); |
| | double newValue = RS_Math::eval(cbDimTextHeight->currentText(), &ok1); |
| | |
| | if (ok1 && (std::abs(oldValue - newValue) > RS_TOLERANCE)) { |
| | m_graphic->addVariable("$DIMTXT", newValue, 40); |
| | } |
| | m_graphic->addVariable("$DIMEXE", |
| | RS_Math::eval(cbDimExe->currentText()), 40); |
| | m_graphic->addVariable("$DIMEXO", |
| | RS_Math::eval(cbDimExo->currentText()), 40); |
| | bool ok2 = true; |
| | oldValue = m_graphic->getVariableDouble("$DIMGAP", 1); |
| | newValue = RS_Math::eval(cbDimGap->currentText(), &ok2); |
| | |
| | ok2 &= (std::abs(oldValue - newValue) > RS_TOLERANCE); |
| | if (ok2) { |
| | m_graphic->addVariable("$DIMGAP", newValue, 40); |
| | } |
| | ok1 = ok1 || ok2; |
| | oldValue = m_graphic->getVariableDouble("$DIMLFAC", 1); |
| | newValue = RS_Math::eval(cbDimFactor->currentText(), &ok2); |
| | ok2 &= (std::abs(oldValue - newValue) > RS_TOLERANCE); |
| | ok1 = ok1 || ok2; |
| | oldValue = m_graphic->getVariableDouble("$DIMSCALE", 1); |
| | newValue = RS_Math::eval(cbDimScale->currentText(), &ok2); |
| | ok2 &= (std::abs(oldValue - newValue) > RS_TOLERANCE); |
| | ok1 = ok1 || ok2; |
| |
|
| | m_graphic->addVariable("$DIMASZ", |
| | RS_Math::eval(cbDimAsz->currentText()), 40); |
| | |
| | m_graphic->addVariable("$DIMTSZ", |
| | RS_Math::eval(cbDimTsz->currentText()), 40); |
| | |
| | int iOldIndex = m_graphic->getVariableInt("$DIMTIH", 0); |
| | int iNewIndex = cbDimTih->currentIndex(); |
| | if (iOldIndex != iNewIndex) { |
| | ok1 = true; |
| | m_graphic->addVariable("$DIMTIH", iNewIndex, 70); |
| | } |
| | |
| | double dimFactor = RS_Math::eval(cbDimFactor->currentText()); |
| | if (RS_TOLERANCE > std::abs(dimFactor)) { |
| | dimFactor = 1.0; |
| | } |
| | m_graphic->addVariable("$DIMLFAC", dimFactor, 40); |
| | |
| | double dimScale = RS_Math::eval(cbDimScale->currentText()); |
| | if (dimScale <= DBL_EPSILON) |
| | dimScale = 1.0; |
| | m_graphic->addVariable("$DIMSCALE", dimScale, 40); |
| |
|
| | RS2::LineWidth dimLwDLineWidth = cbDimLwD->getWidth(); |
| | int lineWidthDValue = RS2::lineWidthToInt(dimLwDLineWidth); |
| | m_graphic->addVariable("$DIMLWD", lineWidthDValue, 70); |
| | |
| |
|
| | RS2::LineWidth dimLwELineWidth = cbDimLwE->getWidth(); |
| | int lineWidthEValue = RS2::lineWidthToInt(dimLwELineWidth); |
| | m_graphic->addVariable("$DIMLWE", lineWidthEValue, 70); |
| | |
| |
|
| | m_graphic->addVariable("$DIMFXL", cbDimFxL->value(), 40); |
| | m_graphic->addVariable("$DIMFXLON", cbDimFxLon->isChecked() ? 1 : 0, 70); |
| | m_graphic->addVariable("$DIMLUNIT", cbDimLUnit->currentIndex() + 1, 70); |
| | m_graphic->addVariable("$DIMDEC", cbDimDec->currentIndex(), 70); |
| | m_graphic->addVariable("$DIMZIN", cbDimZin->getData(), 70); |
| | m_graphic->addVariable("$DIMAUNIT", cbDimAUnit->currentIndex(), 70); |
| | m_graphic->addVariable("$DIMADEC", cbDimADec->currentIndex(), 70); |
| | |
| | m_graphic->addVariable("$DIMAZIN", cbDimAZin->getData(), 70); |
| | int colNum, colRGB; |
| | colNum = RS_FilterDXFRW::colorToNumber(cbDimClrD->getColor(), &colRGB); |
| | m_graphic->addVariable("$DIMCLRD", colNum, 70); |
| | colNum = RS_FilterDXFRW::colorToNumber(cbDimClrE->getColor(), &colRGB); |
| | m_graphic->addVariable("$DIMCLRE", colNum, 70); |
| | colNum = RS_FilterDXFRW::colorToNumber(cbDimClrT->getColor(), &colRGB); |
| | m_graphic->addVariable("$DIMCLRT", colNum, 70); |
| | if (cbDimTxSty->getFont()) |
| | m_graphic->addVariable("$DIMTXSTY", cbDimTxSty->getFont()->getFileName(), 2); |
| | m_graphic->addVariable("$DIMDSEP", (cbDimDSep->currentIndex() == 1) ? 44 : 0, 70); |
| | m_graphic->updateDimensions(ok1); |
| | } |
| |
|
| | bool QG_DlgOptionsDrawing::validateDimensionsTab() { |
| | LC_DimStyleTreeModel* model = getDimStylesModel(); |
| | QList<LC_DimStyleItem*> items; |
| | model->collectAllStyleItems(items); |
| |
|
| | QList<LC_DimStyle*> newDimStyles; |
| | QString currentDimStyleName; |
| | for (LC_DimStyleItem* item: items) { |
| | auto editedStyle = item->dimStyle(); |
| | newDimStyles.push_back(editedStyle->getCopy()); |
| | if (item->isActive()) { |
| | currentDimStyleName = editedStyle->getName(); |
| | m_graphic->updateFallbackDimStyle(editedStyle); |
| | } |
| | } |
| |
|
| | m_graphic->replaceDimStylesList(currentDimStyleName, newDimStyles); |
| |
|
| | |
| | model->cleanup(false); |
| | m_graphic->updateDimensions(false); |
| | return true; |
| | } |
| |
|
| | bool QG_DlgOptionsDrawing::validatePointsTab() { |
| | |
| | |
| | int pdmode = LC_DEFAULTS_PDMode; |
| |
|
| | if (bDot->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_CentreDot; |
| | } |
| | else if (bBlank->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_CentreBlank; |
| | } |
| | else if (bPlus->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_CentrePlus; |
| | } |
| | else if (bCross->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_CentreCross; |
| | } |
| | else if (bTick->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_CentreTick; |
| | } |
| | else if (bDotCircle->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreDot); |
| | } |
| | else if (bBlankCircle->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreBlank); |
| | } |
| | else if (bPlusCircle->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentrePlus); |
| | } |
| | else if (bCrossCircle->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreCross); |
| | } |
| | else if (bTickCircle->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircle(DXF_FORMAT_PDMode_CentreTick); |
| | } |
| | else if (bDotSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreDot); |
| | } |
| | else if (bBlankSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreBlank); |
| | } |
| | else if (bPlusSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentrePlus); |
| | } |
| | else if (bCrossSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreCross); |
| | } |
| | else if (bTickSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseSquare(DXF_FORMAT_PDMode_CentreTick); |
| | } |
| | else if (bDotCircleSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreDot); |
| | } |
| | else if (bBlankCircleSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreBlank); |
| | } |
| | else if (bPlusCircleSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentrePlus); |
| | } |
| | else if (bCrossCircleSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreCross); |
| | } |
| | else if (bTickCircleSquare->isChecked()) { |
| | pdmode = DXF_FORMAT_PDMode_EncloseCircleSquare(DXF_FORMAT_PDMode_CentreTick); |
| | } |
| |
|
| | m_graphic->addVariable("$PDMODE", pdmode, DXF_FORMAT_GC_PDMode); |
| |
|
| | bool ok{false}; |
| | double pdsize = RS_Math::eval(lePointSize->text(), &ok); |
| | if (!ok) { |
| | pdsize = LC_DEFAULTS_PDSize; |
| | } |
| |
|
| | if (pdsize > 0.0 && rbRelSize->isChecked()) { |
| | pdsize = -pdsize; |
| | } |
| |
|
| | m_graphic->addVariable("$PDSIZE", pdsize, DXF_FORMAT_GC_PDSize); |
| | return true; |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::validateSplinesTab() { |
| | |
| | m_graphic->addVariable("$SPLINESEGS",(int) RS_Math::eval(cbSplineSegs->currentText()), 70); |
| |
|
| | RS_DEBUG->print("QG_DlgOptionsDrawing::validate: splinesegs is: %s", |
| | cbSplineSegs->currentText().toLatin1().data()); |
| |
|
| | m_graphic->addVariable("$JOINSTYLE", cbLineJoin ->currentIndex(), DXF_FORMAT_GC_JoinStyle); |
| | m_graphic->addVariable("$ENDCAPS", cbLineCap->currentIndex(), DXF_FORMAT_GC_Endcaps); |
| | |
| | m_graphic->updateSplines(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::validateGridTab() { |
| | |
| | |
| |
|
| | emit QC_ApplicationWindow::getAppWindow()->gridChanged(cbGridOn->isChecked()); |
| |
|
| | *m_spacing = RS_Vector{0.0, 0.0, 0.0}; |
| | m_graphic->setGridOn(cbGridOn->isChecked()); |
| | *m_spacing = RS_Vector{0.0, 0.0}; |
| | if (cbXSpacing->currentText() == tr("auto")) { |
| | m_spacing->x = 0.0; |
| | } else { |
| | m_spacing->x = cbXSpacing->currentText().toDouble(); |
| | } |
| | if (cbYSpacing->currentText() == tr("auto")) { |
| | m_spacing->y = 0.0; |
| | } else { |
| | m_spacing->y = cbYSpacing->currentText().toDouble(); |
| | } |
| | m_graphic->addVariable("$GRIDUNIT", *m_spacing, 10); |
| |
|
| | bool isometricGrid = !rbOrthogonalGrid->isChecked(); |
| |
|
| | m_graphic->setIsometricGrid(isometricGrid); |
| |
|
| | RS2::IsoGridViewType isoView = RS2::IsoGridViewType::IsoTop; |
| | if (isometricGrid){ |
| | if (rbIsoLeft->isChecked()){ |
| | isoView = RS2::IsoGridViewType::IsoLeft; |
| | } |
| | else if (rbIsoTop->isChecked()){ |
| | isoView = RS2::IsoGridViewType::IsoTop; |
| | } |
| | else if (rbIsoRight->isChecked()){ |
| | isoView = RS2::IsoGridViewType::IsoRight; |
| | } |
| | m_graphic->setIsoView(isoView); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::validatePaperTab() { |
| | RS2::PaperFormat currentFormat{static_cast<RS2::PaperFormat>(cbPaperFormat->currentIndex())}; |
| | |
| | m_graphic->setPaperFormat(currentFormat, rbLandscape->isChecked()); |
| | |
| | if (RS2::Custom == currentFormat) { |
| | m_graphic->setPaperSize(RS_Vector(RS_Math::eval(lePaperWidth->text()), |
| | RS_Math::eval(lePaperHeight->text()))); |
| | bool landscape; |
| | m_graphic->getPaperFormat(&landscape); |
| | rbLandscape->setChecked(landscape); |
| | } |
| |
|
| | |
| | m_graphic->setMarginsInUnits(RS_Math::eval(leMarginLeft->text()), |
| | RS_Math::eval(leMarginTop->text()), |
| | RS_Math::eval(leMarginRight->text()), |
| | RS_Math::eval(leMarginBottom->text())); |
| | |
| | m_graphic->setPagesNum(sbPagesNumH->value(), |
| | sbPagesNumV->value()); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::validateMetaTab() { |
| | m_graphic->addVariable("$TITLE", leMetaTitle->text(), 1); |
| | m_graphic->addVariable("$SUBJECT", leMetaSubject->text(), 1); |
| | m_graphic->addVariable("$AUTHOR", leMetaAuthor->text(), 1); |
| | m_graphic->addVariable("$KEYWORDS", leMetaKeywords->text(), 1); |
| | m_graphic->addVariable("$COMMENTS", leMetaComments->toPlainText(), 1); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::validateUserTab() { |
| | m_graphic->addVariable("$USERI1", sbUserI1->value(),70); |
| | m_graphic->addVariable("$USERI2", sbUserI2->value(),70); |
| | m_graphic->addVariable("$USERI3", sbUserI3->value(),70); |
| | m_graphic->addVariable("$USERI4", sbUserI4->value(),70); |
| | m_graphic->addVariable("$USERI5", sbUserI5->value(),70); |
| |
|
| | m_graphic->addVariable("$USERR1", RS_Math::eval(leUserR1->text(),0.0),40); |
| | m_graphic->addVariable("$USERR2", RS_Math::eval(leUserR2->text(),0.0),40); |
| | m_graphic->addVariable("$USERR3", RS_Math::eval(leUserR3->text(),0.0),40); |
| | m_graphic->addVariable("$USERR4", RS_Math::eval(leUserR4->text(),0.0),40); |
| | m_graphic->addVariable("$USERR5", RS_Math::eval(leUserR5->text(),0.0),40); |
| |
|
| | int row_count = twCustomVars->rowCount(); |
| |
|
| | QHash<QString, QString> newCustomVars; |
| | for (int i = 0; i < row_count; i++) { |
| | QString name = twCustomVars->item(i, 0)->text(); |
| | QString value = twCustomVars->item(i, 1)->text(); |
| | newCustomVars.insert(name, value); |
| | } |
| | m_graphic->replaceCustomVars(newCustomVars); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::validateUnitsTab() { |
| | |
| | auto unit = static_cast<RS2::Unit>(cbUnit->currentIndex()); |
| | m_graphic->setUnit(unit); |
| |
|
| | RS_Units::setCurrentDrawingUnits(unit); |
| |
|
| | m_graphic->addVariable("$LUNITS", cbLengthFormat->currentIndex() + 1, 70); |
| | m_graphic->addVariable("$LUPREC", cbLengthPrecision->currentIndex(), 70); |
| | m_graphic->addVariable("$AUNITS", cbAngleFormat->currentIndex(), 70); |
| | m_graphic->addVariable("$AUPREC", cbAnglePrecision->currentIndex(), 70); |
| |
|
| | |
| | bool ok{false}; |
| | double baseAngle = RS_Math::eval(leAngleBaseZero->text(), &ok); |
| | if (ok){ |
| | double baseAngleRad = RS_Math::deg2rad(baseAngle); |
| | m_graphic->setAnglesBase(baseAngleRad); |
| | } |
| | bool anglesCounterClockwise = rbAngleBasePositive->isChecked(); |
| | m_graphic->setAnglesCounterClockwise(anglesCounterClockwise); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::validate() { |
| | auto f = (RS2::LinearFormat) cbLengthFormat->currentIndex(); |
| | if (f == RS2::Engineering || f == RS2::Architectural) { |
| | if (static_cast<RS2::Unit>(cbUnit->currentIndex()) != RS2::Inch) { |
| | QMessageBox::warning(this, tr("Options"), |
| | tr("For the length formats 'Engineering' and 'Architectural', the " |
| | "unit must be set to Inch.")); |
| | return; |
| | } |
| | } |
| | if (f == RS2::ArchitecturalMetric) { |
| | if (static_cast<RS2::Unit>(cbUnit->currentIndex()) != RS2::Meter) { |
| | QMessageBox::warning(this, tr("Options"), |
| | tr("For the length format 'Architectural (metric)', the " |
| | "unit must be set to Meter.")); |
| | return; |
| | } |
| | } |
| |
|
| | if (m_graphic != nullptr) { |
| | validatePaperTab(); |
| | validateUnitsTab(); |
| | validateGridTab(); |
| | validateSplinesTab(); |
| |
|
| | |
| | |
| | #ifdef ENABLE_LEGACY_DIMENSIONS_TAB |
| | _toRemove_validateDimsOld(); |
| | #endif |
| | validateDimensionsTab(); |
| | validatePointsTab(); |
| | validateMetaTab(); |
| | validateUserTab(); |
| |
|
| | |
| | m_graphic->setModified(true); |
| | } |
| | accept(); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updateLengthPrecision() { |
| | RS2::LinearFormat linearFormat = linearFormatFromUI(cbLengthFormat->currentIndex()); |
| | updateLengthPrecisionCombobox(linearFormat, cbLengthPrecision); |
| |
|
| | switch (linearFormat) { |
| | case RS2::Engineering: |
| | case RS2::Architectural: { |
| | cbUnit->setCurrentIndex(RS2::Inch); |
| | break; |
| | } |
| | case RS2::ArchitecturalMetric: { |
| | cbUnit->setCurrentIndex(RS2::Meter); |
| | break; |
| | } |
| | case RS2::Decimal: { |
| | auto unit = static_cast<RS2::Unit>(cbUnit->currentIndex()); |
| | if (unit == RS2::Foot || unit == RS2::Inch || unit == RS2::Microinch || unit == RS2::Mil || unit == RS2::Mile || unit == RS2::Yard) { |
| | cbUnit->setCurrentIndex(RS2::Millimeter); |
| | } |
| | break; |
| | } |
| | default: |
| | break; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updateDimLengthPrecision() { |
| | RS2::LinearFormat linearFormat = linearFormatFromUI(cbDimLUnit->currentIndex()); |
| | updateLengthPrecisionCombobox(linearFormat, cbDimDec); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::updateLengthPrecisionCombobox(RS2::LinearFormat unit, QComboBox* p){ |
| |
|
| | p->clear(); |
| |
|
| | switch (unit) { |
| | |
| | case RS2::Scientific: { |
| | p->addItem("0E+01"); |
| | p->addItem("0.0E+01"); |
| | p->addItem("0.00E+01"); |
| | p->addItem("0.000E+01"); |
| | p->addItem("0.0000E+01"); |
| | p->addItem("0.00000E+01"); |
| | p->addItem("0.000000E+01"); |
| | p->addItem("0.0000000E+01"); |
| | p->addItem("0.00000000E+01"); |
| |
|
| | |
| | p->setCurrentIndex(2); |
| | break; |
| | } |
| | case RS2::Decimal: { |
| | |
| | |
| | for (int i = 0; i <= 8; i++) { |
| | p->addItem(QString("%1").arg(0.0, 0, 'f', i)); |
| | } |
| | p->setCurrentIndex(2); |
| | break; |
| | } |
| | case RS2::Architectural: { |
| | p->addItem("0'-0\""); |
| | p->addItem("0'-0 1/2\""); |
| | p->addItem("0'-0 1/4\""); |
| | p->addItem("0'-0 1/8\""); |
| | p->addItem("0'-0 1/16\""); |
| | p->addItem("0'-0 1/32\""); |
| | p->addItem("0'-0 1/64\""); |
| | p->addItem("0'-0 1/128\""); |
| |
|
| | p->setCurrentIndex(2); |
| | break; |
| | } |
| | case RS2::Engineering: { |
| | p->addItem("0'-0\""); |
| | p->addItem("0'-0.0\""); |
| | p->addItem("0'-0.00\""); |
| | p->addItem("0'-0.000\""); |
| | p->addItem("0'-0.0000\""); |
| | p->addItem("0'-0.00000\""); |
| | p->addItem("0'-0.000000\""); |
| | p->addItem("0'-0.0000000\""); |
| | p->addItem("0'-0.00000000\""); |
| |
|
| | p->setCurrentIndex(2); |
| | break; |
| | } |
| | case RS2::Fractional: { |
| | p->addItem("0"); |
| | p->addItem("0 1/2"); |
| | p->addItem("0 1/4"); |
| | p->addItem("0 1/8"); |
| | p->addItem("0 1/16"); |
| | p->addItem("0 1/32"); |
| | p->addItem("0 1/64"); |
| | p->addItem("0 1/128"); |
| |
|
| | p->setCurrentIndex(2); |
| | break; |
| | } |
| | case RS2::ArchitecturalMetric: { |
| | for (int i = 0; i <= 8; i++) { |
| | p->addItem(QString("%1").arg(0.0, 0, 'f', i)); |
| | } |
| |
|
| | p->setCurrentIndex(2); |
| | break; |
| | } |
| | default: |
| | LC_ERR << "QG_DlgOptionsDrawing::updateLengthPrecisionCombobox: error"; |
| | break; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updateAnglePrecision() { |
| | RS2::AngleFormat angleFormat = angleFormatFromUI(cbAngleFormat->currentIndex()); |
| | updateAnglePrecisionCombobox(angleFormat, cbAnglePrecision); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updateDimAnglePrecision() { |
| | RS2::AngleFormat angleFormat = angleFormatFromUI(cbDimAUnit->currentIndex()); |
| | updateAnglePrecisionCombobox(angleFormat, cbDimADec); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updateUnitsPreview() { |
| | QString prev = RS_Units::formatLinear(14.43112351, |
| | static_cast<RS2::Unit>(cbUnit->currentIndex()), |
| | static_cast<RS2::LinearFormat>(cbLengthFormat->currentIndex()), |
| | cbLengthPrecision->currentIndex()); |
| | lLinear->setText(prev); |
| |
|
| | prev = RS_Units::formatAngle(0.5327714, |
| | static_cast<RS2::AngleFormat>(cbAngleFormat->currentIndex()), |
| | cbAnglePrecision->currentIndex()); |
| | lAngular->setText(prev); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updatePaperSize() { |
| | auto format = (RS2::PaperFormat)cbPaperFormat->currentIndex(); |
| |
|
| | RS_Vector s; |
| | if (format==RS2::Custom) { |
| | s.x = RS_Math::eval(lePaperWidth->text()); |
| | s.y = RS_Math::eval(lePaperHeight->text()); |
| | } |
| | else { |
| | |
| | s = RS_Units::convert( |
| | RS_Units::paperFormatToSize(format), |
| | RS2::Millimeter, |
| | static_cast<RS2::Unit>(cbUnit->currentIndex()) |
| | ); |
| | } |
| |
|
| | if (rbLandscape->isChecked() != (s.x > s.y)) { |
| | std::swap(s.x, s.y); |
| | } |
| | m_graphic->setPaperSize(s); |
| |
|
| | lePaperWidth->blockSignals(true); |
| | lePaperWidth->setText(QString("%1").setNum(s.x,'g',5)); |
| | lePaperWidth->blockSignals(false); |
| |
|
| | lePaperHeight->blockSignals(true); |
| | lePaperHeight->setText(QString("%1").setNum(s.y,'g',5)); |
| | lePaperHeight->blockSignals(false); |
| |
|
| | if (RS2::Custom == cbPaperFormat->currentIndex()) { |
| | lePaperWidth->setEnabled(true); |
| | lePaperHeight->setEnabled(true); |
| | } else { |
| | lePaperWidth->setEnabled(false); |
| | lePaperHeight->setEnabled(false); |
| | } |
| | updateUnitsPreview(); |
| | updatePaperPreview(); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updateUnitLabels() { |
| | auto u = static_cast<RS2::Unit>(cbUnit->currentIndex()); |
| | QString unitSign = RS_Units::unitToSign(u); |
| | auto labels = {lDimUnit1, lDimUnit2, lDimUnit3, lDimUnit4, lDimUnit5, lDimUnit6, lDimUnit7}; |
| | for(QLabel* unitLabel : labels) { |
| | unitLabel->setText(unitSign); |
| | } |
| | |
| | updatePaperSize(); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updatePaperPreview() { |
| | auto paperWidthText = lePaperWidth->text(); |
| | auto paperHeightText = lePaperHeight->text(); |
| |
|
| | double paperW = RS_Math::eval(paperWidthText); |
| | double paperH = RS_Math::eval(paperHeightText); |
| |
|
| | rbLandscape->blockSignals(true); |
| | if (paperW > paperH) { |
| | rbLandscape->setChecked(true); |
| | } else { |
| | rbPortrait->setChecked(true); |
| | } |
| | rbLandscape->blockSignals(false); |
| | |
| | int previewW = gvPaperPreview->width() - 10; |
| | int previewH = gvPaperPreview->height() - 10; |
| | double scale = qMin(previewW / paperW, previewH / paperH); |
| | int lMargin = qRound(RS_Math::eval(leMarginLeft->text(),-1) * scale); |
| | if (lMargin < 0.0) |
| | lMargin = m_graphic->getMarginLeftInUnits(); |
| | int tMargin = qRound(RS_Math::eval(leMarginTop->text(),-1) * scale); |
| | if (tMargin < 0.0) |
| | tMargin = m_graphic->getMarginTopInUnits(); |
| | int rMargin = qRound(RS_Math::eval(leMarginRight->text(),-1) * scale); |
| | if (rMargin < 0.0) |
| | rMargin = m_graphic->getMarginRightInUnits(); |
| | int bMargin = qRound(RS_Math::eval(leMarginBottom->text(),-1) * scale); |
| | if (bMargin < 0.0) |
| | bMargin = m_graphic->getMarginBottomInUnits(); |
| | int printAreaW = qRound(paperW*scale) - lMargin - rMargin; |
| | int printAreaH = qRound(paperH*scale) - tMargin - bMargin; |
| | m_paperScene->clear(); |
| | m_paperScene->setSceneRect(0, 0, qRound(paperW*scale), qRound(paperH*scale)); |
| | m_paperScene->addRect(0, 0, qRound(paperW*scale), qRound(paperH*scale), |
| | QPen(Qt::black), QBrush(Qt::lightGray)); |
| | m_paperScene->addRect(lMargin+1, tMargin+1, printAreaW-1, printAreaH-1, |
| | QPen(Qt::NoPen), QBrush(Qt::white)); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::resizeEvent(QResizeEvent* event) { |
| | if (m_graphic != nullptr) { |
| | updatePaperPreview(); |
| | m_previewView->zoomAuto(); |
| | } |
| | LC_Dialog::resizeEvent(event); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::showEvent(QShowEvent* event) { |
| | updatePaperPreview(); |
| | LC_Dialog::showEvent(event); |
| | } |
| |
|
| | |
| | void QG_DlgOptionsDrawing::on_cbGridOn_toggled(bool checked){ |
| | rbIsoTop->setEnabled(checked); |
| | rbOrthogonalGrid->setEnabled(checked); |
| | rbIsoLeft->setEnabled(checked); |
| | rbIsoRight->setEnabled(checked); |
| | cbXSpacing->setEnabled(checked && rbOrthogonalGrid->isChecked()); |
| | cbYSpacing->setEnabled(checked); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onLandscapeToggled(bool ) { |
| | updatePaperSize(); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::disableXSpacing(bool checked) { |
| | if (checked){ |
| | cbXSpacing->setEnabled(false); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::enableXSpacing(bool checked) { |
| | if (checked){ |
| | cbXSpacing ->setEnabled(true); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onDimFxLonToggled(bool checked) { |
| | cbDimFxL->setEnabled(checked); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::onRelSizeToggled([[maybe_unused]] bool checked) { |
| | |
| | updateLPtSzUnits(); |
| | } |
| |
|
| | |
| | void QG_DlgOptionsDrawing::updateLPtSzUnits() { |
| | |
| | if (rbRelSize->isChecked()) |
| | lPtSzUnits->setText(QApplication::translate("QG_DlgOptionsDrawing", "Screen %", nullptr)); |
| | else |
| | lPtSzUnits->setText(QApplication::translate("QG_DlgOptionsDrawing", "Dwg Units", nullptr)); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::showInitialTab(int tabIndex) { |
| | if (tabIndex > 0){ |
| | tabWidget->setCurrentIndex(tabIndex); |
| | } |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::fillLinearUnitsCombobox(QComboBox* combobox) { |
| | QStringList unitList; |
| | unitList << tr("Scientific") |
| | << tr("Decimal") |
| | << tr("Engineering") |
| | << tr("Architectural") |
| | << tr("Fractional") |
| | << tr("Architectural (metric)"); |
| |
|
| | combobox->insertItems(0, unitList); |
| | } |
| |
|
| | void QG_DlgOptionsDrawing::fillAngleUnitsCombobox(QComboBox* combobox) { |
| | |
| | QStringList aunitList; |
| | aunitList << tr("Decimal Degrees") |
| | << tr("Deg/min/sec") |
| | << tr("Gradians") |
| | << tr("Radians") |
| | << tr("Surveyor's units"); |
| | combobox->insertItems(0, aunitList); |
| | } |
| |
|
| | RS2::AngleFormat QG_DlgOptionsDrawing::angleFormatFromUI(int current_index) { |
| | switch (current_index) { |
| | case 0: |
| | return RS2::DegreesDecimal; |
| | case 1: |
| | return RS2::DegreesMinutesSeconds; |
| | case 2: |
| | return RS2::Gradians; |
| | case 3: |
| | return RS2::Radians; |
| | case 4: |
| | return RS2::Surveyors; |
| | default: |
| | return RS2::DegreesDecimal; |
| | } |
| | } |
| |
|
| | RS2::LinearFormat QG_DlgOptionsDrawing::linearFormatFromUI(int currentIndex) { |
| | switch (currentIndex) { |
| | case 0: |
| | return RS2::Scientific; |
| | case 1: |
| | return RS2::Decimal; |
| | case 3: |
| | return RS2::Architectural; |
| | case 2: |
| | return RS2::Engineering; |
| | case 4: |
| | return RS2::Fractional; |
| | case 5: |
| | return RS2::ArchitecturalMetric; |
| | default: |
| | LC_ERR << QString("QG_DlgOptionsDrawing::linearFormatFromUI: error. Value: %1").arg(currentIndex); |
| | return RS2::Decimal; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_DlgOptionsDrawing::updateAnglePrecisionCombobox(RS2::AngleFormat format, QComboBox* p) { |
| | int index = p->currentIndex(); |
| | p->clear(); |
| | switch (format) { |
| | case RS2::DegreesDecimal: { |
| | for (int i = 0; i <= 8; i++) { |
| | p->addItem(QString("%1").arg(0.0, 0, 'f', i)); |
| | } |
| | break; |
| | } |
| | case RS2::AngleFormat::DegreesMinutesSeconds: { |
| | p->addItem(QString("0%1").arg(QChar(0xB0))); |
| | p->addItem(QString("0%100'").arg(QChar(0xB0))); |
| | p->addItem(QString("0%100'00\"").arg(QChar(0xB0))); |
| | p->addItem(QString("0%100'00.0\"").arg(QChar(0xB0))); |
| | p->addItem(QString("0%100'00.00\"").arg(QChar(0xB0))); |
| | p->addItem(QString("0%100'00.000\"").arg(QChar(0xB0))); |
| | p->addItem(QString("0%100'00.0000\"").arg(QChar(0xB0))); |
| | break; |
| | } |
| | case RS2::AngleFormat::Gradians: { |
| | p->addItem("0g"); |
| | p->addItem("0.0g"); |
| | p->addItem("0.00g"); |
| | p->addItem("0.000g"); |
| | p->addItem("0.0000g"); |
| | p->addItem("0.00000g"); |
| | p->addItem("0.000000g"); |
| | p->addItem("0.0000000g"); |
| | p->addItem("0.00000000g"); |
| | break; |
| | } |
| | case RS2::AngleFormat::Radians: { |
| | p->addItem("0r"); |
| | p->addItem("0.0r"); |
| | p->addItem("0.00r"); |
| | p->addItem("0.000r"); |
| | p->addItem("0.0000r"); |
| | p->addItem("0.00000r"); |
| | p->addItem("0.000000r"); |
| | p->addItem("0.0000000r"); |
| | p->addItem("0.00000000r"); |
| | break; |
| | } |
| | case RS2::AngleFormat::Surveyors:{ |
| |
|
| | p->addItem("N 0d E"); |
| | p->addItem("N 0d00' E"); |
| | p->addItem("N 0d00'00\" E"); |
| | p->addItem("N 0d00'00.0\" E"); |
| | p->addItem("N 0d00'00.00\" E"); |
| | p->addItem("N 0d00'00.000\" E"); |
| | p->addItem("N 0d00'00.0000\" E"); |
| | break; |
| | } |
| | default: |
| | break; |
| | } |
| | p->setCurrentIndex(index); |
| | } |
| |
|