This commit is contained in:
Chenwenxuan
2024-03-06 14:54:30 +08:00
commit edac2715f0
1525 changed files with 809982 additions and 0 deletions

View File

@@ -0,0 +1,152 @@
#include <QMouseEvent>
#include <QGridLayout>
#include <QActionGroup>
#include <QIcon>
#include <QToolButton>
#include <QToolBar>
#include "lc_cadtoolbarinterface.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
#include "rs_debug.h"
LC_CadToolBarInterface::LC_CadToolBarInterface(QG_CadToolBar* _parentTB, Qt::WindowFlags fl):
QWidget(_parentTB, fl)
,cadToolBar(_parentTB)
,actionHandler(nullptr)
,m_pHidden(new QAction("ActionHidden", this))
,m_pGrid0(new QToolBar)
,m_pGrid1(new QToolBar)
,m_pActionGroup(new QActionGroup(this))
{
}
void LC_CadToolBarInterface::initToolBars()
{
switch(rtti()){
case RS2::ToolBarSelect:
m_pButtonForward = new QAction( QIcon(":/extui/forward.png"), "Continue", this);
//continue to default, no break by design
default:
m_pButtonBack = new QAction(QIcon(":/extui/back.png"), "Back", this);
case RS2::ToolBarMain:
break;
}
setStyleSheet("QToolBar{ margin: 0px }");
setContentsMargins(0,0,0,0);
// setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
for(auto p: {m_pGrid0, m_pGrid1}){
p->setFloatable(false);
p->setMovable(false);
p->setOrientation(Qt::Vertical);
p->setContentsMargins(0,0,0,0);
}
m_pActionGroup->setExclusive(true);
m_pHidden->setCheckable(true);
m_pHidden->setChecked(true);
m_pActionGroup->addAction(m_pHidden);
QHBoxLayout* hLayout=new QHBoxLayout;
hLayout->addWidget(m_pGrid0);
hLayout->addWidget(m_pGrid1);
hLayout->setSpacing(1);
hLayout->setContentsMargins(0,0,0,0);
QVBoxLayout* vLayout=new QVBoxLayout;
vLayout->setSpacing(1);
vLayout->setContentsMargins(0,0,0,0);
if(m_pButtonBack){
QToolButton* button=new QToolButton;
button->setDefaultAction(m_pButtonBack);
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
vLayout->addWidget(button);
connect(m_pButtonBack, SIGNAL(triggered()), cadToolBar, SLOT(back()));
}
vLayout->addLayout(hLayout);
if(rtti()!=RS2::ToolBarSelect)
vLayout->addStretch(1);
setLayout(vLayout);
}
void LC_CadToolBarInterface::setActionHandler(QG_ActionHandler* ah)
{
actionHandler=ah;
}
void LC_CadToolBarInterface::finishCurrentAction(bool resetToolBar)
{
if(!actionHandler) return;
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction) {
currentAction->finish(resetToolBar); //finish the action, but do not update toolBar
}
}
void LC_CadToolBarInterface::killSelectActions()
{
if(!actionHandler) return;
actionHandler->killSelectActions();
}
void LC_CadToolBarInterface::killAllActions()
{
if(!actionHandler) return;
actionHandler->killAllActions();
}
QSize LC_CadToolBarInterface::sizeHint() const
{
return QSize(-1,-1);
}
void LC_CadToolBarInterface::mousePressEvent(QMouseEvent* e) {
if (e->button()==Qt::RightButton && cadToolBar) {
finishCurrentAction(true);
cadToolBar->showPreviousToolBar(true);
e->accept();
}
}
void LC_CadToolBarInterface::back()
{
finishCurrentAction(true);
if (cadToolBar) {
cadToolBar->showPreviousToolBar(true);
}
}
void LC_CadToolBarInterface::addSubAction(QAction*const action, bool addGroup)
{
RS_DEBUG->print("LC_CadToolBarInterface::addSubAction(): begin\n");
switch(rtti()){
case RS2::ToolBarMain:
action->setCheckable(false);
break;
default:
action->setCheckable(true);
}
if(actions0>actions1){
m_pGrid1->addAction(action);
++actions1;
}else{
m_pGrid0->addAction(action);
++actions0;
}
if(addGroup) m_pActionGroup->addAction(action);
RS_DEBUG->print("LC_CadToolBarInterface::addSubAction(): end\n");
}
void LC_CadToolBarInterface::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
for(auto p: actions){
this->addSubAction(p, addGroup);
}
resize(cadToolBar->size());
}

View File

@@ -0,0 +1,58 @@
#ifndef LC_CADTOOLBARINTERFACE_H
#define LC_CADTOOLBARINTERFACE_H
#include <QWidget>
#include "rs.h"
class QToolBar;
class QG_CadToolBar;
class QG_ActionHandler;
class RS_ActionInterface;
class QAction;
class QGridLayout;
class QActionGroup;
class LC_CadToolBarInterface: public QWidget
{
public:
LC_CadToolBarInterface() = delete;
LC_CadToolBarInterface(QG_CadToolBar* _parentTB, Qt::WindowFlags fl = 0);
virtual ~LC_CadToolBarInterface()=default;
virtual RS2::ToolBarId rtti() const = 0;
//! \{ \brief populate toolbar with QAction buttons
void addSubAction(QAction*const action, bool addGroup=true);
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
//! \}
virtual void setActionHandler(QG_ActionHandler* ah);
void finishCurrentAction(bool resetToolBar=false); //clear current action
void killSelectActions();
void killAllActions();
virtual void resetToolBar() {}
virtual void runNextAction() {}
virtual void restoreAction() {} //restore action from checked button
virtual void showCadToolBar(RS2::ActionType /*actionType*/) {}
virtual void setSelectAction( RS_ActionInterface * /*selectAction*/ ) {}
virtual void setNextAction( int /*nextAction*/ ) {}
virtual QSize sizeHint() const;
public slots:
virtual void back();
virtual void mousePressEvent( QMouseEvent * e );
// virtual void contextMenuEvent( QContextMenuEvent * e );
protected:
QG_CadToolBar* cadToolBar;
QG_ActionHandler* actionHandler;
QAction* m_pButtonBack=nullptr;
QAction* m_pButtonForward=nullptr;
QAction* m_pHidden;
QToolBar *m_pGrid0, *m_pGrid1;
size_t actions0=0, actions1=0;
QActionGroup* m_pActionGroup;
void initToolBars();
};
#endif // LC_CADTOOLBARINTERFACE_H

View File

