start PropertyQuantity and InputField

This commit is contained in:
jriegel 2013-09-22 21:23:25 +02:00
parent 3ee7b20927
commit 4732a800e9
9 changed files with 203 additions and 0 deletions

View File

@ -94,6 +94,8 @@ FeatureTest::FeatureTest()
ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ),
"An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
ADD_PROPERTY(Quantity,(1.0));
}
FeatureTest::~FeatureTest()

View File

@ -93,6 +93,8 @@ public:
App::PropertyInteger TypeAll;
App::PropertyInteger TypeTransient;
App::PropertyQuantity Quantity;
/** @name methods overide Feature */
//@{
/// recalculate the Feature

View File

@ -38,6 +38,7 @@
#include "PropertyUnits.h"
#include <Base/PyObjectBase.h>
#include <Base/QuantityPy.h>
#define new DEBUG_CLIENTBLOCK
using namespace App;
@ -47,6 +48,29 @@ using namespace std;
//**************************************************************************
//**************************************************************************
// PropertyFloatUnit
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(App::PropertyQuantity, App::PropertyFloat);
const char* PropertyQuantity::getEditorName(void) const
{
return "Gui::PropertyEditor::PropertyUnitItem";
}
PyObject *PropertyQuantity::getPyObject(void)
{
return new QuantityPy (new Quantity( _dValue,_Unit));
}
void PropertyQuantity::setPyObject(PyObject *value)
{
setValue(UnitsApi::toDblWithUserPrefs(Length,value));
}
//**************************************************************************
//**************************************************************************

View File

@ -32,6 +32,7 @@
#include <vector>
#include <boost/filesystem/path.hpp>
#include <Base/Unit.h>
#include "PropertyStandard.h"
namespace Base {
@ -42,6 +43,25 @@ class Writer;
namespace App
{
/** Float with Unit property
* This is a property for float with a predefined Unit associated .
*/
class AppExport PropertyQuantity : public PropertyFloat
{
TYPESYSTEM_HEADER();
public:
PropertyQuantity(void){}
virtual ~PropertyQuantity(){}
virtual const char* getEditorName(void) const;
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
void setUnit(const Base::Unit &u){_Unit = u;}
const Base::Unit &getUnit(void)const{return _Unit;}
protected:
Base::Unit _Unit;
};
/** Distance property
* This is a property for representing distances. It is basically a float

View File

@ -28,6 +28,15 @@
#include "Quantity.h"
#include "Exception.h"
// suppress annoying warnings from generated source files
#ifdef _MSC_VER
# pragma warning(disable : 4003)
# pragma warning(disable : 4018)
# pragma warning(disable : 4065)
# pragma warning( disable : 4273 )
# pragma warning(disable : 4335) // disable MAC file format warning on VC
#endif
using namespace Base;
Quantity::Quantity()

View File

@ -173,6 +173,7 @@ set(Gui_MOC_HDRS
NetworkRetriever.h
OnlineDocumentation.h
Placement.h
InputField.h
PrefWidgets.h
ProgressBar.h
PropertyPage.h
@ -738,6 +739,7 @@ SET(Widget_CPP_SRCS
MainWindow.cpp
MDIView.cpp
PrefWidgets.cpp
InputField.cpp
ProgressBar.cpp
SpinBox.cpp
Splashscreen.cpp
@ -750,6 +752,7 @@ SET(Widget_HPP_SRCS
MainWindow.h
MDIView.h
PrefWidgets.h
InputField.h
ProgressBar.h
SpinBox.h
Splashscreen.h

76
src/Gui/InputField.cpp Normal file
View File

@ -0,0 +1,76 @@
/***************************************************************************
* Copyright (c) 2013 Juergen Riegel *
* *
* 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"
#include <Base/Console.h>
#include "InputField.h"
using namespace Gui;
// --------------------------------------------------------------------
InputField::InputField ( QWidget * parent )
: QLineEdit(parent)
{
}
InputField::~InputField()
{
}
/** Sets the preference path to \a path. */
void InputField::setParamGrpPath( const QByteArray& path )
{
//#ifdef FC_DEBUG
// if (getWindowParameter().isValid())
// {
// if ( paramGrpPath() != path )
// Base::Console().Warning("Widget already attached\n");
// }
//#endif
//
// if ( paramGrpPath() != path )
// {
// if ( setGroupName( path ) )
// {
// m_sPrefGrp = path;
// assert(getWindowParameter().isValid());
// getWindowParameter()->Attach(this);
// }
// }
}
/** Returns the widget's preferences path. */
QByteArray InputField::paramGrpPath() const
{
return m_sPrefGrp;
}
// --------------------------------------------------------------------
#include "moc_InputField.cpp"

65
src/Gui/InputField.h Normal file
View File

@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (c) 2013 Juergen Riegel *
* *
* 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 GUI_INPUTFIELD_H
#define GUI_INPUTFIELD_H
#include <Base/Parameter.h>
#include "Widgets.h"
#include "Window.h"
#include "SpinBox.h"
#include "FileDialog.h"
namespace Gui {
/**
* The InputField class.
* \author Jürgen Riegel
*/
class GuiExport InputField : public QLineEdit
{
Q_OBJECT
Q_PROPERTY( QByteArray prefPath READ paramGrpPath WRITE setParamGrpPath )
public:
InputField ( QWidget * parent = 0 );
virtual ~InputField();
// PROPERTIES
// getters
QByteArray paramGrpPath () const;
// setters
void setParamGrpPath ( const QByteArray& name );
private:
QByteArray m_sPrefGrp;
};
} // namespace Gui
#endif // GUI_INPUTFIELD_H

View File

@ -46,6 +46,7 @@
#include "DlgKeyboardImp.h"
#include "DlgCustomizeSpaceball.h"
#include "DlgCustomizeSpNavSettings.h"
#include "InputField.h"
using namespace Gui;
using namespace Gui::Dialog;
@ -82,6 +83,7 @@ WidgetFactorySupplier::WidgetFactorySupplier()
// ADD YOUR PREFERENCE WIDGETS HERE
//
//
new WidgetProducer<Gui::InputField>;
new WidgetProducer<Gui::PrefSpinBox>;
new WidgetProducer<Gui::PrefDoubleSpinBox>;
new WidgetProducer<Gui::PrefLineEdit>;