Sketcher: Dialog for arbritary sides regular polygon

This commit is contained in:
Abdullah Tahiri
2017-12-18 17:36:29 +01:00
committed by wmayer
parent d0c1b147dd
commit 27c202a1f0
4 changed files with 245 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ set(SketcherGui_MOC_HDRS
SketchMirrorDialog.h
SketcherSettings.h
SketchRectangularArrayDialog.h
SketcherRegularPolygonDialog.h
PropertyConstraintListItem.h
)
fc_wrap_cpp(SketcherGui_MOC_SRCS ${SketcherGui_MOC_HDRS})
@@ -62,6 +63,7 @@ set(SketcherGui_UIC_SRCS
SketcherSettings.ui
SketcherSettingsColors.ui
SketchRectangularArrayDialog.ui
SketcherRegularPolygonDialog.ui
)
if(BUILD_QT5)
@@ -127,6 +129,8 @@ SET(SketcherGui_SRCS
SketcherSettings.h
SketchRectangularArrayDialog.h
SketchRectangularArrayDialog.cpp
SketcherRegularPolygonDialog.h
SketcherRegularPolygonDialog.cpp
TaskDlgEditSketch.cpp
TaskDlgEditSketch.h
ViewProviderPython.cpp

View File

@@ -0,0 +1,69 @@
/***************************************************************************
* Copyright (c) 2017 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QPixmap>
# include <QDialog>
#endif
#include <Gui/BitmapFactory.h>
#include <Gui/MainWindow.h>
#include <Base/Tools.h>
#include <Base/UnitsApi.h>
#include "ui_SketcherRegularPolygonDialog.h"
#include "SketcherRegularPolygonDialog.h"
using namespace SketcherGui;
SketcherRegularPolygonDialog::SketcherRegularPolygonDialog(void)
: QDialog(Gui::getMainWindow()), ui(new Ui_SketcherRegularPolygonDialog)
{
ui->setupUi(this);
ui->sidesQuantitySpinBox->onRestore();
updateValues();
}
SketcherRegularPolygonDialog::~SketcherRegularPolygonDialog()
{
}
void SketcherRegularPolygonDialog::accept()
{
ui->sidesQuantitySpinBox->onSave();
updateValues();
QDialog::accept();
}
void SketcherRegularPolygonDialog::updateValues(void)
{
sides = ui->sidesQuantitySpinBox->value();
}
#include "moc_SketcherRegularPolygonDialog.cpp"

View File

@@ -0,0 +1,52 @@
/***************************************************************************
* Copyright (c) 2017 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef SKETCHERGUI_SketcherRegularPolygonDialog_H
#define SKETCHERGUI_SketcherRegularPolygonDialog_H
#include <Base/Placement.h>
#include <QDialog>
namespace SketcherGui {
class Ui_SketcherRegularPolygonDialog;
class SketcherRegularPolygonDialog : public QDialog
{
Q_OBJECT
public:
SketcherRegularPolygonDialog(void);
~SketcherRegularPolygonDialog();
void accept();
int sides;
protected:
void updateValues(void);
private:
Ui_SketcherRegularPolygonDialog* ui;
};
}
#endif // SKETCHERGUI_SketcherRegularPolygonDialog_H

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SketcherGui::SketcherRegularPolygonDialog</class>
<widget class="QDialog" name="SketcherGui::SketcherRegularPolygonDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>86</height>
</rect>
</property>
<property name="windowTitle">
<string>Create array</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Number of Sides:</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefSpinBox" name="sidesQuantitySpinBox">
<property name="toolTip">
<string>Number of columns of the linear array</string>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="value">
<number>9</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultRegularPolygonSides</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<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>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SketcherGui::SketcherRegularPolygonDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SketcherGui::SketcherRegularPolygonDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>