@@ -0,0 +1,103 @@
#include <QStandardItemModel>
#include "lc_dlgsplinepoints.h"
#include "lc_splinepoints.h"
#include "rs_graphic.h"
#include "rs_math.h"
#include "ui_lc_dlgsplinepoints.h"
LC_DlgSplinePoints::LC_DlgSplinePoints(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
, ui(new Ui::DlgSplinePoints{})
{
setModal(modal);
ui->setupUi(this);
connect(ui->rbSplinePoints, SIGNAL(toggled(bool)),
this, SLOT(updatePoints())
);
}
LC_DlgSplinePoints::~LC_DlgSplinePoints() = default;
void LC_DlgSplinePoints::languageChange()
{
ui->retranslateUi(this);
}
void LC_DlgSplinePoints::setSpline(LC_SplinePoints& b)
{
bezier = &b;
//pen = spline->getPen();
ui->wPen->setPen(b.getPen(false), true, false, "Pen");
RS_Graphic* graphic = b.getGraphic();
if (graphic) {
ui->cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = b.getLayer(false);
if (lay) {
ui->cbLayer->setLayer(*lay);
}
ui->cbClosed->setChecked(b.isClosed());
//number of control points
auto const& bData = b.getData();
auto const n = bData.splinePoints.size();
if (n <= 2) {
ui->rbControlPoints->setChecked(true);
ui->rbSplinePoints->setEnabled(false);
} else
ui->rbSplinePoints->setChecked(true);
updatePoints();
}
void LC_DlgSplinePoints::updatePoints()
{
bool const useSpline = ui->rbSplinePoints->isChecked();
auto const& bData = bezier->getData();
auto const& pts = useSpline?bData.splinePoints:bData.controlPoints;
auto model = new QStandardItemModel(pts.size(), 2, this);
model->setHorizontalHeaderLabels({"x", "y"});
//set spline data
for (size_t row = 0; row < pts.size(); ++row) {
auto const& vp = pts.at(row);
QStandardItem* x = new QStandardItem(QString::number(vp.x));
model->setItem(row, 0, x);
QStandardItem* y = new QStandardItem(QString::number(vp.y));
model->setItem(row, 1, y);
}
ui->tvPoints->setModel(model);
}
void LC_DlgSplinePoints::updateSpline()
{
if (!bezier) return;
//update closed
bezier->setClosed(ui->cbClosed->isChecked());
//update pen
bezier->setPen(ui->wPen->getPen());
//update layer
bezier->setLayer(ui->cbLayer->currentText());
//update Spline Points
auto model = static_cast<QStandardItemModel*>(ui->tvPoints->model());
size_t const n = model->rowCount();
auto& d = bezier->getData();
//update points
bool const useSpline = ui->rbSplinePoints->isChecked();
auto& vps = useSpline?d.splinePoints:d.controlPoints;
size_t const n0 = vps.size();
//update points
for (size_t i = 0; i < n; ++i) {
auto& vp = vps.at(i<n0?i:n0 - 1);
auto const& vpx = model->item(i, 0)->text();
vp.x = RS_Math::eval(vpx, vp.x);
auto const& vpy = model->item(i, 1)->text();
vp.y = RS_Math::eval(vpy, vp.y);
}
bezier->update();
}

View File

@@ -0,0 +1,38 @@
#ifndef LC_DLGSPLINEPOINTS_H
#define LC_DLGSPLINEPOINTS_H
#include<memory>
#include <QDialog>
class LC_SplinePoints;
namespace Ui {
class DlgSplinePoints;
}
class LC_DlgSplinePoints : public QDialog
{
Q_OBJECT
public:
LC_DlgSplinePoints(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
virtual ~LC_DlgSplinePoints();
public slots:
virtual void setSpline(LC_SplinePoints& b);
virtual void updateSpline();
void updatePoints();
protected slots:
virtual void languageChange();
private:
LC_DlgSplinePoints(LC_DlgSplinePoints const&) = delete;
LC_DlgSplinePoints& operator = (LC_DlgSplinePoints const&) = delete;
LC_DlgSplinePoints(LC_DlgSplinePoints &&) = delete;
LC_DlgSplinePoints& operator = (LC_DlgSplinePoints &&) = delete;
LC_SplinePoints* bezier;
std::unique_ptr<Ui::DlgSplinePoints> ui;
};
#endif // LC_DLGSPLINEPOINTS_H

View File

@@ -0,0 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgSplinePoints</class>
<widget class="QDialog" name="DlgSplinePoints">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>406</width>
<height>320</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string>SplinePoints</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="buttonGroup8">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Geometry</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="cbClosed">
<property name="text">
<string>Closed</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="rbSplinePoints">
<property name="text">
<string>Spline Points</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbControlPoints">
<property name="text">
<string>Control Points</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QTableView" name="tvPoints">
<property name="minimumSize">
<size>
<width>320</width>
<height>240</height>
</size>
</property>
<property name="toolTip">
<string>Points on Spline</string>
</property>
<property name="whatsThis">
<string>Points on Spline</string>
</property>
<property name="textElideMode">
<enum>Qt::ElideRight</enum>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="3" column="0">
<spacer name="spacer58">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DlgSplinePoints</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>202</x>
<y>217</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DlgSplinePoints</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>202</x>
<y>217</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,44 @@
/*
**********************************************************************************
**
** This file was created for the LibreCAD project (librecad.org), a 2D CAD program.
**
** Copyright (C) 2015 ravas (github.com/r-a-v-a-s)
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**********************************************************************************
*/
#include "lc_widgetoptionsdialog.h"
#include <QFileDialog>
LC_WidgetOptionsDialog::LC_WidgetOptionsDialog(QWidget* parent)
: QDialog(parent)
{
setupUi(this);
connect(stylesheet_button, SIGNAL(released()),
this, SLOT(chooseStyleSheet()));
}
void LC_WidgetOptionsDialog::chooseStyleSheet()
{
QString path = QFileDialog::getOpenFileName(this);
if (!path.isEmpty())
{
stylesheet_field->setText(QDir::toNativeSeparators(path));
}
}

View File

@@ -0,0 +1,23 @@
#ifndef LC_WIDGETOPTIONSDIALOG_H
#define LC_WIDGETOPTIONSDIALOG_H
#include "ui_lc_widgetoptionsdialog.h"
/**
* a generic dialog for native Qt widget options
*/
class LC_WidgetOptionsDialog
: public QDialog
, public Ui::LC_WidgetOptionsDialog
{
Q_OBJECT
public:
explicit LC_WidgetOptionsDialog(QWidget* parent = 0);
public slots:
void chooseStyleSheet();
};
#endif // LC_WIDGETOPTIONSDIALOG_H

View File

@@ -0,0 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LC_WidgetOptionsDialog</class>
<widget class="QDialog" name="LC_WidgetOptionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>326</width>
<height>417</height>
</rect>
</property>
<property name="windowTitle">
<string>Widget Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Toolbar</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QCheckBox" name="toolbar_icon_size_checkbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Icon Size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="toolbar_icon_size_spinbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>side length in pixels</string>
</property>
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>150</number>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="theme_checkbox">
<property name="text">
<string>Use themed icons</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QCheckBox" name="style_checkbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Style</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="style_combobox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="stylesheet_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Style Sheet</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLineEdit" name="stylesheet_field">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Input the path of a Qt style sheet.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Statusbar</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QCheckBox" name="statusbar_height_checkbox">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="statusbar_height_spinbox"/>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="statusbar_fontsize_checkbox">
<property name="text">
<string>Font Size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="statusbar_fontsize_spinbox"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>LC_WidgetOptionsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>107</x>
<y>249</y>
</hint>
<hint type="destinationlabel">
<x>89</x>
<y>220</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>LC_WidgetOptionsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>189</x>
<y>249</y>
</hint>
<hint type="destinationlabel">
<x>256</x>
<y>184</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,15 @@
#include "qg_activelayername.h"
#include "rs_settings.h"
QG_ActiveLayerName::QG_ActiveLayerName(QWidget *parent) :
QWidget(parent)
{
setupUi(this);
lActiveLayerName->setText("");
}
void QG_ActiveLayerName::activeLayerChanged(const QString& name)
{
lActiveLayerName->setText(name);
}

View File

@@ -0,0 +1,16 @@
#ifndef QG_ACTIVELAYERNAME_H
#define QG_ACTIVELAYERNAME_H
#include "ui_qg_activelayername.h"
class QG_ActiveLayerName : public QWidget, public Ui::QG_ActiveLayerName
{
Q_OBJECT
public:
explicit QG_ActiveLayerName(QWidget *parent = 0);
void activeLayerChanged(const QString& name);
};
#endif // QG_ACTIVELAYERNAME_H

View File

@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_ActiveLayerName</class>
<widget class="QWidget" name="QG_ActiveLayerName">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>112</width>
<height>32</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>112</width>
<height>29</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>160</height>
</size>
</property>
<property name="windowTitle">
<string>Selection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lActiveLayer">
<property name="minimumSize">
<size>
<width>46</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Current Layer</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lActiveLayerName">
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Helvetica'; font-size:7pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Name of Current Active Layer&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="indent">
<number>0</number>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

108
ui/forms/qg_arcoptions.cpp Normal file
View File

@@ -0,0 +1,108 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_arcoptions.h"
#include "rs_actiondrawarc.h"
#include "rs_settings.h"
#include "rs_debug.h"
#include "ui_qg_arcoptions.h"
/*
* Constructs a QG_ArcOptions as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_ArcOptions::QG_ArcOptions(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, ui(new Ui::Ui_ArcOptions{})
{
ui->setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_ArcOptions::~QG_ArcOptions() {
saveSettings();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_ArcOptions::languageChange()
{
ui->retranslateUi(this);
}
void QG_ArcOptions::saveSettings() {
RS_SETTINGS->beginGroup("/Draw");
RS_SETTINGS->writeEntry("/ArcReversed", (int)ui->rbNeg->isChecked());
RS_SETTINGS->endGroup();
}
void QG_ArcOptions::setAction(RS_ActionInterface* a, bool update) {
if (a && a->rtti()==RS2::ActionDrawArc) {
action = static_cast<RS_ActionDrawArc*>(a);
bool reversed;
if (update) {
reversed = action->isReversed();
} else {
RS_SETTINGS->beginGroup("/Draw");
reversed = RS_SETTINGS->readNumEntry("/ArcReversed", 0);
RS_SETTINGS->endGroup();
action->setReversed(reversed);
}
ui->rbNeg->setChecked(reversed);
} else {
RS_DEBUG->print(RS_Debug::D_ERROR, "QG_ArcOptions::setAction: wrong action type");
action = nullptr;
}
}
/*void QG_ArcOptions::init() {
data = nullptr;
RS_SETTINGS->beginGroup("/Draw");
bool reversed = RS_SETTINGS->readNumEntry("/ArcReversed", 0);
RS_SETTINGS->endGroup();
rbNeg->setChecked(reversed);
}*/
/*void QG_ArcOptions::setData(RS_ArcData* d) {
data = d;
updateDirection(false);
}*/
void QG_ArcOptions::updateDirection(bool /*pos*/) {
if (action) {
action->setReversed(!(ui->rbPos->isChecked()));
}
}

62
ui/forms/qg_arcoptions.h Normal file
View File

@@ -0,0 +1,62 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_ARCOPTIONS_H
#define QG_ARCOPTIONS_H
#include<memory>
#include<QWidget>
class RS_ActionDrawArc;
class RS_ActionInterface;
namespace Ui {
class Ui_ArcOptions;
}
class QG_ArcOptions : public QWidget
{
Q_OBJECT
public:
QG_ArcOptions(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_ArcOptions();
public slots:
virtual void setAction( RS_ActionInterface * a, bool update );
virtual void updateDirection( bool );
protected:
RS_ActionDrawArc* action;
std::unique_ptr<Ui::Ui_ArcOptions> ui;
protected slots:
virtual void languageChange();
private:
void saveSettings();
};
#endif // QG_ARCOPTIONS_H

178
ui/forms/qg_arcoptions.ui Normal file
View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ui_ArcOptions</class>
<widget class="QWidget" name="Ui_ArcOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>113</width>
<height>28</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>113</width>
<height>22</height>
</size>
</property>
<property name="windowTitle">
<string>Arc Options</string>
</property>
<widget class="QGroupBox" name="buttonGroup1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>113</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="lineWidth" stdset="0">
<number>0</number>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>2</x>
<y>1</y>
<width>119</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,1">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="rbPos">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Counterclockwise</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/dirpos.png</normaloff>:/extui/dirpos.png</iconset>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="sep1">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>3</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbNeg">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Clockwise</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/dirneg.png</normaloff>:/extui/dirneg.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="../../../res/extui/extui.qrc"/>
</resources>
<connections>
<connection>
<sender>rbPos</sender>
<signal>toggled(bool)</signal>
<receiver>QG_ArcOptions</receiver>
<slot>updateDirection(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>rbNeg</sender>
<signal>toggled(bool)</signal>
<receiver>QG_ArcOptions</receiver>
<slot>updateDirection(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,183 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cmath>
#include <QAction>
#include "qg_arctangentialoptions.h"
#include "rs_actiondrawarctangential.h"
#include "rs_settings.h"
#include "rs_math.h"
#include "rs_debug.h"
#include "ui_qg_arctangentialoptions.h"
#ifdef EMU_C99
#include "emu_c99.h"
#endif
/*
* Constructs a QG_ArcTangentialOptions as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_ArcTangentialOptions::QG_ArcTangentialOptions(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, ui(new Ui::Ui_ArcTangentialOptions{})
{
ui->setupUi(this);
}
QG_ArcTangentialOptions::~QG_ArcTangentialOptions()
{
saveSettings();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_ArcTangentialOptions::languageChange()
{
ui->retranslateUi(this);
}
void QG_ArcTangentialOptions::saveSettings() {
RS_SETTINGS->beginGroup("/Draw");
RS_SETTINGS->writeEntry("/ArcTangentialRadius", ui->leRadius->text());
RS_SETTINGS->writeEntry("/ArcTangentialAngle", ui->leAngle->text());
if(ui->rbRadius->isChecked()) {
RS_SETTINGS->writeEntry("/ArcTangentialByRadius", QString{"1"});
}else {
RS_SETTINGS->writeEntry("/ArcTangentialByRadius", QString{"0"});
}
RS_SETTINGS->endGroup();
// delete leRadius->validator();
// delete leAngle->validator();
}
void QG_ArcTangentialOptions::setAction(RS_ActionInterface* a, bool update) {
if (a && a->rtti()==RS2::ActionDrawArcTangential) {
action = static_cast<RS_ActionDrawArcTangential*>(a);
QString sr,sa;
bool bbr;
if (update) {
sr = QString("%1").arg(action->getRadius());
sa = QString("%1").arg(action->getAngle()*180./M_PI);
bbr= action->getByRadius();
} else {
RS_SETTINGS->beginGroup("/Draw");
sr = RS_SETTINGS->readEntry("/ArcTangentialRadius", "1.0");
sa = RS_SETTINGS->readEntry("/ArcTangentialAngle", "90");
int br = RS_SETTINGS->readNumEntry("/ArcTangentialByRadius", 1);
bbr = ( br != 0 );
RS_SETTINGS->endGroup();
action->setRadius(sr.toDouble());
action->setAngle(sa.toDouble()*M_PI/180.);
action->setByRadius(bbr);
}
ui->leRadius->setText(sr);
ui->leAngle->setText(sa);
updateByRadius(bbr);
} else {
RS_DEBUG->print(RS_Debug::D_ERROR,
"QG_ArcTangentialOptions::setAction: wrong action type");
action = nullptr;
}
}
/*void QG_ArcTangentialOptions::init() {
data = nullptr;
RS_SETTINGS->beginGroup("/Draw");
bool reversed = RS_SETTINGS->readNumEntry("/ArcReversed", 0);
RS_SETTINGS->endGroup();
rbNeg->setChecked(reversed);
}*/
/*void QG_ArcTangentialOptions::setData(RS_ArcData* d) {
data = d;
updateDirection(false);
}*/
void QG_ArcTangentialOptions::updateRadius(const QString& s) {
ui->leRadius->setText(s);
}
void QG_ArcTangentialOptions::updateAngle(const QString& s) {
ui->leAngle->setText(s);
}
void QG_ArcTangentialOptions::updateByRadius(const bool br) {
ui->rbRadius->setChecked(br);
ui->rbAngle->setChecked(!br);
ui->leRadius->setDisabled(!br);
ui->leAngle->setDisabled(br);
}
void QG_ArcTangentialOptions::on_leRadius_editingFinished()
{
if(ui->rbRadius->isChecked()) {
bool ok;
double d=fabs(RS_Math::eval(ui->leRadius->text(), &ok));
if(!ok) return;
if (d<RS_TOLERANCE) d=1.0;
//updateRadius(QString::number(d,'g',5));
action->setRadius(d);
action->setByRadius(true);
ui->leRadius->setText(QString::number(d,'g', 5));
}
}
void QG_ArcTangentialOptions::on_leAngle_editingFinished()
{
if(ui->rbAngle->isChecked()) {
bool ok;
double d=RS_Math::correctAngle(RS_Math::eval(ui->leAngle->text(), &ok)*M_PI/180.);
if(!ok) return;
if(d<RS_TOLERANCE_ANGLE || d + RS_TOLERANCE_ANGLE > 2. * M_PI) d=M_PI; // can not do full circle
action->setAngle(d);
//updateAngle(QString::number(d*180./M_PI,'g',5));
action->setByRadius(false);
ui->leAngle->setText(QString::number(RS_Math::rad2deg( d),'g',5));
}
}
void QG_ArcTangentialOptions::on_rbRadius_clicked(bool /*checked*/)
{
action->setByRadius(true);
action->setRadius(ui->leRadius->text().toDouble());
updateByRadius(true);
}
void QG_ArcTangentialOptions::on_rbAngle_clicked(bool /*checked*/)
{
action->setByRadius(false);
action->setAngle(ui->leAngle->text().toDouble()*M_PI/180.);
updateByRadius(false);
}

View File

@@ -0,0 +1,74 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_ARCTANGENTIALOPTIONS_H
#define QG_ARCTANGENTIALOPTIONS_H
#include<memory>
#include<QWidget>
class RS_ActionInterface;
class RS_ActionDrawArcTangential;
namespace Ui {
class Ui_ArcTangentialOptions;
}
class QG_ArcTangentialOptions : public QWidget
{
Q_OBJECT
public:
QG_ArcTangentialOptions(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_ArcTangentialOptions();
public slots:
virtual void setAction( RS_ActionInterface * a, bool update );
virtual void updateRadius(const QString& s );
virtual void updateAngle(const QString& s );
virtual void updateByRadius(const bool br);
protected:
RS_ActionDrawArcTangential* action;
protected slots:
virtual void languageChange();
private slots:
void on_leRadius_editingFinished();
void on_leAngle_editingFinished();
void on_rbRadius_clicked(bool checked);
void on_rbAngle_clicked(bool checked);
private:
std::unique_ptr<Ui::Ui_ArcTangentialOptions> ui;
void saveSettings();
};
#endif // QG_ARCTANGENTIALOPTIONS_H

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ui_ArcTangentialOptions</class>
<widget class="QWidget" name="Ui_ArcTangentialOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>258</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>248</width>
<height>22</height>
</size>
</property>
<property name="windowTitle">
<string>Tangential Arc Options</string>
</property>
<widget class="Line" name="sep1">
<property name="geometry">
<rect>
<x>124</x>
<y>0</y>
<width>16</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
<widget class="QLineEdit" name="leRadius">
<property name="geometry">
<rect>
<x>70</x>
<y>0</y>
<width>60</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Radius of the tangential arc</string>
</property>
</widget>
<widget class="QLineEdit" name="leAngle">
<property name="geometry">
<rect>
<x>192</x>
<y>0</y>
<width>60</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Total subtending angle of the tangential arc</string>
</property>
</widget>
<widget class="QRadioButton" name="rbRadius">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>70</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string extracomment="Draw Tangential Arc by the given radius">Radius</string>
</property>
<property name="iconSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="rbAngle">
<property name="geometry">
<rect>
<x>130</x>
<y>0</y>
<width>65</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string extracomment="Draw Tangential Arc by the given radius">Angle</string>
</property>
<property name="iconSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>leRadius</tabstop>
<tabstop>leAngle</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>leRadius</sender>
<signal>editingFinished()</signal>
<receiver>QG_ArcTangentialOptions</receiver>
<slot>on_leRadius_editingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>70</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leAngle</sender>
<signal>editingFinished()</signal>
<receiver>QG_ArcTangentialOptions</receiver>
<slot>on_leAngle_editingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>70</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,103 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_beveloptions.h"
#include "rs_actionmodifybevel.h"
#include "ui_qg_beveloptions.h"
#include "rs_settings.h"
#include "rs_math.h"
#include "rs_debug.h"
/*
* Constructs a QG_BevelOptions as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_BevelOptions::QG_BevelOptions(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, ui(new Ui::Ui_BevelOptions{})
{
ui->setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_BevelOptions::~QG_BevelOptions() {
saveSettings();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_BevelOptions::languageChange()
{
ui->retranslateUi(this);
}
void QG_BevelOptions::saveSettings() {
RS_SETTINGS->beginGroup("/Modify");
RS_SETTINGS->writeEntry("/BevelLength1", ui->leLength1->text());
RS_SETTINGS->writeEntry("/BevelLength2", ui->leLength2->text());
RS_SETTINGS->writeEntry("/BevelTrim", (int)ui->cbTrim->isChecked());
RS_SETTINGS->endGroup();
}
void QG_BevelOptions::setAction(RS_ActionInterface* a, bool update) {
if (a && a->rtti()==RS2::ActionModifyBevel) {
action = static_cast<RS_ActionModifyBevel*>(a);
QString sd1;
QString sd2;
QString st;
if (update) {
sd1 = QString("%1").arg(action->getLength1());
sd2 = QString("%1").arg(action->getLength2());
st = QString("%1").arg((int)action->isTrimOn());
} else {
RS_SETTINGS->beginGroup("/Modify");
sd1 = RS_SETTINGS->readEntry("/BevelLength1", "1.0");
sd2 = RS_SETTINGS->readEntry("/BevelLength2", "1.0");
st = RS_SETTINGS->readEntry("/BevelTrim", "1");
RS_SETTINGS->endGroup();
}
ui->leLength1->setText(sd1);
ui->leLength2->setText(sd2);
ui->cbTrim->setChecked(st=="1");
} else {
RS_DEBUG->print(RS_Debug::D_ERROR,
"QG_BevelOptions::setAction: wrong action type");
action = nullptr;
}
}
void QG_BevelOptions::updateData() {
if (action) {
action->setTrim(ui->cbTrim->isChecked());
action->setLength1(RS_Math::eval(ui->leLength1->text()));
action->setLength2(RS_Math::eval(ui->leLength2->text()));
}
}

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_BEVELOPTIONS_H
#define QG_BEVELOPTIONS_H
#include<memory>
#include<QWidget>
class RS_ActionModifyBevel;
class RS_ActionInterface;
namespace Ui {
class Ui_BevelOptions;
}
class QG_BevelOptions : public QWidget
{
Q_OBJECT
public:
QG_BevelOptions(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_BevelOptions();
public slots:
virtual void setAction( RS_ActionInterface * a, bool update );
virtual void updateData();
protected:
RS_ActionModifyBevel* action;
std::unique_ptr<Ui::Ui_BevelOptions> ui;
protected slots:
virtual void languageChange();
void saveSettings();
};
#endif // QG_BEVELOPTIONS_H

172
ui/forms/qg_beveloptions.ui Normal file
View File

@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ui_BevelOptions</class>
<widget class="QWidget" name="Ui_BevelOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>341</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>341</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>32767</height>
</size>
</property>
<property name="windowTitle">
<string>Bevel Options</string>
</property>
<property name="toolTip">
<string/>
</property>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QCheckBox" name="cbTrim">
<property name="toolTip">
<string>Check to trim both entities to the bevel</string>
</property>
<property name="text">
<string>Trim</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="sep1_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lLength1">
<property name="text">
<string>Length 1:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leLength1"/>
</item>
<item>
<widget class="QLabel" name="lLength2">
<property name="text">
<string>Length 2:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leLength2"/>
</item>
<item>
<widget class="Line" name="sep1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>leLength1</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_BevelOptions</receiver>
<slot>updateData()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbTrim</sender>
<signal>toggled(bool)</signal>
<receiver>Ui_BevelOptions</receiver>
<slot>updateData()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leLength2</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_BevelOptions</receiver>
<slot>updateData()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,90 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include <QMessageBox>
#include "qg_blockdialog.h"
#include "rs_blocklist.h"
#include "rs_block.h"
#include "rs_debug.h"
/*
* Constructs a QG_BlockDialog as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_BlockDialog::QG_BlockDialog(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_BlockDialog::languageChange()
{
retranslateUi(this);
}
void QG_BlockDialog::setBlockList(RS_BlockList* l) {
RS_DEBUG->print("QG_BlockDialog::setBlockList");
blockList = l;
if (blockList) {
RS_Block* block = blockList->getActive();
if (block) {
leName->setText(block->getName());
}
}
}
RS_BlockData QG_BlockDialog::getBlockData() {
return RS_BlockData(leName->text(), RS_Vector(0.0,0.0), false);
}
void QG_BlockDialog::validate() {
QString name = leName->text();
if (!name.isEmpty()) {
if (blockList && !blockList->find(name)) {
accept();
} else {
QMessageBox::warning( this, tr("Renaming Block"),
tr("Could not name block. A block named \"%1\" "
"already exists.").arg(leName->text()),
QMessageBox::Ok,
Qt::NoButton);
}
}
}
void QG_BlockDialog::cancel() {
leName->setText("");
reject();
}

57
ui/forms/qg_blockdialog.h Normal file
View File

@@ -0,0 +1,57 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_BLOCKDIALOG_H
#define QG_BLOCKDIALOG_H
#include "ui_qg_blockdialog.h"
class RS_BlockList;
struct RS_BlockData;
class QG_BlockDialog : public QDialog, public Ui::QG_BlockDialog
{
Q_OBJECT
public:
QG_BlockDialog(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_BlockDialog()=default;
virtual RS_BlockData getBlockData();
public slots:
virtual void setBlockList( RS_BlockList * l );
virtual void validate();
virtual void cancel();
protected:
RS_BlockList* blockList;
protected slots:
virtual void languageChange();
};
#endif // QG_BLOCKDIALOG_H

120
ui/forms/qg_blockdialog.ui Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_BlockDialog</class>
<widget class="QDialog" name="QG_BlockDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>253</width>
<height>79</height>
</rect>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Block Settings</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>11</number>
</property>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lName">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Block Name:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer87">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>29</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="leName">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_BlockDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>60</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_BlockDialog</receiver>
<slot>validate()</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>60</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

434
ui/forms/qg_cadtoolbar.cpp Normal file
View File

@@ -0,0 +1,434 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include <QMouseEvent>
#include "qg_cadtoolbar.h"
#include "rs_dialogfactory.h"
#include "rs_actioninterface.h"
#include "qg_cadtoolbararcs.h"
#include "qg_cadtoolbarcircles.h"
#include "qg_cadtoolbardim.h"
#include "qg_cadtoolbarellipses.h"
#include "qg_cadtoolbarinfo.h"
#include "qg_cadtoolbarlines.h"
#include "qg_cadtoolbarmain.h"
#include "qg_cadtoolbarmodify.h"
#include "qg_cadtoolbarpolylines.h"
#include "qg_cadtoolbarselect.h"
#include "qg_cadtoolbarsplines.h"
#include "rs_debug.h"
#include "qc_applicationwindow.h"
/*
* Constructs a QG_CadToolBar as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBar::QG_CadToolBar(QWidget* parent, const char* name)
: QToolBar(parent)
,actionHandler(nullptr)
{
setObjectName(name);
setCursor(Qt::ArrowCursor);
#if QT_VERSION >= 0x050500
auto const dPxlRatio=QC_ApplicationWindow::getAppWindow()->devicePixelRatio();
setMinimumSize(73*dPxlRatio,400*dPxlRatio);
#else
setMinimumSize(73,400);
#endif
setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
setFloatable(false);
init();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
//void QG_CadToolBar::languageChange()
//{
// retranslateUi(this);
//}
void QG_CadToolBar::init() {
//create sub cad toolbars
const std::initializer_list<LC_CadToolBarInterface*> tbs={
new QG_CadToolBarMain(this)
,new QG_CadToolBarLines(this)
,new QG_CadToolBarArcs(this)
,new QG_CadToolBarCircles(this)
,new QG_CadToolBarEllipses(this)
,new QG_CadToolBarSplines(this)
,new QG_CadToolBarPolylines(this)
,new QG_CadToolBarDim(this)
,new QG_CadToolBarInfo(this)
,new QG_CadToolBarModify(this)
,new QG_CadToolBarSelect(this)
};
for(auto p: tbs){
p->hide();
m_toolbars[p->rtti()]= p;
}
}
QSize QG_CadToolBar::sizeHint() const
{
return QSize(-1, -1);
}
void QG_CadToolBar::populateSubToolBar(const std::vector<QAction*>& actions, RS2::ToolBarId toolbarID)
{
RS_DEBUG->print("QG_CadToolBar::populateSubToolBar(): begin\n");
if(!m_toolbars.count(toolbarID)) return;
LC_CadToolBarInterface*const p = m_toolbars[toolbarID];
p->addSubActions(actions, true);
RS_DEBUG->print("QG_CadToolBar::populateSubToolBar(): end\n");
}
/**
* Called from the sub toolbar
*/
void QG_CadToolBar::back() {
finishCurrentAction(false);
showPreviousToolBar(true);
// emit(signalBack());
}
void QG_CadToolBar::finishCurrentAction(bool resetToolBar)
{
if(!actionHandler) return;
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction) {
currentAction->finish(resetToolBar); //finish the action, but do not update toolBar
}
}
/**
* Called from the application.
*/
void QG_CadToolBar::forceNext() {
if(activeToolbars.size()==0) return;
auto p=activeToolbars.back();
if (p && p->rtti() == RS2::ToolBarSelect)
p->runNextAction();
}
void QG_CadToolBar::mouseReleaseEvent(QMouseEvent* e) {
if (e->button()==Qt::RightButton) {
back();
e->accept();
}
}
void QG_CadToolBar::contextMenuEvent(QContextMenuEvent *e) {
e->accept();
}
/**
* Creates all tool bars and shows the main toolbar.
*
* @param ah Pointer to action handler which will deal with the actions in this tool bar.
*/
void QG_CadToolBar::setActionHandler(QG_ActionHandler* ah) {
actionHandler = ah;
for(const auto& p: m_toolbars){
p.second->setActionHandler(ah);
}
}
void QG_CadToolBar::hideSubToolBars(){
for(auto p: activeToolbars){
p->hide();
}
}
void QG_CadToolBar::showSubToolBar(){
LC_CadToolBarInterface* const p = activeToolbars.back();
if (!p->isVisible()) { // On OSX, without this line LibreCAD wuld crash. Not sure if it's a Qt problem or 'somewhere' logic within LibreCAD
//shift down to show the handle to move the toolbar
//has to be 20, 10 is not enough
p->move(0,20);
p->show();
}
p->resize(size());
adjustSize();
}
void QG_CadToolBar::showPreviousToolBar(bool cleanup) {
// cleanup mouse hint when showing previous tool bar, bug#3480121
RS_DIALOGFACTORY->updateMouseWidget();
// for(auto p: activeToolbars){
// qDebug()<<"QG_CadToolBar::showPreviousToolBar():begin "<<p->rtti();
// }
if(cleanup){
if(actionHandler) {
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction && currentAction->rtti() != RS2::ActionDefault) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
if(activeToolbars.size()>1){
if(activeToolbars.back()) activeToolbars.back() ->setVisible(false);
activeToolbars.pop_back();
}
// std::cout<<"QG_CadToolBar::showPreviousToolBar(true): toolbars.size()="<<toolbars.size()<<std::endl;
showToolBar(activeToolbars.back()->rtti());
}else{
hideSubToolBars();
// std::cout<<"QG_CadToolBar::showPreviousToolBar(false): toolbars.size()="<<toolbars.size()<<std::endl;
if(activeToolbars.size()>1){
// std::cout<<"QG_CadToolBar::showPreviousToolBar(false): hide:"<<toolbarIDs[toolbars.size()-1]<<std::endl;
if (!activeToolbars.back()) activeToolbars.back()->setVisible(false);
activeToolbars.pop_back();
}
// std::cout<<"QG_CadToolBar::showPreviousToolBar(false): toolbars.size()="<<toolbars.size()<<std::endl;
showSubToolBar();
}
// for(auto p: activeToolbars){
// qDebug()<<"QG_CadToolBar::showPreviousToolBar():end "<<p->rtti();
// }
}
void QG_CadToolBar::showToolBar(RS2::ToolBarId id, bool restoreAction ) {
LC_CadToolBarInterface* newTb;
if(m_toolbars.count(id)){
newTb=m_toolbars[id];
}else{
newTb=m_toolbars[RS2::ToolBarMain];
}
if(restoreAction) newTb->restoreAction();
hideSubToolBars();
auto it=std::find(activeToolbars.begin(), activeToolbars.end(), newTb);
if(it != activeToolbars.end()){
activeToolbars.erase(it+1,activeToolbars.end());
}
if(!( activeToolbars.size()>0 && newTb == activeToolbars.back())) {
activeToolbars.push_back(newTb);
}
showSubToolBar();
adjustSize();
}
void QG_CadToolBar::resetToolBar() {
LC_CadToolBarInterface* currentTb=activeToolbars.back();
currentTb->resetToolBar();
}
void QG_CadToolBar::showToolBarMain() {
showToolBar(RS2::ToolBarMain);
}
void QG_CadToolBar::showToolBarLines() {
showToolBar(RS2::ToolBarLines);
}
void QG_CadToolBar::showToolBarArcs() {
showToolBar(RS2::ToolBarArcs);
}
void QG_CadToolBar::showToolBarEllipses() {
showToolBar(RS2::ToolBarEllipses);
}
void QG_CadToolBar::showToolBarSplines() {
showToolBar(RS2::ToolBarSplines);
}
void QG_CadToolBar::showToolBarPolylines() {
showToolBar(RS2::ToolBarPolylines);
}
void QG_CadToolBar::showToolBarCircles() {
showToolBar(RS2::ToolBarCircles);
}
void QG_CadToolBar::showToolBarInfo() {
showToolBar(RS2::ToolBarInfo);
}
void QG_CadToolBar::showToolBarModify() {
showToolBar(RS2::ToolBarModify);
}
void QG_CadToolBar::showToolBarDim() {
showToolBar(RS2::ToolBarDim);
}
void QG_CadToolBar::showToolBarSelect() {
showToolBarSelect(nullptr, -1);
}
void QG_CadToolBar::showToolBarSelect(RS_ActionInterface* selectAction,
int nextAction) {
auto p=m_toolbars[RS2::ToolBarSelect];
p->setNextAction(nextAction);
p->setSelectAction(selectAction);
showToolBar(RS2::ToolBarSelect);
showSubToolBar();
}
void QG_CadToolBar::showCadToolBar(RS2::ActionType actionType, bool cleanup){
RS2::ToolBarId id=RS2::ToolBarNone;
switch(actionType){
//no op
default:
return;
//default action resets toolbar, issue#295
case RS2::ActionDefault:
break;
case RS2::ActionDrawImage:
case RS2::ActionDrawPoint:
case RS2::ActionDrawMText:
id=RS2::ToolBarMain;
break;
case RS2::ActionDrawArc:
case RS2::ActionDrawArc3P:
case RS2::ActionDrawArcParallel:
case RS2::ActionDrawArcTangential:
id=RS2::ToolBarArcs;
break;
case RS2::ActionDrawCircle:
case RS2::ActionDrawCircle2P:
case RS2::ActionDrawCircle3P:
case RS2::ActionDrawCircleCR:
case RS2::ActionDrawCircleParallel:
case RS2::ActionDrawCircleInscribe:
case RS2::ActionDrawCircleTan2:
case RS2::ActionDrawCircleTan2_1P:
case RS2::ActionDrawCircleTan1_2P:
id=RS2::ToolBarCircles;
break;
case RS2::ActionDrawEllipseArcAxis:
case RS2::ActionDrawEllipseAxis:
case RS2::ActionDrawEllipseFociPoint:
case RS2::ActionDrawEllipse4Points:
case RS2::ActionDrawEllipseCenter3Points:
case RS2::ActionDrawEllipseInscribe:
id=RS2::ToolBarEllipses;
break;
case RS2::ActionDrawSpline:
case RS2::ActionDrawSplinePoints:
id=RS2::ToolBarSplines;
break;
case RS2::ActionDrawLine:
case RS2::ActionDrawLineAngle:
case RS2::ActionDrawLineBisector:
case RS2::ActionDrawLineFree:
case RS2::ActionDrawLineHorVert:
case RS2::ActionDrawLineHorizontal:
case RS2::ActionDrawLineOrthogonal:
case RS2::ActionDrawLineOrthTan:
case RS2::ActionDrawLineParallel:
case RS2::ActionDrawLineParallelThrough:
case RS2::ActionDrawLinePolygonCenCor:
case RS2::ActionDrawLinePolygonCorCor:
case RS2::ActionDrawLineRectangle:
case RS2::ActionDrawLineRelAngle:
case RS2::ActionDrawLineTangent1:
case RS2::ActionDrawLineTangent2:
case RS2::ActionDrawLineVertical:
id=RS2::ToolBarLines;
break;
case RS2::ActionDrawPolyline:
case RS2::ActionPolylineAdd:
case RS2::ActionPolylineAppend:
case RS2::ActionPolylineDel:
case RS2::ActionPolylineDelBetween:
case RS2::ActionPolylineTrim:
case RS2::ActionPolylineEquidistant:
case RS2::ActionPolylineSegment:
id=RS2::ToolBarPolylines;
break;
case RS2::ActionDimAligned:
case RS2::ActionDimLinear:
case RS2::ActionDimLinearVer:
case RS2::ActionDimLinearHor:
case RS2::ActionDimRadial:
case RS2::ActionDimDiametric:
case RS2::ActionDimAngular:
case RS2::ActionDimLeader:
id=RS2::ToolBarDim;
break;
case RS2::ActionModifyAttributes:
case RS2::ActionModifyAttributesNoSelect:
case RS2::ActionModifyDelete:
case RS2::ActionModifyDeleteNoSelect:
case RS2::ActionModifyDeleteQuick:
case RS2::ActionModifyDeleteFree:
case RS2::ActionModifyMove:
case RS2::ActionModifyMoveNoSelect:
case RS2::ActionModifyRotate:
case RS2::ActionModifyRotateNoSelect:
case RS2::ActionModifyScale:
case RS2::ActionModifyScaleNoSelect:
case RS2::ActionModifyMirror:
case RS2::ActionModifyMirrorNoSelect:
case RS2::ActionModifyMoveRotate:
case RS2::ActionModifyMoveRotateNoSelect:
case RS2::ActionModifyRotate2:
case RS2::ActionModifyRotate2NoSelect:
case RS2::ActionModifyEntity:
case RS2::ActionModifyTrim:
case RS2::ActionModifyTrim2:
case RS2::ActionModifyTrimAmount:
case RS2::ActionModifyCut:
case RS2::ActionModifyStretch:
case RS2::ActionModifyBevel:
case RS2::ActionModifyRound:
case RS2::ActionModifyOffset:
case RS2::ActionModifyOffsetNoSelect:
case RS2::ActionModifyRevertDirection:
case RS2::ActionModifyRevertDirectionNoSelect:
id=RS2::ToolBarModify;
break;
case RS2::ActionInfoInside:
case RS2::ActionInfoDist:
case RS2::ActionInfoDist2:
case RS2::ActionInfoAngle:
case RS2::ActionInfoTotalLength:
case RS2::ActionInfoTotalLengthNoSelect:
case RS2::ActionInfoArea:
id=RS2::ToolBarInfo;
break;
}
if(id != RS2::ToolBarNone){
m_toolbars[id]->showCadToolBar(actionType);
showToolBar(id, false);
}
if(cleanup){
if(actionHandler ) {
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
}
}

104
ui/forms/qg_cadtoolbar.h Normal file
View File

@@ -0,0 +1,104 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBAR_H
#define QG_CADTOOLBAR_H
#include <QToolBar>
#include <vector>
#include <map>
#include "rs.h"
class QG_ActionHandler;
class LC_CadToolBarInterface;
class RS_ActionInterface;
class QActions;
class QG_CadToolBar : public QToolBar
{
Q_OBJECT
public:
QG_CadToolBar(QWidget* parent = 0, const char* name = 0);
~QG_CadToolBar() = default;
/**
* @brief populateSubToolBars add actions to subtoolbars
* @param actions
*/
void populateSubToolBar(const std::vector<QAction*>& actions, RS2::ToolBarId toolbarID);
virtual QSize sizeHint() const;
public slots:
void back();
void forceNext();
void mouseReleaseEvent( QMouseEvent * e );
void contextMenuEvent( QContextMenuEvent * e );
void setActionHandler( QG_ActionHandler * ah );
/** \brief showToolBar show the toolbar by id
* if restoreAction is true, also, start the action specified by the checked button of the toolbar
**/
void showToolBar(RS2::ToolBarId id, bool restoreAction = true );
void showToolBarMain();
void showToolBarLines();
void showToolBarArcs();
void showToolBarEllipses();
void showToolBarSplines();
void showToolBarPolylines();
void showToolBarCircles();
void showToolBarInfo();
void showToolBarModify();
void showToolBarDim();
void showToolBarSelect();
void showToolBarSelect( RS_ActionInterface * selectAction, int nextAction );
void showPreviousToolBar(bool cleanup = true);
void showCadToolBar(RS2::ActionType actionType, bool cleanup=false);
void resetToolBar();
signals:
void signalBack();
void signalNext();
protected:
/**
* @brief m_toolbars holds cad toolbars managed by this LC_CadToolBar instance
*/
std::map<RS2::ToolBarId, LC_CadToolBarInterface*> m_toolbars;
QG_ActionHandler* actionHandler;
std::vector<LC_CadToolBarInterface*> activeToolbars;
protected slots:
// virtual void languageChange();
void hideSubToolBars();
void showSubToolBar();
private:
void init();
void finishCurrentAction(bool resetToolBar=false);
};
#endif // QG_CADTOOLBAR_H

View File

@@ -0,0 +1,120 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QVBoxLayout>
#include<QToolButton>
#include<QToolBar>
#include<QAction>
#include "qg_cadtoolbararcs.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
#include "rs_debug.h"
/*
* Constructs a QG_CadToolBarArcs as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarArcs::QG_CadToolBarArcs(QG_CadToolBar* parent, Qt::WindowFlags fl):
LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarArcs::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
RS_DEBUG->print("QG_CadToolBarArcs::addSubActions(): begin\n");
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons={
&bArc, &bArc3P, &bArcParallel, &bArcTangential
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
RS_DEBUG->print("QG_CadToolBarArcs::addSubActions(): end\n");
}
//restore action from checked button
void QG_CadToolBarArcs::restoreAction()
{
if(!(actionHandler&&bArc)) return;
if ( bArc ->isChecked() ) {
actionHandler->slotDrawArc();
return;
}
if ( bArc3P ->isChecked() ) {
actionHandler->slotDrawArc3P();
return;
}
if ( bArcParallel ->isChecked() ) {
actionHandler->slotDrawArcParallel();
return;
}
if ( bArcTangential ->isChecked() ) {
actionHandler->slotDrawArcTangential();
return;
}
//clear all action
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarArcs::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarArcs::on_bBack_clicked()
{
finishCurrentAction(true);
cadToolBar->showPreviousToolBar();
}
void QG_CadToolBarArcs::showCadToolBar(RS2::ActionType actionType) {
if(!bArc) return;
switch(actionType){
case RS2::ActionDrawArc:
bArc->setChecked(true);
return;
case RS2::ActionDrawArc3P:
bArc3P->setChecked(true);
return;
case RS2::ActionDrawArcParallel:
bArcParallel->setChecked(true);
return;
case RS2::ActionDrawArcTangential:
bArcTangential->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
return;
}
}
//EOF

View File

@@ -0,0 +1,59 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARARCS_H
#define QG_CADTOOLBARARCS_H
class QG_CadToolBar;
#include "qg_actionhandler.h"
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarArcs : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarArcs(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarArcs() = default;
void restoreAction(); //restore action from checked button
virtual void resetToolBar();
RS2::ToolBarId rtti() const
{
return RS2::ToolBarArcs;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction* bArc=nullptr, *bArc3P=nullptr, *bArcParallel=nullptr, *bArcTangential=nullptr;
};
#endif // QG_CADTOOLBARARCS_H

View File

@@ -0,0 +1,171 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbarcircles.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarCircles as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarCircles::QG_CadToolBarCircles(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarCircles::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons= {
&bCircle, &bCircleCR, &bCircle2P, &bCircle2PR, &bCircle3P,
&bCircleParallel, &bCircleInscribe, &bCircleTan1_2P, &bCircleTan2,
&bCircleTan2_1P, &bCircleTan3
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
void QG_CadToolBarCircles::back() {
if (cadToolBar) {
cadToolBar->back();
}
}
//restore action from checked button
void QG_CadToolBarCircles::restoreAction()
{
if(!(actionHandler && bCircle)) return;
if ( bCircle ->isChecked() ) {
actionHandler->slotDrawCircle();
return;
}
if ( bCircleCR ->isChecked() ) {
actionHandler->slotDrawCircleCR();
return;
}
if ( bCircle2P ->isChecked() ) {
actionHandler->slotDrawCircle2P();
return;
}
if ( bCircle2PR ->isChecked() ) {
actionHandler->slotDrawCircle2PR();
return;
}
if ( bCircle3P ->isChecked() ) {
actionHandler->slotDrawCircle3P();
return;
}
if ( bCircleParallel ->isChecked() ) {
actionHandler->slotDrawCircleParallel();
return;
}
if ( bCircleInscribe ->isChecked() ) {
actionHandler->slotDrawCircleInscribe();
return;
}
if ( bCircleTan2 ->isChecked() ) {
actionHandler->slotDrawCircleTan2();
return;
}
if ( bCircleTan3 ->isChecked() ) {
actionHandler->slotDrawCircleTan3();
return;
}
if(bCircleTan2_1P->isChecked()){
actionHandler->slotDrawCircleTan2_1P();
return;
}
if(bCircleTan1_2P->isChecked()){
actionHandler->slotDrawCircleTan1_2P();
return;
}
//clear all action
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarCircles::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarCircles::on_bBack_clicked()
{
finishCurrentAction(true);
cadToolBar->showPreviousToolBar();
}
void QG_CadToolBarCircles::showCadToolBar(RS2::ActionType actionType){
if(!bCircle) return;
switch(actionType){
case RS2::ActionDrawCircle:
bCircle->setChecked(true);
return;
case RS2::ActionDrawCircle2P:
bCircle2P->setChecked(true);
return;
case RS2::ActionDrawCircle2PR:
bCircle2PR->setChecked(true);
return;
case RS2::ActionDrawCircle3P:
bCircle3P->setChecked(true);
return;
case RS2::ActionDrawCircleCR:
bCircleCR->setChecked(true);
return;
case RS2::ActionDrawCircleParallel:
bCircleParallel->setChecked(true);
return;
case RS2::ActionDrawCircleInscribe:
bCircleInscribe->setChecked(true);
return;
case RS2::ActionDrawCircleTan2:
bCircleTan2->setChecked(true);
return;
case RS2::ActionDrawCircleTan3:
bCircleTan3->setChecked(true);
return;
case RS2::ActionDrawCircleTan1_2P:
bCircleTan1_2P->setChecked(true);
return;
case RS2::ActionDrawCircleTan2_1P:
bCircleTan2_1P->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
return;
}
}
//EOF

View File

@@ -0,0 +1,71 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARCIRCLES_H
#define QG_CADTOOLBARCIRCLES_H
class QG_CadToolBar;
#include "qg_actionhandler.h"
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarCircles : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarCircles(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarCircles() = default;
//restore action from checked button
virtual void restoreAction();
RS2::ToolBarId rtti() const
{
return RS2::ToolBarCircles;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void back();
virtual void resetToolBar();
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction *bCircle=nullptr,
*bCircleCR=nullptr,
*bCircle2P=nullptr,
*bCircle2PR=nullptr,
*bCircle3P=nullptr,
*bCircleParallel=nullptr,
*bCircleInscribe=nullptr,
*bCircleTan2=nullptr,
*bCircleTan3=nullptr,
*bCircleTan2_1P=nullptr,
*bCircleTan1_2P=nullptr;
};
#endif // QG_CADTOOLBARCIRCLES_H

View File

@@ -0,0 +1,141 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbardim.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarDim as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarDim::QG_CadToolBarDim(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarDim::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons={
&bAligned, &bLinear, &bLinearHor, &bLinearVer, &bRadial,
&bDiametric, &bAngular, &bLeader
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
//restore action from checked button
void QG_CadToolBarDim::restoreAction()
{
if(!(actionHandler && bAligned)) return;
if ( bAligned ->isChecked() ) {
actionHandler->slotDimAligned();
return;
}
if ( bLinear ->isChecked() ) {
actionHandler->slotDimLinear();
return;
}
if ( bLinearHor ->isChecked() ) {
actionHandler->slotDimLinearHor();
return;
}
if ( bLinearVer ->isChecked() ) {
actionHandler->slotDimLinearVer();
return;
}
if ( bRadial ->isChecked() ) {
actionHandler->slotDimRadial();
return;
}
if ( bDiametric ->isChecked() ) {
actionHandler->slotDimDiametric();
return;
}
if ( bAngular ->isChecked() ) {
actionHandler->slotDimAngular();
return;
}
if ( bLeader ->isChecked() ) {
actionHandler->slotDimLeader();
return;
}
//clear all action
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarDim::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarDim::on_bBack_clicked()
{
finishCurrentAction(true);
cadToolBar->showPreviousToolBar();
}
void QG_CadToolBarDim::showCadToolBar(RS2::ActionType actionType){
if(!bAligned) return;
switch(actionType){
case RS2::ActionDimAligned:
bAligned->setChecked(true);
return;
case RS2::ActionDimLinear:
bLinear->setChecked(true);
return;
case RS2::ActionDimLinearVer:
bLinearVer->setChecked(true);
return;
case RS2::ActionDimLinearHor:
bLinearHor->setChecked(true);
return;
case RS2::ActionDimRadial:
bRadial->setChecked(true);
return;
case RS2::ActionDimDiametric:
bDiametric->setChecked(true);
return;
case RS2::ActionDimAngular:
bAngular->setChecked(true);
return;
case RS2::ActionDimLeader:
bLeader->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
return;
}
}

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARDIM_H
#define QG_CADTOOLBARDIM_H
class QG_CadToolBar;
#include "qg_actionhandler.h"
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarDim : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarDim(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarDim() = default;
virtual void restoreAction(); //restore action from checked button
RS2::ToolBarId rtti() const
{
return RS2::ToolBarDim;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void resetToolBar();
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction *bAligned=nullptr,*bLinear=nullptr,*bLinearHor=nullptr,*bLinearVer=nullptr,
*bRadial=nullptr,*bDiametric=nullptr,*bAngular=nullptr,*bLeader=nullptr;
};
#endif // QG_CADTOOLBARDIM_H

View File

@@ -0,0 +1,129 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbarellipses.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarEllipses as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarEllipses::QG_CadToolBarEllipses(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarEllipses::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons={
&bEllipseAxes, &bEllipseArcAxes , &bEllipseFociPoint ,
&bEllipse4Points , &bEllipseCenter3Points , &bEllipseInscribe
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
//restore action from checked button
void QG_CadToolBarEllipses::restoreAction()
{
if(!(actionHandler && bEllipseAxes)) return;
if ( bEllipseAxes ->isChecked() ) {
actionHandler->slotDrawEllipseAxis();
return;
}
if ( bEllipseArcAxes ->isChecked() ) {
actionHandler->slotDrawEllipseArcAxis();
return;
}
if ( bEllipseFociPoint ->isChecked() ) {
actionHandler->slotDrawEllipseFociPoint();
return;
}
if ( bEllipse4Points ->isChecked() ) {
actionHandler->slotDrawEllipse4Points();
return;
}
if ( bEllipseCenter3Points ->isChecked() ) {
actionHandler->slotDrawEllipseCenter3Points();
return;
}
if ( bEllipseInscribe ->isChecked() ) {
actionHandler->slotDrawEllipseInscribe();
return;
}
//clear all action
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarEllipses::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarEllipses::on_bBack_clicked()
{
finishCurrentAction(true);
cadToolBar->showPreviousToolBar();
}
void QG_CadToolBarEllipses::showCadToolBar(RS2::ActionType actionType) {
if(!bEllipseAxes) return;
switch(actionType){
case RS2::ActionDrawEllipseAxis:
bEllipseAxes ->setChecked(true);
return;
case RS2::ActionDrawEllipseArcAxis:
bEllipseArcAxes ->setChecked(true);
return;
case RS2::ActionDrawEllipseFociPoint:
bEllipseFociPoint ->setChecked(true);
return;
case RS2::ActionDrawEllipse4Points:
bEllipse4Points ->setChecked(true);
return;
case RS2::ActionDrawEllipseCenter3Points:
bEllipseCenter3Points ->setChecked(true);
return;
case RS2::ActionDrawEllipseInscribe:
bEllipseInscribe ->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
return;
}
}

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARELLIPSES_H
#define QG_CADTOOLBARELLIPSES_H
class QG_CadToolBar;
#include "qg_actionhandler.h"
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarEllipses : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarEllipses(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarEllipses() = default;
//restore action from checked button
virtual void restoreAction();
RS2::ToolBarId rtti() const
{
return RS2::ToolBarEllipses;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void resetToolBar();
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction *bEllipseAxes=nullptr, *bEllipseArcAxes=nullptr, *bEllipseFociPoint=nullptr, *bEllipse4Points=nullptr,
*bEllipseCenter3Points=nullptr, *bEllipseInscribe=nullptr;
};
#endif // QG_CADTOOLBARELLIPSES_H

View File

@@ -0,0 +1,126 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbarinfo.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarInfo as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarInfo::QG_CadToolBarInfo(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarInfo::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons={
&bDist, &bDist2, &bAngle, &bTotalLength, &bArea
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
//restore action from checked button
void QG_CadToolBarInfo::restoreAction()
{
if(!(actionHandler && bDist)) return;
//clear all action
if ( bDist ->isChecked() ) {
actionHandler->slotInfoDist();
return;
}
if ( bDist2 ->isChecked() ) {
actionHandler->slotInfoDist2();
return;
}
if ( bAngle ->isChecked() ) {
actionHandler->slotInfoAngle();
return;
}
if ( bTotalLength ->isChecked() ) {
actionHandler->slotInfoTotalLength();
return;
}
if ( bArea ->isChecked() ) {
actionHandler->slotInfoArea();
return;
}
//default to measure point to point distance
//bDist->setChecked(true);
//actionHandler->slotInfoDist();
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarInfo::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarInfo::on_bBack_clicked()
{
finishCurrentAction(true);
cadToolBar->showPreviousToolBar();
}
void QG_CadToolBarInfo:: showCadToolBar(RS2::ActionType actionType){
if(!bDist) return;
switch(actionType){
// case RS2::ActionInfoInside:
case RS2::ActionInfoDist:
bDist->setChecked(true);
return;
case RS2::ActionInfoDist2:
bDist2->setChecked(true);
return;
case RS2::ActionInfoAngle:
bAngle->setChecked(true);
return;
case RS2::ActionInfoTotalLength:
bTotalLength->setChecked(true);
return;
// case RS2::ActionInfoTotalLengthNoSelect:
case RS2::ActionInfoArea:
bArea->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
}
}
//EOF

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARINFO_H
#define QG_CADTOOLBARINFO_H
class QG_CadToolBar;
#include "qg_actionhandler.h"
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarInfo : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarInfo(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarInfo() = default;
//restore action from checked button
virtual void restoreAction();
RS2::ToolBarId rtti() const
{
return RS2::ToolBarInfo;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void resetToolBar();
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction *bDist=nullptr, *bDist2=nullptr, *bAngle=nullptr, *bTotalLength=nullptr, *bArea=nullptr;
};
#endif // QG_CADTOOLBARINFO_H

View File

@@ -0,0 +1,301 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbarlines.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarLines as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarLines::QG_CadToolBarLines(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarLines::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const &buttons= {
&bNormal, &bAngle, &bHorizontal, &bVertical, &bRectangle,
&bParallel, &bParallelThrough, &bBisector, &bTangent1, &bTangent2, &bOrthTan,
&bOrthogonal, &bRelAngle, &bPolygon, &bPolygon2, &bFree
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
void QG_CadToolBarLines::drawLine() {
if (actionHandler) {
actionHandler->slotDrawLine();
}
}
void QG_CadToolBarLines::drawLineAngle() {
if (actionHandler) {
actionHandler->slotDrawLineAngle();
}
}
void QG_CadToolBarLines::drawLineHorizontal() {
if (actionHandler) {
actionHandler->slotDrawLineHorizontal();
}
}
void QG_CadToolBarLines::drawLineHorVert() {
if (actionHandler) {
actionHandler->slotDrawLineHorVert();
}
}
void QG_CadToolBarLines::drawLineVertical() {
if (actionHandler) {
actionHandler->slotDrawLineVertical();
}
}
void QG_CadToolBarLines::drawLineParallel() {
if (actionHandler) {
actionHandler->slotDrawLineParallel();
}
}
void QG_CadToolBarLines::drawLineParallelThrough() {
if (actionHandler) {
actionHandler->slotDrawLineParallelThrough();
}
}
void QG_CadToolBarLines::drawLineRectangle() {
if (actionHandler) {
actionHandler->slotDrawLineRectangle();
}
}
void QG_CadToolBarLines::drawLineBisector() {
if (actionHandler) {
actionHandler->slotDrawLineBisector();
}
}
void QG_CadToolBarLines::drawLineTangent1() {
if (actionHandler) {
actionHandler->slotDrawLineTangent1();
}
}
void QG_CadToolBarLines::drawLineTangent2() {
if (actionHandler) {
actionHandler->slotDrawLineTangent2();
}
}
void QG_CadToolBarLines::drawLineOrthogonal() {
if (actionHandler) {
actionHandler->slotDrawLineOrthogonal();
}
}
void QG_CadToolBarLines::drawLineOrthTan() {
if (actionHandler) {
actionHandler->slotDrawLineOrthTan();
}
}
void QG_CadToolBarLines::drawLineRelAngle() {
if (actionHandler) {
actionHandler->slotDrawLineRelAngle();
}
}
void QG_CadToolBarLines::drawLineFree() {
if (actionHandler) {
actionHandler->slotDrawLineFree();
}
}
void QG_CadToolBarLines::drawLinePolygon() {
if (actionHandler) {
actionHandler->slotDrawLinePolygon();
}
}
void QG_CadToolBarLines::drawLinePolygon2() {
if (actionHandler) {
actionHandler->slotDrawLinePolygon2();
}
}
//restore action from checked
void QG_CadToolBarLines::restoreAction() {
if(!actionHandler) return;
if(!bNormal) return;
if(bNormal->isChecked()) {
actionHandler->slotDrawLine();
return;
}
if(bAngle->isChecked()) {
actionHandler->slotDrawLineAngle();
return;
}
if(bHorizontal->isChecked()) {
actionHandler->slotDrawLineHorizontal();
return;
}
if(bVertical->isChecked()) {
actionHandler->slotDrawLineVertical();
return;
}
if(bRectangle->isChecked()) {
actionHandler->slotDrawLineRectangle();
return;
}
if(bBisector->isChecked()) {
actionHandler->slotDrawLineBisector();
return;
}
if(bParallel->isChecked()) {
actionHandler->slotDrawLineParallel();
return;
}
if(bParallelThrough->isChecked()) {
actionHandler->slotDrawLineParallelThrough();
return;
}
if(bTangent1->isChecked()) {
actionHandler->slotDrawLineTangent1();
return;
}
if(bTangent2->isChecked()) {
actionHandler->slotDrawLineTangent2();
return;
}
if(bOrthTan->isChecked()) {
actionHandler->slotDrawLineOrthTan();
return;
}
if(bOrthogonal->isChecked()) {
actionHandler->slotDrawLineOrthogonal();
return;
}
if(bRelAngle->isChecked()) {
actionHandler->slotDrawLineRelAngle();
return;
}
if(bPolygon->isChecked()) {
actionHandler->slotDrawLinePolygon();
return;
}
if(bPolygon2->isChecked()) {
actionHandler->slotDrawLinePolygon2();
return;
}
if(bFree->isChecked()) {
actionHandler->slotDrawLineFree();
return;
}
//clear all action
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarLines::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarLines::on_bBack_clicked()
{
finishCurrentAction(true);
LC_CadToolBarInterface::back();
}
void QG_CadToolBarLines::showCadToolBar(RS2::ActionType actionType) {
if(!bNormal) return;
switch(actionType){
case RS2::ActionDrawLine:
bNormal->setChecked(true);
return;
case RS2::ActionDrawLineAngle:
bAngle->setChecked(true);
return;
case RS2::ActionDrawLineBisector:
bBisector->setChecked(true);
return;
case RS2::ActionDrawLineFree:
bFree->setChecked(true);
return;
case RS2::RS2::ActionDrawLineVertical:
bVertical->setChecked(true);
return;
case RS2::ActionDrawLineHorizontal:
bHorizontal->setChecked(true);
return;
case RS2::ActionDrawLineOrthogonal:
bOrthogonal->setChecked(true);
return;
case RS2::ActionDrawLineOrthTan:
bOrthTan->setChecked(true);
return;
case RS2::ActionDrawLineParallel:
bParallel->setChecked(true);
return;
case RS2::ActionDrawLineParallelThrough:
bParallelThrough->setChecked(true);
return;
case RS2::ActionDrawLinePolygonCenCor:
bPolygon->setChecked(true);
return;
case RS2::ActionDrawLinePolygonCorCor:
bPolygon2->setChecked(true);
return;
case RS2::ActionDrawLineRectangle:
bRectangle->setChecked(true);
return;
case RS2::ActionDrawLineRelAngle:
bRelAngle->setChecked(true);
return;
case RS2::ActionDrawLineTangent1:
bTangent1->setChecked(true);
return;
case RS2::ActionDrawLineTangent2:
bTangent2->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
return;
}
}

View File

@@ -0,0 +1,77 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARLINES_H
#define QG_CADTOOLBARLINES_H
class QG_CadToolBar;
#include "qg_actionhandler.h"
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarLines : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarLines(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarLines() = default;
virtual void restoreAction(); //restore action from checked button
RS2::ToolBarId rtti() const
{
return RS2::ToolBarLines;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void drawLine();
virtual void drawLineAngle();
virtual void drawLineHorizontal();
virtual void drawLineHorVert();
virtual void drawLineVertical();
virtual void drawLineParallel();
virtual void drawLineParallelThrough();
virtual void drawLineRectangle();
virtual void drawLineBisector();
virtual void drawLineTangent1();
virtual void drawLineTangent2();
virtual void drawLineOrthogonal();
virtual void drawLineOrthTan();
virtual void drawLineRelAngle();
virtual void drawLineFree();
virtual void drawLinePolygon();
virtual void drawLinePolygon2();
virtual void resetToolBar();
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction *bNormal=nullptr, *bAngle=nullptr, *bHorizontal=nullptr, *bVertical=nullptr, *bRectangle=nullptr, *bBisector=nullptr,
*bParallel=nullptr, *bParallelThrough=nullptr, *bTangent1=nullptr, *bTangent2=nullptr, *bOrthTan=nullptr,
*bOrthogonal=nullptr, *bRelAngle=nullptr, *bPolygon=nullptr, *bPolygon2=nullptr, *bFree=nullptr;
};
#endif // QG_CADTOOLBARLINES_H

View File

@@ -0,0 +1,209 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<QCoreApplication>
#include<QMouseEvent>
#include<QAction>
#include<tuple>
#include<utility>
#include "qg_cadtoolbarmain.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarMain as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarMain::QG_CadToolBarMain(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarMain::addSubActions(const std::vector<QAction*>& actions, bool /*addGroup*/)
{
const std::initializer_list<std::pair<QAction**, RS2::ActionType>> actionTypes=
{
std::make_pair(&bMenuText, RS2::ActionDrawMText),
std::make_pair(&bMenuImage, RS2::ActionDrawImage),
std::make_pair(&bMenuPoint, RS2::ActionDrawPoint),
std::make_pair(&bMenuBlock, RS2::ActionBlocksCreate),
std::make_pair(&bMenuHatch, RS2::ActionDrawHatch)
};
for(auto a: actions){
auto it0=std::find_if(actionTypes.begin(), actionTypes.end(),
[&a](const std::pair<QAction**, RS2::ActionType>& a0)->bool{
return a->data() == a0.second;
});
if(it0==actionTypes.end()) return;
* it0->first = a;
}
if(std::any_of(actionTypes.begin(), actionTypes.end(),
[](const std::pair<QAction**, RS2::ActionType>& a)->bool{
return !*(a.first);
})) return;
const std::initializer_list<std::tuple<QAction**, QString, const char*>> buttons={
std::make_tuple(&bMenuLine, "menuline", R"(Show toolbar "Lines")"),
std::make_tuple(&bMenuArc, "menuarc", R"(Show toolbar "Arcs")"),
std::make_tuple(&bMenuCircle, "menucircle", R"(Show toolbar "Circles")"),
std::make_tuple(&bMenuEllipse, "menuellipse", R"(Show toolbar "Ellipses")"),
std::make_tuple(&bMenuPolyline, "menupolyline", R"(Show toolbar "Polylines")"),
std::make_tuple(&bMenuSpline, "menuspline", R"(Show toolbar "Splines")"),
std::make_tuple(&bMenuDim, "dimhor", R"(Show toolbar "Dimensions")"),
// std::make_tuple(&bMenuHatch, "menuhatch", R"(Create Hatch)"),
std::make_tuple(&bMenuModify, "menuedit", R"(Show toolbar "Modify")"),
std::make_tuple(&bMenuInfo, "menumeasure", R"(Show toolbar "Info")"),
std::make_tuple(&bMenuSelect, "menuselect", R"(Show toolbar "Select")")
};
std::vector<QAction*> listAction;
for(const auto& a: buttons){
QAction* p=new QAction(QIcon(":/extui/"+std::get<1>(a)+".png"),
QCoreApplication::translate("main", std::get<2>(a)), this);
*std::get<0>(a)=p;
listAction.push_back(p);
}
auto it = std::find(listAction.begin(), listAction.end(),bMenuDim);
//add draw actions
listAction.insert(it, bMenuText);
QAction* nullAction=new QAction(this);
nullAction->setEnabled(false);
listAction.insert(it, nullAction);
listAction.insert(it, bMenuPoint);
it = std::find(listAction.begin(), listAction.end(),bMenuModify);
listAction.insert(it, bMenuImage);
it = std::find(listAction.begin(), listAction.end(),bMenuSelect);
listAction.insert(it, bMenuBlock);
it = std::find(listAction.begin(), listAction.end(),bMenuImage);
listAction.insert(it, bMenuHatch);
LC_CadToolBarInterface::addSubActions(listAction, false);
for(auto a: actionTypes){
(*a.first)->setCheckable(true);
m_pActionGroup->addAction(*a.first);
}
if(actionHandler)
setActionHandler(actionHandler);
}
void QG_CadToolBarMain::setActionHandler(QG_ActionHandler* ah)
{
actionHandler=ah;
if(!bMenuLine) return;
connect(bMenuLine, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarLines()));
connect(bMenuArc, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarArcs()));
connect(bMenuCircle, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarCircles()));
connect(bMenuEllipse, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarEllipses()));
connect(bMenuSpline, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarSplines()));
connect(bMenuPolyline, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarPolylines()));
connect(bMenuDim, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarDim()));
connect(bMenuModify, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarModify()));
connect(bMenuInfo, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarInfo()));
connect(bMenuBlock, SIGNAL(triggered()),
actionHandler, SLOT(slotBlocksCreate()));
connect(bMenuSelect, SIGNAL(triggered()),
cadToolBar, SLOT(showToolBarSelect()));
}
//clear current action
void QG_CadToolBarMain::finishCurrentAction(bool resetToolBar)
{
if(!actionHandler) return;
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(resetToolBar); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarMain::slotDrawMText()
{
finishCurrentAction();
actionHandler->slotDrawMText();
}
void QG_CadToolBarMain::slotDrawImage()
{
finishCurrentAction();
actionHandler->slotDrawImage();
}
//restore action from checked button
void QG_CadToolBarMain::restoreAction()
{
if(!(actionHandler&&bMenuPoint)) return;
if ( bMenuPoint ->isChecked() ) {
actionHandler->slotDrawPoint();
return;
}
m_pHidden->setChecked(true);
finishCurrentAction();
}
void QG_CadToolBarMain::resetToolBar()
{
killAllActions();
m_pHidden->setChecked(true);
}
void QG_CadToolBarMain::mousePressEvent(QMouseEvent* e)
{
if (e->button()==Qt::RightButton && cadToolBar) {
resetToolBar();
}
}
void QG_CadToolBarMain::showCadToolBar(RS2::ActionType actionType) {
if(!bMenuImage) return;
switch(actionType){
case RS2::ActionDrawImage:
bMenuImage->setChecked(true);
break;
case RS2::ActionDrawPoint:
bMenuPoint->setChecked(true);
break;
case RS2::ActionDrawMText:
bMenuText->setChecked(true);
break;
default:
m_pHidden->setChecked(true);
break;
}
}

View File

@@ -0,0 +1,63 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARMAIN_H
#define QG_CADTOOLBARMAIN_H
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBar;
class QG_ActionHandler;
class QG_CadToolBarMain : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarMain(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarMain() = default;
virtual void restoreAction(); //restore action from checked button
void finishCurrentAction(bool resetToolBar=false); //clear current action
void resetToolBar();
virtual void setActionHandler(QG_ActionHandler* ah);
virtual void showCadToolBar(RS2::ActionType actionType);
RS2::ToolBarId rtti() const
{
return RS2::ToolBarMain;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void mousePressEvent( QMouseEvent * e );
private slots:
void slotDrawMText();
void slotDrawImage();
private:
QAction *bMenuImage=nullptr, *bMenuPoint=nullptr, *bMenuText=nullptr, *bMenuBlock=nullptr;
QAction *bMenuLine=nullptr, *bMenuArc=nullptr, *bMenuCircle=nullptr, *bMenuEllipse=nullptr, *bMenuSpline=nullptr, *bMenuPolyline=nullptr, *bMenuDim=nullptr, *bMenuHatch=nullptr, *bMenuModify=nullptr, *bMenuInfo=nullptr,
*bMenuSelect=nullptr;
};
#endif

View File

@@ -0,0 +1,233 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbarmodify.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarModify as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarModify::QG_CadToolBarModify(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarModify::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons={
&bMove, &bRotate, &bScale, &bMirror, &bMoveRotate, &bRotate2,
&bRevertDirection, &bTrim, &bTrim2, &bTrimAmount, &bOffset, &bBevel,
&bRound, &bCut, &bStretch, &bEntity, &bAttributes, &bDelete,
&bDeleteQuick, &bExplodeText, &bExplode
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
//restore action from checked
void QG_CadToolBarModify::restoreAction() {
if(!(actionHandler&&bMove)) return;
if ( bMove ->isChecked() ) {
actionHandler->slotModifyMove();
return;
}
if ( bRotate ->isChecked() ) {
actionHandler->slotModifyRotate();
return;
}
if ( bScale ->isChecked() ) {
actionHandler->slotModifyScale();
return;
}
if ( bMirror ->isChecked() ) {
actionHandler->slotModifyMirror();
return;
}
if ( bMoveRotate ->isChecked() ) {
actionHandler->slotModifyMoveRotate();
return;
}
if ( bRotate2 ->isChecked() ) {
actionHandler->slotModifyRotate2();
return;
}
if ( bTrim ->isChecked() ) {
actionHandler->slotModifyTrim();
return;
}
if ( bTrim2 ->isChecked() ) {
actionHandler->slotModifyTrim2();
return;
}
if ( bTrimAmount ->isChecked() ) {
actionHandler->slotModifyTrimAmount();
return;
}
if ( bBevel ->isChecked() ) {
actionHandler->slotModifyBevel();
return;
}
if ( bRound ->isChecked() ) {
actionHandler->slotModifyRound();
return;
}
if ( bCut ->isChecked() ) {
actionHandler->slotModifyCut();
return;
}
if ( bStretch ->isChecked() ) {
actionHandler->slotModifyStretch();
return;
}
if ( bEntity ->isChecked() ) {
actionHandler->slotModifyEntity();
return;
}
if ( bAttributes ->isChecked() ) {
actionHandler->slotModifyAttributes();
return;
}
if ( bDelete ->isChecked() ) {
actionHandler->slotModifyDelete();
return;
}
if ( bExplode ->isChecked() ) {
actionHandler->slotBlocksExplode();
return;
}
if ( bExplodeText ->isChecked() ) {
actionHandler->slotModifyExplodeText();
return;
}
if ( bOffset ->isChecked() ) {
actionHandler->slotModifyOffset();
return;
}
if ( bRevertDirection ->isChecked() ) {
actionHandler->slotModifyRevertDirection();
return;
}
m_pHidden->setChecked(true);
//clear all action
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarModify::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarModify::on_bBack_clicked()
{
finishCurrentAction(true);
cadToolBar->showToolBar(RS2::ToolBarMain);
}
void QG_CadToolBarModify::showCadToolBar(RS2::ActionType actionType) {
if(!bAttributes) return;
switch(actionType){
case RS2::ActionModifyAttributes:
bAttributes->setChecked(true);
return;
case RS2::ActionModifyDelete:
bDelete->setChecked(true);
return;
// case RS2::ActionModifyDeleteQuick:
// case RS2::ActionModifyDeleteFree:
case RS2::ActionModifyMove:
bMove->setChecked(true);
return;
// case RS2::ActionModifyMoveNoSelect:
case RS2::ActionModifyRotate:
bRotate->setChecked(true);
return;
// case RS2::ActionModifyRotateNoSelect:
case RS2::ActionModifyScale:
bScale->setChecked(true);
return;
// case RS2::ActionModifyScaleNoSelect:
case RS2::ActionModifyMirror:
bMirror->setChecked(true);
return;
// case RS2::ActionModifyMirrorNoSelect:
case RS2::ActionModifyMoveRotate:
bMoveRotate->setChecked(true);
return;
// case RS2::ActionModifyMoveRotateNoSelect:
case RS2::ActionModifyRotate2:
bRotate2->setChecked(true);
return;
// case RS2::ActionModifyRotate2NoSelect:
case RS2::ActionModifyEntity:
bEntity->setChecked(true);
return;
case RS2::ActionModifyTrim:
bTrim->setChecked(true);
return;
case RS2::ActionModifyTrim2:
bTrim2->setChecked(true);
return;
case RS2::ActionModifyTrimAmount:
bTrimAmount->setChecked(true);
return;
case RS2::ActionModifyCut:
bCut->setChecked(true);
return;
case RS2::ActionModifyStretch:
bStretch->setChecked(true);
return;
case RS2::ActionModifyBevel:
bBevel->setChecked(true);
return;
case RS2::ActionModifyRound:
bRound->setChecked(true);
return;
case RS2::ActionModifyOffset:
bOffset->setChecked(true);
return;
case RS2::ActionModifyRevertDirection:
bRevertDirection->setChecked(true);
return;
// case RS2::ActionModifyExplodeText:
// bEntityText->setChecked(true);
// case RS2::ActionModifyOffsetNoSelect:
default:
m_pHidden->setChecked(true);
return;
}
}

View File

@@ -0,0 +1,64 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARMODIFY_H
#define QG_CADTOOLBARMODIFY_H
#include <vector>
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBar;
class QG_ActionHandler;
class QG_CadToolBarModify : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarModify(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarModify() = default;
//restore action from checked button
virtual void restoreAction();
virtual void showCadToolBar(RS2::ActionType actionType);
RS2::ToolBarId rtti() const
{
return RS2::ToolBarModify;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void resetToolBar();
private slots:
void on_bBack_clicked();
private:
QAction *bMove=nullptr, *bRotate=nullptr, *bScale=nullptr, *bMirror=nullptr, *bMoveRotate=nullptr, *bRotate2=nullptr,
*bRevertDirection=nullptr, *bTrim=nullptr, *bTrim2=nullptr, *bTrimAmount=nullptr, *bOffset=nullptr, *bBevel=nullptr,
*bRound=nullptr, *bCut=nullptr, *bStretch=nullptr, *bEntity=nullptr, *bAttributes=nullptr, *bDelete=nullptr,
*bDeleteQuick=nullptr, *bExplodeText=nullptr,*bExplode=nullptr;
};
#endif // QG_CADTOOLBARMODIFY_H

View File

@@ -0,0 +1,145 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbarpolylines.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarPolylines as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarPolylines::QG_CadToolBarPolylines(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarPolylines::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons={
&bPolyline, &bPolylineAdd, &bPolylineAppend, &bPolylineDel,
&bPolylineDelBetween, &bPolylineTrim, &bPolylineEquidistant,
&bPolylineSegment
};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
//restore action from checked button
void QG_CadToolBarPolylines::restoreAction()
{
if(!(actionHandler && bPolyline)) return;
if ( bPolyline ->isChecked() ) {
actionHandler->slotDrawPolyline();
return;
}
if ( bPolylineAdd ->isChecked() ) {
actionHandler->slotPolylineAdd();
return;
}
if ( bPolylineAppend ->isChecked() ) {
actionHandler->slotPolylineAppend();
return;
}
if ( bPolylineDel ->isChecked() ) {
actionHandler->slotPolylineDel();
return;
}
if ( bPolylineDelBetween ->isChecked() ) {
actionHandler->slotPolylineDelBetween();
return;
}
if ( bPolylineTrim ->isChecked() ) {
actionHandler->slotPolylineTrim();
return;
}
if ( bPolylineEquidistant ->isChecked() ) {
actionHandler->slotPolylineEquidistant();
return;
}
if ( bPolylineSegment ->isChecked() ) {
actionHandler->slotPolylineSegment();
return;
}
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarPolylines::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarPolylines::on_bBack_clicked()
{
finishCurrentAction(true);
cadToolBar->showPreviousToolBar();
}
void QG_CadToolBarPolylines::showCadToolBar(RS2::ActionType actionType){
if(!bPolyline) return;
switch(actionType){
case RS2::ActionDrawPolyline:
bPolyline->setChecked(true);
return;
case RS2::ActionPolylineAdd:
bPolylineAdd->setChecked(true);
return;
case RS2::ActionPolylineAppend:
bPolylineAppend->setChecked(true);
return;
case RS2::ActionPolylineDel:
bPolylineDel->setChecked(true);
return;
case RS2::ActionPolylineDelBetween:
bPolylineDelBetween->setChecked(true);
return;
case RS2::ActionPolylineTrim:
bPolylineTrim->setChecked(true);
return;
case RS2::ActionPolylineEquidistant:
bPolylineEquidistant->setChecked(true);
return;
case RS2::ActionPolylineSegment:
bPolylineSegment->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
return;
}
}
//EOF

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARPOLYLINES_H
#define QG_CADTOOLBARPOLYLINES_H
class QG_CadToolBar;
class QG_ActionHandler;
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarPolylines : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarPolylines(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarPolylines() = default;
//restore action from checked button
virtual void restoreAction();
RS2::ToolBarId rtti() const
{
return RS2::ToolBarPolylines;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup=true);
public slots:
virtual void resetToolBar();
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction *bPolyline=nullptr,*bPolylineAdd=nullptr,*bPolylineAppend=nullptr,*bPolylineDel=nullptr,
*bPolylineDelBetween=nullptr,*bPolylineTrim=nullptr,*bPolylineEquidistant=nullptr,*bPolylineSegment=nullptr;
};
#endif // QG_CADTOOLBARPOLYLINES_H

View File

@@ -0,0 +1,102 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2015 Dongxu Li (dongxuli2011 at gmail.com)
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include<QAction>
#include<QToolButton>
#include<QLayout>
#include<QMouseEvent>
#include "qg_cadtoolbarselect.h"
#include "qg_cadtoolbar.h"
#include "rs_actionselect.h"
#include "qg_actionhandler.h"
#include "rs_debug.h"
/*
* Constructs a QG_CadToolBarSelect as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarSelect::QG_CadToolBarSelect(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
,nextAction(-1)
,selectAction(nullptr)
{
initToolBars();
if(layout()){
QToolButton* button=new QToolButton;
button->setDefaultAction(m_pButtonForward);
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
layout()->addWidget(button);
static_cast<QVBoxLayout*>(layout())->addStretch(1);
}
connect(m_pButtonForward, SIGNAL(triggered()), this, SLOT(runNextAction()));
}
void QG_CadToolBarSelect::setSelectAction(RS_ActionInterface* selectAction) {
this->selectAction = selectAction;
}
void QG_CadToolBarSelect::setNextAction(int nextAction) {
this->nextAction = nextAction;
if (nextAction==-1) {
// DEBUG_HEADER
m_pButtonForward->setVisible(false);
} else {
// DEBUG_HEADER
m_pButtonForward->setVisible(true);
}
}
void QG_CadToolBarSelect::runNextAction() {
if (selectAction) {
if(selectAction->rtti() == RS2::ActionSelect){
//refuse to run next action if no entity is selected, to avoid segfault by action upon empty selection
//issue#235
if( static_cast<RS_ActionSelect*>(selectAction)->countSelected()==0) return;
}
selectAction->finish();
selectAction = nullptr;
}
if (nextAction!=-1) {
actionHandler->killSelectActions();
actionHandler->setCurrentAction((RS2::ActionType)nextAction);
}
}
void QG_CadToolBarSelect::mousePressEvent(QMouseEvent* e) {
if (e->button()==Qt::RightButton && cadToolBar) {
on_bBack_clicked();
e->accept();
}
}
void QG_CadToolBarSelect::on_bBack_clicked()
{
killSelectActions();
if(cadToolBar){
cadToolBar->showPreviousToolBar(true);
cadToolBar->resetToolBar();
}
}

View File

@@ -0,0 +1,62 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2015 Dongxu Li (dongxuli2011 at gmail.com)
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CADTOOLBARSELECT_H
#define QG_CADTOOLBARSELECT_H
class QG_CadToolBar;
class QG_ActionHandler;
class RS_ActionInterface;
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarSelect : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarSelect(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarSelect() = default;
RS2::ToolBarId rtti() const
{
return RS2::ToolBarSelect;
}
public slots:
virtual void setSelectAction( RS_ActionInterface * selectAction );
virtual void setNextAction( int nextAction );
virtual void runNextAction();
virtual void mousePressEvent( QMouseEvent * e );
private slots:
void on_bBack_clicked();
private:
int nextAction;
RS_ActionInterface* selectAction;
};
#endif // QG_CADTOOLBARSELECT_H

View File

@@ -0,0 +1,93 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2014 Dongxu Li (dongxuli2011@gmail.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/
#include<cassert>
#include<QAction>
#include "qg_cadtoolbarsplines.h"
#include "qg_cadtoolbar.h"
#include "qg_actionhandler.h"
/*
* Constructs a QG_CadToolBarSplines as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CadToolBarSplines::QG_CadToolBarSplines(QG_CadToolBar* parent, Qt::WindowFlags fl)
:LC_CadToolBarInterface(parent, fl)
{
initToolBars();
}
void QG_CadToolBarSplines::addSubActions(const std::vector<QAction*>& actions, bool addGroup)
{
LC_CadToolBarInterface::addSubActions(actions, addGroup);
std::vector<QAction**> const buttons={&bSpline, &bSplineInt};
assert(buttons.size()==actions.size());
for(size_t i=0; i<buttons.size(); ++i)
*buttons[i]=actions[i];
}
//restore action from checked button
void QG_CadToolBarSplines::restoreAction()
{
if(!(actionHandler&&bSpline)) return;
if ( bSpline ->isChecked() ) {
actionHandler->slotDrawSpline();
return;
}
if(bSplineInt->isChecked()){
actionHandler->slotDrawSplinePoints();
return;
}
m_pHidden->setChecked(true);
RS_ActionInterface* currentAction =actionHandler->getCurrentAction();
if(currentAction ) {
currentAction->finish(false); //finish the action, but do not update toolBar
}
}
void QG_CadToolBarSplines::resetToolBar()
{
m_pHidden->setChecked(true);
}
void QG_CadToolBarSplines::showCadToolBar(RS2::ActionType actionType) {
if(!bSpline) return;
switch(actionType){
case RS2::ActionDrawSpline:
bSpline->setChecked(true);
return;
case RS2::ActionDrawSplinePoints:
bSplineInt->setChecked(true);
return;
default:
m_pHidden->setChecked(true);
return;
}
}
void QG_CadToolBarSplines::on_bBack_clicked()
{
finishCurrentAction(true);
LC_CadToolBarInterface::back();
}

View File

@@ -0,0 +1,56 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2014 Dongxu Li (dongxuli2011@gmail.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/
#ifndef QG_CADTOOLBARSPLINES_H
#define QG_CADTOOLBARSPLINES_H
class QG_CadToolBar;
class QG_ActionHandler;
#include "lc_cadtoolbarinterface.h"
class QG_CadToolBarSplines : public LC_CadToolBarInterface
{
Q_OBJECT
public:
QG_CadToolBarSplines(QG_CadToolBar* parent = 0, Qt::WindowFlags fl = 0);
~QG_CadToolBarSplines() = default;
//restore action from checked button
virtual void restoreAction();
RS2::ToolBarId rtti() const
{
return RS2::ToolBarSplines;
}
virtual void addSubActions(const std::vector<QAction*>& actions, bool addGroup);
public slots:
virtual void resetToolBar();
virtual void showCadToolBar(RS2::ActionType actionType);
private slots:
void on_bBack_clicked();
private:
QAction *bSpline=nullptr, *bSplineInt=nullptr;
};
#endif // QG_CADTOOLBARSPLINES_H

View File

@@ -0,0 +1,105 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_circleoptions.h"
#include "rs_settings.h"
#include "rs_math.h"
#include "rs_debug.h"
#include "rs_actiondrawcirclecr.h"
#include "ui_qg_circleoptions.h"
/*
* Constructs a QG_CircleOptions as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CircleOptions::QG_CircleOptions(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, ui(new Ui::Ui_CircleOptions{})
{
ui->setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_CircleOptions::~QG_CircleOptions()
{
saveSettings();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_CircleOptions::languageChange()
{
ui->retranslateUi(this);
}
void QG_CircleOptions::saveSettings() {
RS_SETTINGS->beginGroup("/Draw");
RS_SETTINGS->writeEntry("/CircleRadius", ui->leRadius->text());
RS_SETTINGS->endGroup();
}
void QG_CircleOptions::setAction(RS_ActionInterface* a, bool update) {
if (a && ( a->rtti()==RS2::ActionDrawCircleCR || a->rtti()==RS2::ActionDrawCircle2PR) ) {
action = static_cast<RS_ActionDrawCircleCR*>(a);
QString sr;
if (update) {
sr = QString("%1").arg(action->getRadius());
} else {
RS_SETTINGS->beginGroup("/Draw");
sr = RS_SETTINGS->readEntry("/CircleRadius", "1.0");
RS_SETTINGS->endGroup();
action->setRadius(sr.toDouble());
}
ui->leRadius->setText(sr);
} else {
RS_DEBUG->print(RS_Debug::D_ERROR,
"QG_CircleOptions::setAction: wrong action type");
action = nullptr;
}
}
/*void QG_CircleOptions::setData(RS_CircleData* d) {
data = d;
RS_SETTINGS->beginGroup("/Draw");
QString r = RS_SETTINGS->readEntry("/CircleRadius", "1.0");
RS_SETTINGS->endGroup();
leRadius->setText(r);
}*/
void QG_CircleOptions::updateRadius(const QString& r) {
if (action) {
action->setRadius(RS_Math::eval(r));
}
}

View File

@@ -0,0 +1,61 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_CIRCLEOPTIONS_H
#define QG_CIRCLEOPTIONS_H
#include<memory>
#include<QWidget>
class RS_ActionInterface;
class RS_ActionDrawCircleCR;
namespace Ui {
class Ui_CircleOptions;
}
class QG_CircleOptions : public QWidget
{
Q_OBJECT
public:
QG_CircleOptions(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_CircleOptions();
public slots:
virtual void setAction(RS_ActionInterface * a, bool update );
virtual void updateRadius( const QString & r );
protected:
RS_ActionDrawCircleCR* action;
protected slots:
virtual void languageChange();
private:
void saveSettings();
std::unique_ptr<Ui::Ui_CircleOptions> ui;
};
#endif // QG_CIRCLEOPTIONS_H

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ui_CircleOptions</class>
<widget class="QWidget" name="Ui_CircleOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>111</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>22</height>
</size>
</property>
<property name="windowTitle">
<string>Circle Options</string>
</property>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QLabel" name="lRadius">
<property name="text">
<string>Radius:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leRadius"/>
</item>
<item>
<widget class="Line" name="sep1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>leRadius</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_CircleOptions</receiver>
<slot>updateRadius(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,97 @@
/****************************************************************************
**
* Draw ellipse by foci and a point on ellipse
Copyright (C) 2012 Dongxu Li (dongxuli2011@gmail.com)
Copyright (C) 2012 LibreCAD.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/
#include "qg_circletan2options.h"
#include "rs_actiondrawcircletan2.h"
#include "rs_settings.h"
#include "rs_math.h"
#include "rs_debug.h"
#include "ui_qg_circletan2options.h"
/*
* Constructs a QG_CircleTan2Options as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CircleTan2Options::QG_CircleTan2Options(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, ui(new Ui::Ui_CircleTan2Options{})
{
ui->setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_CircleTan2Options::~QG_CircleTan2Options()
{
saveSettings();
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_CircleTan2Options::languageChange()
{
ui->retranslateUi(this);
}
void QG_CircleTan2Options::saveSettings() {
RS_SETTINGS->beginGroup("/Draw");
RS_SETTINGS->writeEntry("/CircleTan2Radius", ui->leRadius->text());
RS_SETTINGS->endGroup();
}
void QG_CircleTan2Options::setAction(RS_ActionInterface* a, bool update) {
if (a && a->rtti()==RS2::ActionDrawCircleTan2) {
action = static_cast<RS_ActionDrawCircleTan2*>(a);
QString sr;
if (update) {
sr = QString("%1").arg(action->getRadius());
} else {
RS_SETTINGS->beginGroup("/Draw");
sr = RS_SETTINGS->readEntry("/CircleTan2Radius", "1.0");
RS_SETTINGS->endGroup();
}
ui->leRadius->setText(sr);
} else {
RS_DEBUG->print(RS_Debug::D_ERROR,
"QG_CircleTan2Options::setAction: wrong action type");
action = nullptr;
}
}
void QG_CircleTan2Options::updateRadius(const QString& r) {
if (action) {
bool ok;
double radius=RS_Math::eval(r,&ok);
if(ok){
action->setRadius(radius);
}/*else{
ui->leRadius->setText("10.0");
}*/
}
}

View File

@@ -0,0 +1,59 @@
/****************************************************************************
**
* Draw ellipse by foci and a point on ellipse
Copyright (C) 2012 Dongxu Li (dongxuli2011@gmail.com)
Copyright (C) 2012 LibreCAD.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/
#ifndef QG_CIRCLETAN2OPTIONS_H
#define QG_CIRCLETAN2OPTIONS_H
#include<memory>
#include<QWidget>
class RS_ActionInterface;
class RS_ActionDrawCircleTan2;
namespace Ui {
class Ui_CircleTan2Options;
}
class QG_CircleTan2Options : public QWidget
{
Q_OBJECT
public:
QG_CircleTan2Options(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_CircleTan2Options();
public slots:
virtual void setAction( RS_ActionInterface * a, bool update );
virtual void updateRadius( const QString & l );
protected:
RS_ActionDrawCircleTan2* action;
protected slots:
virtual void languageChange();
private:
void saveSettings();
std::unique_ptr<Ui::Ui_CircleTan2Options> ui;
};
#endif
// QG_CIRCLETAN2OPTIONS_H

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ui_CircleTan2Options</class>
<widget class="QWidget" name="Ui_CircleTan2Options">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>110</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>65</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>160</width>
<height>32</height>
</size>
</property>
<property name="windowTitle">
<string>Circle Tangential2 Options</string>
</property>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lRadius">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Radius of the tangential circle to draw&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Radius:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leRadius">
<property name="toolTip">
<string>Radius of tangential circle</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="sep1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>leRadius</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_CircleTan2Options</receiver>
<slot>updateRadius(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,299 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_commandwidget.h"
#include <algorithm>
#include <QAction>
#include <QKeyEvent>
#include <QFileDialog>
#include <QSettings>
#include "qg_actionhandler.h"
#include "rs_commands.h"
#include "rs_commandevent.h"
#include "rs_system.h"
#include "rs_utility.h"
/*
* Constructs a QG_CommandWidget as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CommandWidget::QG_CommandWidget(QWidget* parent, const char* name, Qt::WindowFlags fl)
: QWidget(parent, fl)
, actionHandler(nullptr)
{
setObjectName(name);
setupUi(this);
connect(leCommand, SIGNAL(command(QString)), this, SLOT(handleCommand(QString)));
connect(leCommand, SIGNAL(escape()), this, SLOT(escape()));
connect(leCommand, SIGNAL(focusOut()), this, SLOT(setNormalMode()));
connect(leCommand, SIGNAL(focusIn()), this, SLOT(setCommandMode()));
connect(leCommand, SIGNAL(tabPressed()), this, SLOT(tabPressed()));
connect(leCommand, SIGNAL(clearCommandsHistory()), teHistory, SLOT(clear()));
connect(leCommand, SIGNAL(message(QString)), this, SLOT(appendHistory(QString)));
connect(leCommand, &QG_CommandEdit::keycode, this, &QG_CommandWidget::handleKeycode);
auto a1 = new QAction(QObject::tr("Keycode mode"), this);
a1->setObjectName("keycode_action");
a1->setCheckable(true);
connect(a1, &QAction::toggled, this, &QG_CommandWidget::setKeycodeMode);
options_button->addAction(a1);
QSettings settings;
if (settings.value("Widgets/KeycodeMode", false).toBool())
{
leCommand->keycode_mode = true;
a1->setChecked(true);
}
auto a2 = new QAction(QObject::tr("Load command file"), this);
connect(a2, &QAction::triggered, this, &QG_CommandWidget::chooseCommandFile);
options_button->addAction(a2);
auto a3 = new QAction(QObject::tr("Paste multiple commands"), this);
connect(a3, &QAction::triggered, leCommand, &QG_CommandEdit::modifiedPaste);
options_button->addAction(a3);
options_button->setStyleSheet("QToolButton::menu-indicator { image: none; }");
}
/*
* Destroys the object and frees any allocated resources
*/
QG_CommandWidget::~QG_CommandWidget()
{
QSettings settings;
auto action = findChild<QAction*>("keycode_action");
settings.setValue("Widgets/KeycodeMode", action->isChecked());
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_CommandWidget::languageChange()
{
retranslateUi(this);
}
bool QG_CommandWidget::eventFilter(QObject */*obj*/, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent* e=static_cast<QKeyEvent*>(event);
int key {e->key()};
switch(key) {
case Qt::Key_Return:
case Qt::Key_Enter:
if(!leCommand->text().size())
return false;
else
break;
case Qt::Key_Escape:
return false;
default:
break;
}
//detect Ctl- Alt- modifier, but not Shift
//This should avoid filtering shortcuts, such as Ctl-C
Qt::KeyboardModifiers modifiers {e->modifiers()};
if ( !(Qt::GroupSwitchModifier == modifiers && Qt::Key_At == key) // let '@' key pass for relative coords
&& modifiers != Qt::KeypadModifier
&& modifiers & (Qt::KeyboardModifierMask ^ Qt::ShiftModifier)) {
return false;
}
event->accept();
this->setFocus();
QKeyEvent * newEvent = new QKeyEvent(*static_cast<QKeyEvent*>(event));
QApplication::postEvent(leCommand, newEvent);
return true;
}
return false;
}
void QG_CommandWidget::setFocus()
{
if (!isActiveWindow())
activateWindow();
auto newEvent = new QFocusEvent(QEvent::FocusIn);
QApplication::postEvent(leCommand, newEvent);
leCommand->setFocus();
}
void QG_CommandWidget::setCommand(const QString& cmd) {
if (cmd!="") {
lCommand->setText(cmd);
} else {
lCommand->setText(tr("Command:"));
}
leCommand->setText("");
}
void QG_CommandWidget::appendHistory(const QString& msg) {
teHistory->append(msg);
}
void QG_CommandWidget::handleCommand(QString cmd)
{
cmd = cmd.simplified();
bool isAction=false;
if (!cmd.isEmpty()) {
appendHistory(cmd);
}
if (actionHandler) {
isAction=actionHandler->command(cmd);
}
if (!isAction && !(cmd.contains(',') || cmd.at(0)=='@')) {
appendHistory(tr("Unknown command: %1").arg(cmd));
}
leCommand->setText("");
}
void QG_CommandWidget::tabPressed() {
if (actionHandler) {
QStringList reducedChoice;
QString typed = leCommand->text();
QStringList choice;
// check current command:
choice = actionHandler->getAvailableCommands();
if (choice.count()==0) {
choice = RS_COMMANDS->complete(typed);
}
for (QStringList::Iterator it = choice.begin(); it != choice.end(); ++it) {
if (typed.isEmpty() || (*it).startsWith(typed)) {
reducedChoice << (*it);
}
}
// command found:
if (reducedChoice.count()==1) {
leCommand->setText(reducedChoice.first());
}
else if (reducedChoice.count()>0) {
QString const& proposal = this->getRootCommand(reducedChoice, typed);
appendHistory(reducedChoice.join(", "));
leCommand -> setText(proposal);
}
}
}
void QG_CommandWidget::escape() {
//leCommand->clearFocus();
if (actionHandler) {
actionHandler->command(QString(tr("escape", "escape, go back from action steps")));
}
}
void QG_CommandWidget::setActionHandler(QG_ActionHandler* ah) {
actionHandler = ah;
}
void QG_CommandWidget::setCommandMode() {
QPalette palette;
palette.setColor(lCommand->foregroundRole(), Qt::blue);
lCommand->setPalette(palette);
}
void QG_CommandWidget::setNormalMode() {
QPalette palette;
palette.setColor(lCommand->foregroundRole(), Qt::black);
lCommand->setPalette(palette);
}
QString QG_CommandWidget::getRootCommand( const QStringList & cmdList, const QString & typed ) {
//do we have to check for empty cmdList?
if(cmdList.empty()) return QString();
//find the shortest string in cmdList
auto const& shortestString = * std::min_element(cmdList.begin(), cmdList.end(),
[](QString const& a, QString const& b) -> bool
{
return a.size() < b.size();
}
);
int const lengthShortestString = shortestString.size();
// Now we parse the cmdList list, character of each item by character.
int low = typed.length();
int high = lengthShortestString + 1;
while(high > low + 1) {
int mid = (high + low)/2;
bool common = true;
QString const& proposal = shortestString.left(mid);
for(auto const& substring: cmdList) {
if(!substring.startsWith(proposal)) {
common = false;
break;
}
}
if(common) {
low = mid;
}
else {
high = mid;
}
}
// As we assign just before mid value to low (if strings are common), we can use it as parameter for left.
// If not common -> low value does not changes, even if escaping from the while. This avoids weird behaviors like continuing completion when pressing tab.
return shortestString.left(low);
}
void QG_CommandWidget::chooseCommandFile()
{
QString path = QFileDialog::getOpenFileName(this);
if (!path.isEmpty())
{
leCommand->readCommandFile(path);
}
}
void QG_CommandWidget::handleKeycode(QString code)
{
if (actionHandler->keycode(code))
{
leCommand->clear();
}
}
void QG_CommandWidget::setKeycodeMode(bool state)
{
leCommand->keycode_mode = state;
}

View File

@@ -0,0 +1,64 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_COMMANDWIDGET_H
#define QG_COMMANDWIDGET_H
#include "ui_qg_commandwidget.h"
class QG_ActionHandler;
class QG_CommandWidget : public QWidget, public Ui::QG_CommandWidget
{
Q_OBJECT
public:
QG_CommandWidget(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0);
~QG_CommandWidget();
virtual bool eventFilter(QObject *obj, QEvent *event);
public slots:
virtual void setFocus();
virtual void setCommand( const QString & cmd );
virtual void appendHistory( const QString & msg );
virtual void handleCommand(QString cmd);
virtual void handleKeycode(QString code);
virtual void tabPressed();
virtual void escape();
virtual void setActionHandler( QG_ActionHandler * ah );
virtual void setCommandMode();
virtual void setNormalMode();
static QString getRootCommand( const QStringList & cmdList, const QString & typed );
void setKeycodeMode(bool state);
protected slots:
virtual void languageChange();
virtual void chooseCommandFile();
private:
QG_ActionHandler* actionHandler;
};
#endif // QG_COMMANDWIDGET_H

View File

@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_CommandWidget</class>
<widget class="QWidget" name="QG_CommandWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>196</height>
</rect>
</property>
<property name="windowTitle">
<string>Command Line</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QG_CommandHistory" name="teHistory">
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Command history and output</string>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="documentTitle">
<string notr="true"/>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
<property name="linkUnderline" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lCommand">
<property name="text">
<string>Command:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QG_CommandEdit" name="leCommand"/>
</item>
<item>
<widget class="QToolButton" name="options_button">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../res/icons/icons.qrc">
<normaloff>:/icons/options.svg</normaloff>:/icons/options.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_CommandHistory</class>
<extends>QTextEdit</extends>
<header>qg_commandhistory.h</header>
</customwidget>
<customwidget>
<class>QG_CommandEdit</class>
<extends>QLineEdit</extends>
<header>qg_commandedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../res/icons/icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,134 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_coordinatewidget.h"
#include "rs_settings.h"
#include "rs_vector.h"
#include "rs_graphic.h"
/*
* Constructs a QG_CoordinateWidget as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_CoordinateWidget::QG_CoordinateWidget(QWidget* parent, const char* name, Qt::WindowFlags fl)
: QWidget(parent, fl)
{
setObjectName(name);
setupUi(this);
lCoord1->setText("");
lCoord2->setText("");
lCoord1b->setText("");
lCoord2b->setText("");
graphic = NULL;
prec = 4;
format = RS2::Decimal;
aprec = 2;
aformat = RS2::DegreesDecimal;
}
/*
* Destroys the object and frees any allocated resources
*/
QG_CoordinateWidget::~QG_CoordinateWidget()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_CoordinateWidget::languageChange()
{
retranslateUi(this);
}
void QG_CoordinateWidget::setGraphic(RS_Graphic* graphic) {
this->graphic = graphic;
setCoordinates(RS_Vector(0.0,0.0), RS_Vector(0.0,0.0), true);
}
void QG_CoordinateWidget::setCoordinates(const RS_Vector& abs,
const RS_Vector& rel, bool updateFormat) {
setCoordinates(abs.x, abs.y, rel.x, rel.y, updateFormat);
}
void QG_CoordinateWidget::setCoordinates(double x, double y,
double rx, double ry, bool updateFormat) {
if (graphic) {
if (updateFormat) {
format = graphic->getLinearFormat();
prec = graphic->getLinearPrecision();
aformat = graphic->getAngleFormat();
aprec = graphic->getAnglePrecision();
}
// abs / rel coordinates:
QString absX = RS_Units::formatLinear(x,
graphic->getUnit(),
format, prec);
QString absY = RS_Units::formatLinear(y,
graphic->getUnit(),
format, prec);
QString relX = RS_Units::formatLinear(rx,
graphic->getUnit(),
format, prec);
QString relY = RS_Units::formatLinear(ry,
graphic->getUnit(),
format, prec);
lCoord1->setText(absX + " , " + absY);
lCoord2->setText("@ " + relX + " , " + relY);
// polar coordinates:
RS_Vector v;
v = RS_Vector(x, y);
QString str;
QString rStr = RS_Units::formatLinear(v.magnitude(),
graphic->getUnit(),
format, prec);
QString aStr = RS_Units::formatAngle(v.angle(),
aformat, aprec);
str = rStr + " < " + aStr;
lCoord1b->setText(str);
v = RS_Vector(rx, ry);
rStr = RS_Units::formatLinear(v.magnitude(),
graphic->getUnit(),
format, prec);
aStr = RS_Units::formatAngle(v.angle(),
aformat, aprec);
lCoord2b->setText("@ " + rStr + " < " + aStr);
}
}

View File

@@ -0,0 +1,59 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_COORDINATEWIDGET_H
#define QG_COORDINATEWIDGET_H
#include "ui_qg_coordinatewidget.h"
#include "rs.h"
class RS_Graphic;
class RS_Vector;
class QG_CoordinateWidget : public QWidget, public Ui::QG_CoordinateWidget
{
Q_OBJECT
public:
QG_CoordinateWidget(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0);
~QG_CoordinateWidget();
public slots:
virtual void setGraphic( RS_Graphic * graphic );
virtual void setCoordinates( const RS_Vector & abs, const RS_Vector & rel, bool updateFormat );
virtual void setCoordinates( double x, double y, double rx, double ry, bool updateFormat );
protected slots:
virtual void languageChange();
private:
RS_Graphic* graphic;
int prec;
RS2::LinearFormat format;
int aprec;
RS2::AngleFormat aformat;
};
#endif // QG_COORDINATEWIDGET_H

View File

@@ -0,0 +1,155 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_CoordinateWidget</class>
<widget class="QWidget" name="QG_CoordinateWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>27</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>380</width>
<height>27</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1500</width>
<height>160</height>
</size>
</property>
<property name="windowTitle">
<string>Coordinates</string>
</property>
<layout class="QHBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lCoord1">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Coordinates</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lCoord1b">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Coordinates</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line1">
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lCoord2">
<property name="text">
<string>Coordinates</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lCoord2b">
<property name="text">
<string>Coordinates</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

130
ui/forms/qg_custom.cw Normal file
View File

@@ -0,0 +1,130 @@
<!DOCTYPE CW><CW>
<customwidgets>
<customwidget>
<class>QG_ColorBox</class>
<header location="local">qg_colorbox.h</header>
<sizehint>
<width>140</width>
<height>22</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>0</verdata>
</sizepolicy>
<pixmap>
<data format="XPM.GZ" length="45">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523250004143a55a6b2e0026630c4f</data>
</pixmap>
<signal>colorChanged(const RS_Color&amp;)</signal>
<slot access="protected">slotColorChanged(int)</slot>
</customwidget>
<customwidget>
<class>QG_WidthBox</class>
<header location="local">qg_widthbox.h</header>
<sizehint>
<width>140</width>
<height>22</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>0</verdata>
</sizepolicy>
<pixmap>
<data format="XPM.GZ" length="45">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523250004143a55a6b2e0026630c4f</data>
</pixmap>
<signal>widthChanged(RS::LineWidth)</signal>
<slot access="protected">slotWidthChanged(int)</slot>
</customwidget>
<customwidget>
<class>QG_LineTypeBox</class>
<header location="local">qg_linetypebox.h</header>
<sizehint>
<width>140</width>
<height>22</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>0</verdata>
</sizepolicy>
<pixmap>
<data format="XPM.GZ" length="45">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523250004143a55a6b2e0026630c4f</data>
</pixmap>
<signal>lineTypeChanged(RS::LineType)</signal>
<slot access="protected">slotLineTypeChanged(int)</slot>
</customwidget>
<customwidget>
<class>QG_WidgetPen</class>
<header location="local">qg_widgetpen.h</header>
<sizehint>
<width>-1</width>
<height>-1</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>5</hordata>
<verdata>5</verdata>
</sizepolicy>
<pixmap>
<data format="XPM.GZ" length="45">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523250004143a55a6b2e0026630c4f</data>
</pixmap>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<header location="local">qg_layerbox.h</header>
<sizehint>
<width>140</width>
<height>22</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>0</verdata>
</sizepolicy>
<pixmap>
<data format="XPM.GZ" length="2926">789c9d95594f32591086effd15c4ba3393fae895ee4ce6824540141011b7c95cf406a202caa6f065fefb549faaea0b24996fc623cb937aeb3d55754e871f67a587eb6ee9ecc7c96a1dada74929798e96a5b374339bedfefceb8f9f27a7b65da27fcb724bf6e96f27a783752929f516f32c070402289b3fc39d8203c3136157e276c1260eac0f0ade0907927f2d9c58261f929cad72be0cef8535ff5959e277c201ef0fa02cf1ae7022f9efca12ff301ca81e87c21a5f32db5acf95b0eebfcdd92e2be3a5b0fa7986435bfd6e981d99278c0ae6795c288b3e2b98e3036157d8f839961308af985df51b1b0e9dc0098ddf5a3811fd7dceaee52a370d475e28f9b7ca1c07539f67173c144e65be2fcae2d763f62d89df2acb7cc282393e57b6b9ff58d893fca632c7d1ccc78bbcd48b4c7cc2ec4bfdf0aa2cfbf50be6fa2c65d9af2aacfd2c94e53cccf9fa7645eb7794a59ebdb027fe5565895f09cb7e981a267f9febaf3117fab6702af599e7a5e2049e6dce1377c25affa6608e4786e34a58894dfc8b59f5f890731087e28f2de648fbdb16ccfd6c9465bf7365c732f12f61ed3f5016fd4a59f4e6790fddd00a5d137f638eb4bfa532df5ffc148ea4be5ac17c5ea9b2ecd72b98efff403893fa1accb12d5c5696fd4d7f6152c41f95c53f2a98f56b6597fbf3857da9b75e30fb5584b59fa78239de5596fd3e0be6fdccf311b99115f1fcdaccb12fe77927ac7e2365f1c382793e63e14cfccdf3132571e69b1f07e83327d23fbac2bee4d785d57f2a9c89de9c6fecaa1fce98135bf845b9e2189e2a07e6fee287b0cfcf3bce9525ff5d38927a1bcca9cc1b66ca528ff93d89d338e3f9e182b9c86f31a752ff609d2f847f5f83b5ea31c218137a4f8fac0cc738e10cd6d3b7189f718a2ff88a6f38c339ad05adfcf31d3f7089ab037d42ea356e708b9ff8853bdc6395de6b58c706ad736c1ee823f2de608b146dbcc08e8976f012afb04b3975ec1de853aa2457f749d5c16b1ce00d0ecdf75b1ce1dd11fd1b55d236cef7f8808ff88465b4d02676d03da29f51dd9e513fa28f150c3004246d07002288bfe9e7d45f0712f22635a490d15ef730361e3b389c67aedf2390ea3157e73dc333e9a6f042d13ebc7ed32f6882405d3ee1c678030ee10d6630a76f162c8ee8f37adeb14c0aaa0b3e68b725ac80a2b039a29f630db6e46bc127d5fd45de4b5226b0833d8ea07a445f871ae96dacc218ead08073c835136842eba8be016db830e77a419f21aca143f76c025b9ae7e5813ea35bd5a0731fd1c4877a7f614fde57d085deb7f31ad31dccf54fd087883ab7a88f6baabb45fdf760003707fa09ddd826f66048af1826f00a0bb3aa7009b73082bb03fd2faeffa7fff58cfffcbcfffdfbc93f7f7d62d7</data>
</pixmap>
<signal>layerChanged(const RS_Layer* layer)</signal>
<slot access="public">slot()</slot>
<slot access="public">slotLayerChanged(int index)</slot>
</customwidget>
<customwidget>
<class>QG_FontBox</class>
<header location="local">qg_fontbox.h</header>
<sizehint>
<width>140</width>
<height>22</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>0</verdata>
</sizepolicy>
<pixmap>
<data format="XPM.GZ" length="2926">789c9d95594f32591086effd15c4ba3393fae895ee4ce6824540141011b7c95cf406a202caa6f065fefb549faaea0b24996fc623cb937aeb3d55754e871f67a587eb6ee9ecc7c96a1dada74929798e96a5b374339bedfefceb8f9f27a7b65da27fcb724bf6e96f27a783752929f516f32c070402289b3fc39d8203c3136157e276c1260eac0f0ade0907927f2d9c58261f929cad72be0cef8535ff5959e277c201ef0fa02cf1ae7022f9efca12ff301ca81e87c21a5f32db5acf95b0eebfcdd92e2be3a5b0fa7986435bfd6e981d99278c0ae6795c288b3e2b98e3036157d8f839961308af985df51b1b0e9dc0098ddf5a3811fd7dceaee52a370d475e28f9b7ca1c07539f67173c144e65be2fcae2d763f62d89df2acb7cc282393e57b6b9ff58d893fca632c7d1ccc78bbcd48b4c7cc2ec4bfdf0aa2cfbf50be6fa2c65d9af2aacfd2c94e53cccf9fa7645eb7794a59ebdb027fe5565895f09cb7e981a267f9febaf3117fab6702af599e7a5e2049e6dce1377c25affa6608e4786e34a58894dfc8b59f5f890731087e28f2de648fbdb16ccfd6c9465bf7365c732f12f61ed3f5016fd4a59f4e6790fddd00a5d137f638eb4bfa532df5ffc148ea4be5ac17c5ea9b2ecd72b98efff403893fa1accb12d5c5696fd4d7f6152c41f95c53f2a98f56b6597fbf3857da9b75e30fb5584b59fa78239de5596fd3e0be6fdccf311b99115f1fcdaccb12fe77927ac7e2365f1c382793e63e14cfccdf3132571e69b1f07e83327d23fbac2bee4d785d57f2a9c89de9c6fecaa1fce98135bf845b9e2189e2a07e6fee287b0cfcf3bce9525ff5d38927a1bcca9cc1b66ca528ff93d89d338e3f9e182b9c86f31a752ff609d2f847f5f83b5ea31c218137a4f8fac0cc738e10cd6d3b7189f718a2ff88a6f38c339ad05adfcf31d3f7089ab037d42ea356e708b9ff8853bdc6395de6b58c706ad736c1ee823f2de608b146dbcc08e8976f012afb04b3975ec1de853aa2457f749d5c16b1ce00d0ecdf75b1ce1dd11fd1b55d236cef7f8808ff88465b4d02676d03da29f51dd9e513fa28f150c3004246d07002288bfe9e7d45f0712f22635a490d15ef730361e3b389c67aedf2390ea3157e73dc333e9a6f042d13ebc7ed32f6882405d3ee1c678030ee10d6630a76f162c8ee8f37adeb14c0aaa0b3e68b725ac80a2b039a29f630db6e46bc127d5fd45de4b5226b0833d8ea07a445f871ae96dacc218ead08073c835136842eba8be016db830e77a419f21aca143f76c025b9ae7e5813ea35bd5a0731fd1c4877a7f614fde57d085deb7f31ad31dccf54fd087883ab7a88f6baabb45fdf760003707fa09ddd826f66048af1826f00a0bb3aa7009b73082bb03fd2faeffa7fff58cfffcbcfffdfbc93f7f7d62d7</data>
</pixmap>
<signal>fontChanged(RS_Font*)</signal>
<slot access="protected">slotFontChanged(int)</slot>
</customwidget>
<customwidget>
<class>QG_PatternBox</class>
<header location="local">qg_patternbox.h</header>
<sizehint>
<width>140</width>
<height>22</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>0</verdata>
</sizepolicy>
<pixmap>
<data format="XPM.GZ" length="3326">789c959549532b470cc7ef7c0a17ba51293dcfea994ae580591e186c30c60ba472e859bcb0d8e0153b95ef1e4db7340f777c09a2303feb2fb5a4ee9ef9715219dc372b273f8e164bb59ca49574ace695936cf5febefdf3af3ffe3e3a76dd0afd3a5e5c718f7f3b3a6e2f2b69a5359be60520104055ff689e59ac2c4e2c4e2dce2cce2d1e165c4b6a712dd1dcb1fc67164ff719ac7ae0cde28d15ff60b16be9adfee1d5e2f53eab89956f54b0f295a37ccdefecf7d95fb7e2c756bce6d88f9dd8c4eb7ebcd88bbc5873db8ab7e73db0b85f72a4ebafeed703e3928d3fd01c95fcc81c19469f39754cfc57c14eb530cd5d66893f13367e35628e78fd8530c747cc29c7df08b3ff5673247aac318bbf69d8957ad8eff2faa0e7e75685f18959d6d7fbe5c62ee75389614fe63d2cd9cca327ccf1bb928d3f60f69943bd9f8e17319f1af6657fee78bf53e307bdbeeff8cc78af590531af1f09b35eef4fe00aab8c39e3fc17c29ccf311c3ac6af7261eee7b364137f2dec1aff8a39e0fc922f307ed4f72750411628edaf1b0eb97eb814e6fdf04a36fe9130afd763967e1ac25caf9e6fe8d6a4fe8930d7d3600eb8ff1b61f63f33f37af8a299f287a6febee152df65ce0c2bfdfca87951e09afb7acd2cf5df976cfc93fde71f740c977a7dbfa324e6fcf86858717f7859b2e9e74298e39f853d47fbaf98b97ff810667d4bd8e8e1a7791e29e96727cccf23f12baee7b664937f2bccf9e39275bc52cc39d7df329cb81c3f14e6f5f5fd88d3d29f0973fe65c9467f2eec9b7ea6cc21d7db2cd9e49b31733f90976ceaab0af37a0f25ebf5c033cfff24643f324b7c2cccfe79c926fe9439e7faf5f351a5491eea97b532f9d254fa7d610e397ec02cf9cf99733e3f7a3e892ff97065387599e7c2354ff3a77064decf5be6d0dc675c0b73fc17b3320c4f863399ef9530d7a3cf5f922539bf2f3786cb78d770c6f5b7978521a0c20453cc30b72ca36f13f2427b297a1ce208c738c19703f68a6ff88e538a9a193de51ee1077ee21c17b8c415aec93664c5e7176e7187a758c7334c59af28f7279ee3055ee24fbcc26b6ce00dfdbdc526b6c8eef01edbf8801dd62754c99cd48fa4e8620ffb3820ebe3133e6395629ae810bb38657d4a552eb4da23551f7d0c30c49afe3fc218b0d00380627d46fa2555d22d324302296490c3104630269ec08bd6bfc21beb73d2aff00adeb53a8329cce0033e610e13ecc30296b022cf1a36dff46beaaf0f5f94bb506f614794c0699103afa17e40dfa0ef76949dd445cf7046ba73b820bd0797ffd16f6882030c21c78b2237fd5f839f7005d7a41c41e380bea8e786ba3475dd92a2092db8a3cffb03fa35de429b942378a0ba3b94bb499a2f78842e4db47740df049a374df086ba1cc0133cc382545570c03da86f8107beded71ef834cd3b08485d8536cd33dcd3677406b7744e9ab4f284f675600cba94bb0611c4d67ea5746277851e723ae64b9ae308460a28daa5fe63a554a2d26fe721a1f37d4a67d051193ab0823a5c42435b8f5e5cb91aaa911a7f3b6f8a6e439d4eece0b0a9548dd5e4db7906aae88cd8a5355fa9af7d7b05a0dc0fbfee0b45cc28a2835350f0061bcbdea058bff3eb3efe8ffbfecfef47ff02c914d57c</data>
</pixmap>
<signal>patternChanged(RS_Pattern*)</signal>
<slot access="public">slot()</slot>
<slot access="public">slotPatternChanged(int)</slot>
</customwidget>
</customwidgets>
</CW>

View File

@@ -0,0 +1,114 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dimensionlabeleditor.h"
/*
* Constructs a QG_DimensionLabelEditor as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_DimensionLabelEditor::QG_DimensionLabelEditor(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DimensionLabelEditor::~QG_DimensionLabelEditor()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DimensionLabelEditor::languageChange()
{
retranslateUi(this);
}
void QG_DimensionLabelEditor::setLabel(const QString& l) {
int i0, i1a, i1b, i2;
QString label, tol1, tol2;
bool hasDiameter = false;
label = l;
if ( !label.isEmpty()) {
if (label.at(0)==QChar(0x2205) || label.at(0)==QChar(0xF8)) {
hasDiameter = true;
bDiameter->setChecked(true);
}
}
i0 = l.indexOf("\\S");
if (i0>=0) {
i1a = l.indexOf("^ ", i0);
i1b = i1a+1;
if (i1a<0) {
i1a = i1b = l.indexOf('^', i0);
}
if (i1a>=0) {
i2 = l.indexOf(';', i1b);
label = l.mid(0, i0);
tol1 = l.mid(i0+2, i1a-i0-2);
tol2 = l.mid(i1b+1, i2-i1b-1);
}
}
leLabel->setText(label.mid(hasDiameter));
leTol1->setText(tol1);
leTol2->setText(tol2);
}
QString QG_DimensionLabelEditor::getLabel() {
QString l = leLabel->text();
// diameter:
if (bDiameter->isChecked()) {
if (l.isEmpty()) {
l = QString("%1<>").arg(QChar(0x2205));
}
else {
l = QChar(0x2205) + l;
}
}
if (leTol1->text().isEmpty() && leTol2->text().isEmpty()) {
return l;
}
else {
return l + "\\S" + leTol1->text() +
"^ " + leTol2->text() + ";";
}
}
void QG_DimensionLabelEditor::insertSign(const QString& s) {
leLabel->insert(s.left(1));
}

View File

@@ -0,0 +1,50 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DIMENSIONLABELEDITOR_H
#define QG_DIMENSIONLABELEDITOR_H
#include "ui_qg_dimensionlabeleditor.h"
class QG_DimensionLabelEditor : public QWidget, public Ui::QG_DimensionLabelEditor
{
Q_OBJECT
public:
QG_DimensionLabelEditor(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_DimensionLabelEditor();
virtual QString getLabel();
public slots:
virtual void setLabel( const QString & l );
virtual void insertSign( const QString & s );
protected slots:
virtual void languageChange();
};
#endif // QG_DIMENSIONLABELEDITOR_H

View File

@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DimensionLabelEditor</class>
<widget class="QWidget" name="QG_DimensionLabelEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>220</width>
<height>124</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Dimension Label Editor</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="bgLabel">
<property name="title">
<string>Dimension Label:</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Label:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bDiameter">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/char_diameter.png</normaloff>:/extui/char_diameter.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="leTol1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leTol2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Insert:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbSymbol">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>⌀ (Diameter)</string>
</property>
</item>
<item>
<property name="text">
<string>° (Degree)</string>
</property>
</item>
<item>
<property name="text">
<string>± (Plus / Minus)</string>
</property>
</item>
<item>
<property name="text">
<string>π (Pi)</string>
</property>
</item>
<item>
<property name="text">
<string>× (Times)</string>
</property>
</item>
<item>
<property name="text">
<string>÷ (Division)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="../../../res/extui/extui.qrc"/>
</resources>
<connections>
<connection>
<sender>cbSymbol</sender>
<signal>activated(QString)</signal>
<receiver>QG_DimensionLabelEditor</receiver>
<slot>insertSign(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,101 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dimlinearoptions.h"
#include "rs_settings.h"
#include "rs_math.h"
#include "rs_debug.h"
#include "ui_qg_dimlinearoptions.h"
#include "rs_actiondimlinear.h"
/*
* Constructs a QG_DimLinearOptions as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_DimLinearOptions::QG_DimLinearOptions(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, ui(new Ui::Ui_DimLinearOptions{})
{
ui->setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DimLinearOptions::~QG_DimLinearOptions()
{
saveSettings();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DimLinearOptions::languageChange()
{
ui->retranslateUi(this);
}
void QG_DimLinearOptions::saveSettings() {
RS_SETTINGS->beginGroup("/Dimension");
RS_SETTINGS->writeEntry("/Angle", ui->leAngle->text());
RS_SETTINGS->endGroup();
}
void QG_DimLinearOptions::setAction(RS_ActionInterface* a, bool update) {
if (a && a->rtti()==RS2::ActionDimLinear) {
action = static_cast<RS_ActionDimLinear*>(a);
QString sa;
if (!update) {
sa = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
} else {
RS_SETTINGS->beginGroup("/Dimension");
sa = RS_SETTINGS->readEntry("/Angle", "0.0");
RS_SETTINGS->endGroup();
}
ui->leAngle->setText(sa);
} else {
RS_DEBUG->print(RS_Debug::D_ERROR,
"QG_DimLinearOptions::setAction: wrong action type");
action = nullptr;
}
}
void QG_DimLinearOptions::updateAngle(const QString & a) {
if (action) {
action->setAngle(RS_Math::deg2rad(RS_Math::eval(a)));
}
}
void QG_DimLinearOptions::setHor() {
ui->leAngle->setText("0");
}
void QG_DimLinearOptions::setVer() {
ui->leAngle->setText("90");
}

View File

@@ -0,0 +1,63 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DIMLINEAROPTIONS_H
#define QG_DIMLINEAROPTIONS_H
#include<memory>
#include<QWidget>
class RS_ActionInterface;
class RS_ActionDimLinear;
namespace Ui{
class Ui_DimLinearOptions;
}
class QG_DimLinearOptions : public QWidget
{
Q_OBJECT
public:
QG_DimLinearOptions(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_DimLinearOptions();
public slots:
virtual void setAction( RS_ActionInterface * a, bool update );
virtual void updateAngle( const QString& a );
virtual void setHor();
virtual void setVer();
protected:
RS_ActionDimLinear* action;
protected slots:
virtual void languageChange();
private:
void saveSettings();
std::unique_ptr<Ui::Ui_DimLinearOptions> ui;
};
#endif // QG_DIMLINEAROPTIONS_H

View File

@@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ui_DimLinearOptions</class>
<widget class="QWidget" name="Ui_DimLinearOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>22</height>
</size>
</property>
<property name="windowTitle">
<string>Linear Dimension Options</string>
</property>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QLabel" name="lAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>19</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Angle:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>19</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bHor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>19</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/dimhor.png</normaloff>:/extui/dimhor.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bVer">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>19</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/dimver.png</normaloff>:/extui/dimver.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="Line" name="sep1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>19</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="../../../res/extui/extui.qrc"/>
</resources>
<connections>
<connection>
<sender>leAngle</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_DimLinearOptions</receiver>
<slot>updateAngle(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>bHor</sender>
<signal>clicked()</signal>
<receiver>Ui_DimLinearOptions</receiver>
<slot>setHor()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>bVer</sender>
<signal>clicked()</signal>
<receiver>Ui_DimLinearOptions</receiver>
<slot>setVer()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

120
ui/forms/qg_dimoptions.cpp Normal file
View File

@@ -0,0 +1,120 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dimoptions.h"
#include "rs_settings.h"
#include "rs_debug.h"
#include "ui_qg_dimoptions.h"
#include "rs_actiondimension.h"
/*
* Constructs a QG_DimOptions as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
QG_DimOptions::QG_DimOptions(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl)
, ui(new Ui::Ui_DimOptions{})
{
ui->setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DimOptions::~QG_DimOptions()
{
saveSettings();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DimOptions::languageChange()
{
ui->retranslateUi(this);
}
void QG_DimOptions::saveSettings() {
RS_SETTINGS->beginGroup("/Draw");
RS_SETTINGS->writeEntry("/DimLabel", ui->leLabel->text());
RS_SETTINGS->writeEntry("/DimTol1", ui->leTol1->text());
RS_SETTINGS->writeEntry("/DimTol2", ui->leTol2->text());
RS_SETTINGS->endGroup();
}
void QG_DimOptions::setAction(RS_ActionInterface* a, bool update) {
if (a && RS_ActionDimension::isDimensionAction(a->rtti())) {
action = static_cast<RS_ActionDimension*>(a);
QString st;
QString stol1;
QString stol2;
bool diam;
if (update) {
st = action->getLabel();
stol1 = action->getTol1();
stol2 = action->getTol2();
diam = action->getDiameter();
} else {
//st = "";
RS_SETTINGS->beginGroup("/Draw");
st = RS_SETTINGS->readEntry("/DimLabel", "");
stol1 = RS_SETTINGS->readEntry("/DimTol1", "");
stol2 = RS_SETTINGS->readEntry("/DimTol2", "");
diam = (bool)RS_SETTINGS->readNumEntry("/DimDiameter", 0);
RS_SETTINGS->endGroup();
}
ui->leLabel->setText(st);
ui->leTol1->setText(stol1);
ui->leTol2->setText(stol2);
ui->bDiameter->setChecked(diam);
} else {
RS_DEBUG->print(RS_Debug::D_ERROR,
"QG_DimensionOptions::setAction: wrong action type");
action = nullptr;
}
}
void QG_DimOptions::updateLabel() {
if (action) {
action->setText("");
action->setLabel(ui->leLabel->text());
action->setDiameter(ui->bDiameter->isChecked());
action->setTol1(ui->leTol1->text());
action->setTol2(ui->leTol2->text());
action->setText(action->getText());
}
}
void QG_DimOptions::insertSign(const QString& c) {
ui->leLabel->insert(c);
}

62
ui/forms/qg_dimoptions.h Normal file
View File

@@ -0,0 +1,62 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DIMOPTIONS_H
#define QG_DIMOPTIONS_H
#include<memory>
#include<QWidget>
class RS_ActionInterface;
class RS_ActionDimension;
namespace Ui {
class Ui_DimOptions;
}
class QG_DimOptions : public QWidget
{
Q_OBJECT
public:
QG_DimOptions(QWidget* parent = 0, Qt::WindowFlags fl = 0);
~QG_DimOptions();
public slots:
virtual void setAction( RS_ActionInterface * a, bool update );
virtual void updateLabel();
virtual void insertSign( const QString & c );
protected:
RS_ActionDimension* action;
protected slots:
virtual void languageChange();
private:
void saveSettings();
std::unique_ptr<Ui::Ui_DimOptions> ui;
};
#endif // QG_DIMOPTIONS_H

285
ui/forms/qg_dimoptions.ui Normal file
View File

@@ -0,0 +1,285 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ui_DimOptions</class>
<widget class="QWidget" name="Ui_DimOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>420</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>420</width>
<height>22</height>
</size>
</property>
<property name="windowTitle">
<string>Dimension Options</string>
</property>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QLabel" name="lLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Label:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bDiameter">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/char_diameter.png</normaloff>:/extui/char_diameter.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbSymbol">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>⌀</string>
</property>
</item>
<item>
<property name="text">
<string>°</string>
</property>
</item>
<item>
<property name="text">
<string>±</string>
</property>
</item>
<item>
<property name="text">
<string>π</string>
</property>
</item>
<item>
<property name="text">
<string>×</string>
</property>
</item>
<item>
<property name="text">
<string>÷</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/tolerance1.png</normaloff>:/extui/tolerance1.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leTol1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../res/extui/extui.qrc">
<normaloff>:/extui/tolerance2.png</normaloff>:/extui/tolerance2.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leTol2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="Line" name="sep1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="../../../res/extui/extui.qrc"/>
</resources>
<connections>
<connection>
<sender>leLabel</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_DimOptions</receiver>
<slot>updateLabel()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>bDiameter</sender>
<signal>toggled(bool)</signal>
<receiver>Ui_DimOptions</receiver>
<slot>updateLabel()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leTol1</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_DimOptions</receiver>
<slot>updateLabel()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leTol2</sender>
<signal>textChanged(QString)</signal>
<receiver>Ui_DimOptions</receiver>
<slot>updateLabel()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSymbol</sender>
<signal>activated(QString)</signal>
<receiver>Ui_DimOptions</receiver>
<slot>insertSign(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

101
ui/forms/qg_dlgarc.cpp Normal file
View File

@@ -0,0 +1,101 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgarc.h"
#include "rs_arc.h"
#include "rs_graphic.h"
#include "rs_math.h"
/*
* Constructs a QG_DlgArc as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgArc::QG_DlgArc(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgArc::~QG_DlgArc()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgArc::languageChange()
{
retranslateUi(this);
}
void QG_DlgArc::setArc(RS_Arc& a) {
arc = &a;
//pen = arc->getPen();
wPen->setPen(arc->getPen(false), true, false, "Pen");
RS_Graphic* graphic = arc->getGraphic();
if (graphic) {
cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = arc->getLayer(false);
if (lay) {
cbLayer->setLayer(*lay);
}
QString s;
s.setNum(arc->getCenter().x);
leCenterX->setText(s);
s.setNum(arc->getCenter().y);
leCenterY->setText(s);
s.setNum(arc->getRadius());
leRadius->setText(s);
s.setNum(RS_Math::rad2deg(arc->getAngle1()));
leAngle1->setText(s);
s.setNum(RS_Math::rad2deg(arc->getAngle2()));
leAngle2->setText(s);
cbReversed->setChecked(arc->isReversed());
}
void QG_DlgArc::updateArc() {
arc->setCenter(RS_Vector(RS_Math::eval(leCenterX->text()),
RS_Math::eval(leCenterY->text())));
arc->setRadius(RS_Math::eval(leRadius->text()));
arc->setAngle1(RS_Math::deg2rad(RS_Math::eval(leAngle1->text())));
arc->setAngle2(RS_Math::deg2rad(RS_Math::eval(leAngle2->text())));
arc->setReversed(cbReversed->isChecked());
arc->setPen(wPen->getPen());
arc->setLayer(cbLayer->currentText());
arc->calculateBorders();
}

53
ui/forms/qg_dlgarc.h Normal file
View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGARC_H
#define QG_DLGARC_H
class RS_Arc;
#include "ui_qg_dlgarc.h"
class QG_DlgArc : public QDialog, public Ui::QG_DlgArc
{
Q_OBJECT
public:
QG_DlgArc(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgArc();
public slots:
virtual void setArc( RS_Arc & a );
virtual void updateArc();
protected slots:
virtual void languageChange();
private:
RS_Arc* arc;
};
#endif // QG_DLGARC_H

283
ui/forms/qg_dlgarc.ui Normal file
View File

@@ -0,0 +1,283 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgArc</class>
<widget class="QDialog" name="QG_DlgArc">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>389</width>
<height>251</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>190</height>
</size>
</property>
<property name="windowTitle">
<string>Arc</string>
</property>
<layout class="QVBoxLayout" name="gfdgf">
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="buttonGroup8">
<property name="title">
<string>Geometry</string>
</property>
<layout class="QGridLayout">
<item row="2" column="0">
<widget class="QLabel" name="lEndX">
<property name="text">
<string>Radius:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leRadius">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lCenterY">
<property name="text">
<string>Center (y):</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leCenterY">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lCenterX">
<property name="text">
<string>Center (x):</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leCenterX">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lAngle1">
<property name="text">
<string>Start Angle:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="leAngle1">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="leAngle2">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lAngle2">
<property name="text">
<string>End Angle:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="spacer58">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1">
<spacer name="spacer61">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="cbReversed">
<property name="text">
<string>Reversed</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leCenterX</tabstop>
<tabstop>leCenterY</tabstop>
<tabstop>leRadius</tabstop>
<tabstop>leAngle1</tabstop>
<tabstop>leAngle2</tabstop>
<tabstop>cbReversed</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgArc</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>189</x>
<y>234</y>
</hint>
<hint type="destinationlabel">
<x>189</x>
<y>125</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgArc</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>189</x>
<y>234</y>
</hint>
<hint type="destinationlabel">
<x>189</x>
<y>125</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,89 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgattributes.h"
/*
* Constructs a QG_DlgAttributes as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgAttributes::QG_DlgAttributes(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgAttributes::~QG_DlgAttributes()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgAttributes::languageChange()
{
retranslateUi(this);
}
void QG_DlgAttributes::setData(RS_AttributesData* data, RS_LayerList& layerList) {
this->data = data;
//pen = line->getPen();
wPen->setPen(data->pen, true, true, "Pen");
//RS_Graphic* graphic = line->getGraphic();
//if (graphic) {
cbLayer->init(layerList, false, true);
//}
//cbLayer->setLayer(data->layer);
//RS_Layer* lay = line->getLayer(false);
//if (lay) {
// cbLayer->setLayer(*lay);
//}
}
void QG_DlgAttributes::updateData() {
data->pen = wPen->getPen();
data->layer = cbLayer->currentText();
data->changeColor = !wPen->isColorUnchanged();
data->changeLineType = !wPen->isLineTypeUnchanged();
data->changeWidth = !wPen->isWidthUnchanged();
data->changeLayer = !cbLayer->isUnchanged();
data->applyBlockDeep = cbBlockDeep->isChecked();
}

View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGATTRIBUTES_H
#define QG_DLGATTRIBUTES_H
#include "ui_qg_dlgattributes.h"
#include "rs_modification.h"
class QG_DlgAttributes : public QDialog, public Ui::QG_DlgAttributes
{
Q_OBJECT
public:
QG_DlgAttributes(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgAttributes();
public slots:
virtual void setData( RS_AttributesData * data, RS_LayerList & layerList );
virtual void updateData();
protected slots:
virtual void languageChange();
private:
RS_Pen pen;
RS_AttributesData* data;
};
#endif // QG_DLGATTRIBUTES_H

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgAttributes</class>
<widget class="QDialog" name="QG_DlgAttributes">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>192</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Attributes</string>
</property>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbBlockDeep">
<property name="toolTip">
<string>Apply attributes also to all sub-entities of selected INSERT.
This recursively modifies all entities of the Block itself.</string>
</property>
<property name="text">
<string>Apply attributes Block-deep</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgAttributes</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgAttributes</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

94
ui/forms/qg_dlgcircle.cpp Normal file
View File

@@ -0,0 +1,94 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgcircle.h"
#include "rs_circle.h"
#include "rs_graphic.h"
#include "rs_math.h"
/*
* Constructs a QG_DlgCircle as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgCircle::QG_DlgCircle(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgCircle::~QG_DlgCircle()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgCircle::languageChange()
{
retranslateUi(this);
}
void QG_DlgCircle::setCircle(RS_Circle& c) {
circle = &c;
//pen = circle->getPen();
wPen->setPen(circle->getPen(false), true, false, "Pen");
RS_Graphic* graphic = circle->getGraphic();
if (graphic) {
cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = circle->getLayer(false);
if (lay) {
cbLayer->setLayer(*lay);
}
QString s;
s.setNum(circle->getCenter().x);
leCenterX->setText(s);
s.setNum(circle->getCenter().y);
leCenterY->setText(s);
s.setNum(circle->getRadius());
leRadius->setText(s);
}
void QG_DlgCircle::updateCircle() {
circle->setCenter(RS_Vector(RS_Math::eval(leCenterX->text()),
RS_Math::eval(leCenterY->text())));
circle->setRadius(RS_Math::eval(leRadius->text()));
circle->setPen(wPen->getPen());
circle->setLayer(cbLayer->currentText());
circle->calculateBorders();
}

53
ui/forms/qg_dlgcircle.h Normal file
View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGCIRCLE_H
#define QG_DLGCIRCLE_H
class RS_Circle;
#include "ui_qg_dlgcircle.h"
class QG_DlgCircle : public QDialog, public Ui::QG_DlgCircle
{
Q_OBJECT
public:
QG_DlgCircle(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgCircle();
public slots:
virtual void setCircle( RS_Circle & c );
virtual void updateCircle();
protected slots:
virtual void languageChange();
private:
RS_Circle* circle;
};
#endif // QG_DLGCIRCLE_H

233
ui/forms/qg_dlgcircle.ui Normal file
View File

@@ -0,0 +1,233 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgCircle</class>
<widget class="QDialog" name="QG_DlgCircle">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>192</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>190</height>
</size>
</property>
<property name="windowTitle">
<string>Circle</string>
</property>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="buttonGroup8">
<property name="title">
<string>Geometry</string>
</property>
<layout class="QGridLayout">
<item row="2" column="0">
<widget class="QLabel" name="lEndX">
<property name="text">
<string>Radius:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leRadius">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lCenterY">
<property name="text">
<string>Center (y):</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leCenterY">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lCenterX">
<property name="text">
<string>Center (x):</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leCenterX">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="spacer58">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<spacer name="spacer61">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leCenterX</tabstop>
<tabstop>leCenterY</tabstop>
<tabstop>leRadius</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgCircle</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>189</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgCircle</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>189</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,82 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgdimension.h"
#include "rs_graphic.h"
/*
* Constructs a QG_DlgDimension as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgDimension::QG_DlgDimension(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgDimension::~QG_DlgDimension()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgDimension::languageChange()
{
retranslateUi(this);
}
void QG_DlgDimension::setDim(RS_Dimension& d) {
dim = &d;
wPen->setPen(dim->getPen(false), true, false, "Pen");
RS_Graphic* graphic = dim->getGraphic();
if (graphic) {
cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = dim->getLayer(false);
if (lay) {
cbLayer->setLayer(*lay);
}
wLabel->setLabel(dim->getLabel(false));
}
void QG_DlgDimension::updateDim() {
dim->setLabel(wLabel->getLabel());
dim->setPen(wPen->getPen());
dim->setLayer(cbLayer->currentText());
}

View File

@@ -0,0 +1,52 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGDIMENSION_H
#define QG_DLGDIMENSION_H
#include "ui_qg_dlgdimension.h"
#include "rs_dimension.h"
class QG_DlgDimension : public QDialog, public Ui::QG_DlgDimension
{
Q_OBJECT
public:
QG_DlgDimension(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgDimension();
public slots:
virtual void setDim( RS_Dimension & d );
virtual void updateDim();
protected slots:
virtual void languageChange();
private:
RS_Dimension* dim;
};
#endif // QG_DLGDIMENSION_H

138
ui/forms/qg_dlgdimension.ui Normal file
View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgDimension</class>
<widget class="QDialog" name="QG_DlgDimension">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>218</height>
</rect>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Dimension</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>11</number>
</property>
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QG_DimensionLabelEditor" name="wLabel" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
<customwidget>
<class>QG_DimensionLabelEditor</class>
<extends>QWidget</extends>
<header>qg_dimensionlabeleditor.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgDimension</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>211</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgDimension</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>211</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,86 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgdimlinear.h"
#include "rs_dimlinear.h"
#include "rs_graphic.h"
#include "rs_math.h"
/*
* Constructs a QG_DlgDimLinear as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgDimLinear::QG_DlgDimLinear(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgDimLinear::~QG_DlgDimLinear()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgDimLinear::languageChange()
{
retranslateUi(this);
}
void QG_DlgDimLinear::setDim(RS_DimLinear& d) {
dim = &d;
wPen->setPen(dim->getPen(false), true, false, "Pen");
RS_Graphic* graphic = dim->getGraphic();
if (graphic) {
cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = dim->getLayer(false);
if (lay) {
cbLayer->setLayer(*lay);
}
wLabel->setLabel(dim->getLabel(false));
leAngle->setText(QString("%1").arg(RS_Math::rad2deg(dim->getAngle())));
}
void QG_DlgDimLinear::updateDim() {
dim->setLabel(wLabel->getLabel());
dim->setAngle(RS_Math::deg2rad(RS_Math::eval(leAngle->text(), 0.0)));
dim->setPen(wPen->getPen());
dim->setLayer(cbLayer->currentText());
}

View File

@@ -0,0 +1,52 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGDIMLINEAR_H
#define QG_DLGDIMLINEAR_H
#include "ui_qg_dlgdimlinear.h"
class RS_DimLinear;
class QG_DlgDimLinear : public QDialog, public Ui::QG_DlgDimLinear
{
Q_OBJECT
public:
QG_DlgDimLinear(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgDimLinear();
public slots:
virtual void setDim( RS_DimLinear & d );
virtual void updateDim();
protected slots:
virtual void languageChange();
private:
RS_DimLinear* dim;
};
#endif // QG_DLGDIMLINEAR_H

198
ui/forms/qg_dlgdimlinear.ui Normal file
View File

@@ -0,0 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgDimLinear</class>
<widget class="QDialog" name="QG_DlgDimLinear">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>218</height>
</rect>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Linear Dimension</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>11</number>
</property>
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QG_DimensionLabelEditor" name="wLabel" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="bgGeometry">
<property name="title">
<string>Geometry</string>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>19</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Angle:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>19</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
<customwidget>
<class>QG_DimensionLabelEditor</class>
<extends>QWidget</extends>
<header>qg_dimensionlabeleditor.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgDimLinear</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>211</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgDimLinear</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>211</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

112
ui/forms/qg_dlgellipse.cpp Normal file
View File

@@ -0,0 +1,112 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgellipse.h"
#include "rs_ellipse.h"
#include "rs_graphic.h"
#include "rs_math.h"
/*
* Constructs a QG_DlgEllipse as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgEllipse::QG_DlgEllipse(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgEllipse::~QG_DlgEllipse()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgEllipse::languageChange()
{
retranslateUi(this);
}
void QG_DlgEllipse::setEllipse(RS_Ellipse& e) {
ellipse = &e;
//pen = ellipse->getPen();
wPen->setPen(ellipse->getPen(false), true, false, "Pen");
RS_Graphic* graphic = ellipse->getGraphic();
if (graphic) {
cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = ellipse->getLayer(false);
if (lay) {
cbLayer->setLayer(*lay);
}
QString s;
s.setNum(ellipse->getCenter().x);
leCenterX->setText(s);
s.setNum(ellipse->getCenter().y);
leCenterY->setText(s);
s.setNum(ellipse->getMajorP().magnitude());
leMajor->setText(s);
s.setNum(ellipse->getMajorP().magnitude()*ellipse->getRatio());
leMinor->setText(s);
s.setNum(RS_Math::rad2deg(ellipse->getMajorP().angle()));
leRotation->setText(s);
s.setNum(RS_Math::rad2deg(ellipse->getAngle1()));
leAngle1->setText(s);
s.setNum(RS_Math::rad2deg(ellipse->getAngle2()));
leAngle2->setText(s);
cbReversed->setChecked(ellipse->isReversed());
}
void QG_DlgEllipse::updateEllipse() {
ellipse->setCenter(RS_Vector(RS_Math::eval(leCenterX->text()),
RS_Math::eval(leCenterY->text())));
RS_Vector v = RS_Vector::polar(RS_Math::eval(leMajor->text()),
RS_Math::deg2rad(RS_Math::eval(leRotation->text())));
ellipse->setMajorP(v);
if (RS_Math::eval(leMajor->text())>1.0e-6) {
ellipse->setRatio(RS_Math::eval(leMinor->text())/RS_Math::eval(leMajor->text()));
}
else {
ellipse->setRatio(1.0);
}
ellipse->setAngle1(RS_Math::deg2rad(RS_Math::eval(leAngle1->text())));
ellipse->setAngle2(RS_Math::deg2rad(RS_Math::eval(leAngle2->text())));
ellipse->setReversed(cbReversed->isChecked());
ellipse->setPen(wPen->getPen());
ellipse->setLayer(cbLayer->currentText());
}

53
ui/forms/qg_dlgellipse.h Normal file
View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGELLIPSE_H
#define QG_DLGELLIPSE_H
class RS_Ellipse;
#include "ui_qg_dlgellipse.h"
class QG_DlgEllipse : public QDialog, public Ui::QG_DlgEllipse
{
Q_OBJECT
public:
QG_DlgEllipse(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgEllipse();
public slots:
virtual void setEllipse( RS_Ellipse & e );
virtual void updateEllipse();
protected slots:
virtual void languageChange();
private:
RS_Ellipse* ellipse;
};
#endif // QG_DLGELLIPSE_H

325
ui/forms/qg_dlgellipse.ui Normal file
View File

@@ -0,0 +1,325 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgEllipse</class>
<widget class="QDialog" name="QG_DlgEllipse">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>394</width>
<height>307</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>190</height>
</size>
</property>
<property name="windowTitle">
<string>Ellipse</string>
</property>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="buttonGroup8">
<property name="title">
<string>Geometry</string>
</property>
<layout class="QGridLayout">
<item row="1" column="0">
<widget class="QLabel" name="lCenterY">
<property name="text">
<string>Center (y):</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leCenterY">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lCenterX">
<property name="text">
<string>Center (x):</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leCenterX">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="spacer58">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="1">
<spacer name="spacer61">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lAngle2">
<property name="text">
<string>End Angle:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="leAngle2">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="leAngle1">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lAngle1">
<property name="text">
<string>Start Angle:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lRotation">
<property name="text">
<string>Rotation:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="leRotation">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="leMinor">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lMinor">
<property name="text">
<string>Minor:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lMajor">
<property name="text">
<string>Major:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leMajor">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="cbReversed">
<property name="text">
<string>Reversed</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leCenterX</tabstop>
<tabstop>leCenterY</tabstop>
<tabstop>leMajor</tabstop>
<tabstop>leMinor</tabstop>
<tabstop>leRotation</tabstop>
<tabstop>leAngle1</tabstop>
<tabstop>leAngle2</tabstop>
<tabstop>cbReversed</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgEllipse</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>196</x>
<y>290</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgEllipse</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>196</x>
<y>290</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

201
ui/forms/qg_dlghatch.cpp Normal file
View File

@@ -0,0 +1,201 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlghatch.h"
#include "rs_settings.h"
#include "rs_line.h"
#include "rs_hatch.h"
#include "rs_patternlist.h"
#include "rs_pattern.h"
#include "rs_math.h"
#include "rs_math.h"
/*
* Constructs a QG_DlgHatch as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgHatch::QG_DlgHatch(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
init();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgHatch::languageChange()
{
retranslateUi(this);
}
void QG_DlgHatch::init() {
pattern=nullptr;
hatch = nullptr;
isNew = false;
preview = new RS_EntityContainer();
gvPreview->setContainer(preview);
gvPreview->setBorders(15,15,15,15);
gvPreview->addScrollbars();
cbPattern->init();
}
void QG_DlgHatch::polish() {
QDialog::ensurePolished();
gvPreview->zoomAuto();
}
void QG_DlgHatch::showEvent ( QShowEvent * e) {
QDialog::showEvent(e);
gvPreview->zoomAuto();
}
QG_DlgHatch::~QG_DlgHatch()
{
delete preview;
}
void QG_DlgHatch::setHatch(RS_Hatch& h, bool isNew) {
hatch = &h;
this->isNew = isNew;
RS_SETTINGS->beginGroup("/Draw");
QString enablePrev = RS_SETTINGS->readEntry("/HatchPreview", "0");
RS_SETTINGS->endGroup();
cbEnablePreview->setChecked(enablePrev=="1");
// read defaults from config file:
if (isNew) {
RS_SETTINGS->beginGroup("/Draw");
QString solid = RS_SETTINGS->readEntry("/HatchSolid", "0");
QString pat = RS_SETTINGS->readEntry("/HatchPattern", "ANSI31");
QString scale = RS_SETTINGS->readEntry("/HatchScale", "1.0");
QString angle = RS_SETTINGS->readEntry("/HatchAngle", "0.0");
RS_SETTINGS->endGroup();
cbSolid->setChecked(solid=="1");
setPattern(pat);
leScale->setText(scale);
leAngle->setText(angle);
}
// initialize dialog based on given hatch:
else {
cbSolid->setChecked(hatch->isSolid());
setPattern(hatch->getPattern());
QString s;
s.setNum(hatch->getScale());
leScale->setText(s);
s.setNum(RS_Math::rad2deg(hatch->getAngle()));
leAngle->setText(s);
}
}
void QG_DlgHatch::updateHatch() {
if (hatch) {
hatch->setSolid(cbSolid->isChecked());
hatch->setPattern(cbPattern->currentText());
hatch->setScale(RS_Math::eval(leScale->text()));
hatch->setAngle(RS_Math::deg2rad(RS_Math::eval(leAngle->text())));
}
}
void QG_DlgHatch::setPattern(const QString& p) {
if (!RS_PATTERNLIST->contains(p)) {
cbPattern->addItem(p);
}
cbPattern->setCurrentIndex( cbPattern->findText(p) );
pattern = cbPattern->getPattern();
}
void QG_DlgHatch::resizeEvent ( QResizeEvent * ) {
updatePreview();
}
void QG_DlgHatch::updatePreview() {
if (preview==nullptr) {
return;
}
if (hatch==nullptr || !cbEnablePreview->isChecked()) {
preview->clear();
gvPreview->zoomAuto();
return;
}
pattern = cbPattern->getPattern();
if (pattern->countDeep()==0)
return;
QString patName = cbPattern->currentText();
bool isSolid = cbSolid->isChecked();
double scale = RS_Math::eval(leScale->text(), 1.0);
double angle = RS_Math::deg2rad(RS_Math::eval(leAngle->text(), 0.0));
double prevSize = 100.0;
if (pattern) {
pattern->calculateBorders();
prevSize = std::max(prevSize, pattern->getSize().magnitude());
}
preview->clear();
RS_Hatch* prevHatch = new RS_Hatch(preview,
RS_HatchData(isSolid, scale, angle, patName));
prevHatch->setPen(hatch->getPen());
RS_EntityContainer* loop = new RS_EntityContainer(prevHatch);
loop->setPen(RS_Pen(RS2::FlagInvalid));
loop->addRectangle({0., 0.}, {prevSize,prevSize});
prevHatch->addEntity(loop);
preview->addEntity(prevHatch);
if (!isSolid) {
prevHatch->update();
}
gvPreview->zoomAuto();
}
void QG_DlgHatch::saveSettings()
{
if (isNew)
{
RS_SETTINGS->beginGroup("/Draw");
RS_SETTINGS->writeEntry("/HatchSolid", cbSolid->isChecked());
RS_SETTINGS->writeEntry("/HatchPattern", cbPattern->currentText());
RS_SETTINGS->writeEntry("/HatchScale", leScale->text());
RS_SETTINGS->writeEntry("/HatchAngle", leAngle->text());
RS_SETTINGS->writeEntry("/HatchPreview", cbEnablePreview->isChecked());
RS_SETTINGS->endGroup();
}
}

65
ui/forms/qg_dlghatch.h Normal file
View File

@@ -0,0 +1,65 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGHATCH_H
#define QG_DLGHATCH_H
#include "ui_qg_dlghatch.h"
class RS_Hatch;
class QG_DlgHatch : public QDialog, public Ui::QG_DlgHatch
{
Q_OBJECT
public:
QG_DlgHatch(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgHatch();
void saveSettings();
public slots:
virtual void polish();
virtual void showEvent( QShowEvent * e );
virtual void setHatch( RS_Hatch & h, bool isNew );
virtual void updateHatch();
virtual void setPattern( const QString & p );
virtual void resizeEvent( QResizeEvent * );
virtual void updatePreview();
protected slots:
virtual void languageChange();
private:
RS_EntityContainer* preview;
bool isNew;
RS_Pattern* pattern;
RS_Hatch* hatch;
void init();
};
#endif // QG_DLGHATCH_H

308
ui/forms/qg_dlghatch.ui Normal file
View File

@@ -0,0 +1,308 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgHatch</class>
<widget class="QDialog" name="QG_DlgHatch">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>438</width>
<height>294</height>
</rect>
</property>
<property name="windowTitle">
<string>Choose Hatch Attributes</string>
</property>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QGroupBox" name="bgParameter">
<property name="title">
<string>Pattern</string>
</property>
<layout class="QGridLayout">
<item row="2" column="1">
<widget class="QLineEdit" name="leScale"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="leAngle"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lAngle">
<property name="text">
<string>Angle:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lScale">
<property name="text">
<string>Scale:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QG_PatternBox" name="cbPattern" native="true"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="cbSolid">
<property name="text">
<string>Solid Fill</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="bgPreview">
<property name="title">
<string>Preview</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QCheckBox" name="cbEnablePreview">
<property name="text">
<string>Enable Preview</string>
</property>
</widget>
</item>
<item>
<widget class="QG_GraphicView" name="gvPreview" native="true"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_PatternBox</class>
<extends>QWidget</extends>
<header>qg_patternbox.h</header>
</customwidget>
<customwidget>
<class>QG_GraphicView</class>
<extends>QWidget</extends>
<header>qg_graphicview.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cbSolid</tabstop>
<tabstop>leScale</tabstop>
<tabstop>leAngle</tabstop>
<tabstop>cbEnablePreview</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgHatch</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>218</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgHatch</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>218</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSolid</sender>
<signal>toggled(bool)</signal>
<receiver>cbPattern</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSolid</sender>
<signal>toggled(bool)</signal>
<receiver>leScale</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSolid</sender>
<signal>toggled(bool)</signal>
<receiver>lScale</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSolid</sender>
<signal>toggled(bool)</signal>
<receiver>leAngle</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSolid</sender>
<signal>toggled(bool)</signal>
<receiver>lAngle</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbPattern</sender>
<signal>patternChanged()</signal>
<receiver>QG_DlgHatch</receiver>
<slot>updatePreview()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSolid</sender>
<signal>toggled(bool)</signal>
<receiver>QG_DlgHatch</receiver>
<slot>updatePreview()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leAngle</sender>
<signal>textChanged(QString)</signal>
<receiver>QG_DlgHatch</receiver>
<slot>updatePreview()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leScale</sender>
<signal>textChanged(QString)</signal>
<receiver>QG_DlgHatch</receiver>
<slot>updatePreview()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbEnablePreview</sender>
<signal>toggled(bool)</signal>
<receiver>QG_DlgHatch</receiver>
<slot>updatePreview()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

137
ui/forms/qg_dlgimage.cpp Normal file
View File

@@ -0,0 +1,137 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2011 Rallaz (rallazz@gmail.com)
**
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgimage.h"
#include "rs_image.h"
#include "rs_graphic.h"
#include "rs_math.h"
/*
* Constructs a QG_DlgImage as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgImage::QG_DlgImage(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgImage::~QG_DlgImage()
{
delete val;
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgImage::languageChange()
{
retranslateUi(this);
}
void QG_DlgImage::setImage(RS_Image& e) {
image = &e;
val = new QDoubleValidator(leScale);
//pen = spline->getPen();
wPen->setPen(image->getPen(false), true, false, "Pen");
RS_Graphic* graphic = image->getGraphic();
if (graphic) {
cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = image->getLayer(false);
if (lay) {
cbLayer->setLayer(*lay);
}
leInsertX->setValidator(val);
leInsertY->setValidator(val);
leWidth->setValidator(val);
leHeight->setValidator(val);
leScale->setValidator(val);
leAngle->setValidator(val);
scale = image->getUVector().magnitude();
leInsertX->setText(QString("%1").arg(image->getInsertionPoint().x));
leInsertY->setText(QString("%1").arg(image->getInsertionPoint().y));
leWidth->setText(QString("%1").arg(image->getImageWidth()));
leHeight->setText(QString("%1").arg(image->getImageHeight()));
leScale->setText(QString("%1").arg(scale));
leAngle->setText(QString("%1").arg( RS_Math::rad2deg(image->getUVector().angle()) ));
lePath->setText(image->getFile());
leSize->setText(QString("%1 x %2").arg(image->getWidth()).arg(image->getHeight()));
leDPI->setText(QString("%1").arg(RS_Units::scaleToDpi(scale,image->getGraphicUnit())));
}
void QG_DlgImage::changeWidth() {
double width = leWidth->text().toDouble();
scale = width / image->getWidth();
leHeight->setText(QString("%1").arg(image->getHeight() * scale));
leScale->setText(QString("%1").arg(scale));
}
void QG_DlgImage::changeHeight() {
double height = leHeight->text().toDouble();
scale = height / image->getHeight();
leWidth->setText(QString("%1").arg(image->getWidth() * scale));
leScale->setText(QString("%1").arg(scale));
}
void QG_DlgImage::changeScale() {
scale = leScale->text().toDouble();
leWidth->setText(QString("%1").arg(image->getWidth() * scale));
leHeight->setText(QString("%1").arg(image->getHeight() * scale));
leDPI->setText(QString("%1").arg(RS_Units::scaleToDpi(scale, image->getGraphicUnit())));
}
void QG_DlgImage::changeDPI(){
scale = RS_Units::dpiToScale(leDPI->text().toDouble(), image->getGraphicUnit());
leScale->setText(QString("%1").arg(scale));
leWidth->setText(QString("%1").arg(image->getWidth() * scale));
leHeight->setText(QString("%1").arg(image->getHeight() * scale));
}
void QG_DlgImage::updateImage() {
image->setPen(wPen->getPen());
image->setLayer(cbLayer->currentText());
image->setInsertionPoint(RS_Vector(leInsertX->text().toDouble(), leInsertY->text().toDouble()) );
double orgScale = image->getUVector().magnitude();
scale /= orgScale;
double orgAngle = image->getUVector().angle();
double angle = RS_Math::deg2rad( leAngle->text().toDouble() );
image->scale(image->getInsertionPoint(), RS_Vector(scale, scale));
image->rotate(image->getInsertionPoint(), angle - orgAngle);
image->update();
}

58
ui/forms/qg_dlgimage.h Normal file
View File

@@ -0,0 +1,58 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2011 Rallaz (rallazz@gmail.com)
**
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGIMAGE_H
#define QG_DLGIMAGE_H
class RS_Image;
#include "ui_qg_dlgimage.h"
class QG_DlgImage : public QDialog, public Ui::QG_DlgImage
{
Q_OBJECT
public:
QG_DlgImage(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgImage();
public slots:
virtual void setImage( RS_Image & e );
virtual void changeWidth();
virtual void changeHeight();
virtual void changeScale();
virtual void changeDPI();
virtual void updateImage();
protected slots:
virtual void languageChange();
private:
RS_Image* image;
double scale;
QDoubleValidator *val;
};
#endif // QG_DLGIMAGE_H

410
ui/forms/qg_dlgimage.ui Normal file
View File

@@ -0,0 +1,410 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgImage</class>
<widget class="QDialog" name="QG_DlgImage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>426</width>
<height>331</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>190</height>
</size>
</property>
<property name="windowTitle">
<string>Image</string>
</property>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QG_LayerBox" name="cbLayer" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QG_WidgetPen" name="wPen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="buttonGroup8">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Geometry</string>
</property>
<layout class="QGridLayout">
<item row="2" column="0">
<widget class="QLabel" name="lWidth">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lePath">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leInsertY">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lHeight">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lInsertX">
<property name="text">
<string>insert (x):</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lScale">
<property name="text">
<string>Scale:</string>
</property>
</widget>
</item>
<item row="9" column="0">
<spacer name="spacer58">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="leSize">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="lSize">
<property name="text">
<string>Size (px):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leInsertX">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lPath">
<property name="text">
<string>path:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<spacer name="spacer61">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lInsertY">
<property name="text">
<string>insert (y):</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="leScale">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lAngle">
<property name="text">
<string>Angle:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leWidth">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="leHeight">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="leAngle">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="lDPI">
<property name="text">
<string>DPI</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="leDPI"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QG_WidgetPen</class>
<extends>QWidget</extends>
<header>qg_widgetpen.h</header>
</customwidget>
<customwidget>
<class>QG_LayerBox</class>
<extends>QWidget</extends>
<header>qg_layerbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leInsertX</tabstop>
<tabstop>leInsertY</tabstop>
<tabstop>leWidth</tabstop>
<tabstop>leHeight</tabstop>
<tabstop>leScale</tabstop>
<tabstop>leAngle</tabstop>
<tabstop>lePath</tabstop>
<tabstop>leSize</tabstop>
<tabstop>leDPI</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgImage</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>212</x>
<y>314</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_DlgImage</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>212</x>
<y>314</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leWidth</sender>
<signal>editingFinished()</signal>
<receiver>QG_DlgImage</receiver>
<slot>changeWidth()</slot>
<hints>
<hint type="sourcelabel">
<x>351</x>
<y>98</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>277</y>
</hint>
</hints>
</connection>
<connection>
<sender>leHeight</sender>
<signal>editingFinished()</signal>
<receiver>QG_DlgImage</receiver>
<slot>changeHeight()</slot>
<hints>
<hint type="sourcelabel">
<x>325</x>
<y>122</y>
</hint>
<hint type="destinationlabel">
<x>196</x>
<y>153</y>
</hint>
</hints>
</connection>
<connection>
<sender>leScale</sender>
<signal>editingFinished()</signal>
<receiver>QG_DlgImage</receiver>
<slot>changeScale()</slot>
<hints>
<hint type="sourcelabel">
<x>325</x>
<y>149</y>
</hint>
<hint type="destinationlabel">
<x>196</x>
<y>153</y>
</hint>
</hints>
</connection>
<connection>
<sender>leDPI</sender>
<signal>editingFinished()</signal>
<receiver>QG_DlgImage</receiver>
<slot>changeDPI()</slot>
<hints>
<hint type="sourcelabel">
<x>267</x>
<y>258</y>
</hint>
<hint type="destinationlabel">
<x>217</x>
<y>282</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>changeWidth()</slot>
<slot>changeHeight()</slot>
<slot>changeScale()</slot>
<slot>changeDPI()</slot>
</slots>
</ui>

View File

@@ -0,0 +1,188 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlgimageoptions.h"
#include "rs_math.h"
#include "rs_settings.h"
/*
* Constructs a QG_ImageOptionsDialog as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_ImageOptionsDialog::QG_ImageOptionsDialog(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
init();
}
/*
* Destroys the object and frees any allocated resources
*/
QG_ImageOptionsDialog::~QG_ImageOptionsDialog()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_ImageOptionsDialog::languageChange()
{
retranslateUi(this);
}
void QG_ImageOptionsDialog::init() {
graphicSize = RS_Vector(0.0,0.0);
updateEnabled = false;
useResolution = true;
RS_SETTINGS->beginGroup("/Export");
if (RS_SETTINGS->readEntry("/UseResolution", "1")=="1") {
cbResolution->setCurrentIndex(cbResolution->findText(QString("%1").arg(RS_SETTINGS->readEntry("/Resolution","1"))));
}
else {
leWidth->setText(RS_SETTINGS->readEntry("/Width", "640"));
leHeight->setText(RS_SETTINGS->readEntry("/Height", "480"));
}
if (RS_SETTINGS->readEntry("/BlackBackground", "0")=="1") {
rbBlack->setChecked(true);
rbWhite->setChecked(false);
}
else {
rbBlack->setChecked(false);
rbWhite->setChecked(true);
}
if (RS_SETTINGS->readEntry("/BlackWhite", "1")=="1") {
rbBlackWhite->setChecked(true);
rbColoured->setChecked(false);
}
else {
rbBlackWhite->setChecked(false);
rbColoured->setChecked(true);
}
leLeftRight->setText(RS_SETTINGS->readEntry("/BorderLeftRight", "5"));
leTopBottom->setText(RS_SETTINGS->readEntry("/BorderTopBottom", "5"));
if (RS_SETTINGS->readEntry("/BorderSameSize", "1")=="1") {
cbSameBorders->setChecked(true);
sameBordersChanged();
}
RS_SETTINGS->endGroup();
updateEnabled = true;
}
void QG_ImageOptionsDialog::setGraphicSize(const RS_Vector& s) {
graphicSize = s;
if(!useResolution){
sizeChanged();
}
else {
resolutionChanged();
}
}
void QG_ImageOptionsDialog::ok() {
RS_SETTINGS->beginGroup("/Export");
RS_SETTINGS->writeEntry("/UseResolution", (int)useResolution);
RS_SETTINGS->writeEntry("/Resolution", cbResolution->currentText());
RS_SETTINGS->writeEntry("/Width", leWidth->text());
RS_SETTINGS->writeEntry("/Height", leHeight->text());
RS_SETTINGS->writeEntry("/BorderLeftRight", leLeftRight->text());
RS_SETTINGS->writeEntry("/BorderTopBottom", leTopBottom->text());
RS_SETTINGS->writeEntry("/BorderSameSize", (int)cbSameBorders->isChecked());
RS_SETTINGS->writeEntry("/BlackBackground", (int)rbBlack->isChecked());
RS_SETTINGS->writeEntry("/BlackWhite", (int)rbBlackWhite->isChecked());
RS_SETTINGS->endGroup();
accept();
}
void QG_ImageOptionsDialog::sameBordersChanged() {
if(cbSameBorders->isChecked()) {
leTopBottom->setText(leLeftRight->text());
leTopBottom->setDisabled(true);
}
else {
leTopBottom->setEnabled(true);
}
}
void QG_ImageOptionsDialog::borderChanged() {
if(cbSameBorders->isChecked()) {
leTopBottom->setText(leLeftRight->text());
}
}
void QG_ImageOptionsDialog::sizeChanged() {
if (updateEnabled) {
updateEnabled = false;
useResolution = false;
cbResolution->setCurrentIndex(cbResolution->findText("auto"));
updateEnabled = true;
}
}
void QG_ImageOptionsDialog::resolutionChanged() {
if (updateEnabled) {
updateEnabled = false;
bool ok = false;
double res = RS_Math::eval(cbResolution->currentText(), &ok);
if (!ok) {
res = 1.0;
}
int w = RS_Math::round(res * graphicSize.x);
int h = RS_Math::round(res * graphicSize.y);
useResolution = true;
leWidth->setText(QString("%1").arg(w));
leHeight->setText(QString("%1").arg(h));
updateEnabled = true;
}
}
QSize QG_ImageOptionsDialog::getSize() {
return QSize(RS_Math::round(RS_Math::eval(leWidth->text())),
RS_Math::round(RS_Math::eval(leHeight->text())));
}
QSize QG_ImageOptionsDialog::getBorders() {
return QSize(RS_Math::round(RS_Math::eval(leLeftRight->text())),
RS_Math::round(RS_Math::eval(leTopBottom->text())));
}
bool QG_ImageOptionsDialog::isBackgroundBlack() {
return rbBlack->isChecked();
}
bool QG_ImageOptionsDialog::isBlackWhite() {
return rbBlackWhite->isChecked();
}

View File

@@ -0,0 +1,65 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_IMAGEOPTIONSDIALOG_H
#define QG_IMAGEOPTIONSDIALOG_H
#include "ui_qg_dlgimageoptions.h"
#include "rs_vector.h"
class QG_ImageOptionsDialog : public QDialog, public Ui::QG_ImageOptionsDialog
{
Q_OBJECT
public:
QG_ImageOptionsDialog(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_ImageOptionsDialog();
virtual QSize getSize();
virtual QSize getBorders();
virtual bool isBackgroundBlack();
virtual bool isBlackWhite();
public slots:
virtual void setGraphicSize( const RS_Vector & s );
virtual void ok();
virtual void sizeChanged();
virtual void resolutionChanged();
virtual void sameBordersChanged();
virtual void borderChanged();
protected slots:
virtual void languageChange();
private:
RS_Vector graphicSize;
bool updateEnabled;
bool useResolution;
void init();
};
#endif // QG_IMAGEOPTIONSDIALOG_H

View File

@@ -0,0 +1,496 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_ImageOptionsDialog</class>
<widget class="QDialog" name="QG_ImageOptionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>545</height>
</rect>
</property>
<property name="windowTitle">
<string>Image Export Options</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="bgSize">
<property name="title">
<string>Bitmap Size</string>
</property>
<layout class="QGridLayout">
<item row="2" column="1">
<widget class="QLabel" name="lResolution">
<property name="text">
<string>Resolution:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cbResolution">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>auto</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">3</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">5</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">10</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">15</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">20</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">25</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">50</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">75</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">100</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">150</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">300</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">600</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">1200</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QLabel" name="lWidth">
<property name="text">
<string>Width:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="lHeight">
<property name="text">
<string>Height:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="leHeight">
<property name="text">
<string notr="true">480</string>
</property>
<property name="placeholderText">
<string notr="true"/>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="leWidth">
<property name="text">
<string notr="true">640</string>
</property>
<property name="placeholderText">
<string notr="true"/>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="bgBackground">
<property name="title">
<string>Background</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QRadioButton" name="rbWhite">
<property name="text">
<string>White</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbBlack">
<property name="text">
<string>B&amp;lack</string>
</property>
</widget>
</item>
<item>
<spacer name="hspacer1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="vspacer3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>51</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QGroupBox" name="bgColouring">
<property name="title">
<string>Colouring</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="rbBlackWhite">
<property name="text">
<string>Black / White</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbColoured">
<property name="text">
<string>Coloured</string>
</property>
</widget>
</item>
<item>
<spacer name="hspacer2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="vspacer4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>45</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="bgBorders">
<property name="title">
<string>Borders</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="leLeftRight">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="leTopBottom"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lTopBottom">
<property name="text">
<string>Top / Bottom - Border:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lLeftRight">
<property name="text">
<string>Left / Right - Border:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<spacer name="vspacer5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="cbSameBorders">
<property name="text">
<string>set same size</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>leWidth</tabstop>
<tabstop>leHeight</tabstop>
<tabstop>rbWhite</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_ImageOptionsDialog</receiver>
<slot>ok()</slot>
<hints>
<hint type="sourcelabel">
<x>224</x>
<y>528</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QG_ImageOptionsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>224</x>
<y>528</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leWidth</sender>
<signal>textChanged(QString)</signal>
<receiver>QG_ImageOptionsDialog</receiver>
<slot>sizeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leHeight</sender>
<signal>textChanged(QString)</signal>
<receiver>QG_ImageOptionsDialog</receiver>
<slot>sizeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbResolution</sender>
<signal>editTextChanged(QString)</signal>
<receiver>QG_ImageOptionsDialog</receiver>
<slot>resolutionChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbSameBorders</sender>
<signal>stateChanged(int)</signal>
<receiver>QG_ImageOptionsDialog</receiver>
<slot>sameBordersChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>leLeftRight</sender>
<signal>textChanged(QString)</signal>
<receiver>QG_ImageOptionsDialog</receiver>
<slot>borderChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

101
ui/forms/qg_dlginitial.cpp Normal file
View File

@@ -0,0 +1,101 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlginitial.h"
#include "rs_system.h"
#include "rs_settings.h"
#include "rs_units.h"
/*
* Constructs a QG_DlgInitial as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgInitial::QG_DlgInitial(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
init();
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgInitial::languageChange()
{
retranslateUi(this);
}
void QG_DlgInitial::init() {
// Fill combobox with languages:
QStringList languageList = RS_SYSTEM->getLanguageList();
QString defaultLanguage=RS_SYSTEM->symbolToLanguage(QString("en"));
for (QStringList::Iterator it = languageList.begin();
it!=languageList.end();
it++) {
QString l = RS_SYSTEM->symbolToLanguage(*it);
cbLanguage->addItem(l,*it);
cbLanguageCmd->addItem(l,*it);
}
// units:
for (int i=RS2::None; i<RS2::LastUnit; i++) {
cbUnit->addItem(RS_Units::unitToString((RS2::Unit)i));
}
cbUnit->setCurrentIndex( cbUnit->findText("Millimeter") );
cbLanguage->setCurrentIndex( cbLanguage->findText(defaultLanguage) );
cbLanguageCmd->setCurrentIndex( cbLanguageCmd->findText(defaultLanguage) );
}
void QG_DlgInitial::setText(const QString& t) {
lWelcome->setText(t);
}
void QG_DlgInitial::setPixmap(const QPixmap& p) {
lImage->setPixmap(p);
}
void QG_DlgInitial::ok() {
RS_SETTINGS->beginGroup("/Appearance");
RS_SETTINGS->writeEntry("/Language",
cbLanguage->itemData(cbLanguage->currentIndex()));
RS_SETTINGS->writeEntry("/LanguageCmd",
cbLanguage->itemData(cbLanguage->currentIndex()));
RS_SETTINGS->endGroup();
RS_SETTINGS->beginGroup("/Defaults");
RS_SETTINGS->writeEntry("/Unit", cbUnit->currentText());
RS_SETTINGS->endGroup();
accept();
}

52
ui/forms/qg_dlginitial.h Normal file
View File

@@ -0,0 +1,52 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#ifndef QG_DLGINITIAL_H
#define QG_DLGINITIAL_H
#include "ui_qg_dlginitial.h"
class QG_DlgInitial : public QDialog, public Ui::QG_DlgInitial
{
Q_OBJECT
public:
QG_DlgInitial(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0);
~QG_DlgInitial()=default;
public slots:
virtual void setText( const QString & t );
virtual void setPixmap( const QPixmap & p );
virtual void ok();
protected slots:
virtual void languageChange();
private:
void init();
};
#endif // QG_DLGINITIAL_H

171
ui/forms/qg_dlginitial.ui Normal file
View File

@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QG_DlgInitial</class>
<widget class="QDialog" name="QG_DlgInitial">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>413</width>
<height>340</height>
</rect>
</property>
<property name="windowTitle">
<string>Welcome</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>19</number>
</property>
<item>
<widget class="QLabel" name="lImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::WinPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="pixmap">
<pixmap>image0</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="lWelcome">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;font size=&quot;+1&quot;&gt;&lt;b&gt;Welcome to LibreCAD&lt;/b&gt;
&lt;/font&gt;
&lt;br&gt;
Please choose the unit you want to use for new drawings and your preferred language.&lt;br&gt;
(You can changes these settings later.)</string>
</property>
<property name="alignment">
<set>Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout">
<property name="leftMargin">
<number>14</number>
</property>
<property name="topMargin">
<number>14</number>
</property>
<property name="rightMargin">
<number>14</number>
</property>
<property name="bottomMargin">
<number>14</number>
</property>
<item row="2" column="1">
<widget class="QComboBox" name="cbLanguageCmd"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cbLanguage"/>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cbUnit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lUnit">
<property name="text">
<string>Default Unit:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lLanguage">
<property name="text">
<string>GUI Language:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lCmdLanguage">
<property name="text">
<string>Command Language:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>cbUnit</tabstop>
<tabstop>cbLanguage</tabstop>
<tabstop>cbLanguageCmd</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QG_DlgInitial</receiver>
<slot>ok()</slot>
<hints>
<hint type="sourcelabel">
<x>206</x>
<y>323</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

110
ui/forms/qg_dlginsert.cpp Normal file
View File

@@ -0,0 +1,110 @@
/****************************************************************************
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file gpl-2.0.txt included in the
** packaging of this file.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
** This copyright notice MUST APPEAR in all copies of the script!
**
**********************************************************************/
#include "qg_dlginsert.h"
#include "rs_insert.h"
#include "rs_graphic.h"
#include "rs_math.h"
/*
* Constructs a QG_DlgInsert as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
QG_DlgInsert::QG_DlgInsert(QWidget* parent, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
QG_DlgInsert::~QG_DlgInsert()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void QG_DlgInsert::languageChange()
{
retranslateUi(this);
}
void QG_DlgInsert::setInsert(RS_Insert& i) {
insert = &i;
//pen = insert->getPen();
wPen->setPen(insert->getPen(false), true, false, "Pen");
RS_Graphic* graphic = insert->getGraphic();
if (graphic) {
cbLayer->init(*(graphic->getLayerList()), false, false);
}
RS_Layer* lay = insert->getLayer(false);
if (lay) {
cbLayer->setLayer(*lay);
}
QString s;
s.setNum(insert->getInsertionPoint().x);
leInsertionPointX->setText(s);
s.setNum(insert->getInsertionPoint().y);
leInsertionPointY->setText(s);
s.setNum(insert->getScale().x);
leScaleX->setText(s);
s.setNum(insert->getScale().y);
leScaleY->setText(s);
s.setNum(RS_Math::rad2deg(insert->getAngle()));
leAngle->setText(s);
s.setNum(insert->getRows());
leRows->setText(s);
s.setNum(insert->getCols());
leCols->setText(s);
s.setNum(insert->getSpacing().y);
leRowSpacing->setText(s);
s.setNum(insert->getSpacing().x);
leColSpacing->setText(s);
}
void QG_DlgInsert::updateInsert() {
insert->setInsertionPoint(RS_Vector(RS_Math::eval(leInsertionPointX->text()),
RS_Math::eval(leInsertionPointY->text())));
insert->setScale(RS_Vector(RS_Math::eval(leScaleX->text()),
RS_Math::eval(leScaleY->text())));
insert->setAngle(RS_Math::deg2rad(RS_Math::eval(leAngle->text())));
insert->setRows(RS_Math::round(RS_Math::eval(leRows->text())));
insert->setCols(RS_Math::round(RS_Math::eval(leCols->text())));
insert->setSpacing(RS_Vector(RS_Math::eval(leColSpacing->text()),
RS_Math::eval(leRowSpacing->text())));
insert->setPen(wPen->getPen());
insert->setLayer(cbLayer->currentText());
}

Some files were not shown because too many files have changed in this diff Show More