Skip to content

Commit

Permalink
- fix focus issue with InputField
Browse files Browse the repository at this point in the history
- on document load set camera setting of the MDI views
- do not try to use framebuffer objects when it's not supported on the system
0001690: sketch.getPoint crashes FreeCAD if the point does not exist
0001630: IGES-Export in [mm] turns to [Inches]
0001684: Sweep ignores the list of subshapes
0001667: 'Save file' disabled when viewing a drawing
0001682: Crash after updating editable texts in drawing
0001659: 3dconnexion space navigator moves view even when FreeCAD is not the active application
0001696: Quantity.getValueAs('rad') touches the Property
0001638: Not possible to draw anything
  • Loading branch information
wwmayer committed Aug 28, 2014
1 parent c6edd47 commit 3ecaf87
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 27 deletions.
4 changes: 4 additions & 0 deletions src/App/Application.cpp
Expand Up @@ -2003,6 +2003,10 @@ std::string Application::FindHomePath(const char* sCall)
*i = '/';
}

// fixes #0001638 to avoid to load DLLs from Windows' system directories before FreeCAD's bin folder
std::string binPath = TempHomePath;
binPath += "bin";
SetDllDirectory(binPath.c_str());
return TempHomePath;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Base/QuantityPy.xml
Expand Up @@ -27,14 +27,14 @@ Quantity(string) -- arbitrary mixture of numbers and chars defining a Quantity
</UserDocu>
<DeveloperDocu>Quantity</DeveloperDocu>
</Documentation>
<Methode Name="getUserPreferred">
<Methode Name="getUserPreferred" Const="true">
<Documentation>
<UserDocu>
returns a quantity with the translation factor and a string with the prevered unit
</UserDocu>
</Documentation>
</Methode>
<Methode Name="getValueAs">
<Methode Name="getValueAs" Const="true">
<Documentation>
<UserDocu>
returns a floating point value as the provided unit
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/Application.cpp
Expand Up @@ -1621,11 +1621,11 @@ void Application::runApplication(void)
}
#if QT_VERSION >= 0x040200
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
Base::Console().Log("This system does not support framebuffer objects");
Base::Console().Log("This system does not support framebuffer objects\n");
}
#endif
if (!QGLPixelBuffer::hasOpenGLPbuffers()) {
Base::Console().Log("This system does not support pbuffers");
Base::Console().Log("This system does not support pbuffers\n");
}

QGLFormat::OpenGLVersionFlags version = QGLFormat::openGLVersionFlags ();
Expand Down
8 changes: 6 additions & 2 deletions src/Gui/Document.cpp
Expand Up @@ -697,8 +697,12 @@ void Document::RestoreDocFile(Base::Reader &reader)
sMsg += ppReturn;
if (strcmp(ppReturn, "") != 0) { // non-empty attribute
try {
if (d->_pcAppWnd->sendHasMsgToActiveView("SetCamera"))
d->_pcAppWnd->sendMsgToActiveView(sMsg.c_str());
const char** pReturnIgnore=0;
std::list<MDIView*> mdi = getMDIViews();
for (std::list<MDIView*>::iterator it = mdi.begin(); it != mdi.end(); ++it) {
if ((*it)->onHasMsg("SetCamera"))
(*it)->onMsg(sMsg.c_str(), pReturnIgnore);
}
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Expand Down
3 changes: 3 additions & 0 deletions src/Gui/GuiApplicationNativeEventAware.cpp
Expand Up @@ -100,6 +100,9 @@ void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)

bool Gui::GUIApplicationNativeEventAware::processSpaceballEvent(QObject *object, QEvent *event)
{
if (!activeWindow())
return true;

QApplication::notify(object, event);
if (event->type() == Spaceball::MotionEvent::MotionEventType)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/InputField.cpp
Expand Up @@ -483,6 +483,8 @@ void InputField::focusInEvent(QFocusEvent * event)
if (!this->hasSelectedText())
selectNumber();
}

QLineEdit::focusInEvent(event);
}

void InputField::keyPressEvent(QKeyEvent *event)
Expand Down
9 changes: 7 additions & 2 deletions src/Gui/MouseSelection.cpp
Expand Up @@ -28,6 +28,7 @@
# include <qevent.h>
# include <qpainter.h>
# include <qpixmap.h>
# include <QGLFramebufferObject>
# include <QMenu>
# include <Inventor/SbBox.h>
# include <Inventor/events/SoEvent.h>
Expand Down Expand Up @@ -852,15 +853,19 @@ void RubberbandSelection::initialize()
{
d = new Private(_pcView3D);
_pcView3D->addGraphicsItem(d);
_pcView3D->setRenderFramebuffer(true);
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
_pcView3D->setRenderFramebuffer(true);
}
_pcView3D->scheduleRedraw();
}

void RubberbandSelection::terminate()
{
_pcView3D->removeGraphicsItem(d);
delete d; d = 0;
_pcView3D->setRenderFramebuffer(false);
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
_pcView3D->setRenderFramebuffer(false);
}
_pcView3D->scheduleRedraw();
}

Expand Down
25 changes: 13 additions & 12 deletions src/Mod/Drawing/App/FeaturePage.cpp
Expand Up @@ -155,23 +155,31 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void)

