Merge remote-tracking branch 'svn/trunk'
This commit is contained in:
@@ -1437,7 +1437,8 @@ public:
|
||||
(int)event->type());
|
||||
}
|
||||
try {
|
||||
if (event->type() == Spaceball::ButtonEvent::ButtonEventType || Spaceball::MotionEvent::MotionEventType)
|
||||
if (event->type() == Spaceball::ButtonEvent::ButtonEventType ||
|
||||
event->type() == Spaceball::MotionEvent::MotionEventType)
|
||||
return processSpaceballEvent(receiver, event);
|
||||
else
|
||||
return QApplication::notify(receiver, event);
|
||||
|
||||
@@ -558,6 +558,7 @@ SET(View3D_CPP_SRCS
|
||||
InventorNavigationStyle.cpp
|
||||
CADNavigationStyle.cpp
|
||||
BlenderNavigationStyle.cpp
|
||||
TouchpadNavigationStyle.cpp
|
||||
SplitView3DInventor.cpp
|
||||
View.cpp
|
||||
View3DInventor.cpp
|
||||
|
||||
@@ -204,7 +204,7 @@ void DlgCustomKeyboardImp::on_buttonAssign_clicked()
|
||||
editShortcut->clear();
|
||||
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Shortcut");
|
||||
hGrp->SetASCII(name.constData(), accelLineEditShortcut->text().toAscii());
|
||||
hGrp->SetASCII(name.constData(), accelLineEditShortcut->text().toUtf8());
|
||||
buttonAssign->setEnabled(false);
|
||||
buttonReset->setEnabled(true);
|
||||
}
|
||||
|
||||
@@ -226,6 +226,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
}
|
||||
}
|
||||
}
|
||||
this->button2down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON3:
|
||||
if (press) {
|
||||
@@ -306,10 +307,12 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
BUTTON1DOWN = 1 << 0,
|
||||
BUTTON3DOWN = 1 << 1,
|
||||
CTRLDOWN = 1 << 2,
|
||||
SHIFTDOWN = 1 << 3
|
||||
SHIFTDOWN = 1 << 3,
|
||||
BUTTON2DOWN = 1 << 4
|
||||
};
|
||||
unsigned int combo =
|
||||
(this->button1down ? BUTTON1DOWN : 0) |
|
||||
(this->button2down ? BUTTON2DOWN : 0) |
|
||||
(this->button3down ? BUTTON3DOWN : 0) |
|
||||
(this->ctrldown ? CTRLDOWN : 0) |
|
||||
(this->shiftdown ? SHIFTDOWN : 0);
|
||||
@@ -328,17 +331,19 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
newmode = NavigationStyle::DRAGGING;
|
||||
break;
|
||||
case BUTTON3DOWN:
|
||||
case SHIFTDOWN|BUTTON1DOWN:
|
||||
case CTRLDOWN|SHIFTDOWN:
|
||||
case CTRLDOWN|SHIFTDOWN|BUTTON1DOWN:
|
||||
newmode = NavigationStyle::PANNING;
|
||||
break;
|
||||
case CTRLDOWN:
|
||||
case CTRLDOWN|BUTTON1DOWN:
|
||||
case CTRLDOWN|SHIFTDOWN:
|
||||
case CTRLDOWN|SHIFTDOWN|BUTTON1DOWN:
|
||||
case SHIFTDOWN:
|
||||
case SHIFTDOWN|BUTTON1DOWN:
|
||||
newmode = NavigationStyle::SELECTION;
|
||||
break;
|
||||
case BUTTON1DOWN|BUTTON3DOWN:
|
||||
case CTRLDOWN|BUTTON3DOWN:
|
||||
case CTRLDOWN|SHIFTDOWN|BUTTON2DOWN:
|
||||
newmode = NavigationStyle::ZOOMING;
|
||||
break;
|
||||
|
||||
@@ -365,7 +370,9 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
// If not handled in this class, pass on upwards in the inheritance
|
||||
// hierarchy.
|
||||
if ((curmode == NavigationStyle::SELECTION || viewer->isEditing()) && !processed)
|
||||
if ((curmode == NavigationStyle::SELECTION ||
|
||||
newmode == NavigationStyle::SELECTION ||
|
||||
viewer->isEditing()) && !processed)
|
||||
processed = inherited::processSoEvent(ev);
|
||||
else
|
||||
return TRUE;
|
||||
|
||||
@@ -346,6 +346,7 @@ libFreeCADGui_la_SOURCES=\
|
||||
ToolBarManager.cpp \
|
||||
ToolBox.cpp \
|
||||
ToolBoxManager.cpp \
|
||||
TouchpadNavigationStyle.cpp \
|
||||
Transform.cpp \
|
||||
Transform.h \
|
||||
Tree.cpp \
|
||||
|
||||
@@ -279,6 +279,20 @@ private:
|
||||
SbBool lockButton1;
|
||||
};
|
||||
|
||||
class GuiExport TouchpadNavigationStyle : public UserNavigationStyle {
|
||||
typedef UserNavigationStyle inherited;
|
||||
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
TouchpadNavigationStyle();
|
||||
~TouchpadNavigationStyle();
|
||||
const char* mouseButtons(ViewerMode);
|
||||
|
||||
protected:
|
||||
SbBool processSoEvent(const SoEvent * const ev);
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_NAVIGATIONSTYLE_H
|
||||
|
||||
@@ -123,6 +123,7 @@ void Gui::SoFCDB::init()
|
||||
InventorNavigationStyle ::init();
|
||||
CADNavigationStyle ::init();
|
||||
BlenderNavigationStyle ::init();
|
||||
TouchpadNavigationStyle ::init();
|
||||
|
||||
qRegisterMetaType<Base::Vector3f>("Base::Vector3f");
|
||||
qRegisterMetaType<Base::Vector3d>("Base::Vector3d");
|
||||
|
||||
346
src/Gui/TouchpadNavigationStyle.cpp
Normal file
346
src/Gui/TouchpadNavigationStyle.cpp
Normal file
@@ -0,0 +1,346 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2012 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 <cfloat>
|
||||
# include "InventorAll.h"
|
||||
# include <QAction>
|
||||
# include <QActionGroup>
|
||||
# include <QApplication>
|
||||
# include <QByteArray>
|
||||
# include <QCursor>
|
||||
# include <QList>
|
||||
# include <QMenu>
|
||||
# include <QMetaObject>
|
||||
# include <QRegExp>
|
||||
#endif
|
||||
|
||||
#include <Inventor/sensors/SoTimerSensor.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include "NavigationStyle.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
#include "Application.h"
|
||||
#include "MenuManager.h"
|
||||
#include "MouseSelection.h"
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
/* TRANSLATOR Gui::TouchpadNavigationStyle */
|
||||
|
||||
TYPESYSTEM_SOURCE(Gui::TouchpadNavigationStyle, Gui::UserNavigationStyle);
|
||||
|
||||
TouchpadNavigationStyle::TouchpadNavigationStyle()
|
||||
{
|
||||
}
|
||||
|
||||
TouchpadNavigationStyle::~TouchpadNavigationStyle()
|
||||
{
|
||||
}
|
||||
|
||||
const char* TouchpadNavigationStyle::mouseButtons(ViewerMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case NavigationStyle::SELECTION:
|
||||
return QT_TR_NOOP("Press left mouse button");
|
||||
case NavigationStyle::PANNING:
|
||||
return QT_TR_NOOP("Press SHIFT button");
|
||||
case NavigationStyle::DRAGGING:
|
||||
return QT_TR_NOOP("Press ALT button");
|
||||
case NavigationStyle::ZOOMING:
|
||||
return QT_TR_NOOP("Press PgUp/PgDown button");
|
||||
default:
|
||||
return "No description";
|
||||
}
|
||||
}
|
||||
|
||||
SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
{
|
||||
// Events when in "ready-to-seek" mode are ignored, except those
|
||||
// which influence the seek mode itself -- these are handled further
|
||||
// up the inheritance hierarchy.
|
||||
if (this->isSeekMode()) { return inherited::processSoEvent(ev); }
|
||||
|
||||
const SoType type(ev->getTypeId());
|
||||
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbVec2s size(vp.getViewportSizePixels());
|
||||
const SbVec2f prevnormalized = this->lastmouseposition;
|
||||
const SbVec2s pos(ev->getPosition());
|
||||
const SbVec2f posn((float) pos[0] / (float) SoQtMax((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) SoQtMax((int)(size[1] - 1), 1));
|
||||
|
||||
this->lastmouseposition = posn;
|
||||
|
||||
// Set to TRUE if any event processing happened. Note that it is not
|
||||
// necessary to restrict ourselves to only do one "action" for an
|
||||
// event, we only need this flag to see if any processing happened
|
||||
// at all.
|
||||
SbBool processed = FALSE;
|
||||
|
||||
const ViewerMode curmode = this->currentmode;
|
||||
ViewerMode newmode = curmode;
|
||||
|
||||
// Mismatches in state of the modifier keys happens if the user
|
||||
// presses or releases them outside the viewer window.
|
||||
if (this->ctrldown != ev->wasCtrlDown()) {
|
||||
this->ctrldown = ev->wasCtrlDown();
|
||||
}
|
||||
if (this->shiftdown != ev->wasShiftDown()) {
|
||||
this->shiftdown = ev->wasShiftDown();
|
||||
}
|
||||
if (this->altdown != ev->wasAltDown()) {
|
||||
this->altdown = ev->wasAltDown();
|
||||
}
|
||||
|
||||
// give the nodes in the foreground root the chance to handle events (e.g color bar)
|
||||
if (!processed && !viewer->isEditing()) {
|
||||
processed = handleEventInForeground(ev);
|
||||
if (processed)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Keyboard handling
|
||||
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
|
||||
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
|
||||
switch (event->getKey()) {
|
||||
case SoKeyboardEvent::LEFT_CONTROL:
|
||||
case SoKeyboardEvent::RIGHT_CONTROL:
|
||||
this->ctrldown = press;
|
||||
break;
|
||||
case SoKeyboardEvent::LEFT_SHIFT:
|
||||
case SoKeyboardEvent::RIGHT_SHIFT:
|
||||
this->shiftdown = press;
|
||||
break;
|
||||
case SoKeyboardEvent::LEFT_ALT:
|
||||
case SoKeyboardEvent::RIGHT_ALT:
|
||||
this->altdown = press;
|
||||
break;
|
||||
case SoKeyboardEvent::H:
|
||||
processed = TRUE;
|
||||
viewer->saveHomePosition();
|
||||
break;
|
||||
case SoKeyboardEvent::S:
|
||||
case SoKeyboardEvent::HOME:
|
||||
case SoKeyboardEvent::LEFT_ARROW:
|
||||
case SoKeyboardEvent::UP_ARROW:
|
||||
case SoKeyboardEvent::RIGHT_ARROW:
|
||||
case SoKeyboardEvent::DOWN_ARROW:
|
||||
if (!this->isViewing())
|
||||
this->setViewing(true);
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_UP:
|
||||
if (this->invertZoom)
|
||||
zoom(viewer->getCamera(), 0.05f);
|
||||
else
|
||||
zoom(viewer->getCamera(), -0.05f);
|
||||
processed = TRUE;
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_DOWN:
|
||||
if (this->invertZoom)
|
||||
zoom(viewer->getCamera(), -0.05f);
|
||||
else
|
||||
zoom(viewer->getCamera(), 0.05f);
|
||||
processed = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse Button / Spaceball Button handling
|
||||
if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
|
||||
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
|
||||
const int button = event->getButton();
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
|
||||
|
||||
// SoDebugError::postInfo("processSoEvent", "button = %d", button);
|
||||
switch (button) {
|
||||
case SoMouseButtonEvent::BUTTON1:
|
||||
this->lockrecenter = TRUE;
|
||||
this->button1down = press;
|
||||
if (press && (this->currentmode == NavigationStyle::SEEK_WAIT_MODE)) {
|
||||
newmode = NavigationStyle::SEEK_MODE;
|
||||
this->seekToPoint(pos); // implicitly calls interactiveCountInc()
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (press && (this->currentmode == NavigationStyle::PANNING ||
|
||||
this->currentmode == NavigationStyle::ZOOMING)) {
|
||||
newmode = NavigationStyle::DRAGGING;
|
||||
this->centerTime = ev->getTime();
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (!press && (this->currentmode == NavigationStyle::DRAGGING)) {
|
||||
SbTime tmp = (ev->getTime() - this->centerTime);
|
||||
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
|
||||
if (tmp.getValue() < dci) {
|
||||
newmode = NavigationStyle::ZOOMING;
|
||||
}
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (!press && (this->currentmode == NavigationStyle::DRAGGING)) {
|
||||
this->setViewing(false);
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) {
|
||||
processed = TRUE;
|
||||
}
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON2:
|
||||
// If we are in edit mode then simply ignore the RMB events
|
||||
// to pass the event to the base class.
|
||||
this->lockrecenter = TRUE;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
if (this->currentmode != NavigationStyle::ZOOMING &&
|
||||
this->currentmode != NavigationStyle::PANNING &&
|
||||
this->currentmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Alternative way of rotating & zooming
|
||||
if (press && (this->currentmode == NavigationStyle::PANNING ||
|
||||
this->currentmode == NavigationStyle::ZOOMING)) {
|
||||
newmode = NavigationStyle::DRAGGING;
|
||||
this->centerTime = ev->getTime();
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (!press && (this->currentmode == NavigationStyle::DRAGGING)) {
|
||||
SbTime tmp = (ev->getTime() - this->centerTime);
|
||||
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
|
||||
if (tmp.getValue() < dci) {
|
||||
newmode = NavigationStyle::ZOOMING;
|
||||
}
|
||||
processed = TRUE;
|
||||
}
|
||||
this->button2down = press;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse Movement handling
|
||||
if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) {
|
||||
this->lockrecenter = TRUE;
|
||||
const SoLocation2Event * const event = (const SoLocation2Event *) ev;
|
||||
if (this->currentmode == NavigationStyle::ZOOMING) {
|
||||
this->zoomByCursor(posn, prevnormalized);
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (this->currentmode == NavigationStyle::PANNING) {
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
panCamera(viewer->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (this->currentmode == NavigationStyle::DRAGGING) {
|
||||
this->addToLog(event->getPosition(), event->getTime());
|
||||
this->spin(posn);
|
||||
processed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Spaceball & Joystick handling
|
||||
if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) {
|
||||
SoMotion3Event * const event = (SoMotion3Event *) ev;
|
||||
SoCamera * const camera = viewer->getCamera();
|
||||
|
||||
SbVec3f dir = event->getTranslation();
|
||||
if (camera->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())){
|
||||
static float zoomConstant(-.03f);
|
||||
dir[2] = 0.0;//don't move the cam for z translation.
|
||||
|
||||
SoOrthographicCamera *oCam = static_cast<SoOrthographicCamera *>(camera);
|
||||
oCam->scaleHeight(1.0-event->getTranslation()[2] * zoomConstant);
|
||||
}
|
||||
camera->orientation.getValue().multVec(dir,dir);
|
||||
camera->position = camera->position.getValue() + dir;
|
||||
camera->orientation = event->getRotation() * camera->orientation.getValue();
|
||||
processed = TRUE;
|
||||
}
|
||||
|
||||
enum {
|
||||
BUTTON1DOWN = 1 << 0,
|
||||
BUTTON2DOWN = 1 << 1,
|
||||
CTRLDOWN = 1 << 2,
|
||||
SHIFTDOWN = 1 << 3,
|
||||
ALTDOWN = 1 << 4
|
||||
};
|
||||
unsigned int combo =
|
||||
(this->button1down ? BUTTON1DOWN : 0) |
|
||||
(this->button2down ? BUTTON2DOWN : 0) |
|
||||
(this->ctrldown ? CTRLDOWN : 0) |
|
||||
(this->shiftdown ? SHIFTDOWN : 0) |
|
||||
(this->altdown ? ALTDOWN : 0);
|
||||
|
||||
switch (combo) {
|
||||
case 0:
|
||||
if (curmode == NavigationStyle::SPINNING) { break; }
|
||||
newmode = NavigationStyle::IDLE;
|
||||
break;
|
||||
case BUTTON1DOWN:
|
||||
// make sure not to change the selection when stopping spinning
|
||||
if (curmode == NavigationStyle::SPINNING)
|
||||
newmode = NavigationStyle::IDLE;
|
||||
else
|
||||
newmode = NavigationStyle::SELECTION;
|
||||
break;
|
||||
case CTRLDOWN:
|
||||
newmode = NavigationStyle::IDLE;
|
||||
break;
|
||||
case SHIFTDOWN:
|
||||
newmode = NavigationStyle::PANNING;
|
||||
break;
|
||||
case ALTDOWN:
|
||||
case CTRLDOWN|SHIFTDOWN:
|
||||
newmode = NavigationStyle::DRAGGING;
|
||||
break;
|
||||
case CTRLDOWN|SHIFTDOWN|BUTTON1DOWN:
|
||||
newmode = NavigationStyle::ZOOMING;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
// If not handled in this class, pass on upwards in the inheritance
|
||||
// hierarchy.
|
||||
if (!processed)
|
||||
processed = inherited::processSoEvent(ev);
|
||||
else
|
||||
return TRUE;
|
||||
|
||||
return processed;
|
||||
}
|
||||
@@ -156,6 +156,7 @@ void PartExport initPart()
|
||||
Part::CurveNet ::init();
|
||||
Part::Polygon ::init();
|
||||
Part::Circle ::init();
|
||||
Part::Ellipse ::init();
|
||||
Part::Vertex ::init();
|
||||
Part::Line ::init();
|
||||
Part::Ellipsoid ::init();
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
# include <BRepBuilderAPI_MakeSolid.hxx>
|
||||
# include <BRepBuilderAPI_GTransform.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
# include <gp_Elips.hxx>
|
||||
# include <gp_GTrsf.hxx>
|
||||
# include <GCE2d_MakeSegment.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
@@ -725,3 +726,61 @@ void Wedge::onChanged(const App::Property* prop)
|
||||
}
|
||||
Part::Primitive::onChanged(prop);
|
||||
}
|
||||
|
||||
App::PropertyFloatConstraint::Constraints Ellipse::angleRange = {0.0,360.0,1.0};
|
||||
|
||||
PROPERTY_SOURCE(Part::Ellipse, Part::Primitive)
|
||||
|
||||
|
||||
Ellipse::Ellipse()
|
||||
{
|
||||
ADD_PROPERTY(MajorRadius,(4.0f));
|
||||
ADD_PROPERTY(MinorRadius,(4.0f));
|
||||
ADD_PROPERTY(Angle0,(0.0f));
|
||||
Angle0.setConstraints(&angleRange);
|
||||
ADD_PROPERTY(Angle1,(360.0f));
|
||||
Angle1.setConstraints(&angleRange);
|
||||
}
|
||||
|
||||
Ellipse::~Ellipse()
|
||||
{
|
||||
}
|
||||
|
||||
short Ellipse::mustExecute() const
|
||||
{
|
||||
if (Angle0.isTouched() ||
|
||||
Angle1.isTouched() ||
|
||||
MajorRadius.isTouched() ||
|
||||
MinorRadius.isTouched())
|
||||
return 1;
|
||||
return Part::Feature::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Ellipse::execute(void)
|
||||
{
|
||||
gp_Elips ellipse;
|
||||
ellipse.SetMajorRadius(this->MajorRadius.getValue());
|
||||
ellipse.SetMinorRadius(this->MinorRadius.getValue());
|
||||
|
||||
BRepBuilderAPI_MakeEdge clMakeEdge(ellipse, Base::toRadians<double>(this->Angle0.getValue()),
|
||||
Base::toRadians<double>(this->Angle1.getValue()));
|
||||
const TopoDS_Edge& edge = clMakeEdge.Edge();
|
||||
this->Shape.setValue(edge);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
void Ellipse::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
if (prop == &MajorRadius || prop == &MinorRadius || prop == &Angle0 || prop == &Angle1){
|
||||
try {
|
||||
App::DocumentObjectExecReturn *ret = recompute();
|
||||
delete ret;
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
@@ -265,6 +265,31 @@ protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
};
|
||||
|
||||
class Ellipse : public Part::Primitive
|
||||
{
|
||||
PROPERTY_HEADER(Part::Ellipse);
|
||||
|
||||
public:
|
||||
Ellipse();
|
||||
virtual ~Ellipse();
|
||||
|
||||
App::PropertyFloat MajorRadius;
|
||||
App::PropertyFloat MinorRadius;
|
||||
App::PropertyAngle Angle0;
|
||||
App::PropertyAngle Angle1;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
void onChanged(const App::Property*);
|
||||
//@}
|
||||
|
||||
private:
|
||||
static App::PropertyFloatConstraint::Constraints angleRange;
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
|
||||
@@ -312,7 +312,23 @@ void DlgPrimitives::createPrimitive(const QString& placement)
|
||||
.arg(ui.circleAngle1->value(),0,'f',2)
|
||||
.arg(placement);
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 10) { // vertex
|
||||
else if (ui.comboBox1->currentIndex() == 10) { // ellipse
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Ellipse").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Ellipse\",\"%1\")\n"
|
||||
"App.ActiveDocument.%1.MajorRadius=%2\n"
|
||||
"App.ActiveDocument.%1.MinorRadius=%3\n"
|
||||
"App.ActiveDocument.%1.Angle0=%4\n"
|
||||
"App.ActiveDocument.%1.Angle1=%5\n"
|
||||
"App.ActiveDocument.%1.Placement=%6\n")
|
||||
.arg(name)
|
||||
.arg(ui.ellipseMajorRadius->value(),0,'f',2)
|
||||
.arg(ui.ellipseMinorRadius->value(),0,'f',2)
|
||||
.arg(ui.ellipseAngle0->value(),0,'f',2)
|
||||
.arg(ui.ellipseAngle1->value(),0,'f',2)
|
||||
.arg(placement);
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 11) { // vertex
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Vertex").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Vertex\",\"%1\")\n"
|
||||
@@ -326,7 +342,7 @@ void DlgPrimitives::createPrimitive(const QString& placement)
|
||||
.arg(ui.vertexZ->value(),0,'f',2)
|
||||
.arg(placement);
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 11) { // line
|
||||
else if (ui.comboBox1->currentIndex() == 12) { // line
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Line").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Line\",\"%1\")\n"
|
||||
|
||||
@@ -84,6 +84,11 @@
|
||||
<string>Circle</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ellipse</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Point</string>
|
||||
@@ -966,7 +971,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="wedgeXmin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -976,7 +981,7 @@
|
||||
<item row="0" column="2">
|
||||
<widget class="QDoubleSpinBox" name="wedgeXmax">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -996,7 +1001,7 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="wedgeYmin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1006,7 +1011,7 @@
|
||||
<item row="1" column="2">
|
||||
<widget class="QDoubleSpinBox" name="wedgeYmax">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1026,7 +1031,7 @@
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="wedgeZmin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1036,7 +1041,7 @@
|
||||
<item row="2" column="2">
|
||||
<widget class="QDoubleSpinBox" name="wedgeZmax">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1056,7 +1061,7 @@
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="wedgeX2min">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1069,7 +1074,7 @@
|
||||
<item row="3" column="2">
|
||||
<widget class="QDoubleSpinBox" name="wedgeX2max">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1089,7 +1094,7 @@
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="wedgeZ2min">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1102,7 +1107,7 @@
|
||||
<item row="4" column="2">
|
||||
<widget class="QDoubleSpinBox" name="wedgeZ2max">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -1320,6 +1325,101 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelEllMajorRadius">
|
||||
<property name="text">
|
||||
<string>Major radius:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseMajorRadius">
|
||||
<property name="maximum">
|
||||
<double>1000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>4.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelEllMinorRadius">
|
||||
<property name="text">
|
||||
<string>Minor radius:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseMinorRadius">
|
||||
<property name="maximum">
|
||||
<double>1000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelEllAngle1">
|
||||
<property name="text">
|
||||
<string>Angle 1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseAngle0">
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelEllAngle2">
|
||||
<property name="text">
|
||||
<string>Angle 2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseAngle1">
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>131</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page10_vertex">
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -241,9 +241,6 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
|
||||
|
||||
state->push();
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, srcw);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_PIXEL_MODE_BIT | GL_COLOR_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@@ -282,7 +279,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
|
||||
glEnd();
|
||||
|
||||
// Reset the Mode
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
glPopAttrib();
|
||||
state->pop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user