// checking for freecad editable texts
string outfragment(ofile.str());
if (EditableTexts.getSize() > 0) {
const std::vector<std::string>& editText = EditableTexts.getValues();
if (!editText.empty()) {
boost::regex e1 ("<text.*?freecad:editable=\"(.*?)\".*?<tspan.*?>(.*?)</tspan>");
string::const_iterator begin, end;
begin = outfragment.begin();
end = outfragment.end();
boost::match_results<std::string::const_iterator> what;
int count = 0;
std::size_t count = 0;
std::string newfragment;
newfragment.reserve(outfragment.size());

while (boost::regex_search(begin, end, what, e1)) {
if (count < EditableTexts.getSize()) {
if (count < editText.size()) {
// change values of editable texts
boost::regex e2 ("(<text.*?freecad:editable=\""+what[1].str()+"\".*?<tspan.*?)>(.*?)(</tspan>)");
outfragment = boost::regex_replace(outfragment, e2, "$1>"+EditableTexts.getValues()[count]+"$3");
boost::re_detail::string_out_iterator<std::string > out(newfragment);
boost::regex_replace(out, begin, what[0].second, e2, "$1>"+editText[count]+"$3");
}
count ++;
count++;
begin = what[0].second;
}

// now copy the rest
newfragment.insert(newfragment.end(), begin, end);
outfragment = newfragment;
}

// restoring linebreaks and saving the file
Expand All @@ -184,13 +192,6 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void)

PageResult.setValue(tempName.c_str());

//const char* text = "lskdfjlsd";
//const char* regex = "lskdflds";
//boost::regex e(regex);
//boost::smatch what;
//if(boost::regex_match(string(text), what, e))
//{
//}
return App::DocumentObject::StdReturn;
}

Expand Down
25 changes: 22 additions & 3 deletions src/Mod/Drawing/Gui/DrawingView.cpp
Expand Up @@ -58,6 +58,7 @@
#include <Base/Stream.h>
#include <Base/gzstream.h>
#include <Base/PyObjectBase.h>
#include <Gui/Document.h>
#include <Gui/FileDialog.h>
#include <Gui/WaitCursor.h>

Expand Down Expand Up @@ -312,19 +313,37 @@ bool DrawingView::onMsg(const char* pMsg, const char** ppReturn)
viewAll();
return true;
}
else if (strcmp("Save",pMsg) == 0) {
Gui::Document *doc = getGuiDocument();
if (doc) {
doc->save();
return true;
}
}
else if (strcmp("SaveAs",pMsg) == 0) {
Gui::Document *doc = getGuiDocument();
if (doc) {
doc->saveAs();
return true;
}
}
return false;
}

bool DrawingView::onHasMsg(const char* pMsg) const
{
if (strcmp("ViewFit",pMsg) == 0)
return true;
else if (strcmp("Save",pMsg) == 0)
return getGuiDocument() != 0;
else if (strcmp("SaveAs",pMsg) == 0)
return getGuiDocument() != 0;
else if (strcmp("Print",pMsg) == 0)
return true;
return true;
else if (strcmp("PrintPreview",pMsg) == 0)
return true;
return true;
else if (strcmp("PrintPdf",pMsg) == 0)
return true;
return true;
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Part/App/PartFeatures.cpp
Expand Up @@ -349,7 +349,7 @@ App::DocumentObjectExecReturn *Sweep::execute(void)
}
path = mkWire.Wire();
}
if (shape._Shape.ShapeType() == TopAbs_EDGE) {
else if (shape._Shape.ShapeType() == TopAbs_EDGE) {
path = shape._Shape;
}
else if (shape._Shape.ShapeType() == TopAbs_WIRE) {
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -692,12 +692,10 @@ void TopoShape::write(const char *FileName) const

void TopoShape::exportIges(const char *filename) const
{
Interface_Static::SetCVal("write.iges.unit","IN");
try {
// write iges file
IGESControl_Controller::Init();
IGESControl_Writer aWriter;
//IGESControl_Writer aWriter(Interface_Static::CVal("write.iges.unit"), 1);
aWriter.AddShape(this->_Shape);
aWriter.ComputeModel();
QString fn = QString::fromUtf8(filename);
Expand Down
13 changes: 12 additions & 1 deletion src/Mod/Sketcher/App/SketchObjectPyImp.cpp
Expand Up @@ -355,7 +355,18 @@ PyObject* SketchObjectPy::getPoint(PyObject *args)
if (!PyArg_ParseTuple(args, "ii", &GeoId, &PointType))
return 0;

return new Base::VectorPy(new Base::Vector3d(this->getSketchObjectPtr()->getPoint(GeoId,(Sketcher::PointPos)PointType)));
if (PointType < 0 || PointType > 3) {
PyErr_SetString(PyExc_ValueError, "Invalid point type");
return 0;
}

SketchObject* obj = this->getSketchObjectPtr();
if (GeoId > obj->getHighestCurveIndex() || -GeoId > obj->getExternalGeometryCount()) {
PyErr_SetString(PyExc_ValueError, "Invalid geometry Id");
return 0;
}

return new Base::VectorPy(new Base::Vector3d(obj->getPoint(GeoId,(Sketcher::PointPos)PointType)));
}

PyObject* SketchObjectPy::getAxis(PyObject *args)
Expand Down

0 comments on commit 3ecaf87

Please sign in to comment.