various minor changes:

+ whitespace improvement
+ code cleanup
This commit is contained in:
wmayer
2017-11-21 17:51:22 +01:00
parent 952a4a781f
commit 4d63e9a4c4
20 changed files with 86 additions and 126 deletions

View File

@@ -49,12 +49,11 @@ include_directories(
set(FreeCADApp_LIBS
FreeCADBase
${Boost_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTXML_LIBRARY}
)
if (BUILD_QT5)
include_directories(
${Qt5Core_INCLUDE_DIRS}
${Qt5Xml_INCLUDE_DIRS}
)
list(APPEND FreeCADApp_LIBS
@@ -64,9 +63,11 @@ if (BUILD_QT5)
else()
include_directories(
${QT_QTCORE_INCLUDE_DIR}
${QT_QTXML_INCLUDE_DIR}
)
list(APPEND FreeCADApp_LIBS
${QT_QTCORE_LIBRARY}
${QT_QTCORE_LIBRARY}
${QT_QTXML_LIBRARY}
)
endif()

View File

@@ -222,4 +222,5 @@ template<> const char* App::GeometryPython::getViewProviderName(void) const {
return "Gui::ViewProviderPythonGeometry";
}
// explicit template instantiation
template class AppExport FeaturePythonT<GeoFeature>;}
template class AppExport FeaturePythonT<GeoFeature>;
}

View File

@@ -161,7 +161,7 @@ std::string Property::encodeAttribute(const std::string& str)
for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) {
if (*it == '<')
tmp += "&lt;";
else if (*it == '"')
else if (*it == '\"')
tmp += "&quot;";
else if (*it == '\'')
tmp += "&apos;";
@@ -170,9 +170,11 @@ std::string Property::encodeAttribute(const std::string& str)
else if (*it == '>')
tmp += "&gt;";
else if (*it == '\r')
tmp += "&#xD;";
tmp += "&#13;";
else if (*it == '\n')
tmp += "&#xA;";
tmp += "&#10;";
else if (*it == '\t')
tmp += "&#9;";
else
tmp += *it;
}

View File

@@ -51,7 +51,7 @@ TYPESYSTEM_SOURCE(App::PropertyContainer,Base::Persistence);
// here the implemataion! description should take place in the header file!
PropertyContainer::PropertyContainer()
{
propertyData.parentPropertyData = 0;
propertyData.parentPropertyData = 0;
}
PropertyContainer::~PropertyContainer()

View File

@@ -42,7 +42,6 @@ include_directories(
${COIN3D_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${XercesC_INCLUDE_DIRS}
${QT_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${3DCONNEXION_INCLUDE_DIR}
)
@@ -785,6 +784,7 @@ set(qsint_MOC_HDRS
QSint/actionpanel/actionpanel.h
QSint/actionpanel/taskheader_p.h
)
if(BUILD_QT5)
qt5_wrap_cpp(qsint_MOC_SRCS ${qsint_MOC_HDRS})
else()

View File

@@ -81,6 +81,7 @@ bool GLPainter::begin(QPaintDevice * device)
glLineWidth(1.0f);
glColor4f(1.0, 1.0, 1.0, 0.0);
glViewport(0, 0, this->width, this->height);
#if !defined(HAVE_QT5_OPENGL)
glDrawBuffer(GL_FRONT);
#endif

View File

@@ -58,19 +58,19 @@
#include <Inventor/annex/HardCopy/SoVectorOutput.h>
#include <Inventor/bundles/SoMaterialBundle.h>
#include <Inventor/bundles/SoTextureCoordinateBundle.h>
#include <Inventor/caches/SoNormalCache.h>
#include <Inventor/caches/SoNormalCache.h>
#include <Inventor/details/SoFaceDetail.h>
#include <Inventor/details/SoLineDetail.h>
#include <Inventor/details/SoPointDetail.h>
#include <Inventor/draggers/SoDragger.h>
#include <Inventor/draggers/SoTransformerDragger.h>
#include <Inventor/draggers/SoTrackballDragger.h>
#include <Inventor/elements/SoCoordinateElement.h>
#include <Inventor/elements/SoCreaseAngleElement.h>
#include <Inventor/elements/SoCoordinateElement.h>
#include <Inventor/elements/SoCreaseAngleElement.h>
#include <Inventor/elements/SoGLCacheContextElement.h>
#include <Inventor/elements/SoGLCoordinateElement.h>
#include <Inventor/elements/SoNormalBindingElement.h>
#include <Inventor/elements/SoNormalElement.h>
#include <Inventor/elements/SoGLCoordinateElement.h>
#include <Inventor/elements/SoNormalBindingElement.h>
#include <Inventor/elements/SoNormalElement.h>
#include <Inventor/elements/SoReplacedElement.h>
#include <Inventor/elements/SoViewportRegionElement.h>
#include <Inventor/elements/SoViewVolumeElement.h>
@@ -118,7 +118,7 @@
#include <Inventor/nodes/SoMarkerSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoMaterialBinding.h>
#include <Inventor/nodes/SoMatrixTransform.h>
#include <Inventor/nodes/SoMatrixTransform.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoNurbsSurface.h>
#include <Inventor/nodes/SoOrthographicCamera.h>
@@ -153,6 +153,4 @@
#include <Inventor/sensors/SoNodeSensor.h>
#include <Inventor/VRMLnodes/SoVRMLGroup.h>
#endif
#endif

View File

@@ -28,7 +28,6 @@
# include <QLabel>
# include <QMenu>
# include <QMessageBox>
# include <QGLWidget>
# include <QPainter>
# include <QSplitter>
# include <QStatusBar>

View File

@@ -217,7 +217,7 @@ public:
void slotDeletedObject(const Gui::ViewProvider& Obj);
protected:
bool computeAlignment(const std::vector<PickedPoint>& unnavPts, const std::vector<PickedPoint>& fixPts);
bool computeAlignment(const std::vector<PickedPoint>& movPts, const std::vector<PickedPoint>& fixPts);
void continueAlignment();
void showInstructions();
/** @name Probe picking */

View File

@@ -143,6 +143,7 @@ protected:
virtual void draw();
virtual int popupMenu();
protected:
Gui::Polyline polyline;
bool lastConfirmed;
};

View File

@@ -64,11 +64,11 @@ struct NavigationStyleP {
{
this->animationsteps = 0;
this->animationdelta = 0;
this->animsensor = 0;
this->sensitivity = 2.0f;
this->resetcursorpos = false;
this->dragPointFound = false;
this->dragAtCursor = false;
this->animsensor = 0;
}
static void viewAnimationCB(void * data, SoSensor * sensor);
};

View File

@@ -416,6 +416,7 @@ PythonConsole::PythonConsole(QWidget *parent)
: TextEdit(parent), WindowParameter( "Editor" ), _sourceDrain(NULL)
{
d = new PythonConsoleP();
d->interactive = false;
// create an instance of InteractiveInterpreter
try {

View File

@@ -803,7 +803,7 @@ SoFCSelection::redrawHighlighted(SoAction * action , SbBool doHighlight )
//void* window;
//void* context;
//void *display;
QGLWidget* window;
QtGLWidget* window;
SoGLRenderAction *glAction;
//SoWindowElement::get(state, window, context, display, glAction);
SoGLWidgetElement::get(state, window);

View File

@@ -666,7 +666,6 @@ void View3DInventorViewer::removeViewProvider(ViewProvider* pcProvider)
_ViewProviderSet.erase(pcProvider);
}
SbBool View3DInventorViewer::setEditingViewProvider(Gui::ViewProvider* p, int ModNum)
{
if (this->editViewProvider)
@@ -1746,7 +1745,6 @@ bool View3DInventorViewer::processSoEvent(const SoEvent* ev)
case SoKeyboardEvent::ESCAPE:
case SoKeyboardEvent::Q: // ignore 'Q' keys (to prevent app from being closed)
return inherited::processSoEvent(ev);
default:
break;
}
@@ -2631,51 +2629,7 @@ void View3DInventorViewer::drawArrow(void)
}
// ************************************************************************
#if 0
#define HAND_WITH 24
#define HAND_HEIGHT 24
#define HAND_HOT_X 9
#define HAND_HOT_Y 0
static unsigned char hand_bitmap[] = {
0x00,0x03,0x00,0x80,0x04,0x00,0x80,0x04,0x00,0x80,0x04,0x00,0x80,0x04,0x00,
0x80,0x1c,0x00,0x80,0xe4,0x00,0x80,0x24,0x01,0x80,0x24,0x07,0x8e,0x24,0x09,
0x92,0x24,0x09,0xa4,0x00,0x09,0xc4,0x00,0x08,0x08,0x00,0x08,0x08,0x00,0x08,
0x10,0x00,0x08,0x10,0x00,0x04,0x20,0x00,0x04,0x20,0x00,0x04,0x40,0x00,0x02,
0x80,0x00,0x02,0x00,0x01,0x01,0x00,0xff,0x01,0x00,0x00,0x00,0x00,0xab,0xab,
0xab,0xab,0xab,0xab,0xab,0xab,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x00,0x1b,0x00,0xee,0x04,0xee
};
static unsigned char hand_mask_bitmap[] = {
0x00,0x03,0x00,0x80,0x07,0x00,0x80,0x07,0x00,0x80,0x07,0x00,0x80,0x07,0x00,
0x80,0x1f,0x00,0x80,0xff,0x00,0x80,0xff,0x01,0x80,0xff,0x07,0x8e,0xff,0x0f,
0x9e,0xff,0x0f,0xbc,0xff,0x0f,0xfc,0xff,0x0f,0xf8,0xff,0x0f,0xf8,0xff,0x0f,
0xf0,0xff,0x0f,0xf0,0xff,0x07,0xe0,0xff,0x07,0xe0,0xff,0x07,0xc0,0xff,0x03,
0x80,0xff,0x03,0x00,0xff,0x01,0x00,0xff,0x01,0x00,0x00,0x00,0x00,0xab,0xab,
0xab,0xab,0xab,0xab,0xab,0xab,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
0x00,0x1b,0x00,0xd5,0x07,0x1c
};
#define CROSS_WIDTH 16
#define CROSS_HEIGHT 16
#define CROSS_HOT_X 7
#define CROSS_HOT_Y 7
static unsigned char cross_bitmap[] = {
0xc0, 0x03, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x7f, 0xfe, 0x01, 0x80,
0x01, 0x80, 0x7f, 0xfe, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0xc0, 0x03
};
static unsigned char cross_mask_bitmap[] = {
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03
};
#endif
// Set cursor graphics according to mode.
void View3DInventorViewer::setCursorRepresentation(int modearg)
{
@@ -2705,7 +2659,6 @@ void View3DInventorViewer::setCursorRepresentation(int modearg)
this->getWidget()->setCursor(this->editCursor);
else
this->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
break;
case NavigationStyle::DRAGGING:
@@ -2896,6 +2849,7 @@ PyObject *View3DInventorViewer::getPyObject(void)
Py_INCREF(_viewerPy);
return _viewerPy;
}
/**
* Drops the event \a e and loads the files into the given document.
*/

View File

@@ -1116,7 +1116,7 @@ Py::Object View3DInventorPy::getStereoType(const Py::Tuple& args)
throw Py::Exception();
try {
int mode = (int)(_view->getViewer()->stereoMode());
int mode = (int)(_view->getViewer()->stereoMode());
return Py::String(StereoTypeEnums[mode]);
}
catch (const Base::Exception& e) {
@@ -2163,49 +2163,49 @@ Py::Object View3DInventorPy::addDraggerCallback(const Py::Tuple& args)
Py::Object View3DInventorPy::removeDraggerCallback(const Py::Tuple& args)
{
PyObject* dragger;
char* type;
PyObject* method;
if (!PyArg_ParseTuple(args.ptr(), "OsO", &dragger, &type, &method))
throw Py::Exception();
PyObject* dragger;
char* type;
PyObject* method;
if (!PyArg_ParseTuple(args.ptr(), "OsO", &dragger, &type, &method))
throw Py::Exception();
//Check if dragger is a SoDragger object and cast
void* ptr = 0;
try {
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDragger *", dragger, &ptr, 0);
}
catch (const Base::Exception&) {
throw Py::Exception("The first argument must be of type SoDragger");
}
//Check if dragger is a SoDragger object and cast
void* ptr = 0;
try {
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDragger *", dragger, &ptr, 0);
}
catch (const Base::Exception&) {
throw Py::Exception("The first argument must be of type SoDragger");
}
SoDragger* drag = reinterpret_cast<SoDragger*>(ptr);
try {
if (strcmp(type, "addFinishCallback") == 0) {
drag->removeFinishCallback(draggerCallback, method);
}
else if (strcmp(type, "addStartCallback") == 0) {
drag->removeStartCallback(draggerCallback, method);
}
else if (strcmp(type, "addMotionCallback") == 0) {
drag->removeMotionCallback(draggerCallback, method);
}
else if (strcmp(type, "addValueChangedCallback") == 0) {
drag->removeValueChangedCallback(draggerCallback, method);
}
else {
std::string s;
std::ostringstream s_out;
s_out << type << " is not a valid dragger callback type";
throw Py::Exception(s_out.str());
}
SoDragger* drag = reinterpret_cast<SoDragger*>(ptr);
try {
if (strcmp(type, "addFinishCallback") == 0) {
drag->removeFinishCallback(draggerCallback, method);
}
else if (strcmp(type, "addStartCallback") == 0) {
drag->removeStartCallback(draggerCallback, method);
}
else if (strcmp(type, "addMotionCallback") == 0) {
drag->removeMotionCallback(draggerCallback, method);
}
else if (strcmp(type, "addValueChangedCallback") == 0) {
drag->removeValueChangedCallback(draggerCallback, method);
}
else {
std::string s;
std::ostringstream s_out;
s_out << type << " is not a valid dragger callback type";
throw Py::Exception(s_out.str());
}
callbacks.remove(method);
Py_DECREF(method);
return Py::Callable(method, false);
}
catch (const Py::Exception&) {
throw;
}
callbacks.remove(method);
Py_DECREF(method);
return Py::Callable(method, false);
}
catch (const Py::Exception&) {
throw;
}
}
Py::Object View3DInventorPy::setActiveObject(const Py::Tuple& args)

View File

@@ -281,7 +281,7 @@ void ViewProvider::addDisplayMaskMode(SoNode *node, const char* type)
void ViewProvider::setDisplayMaskMode(const char* type)
{
std::map<std::string, int>::const_iterator it = _sDisplayMaskModes.find( type );
std::map<std::string, int>::const_iterator it = _sDisplayMaskModes.find(type);
if (it != _sDisplayMaskModes.end())
_iActualMode = it->second;
else
@@ -339,7 +339,6 @@ vector<std::string> ViewProvider::getDisplayModes(void) const {
return modes;
}
std::string ViewProvider::getActiveDisplayMode(void) const
{
return _sCurrentMode;
@@ -381,7 +380,7 @@ bool ViewProvider::isVisible() const
}
void ViewProvider::setOverrideMode(const std::string &mode)
{
{
if (mode == "As Is") {
viewOverrideMode = -1;
overrideMode = mode;

View File

@@ -470,7 +470,7 @@ void ViewProviderGeometryObject::setSelectable(bool selectable)
SoSearchAction sa;
sa.setInterest(SoSearchAction::ALL);
sa.setSearchingAll(TRUE);
sa.setSearchingAll(true);
sa.setType(Gui::SoFCSelection::getClassTypeId());
sa.apply(pcRoot);

View File

@@ -58,7 +58,7 @@
# undef _POSIX_C_SOURCE
# undef _XOPEN_SOURCE
# include <basewrapper.h>
# include <conversions.h>
# include <sbkconverter.h>
# include <sbkmodule.h>
# include <typeresolver.h>
# include <shiboken.h>
@@ -75,7 +75,7 @@ PyTypeObject** SbkPySide_QtGuiTypes=NULL;
# undef _POSIX_C_SOURCE
# undef _XOPEN_SOURCE
# include <basewrapper.h>
# include <conversions.h>
# include <sbkconverter.h>
# include <sbkmodule.h>
# include <typeresolver.h>
# include <shiboken.h>
@@ -1254,8 +1254,8 @@ void PyResource::load(const char* name)
/**
* Makes a connection between the sender widget \a sender and its signal \a signal
* of the created resource and Python callback function \a cb.
* If the sender widget does not exist or no resource has been loaded this method returns FALSE,
* otherwise it returns TRUE.
* If the sender widget does not exist or no resource has been loaded this method returns false,
* otherwise it returns true.
*/
bool PyResource::connect(const char* sender, const char* signal, PyObject* cb)
{

View File

@@ -439,7 +439,7 @@ QVariant PropertyItem::data(int column, int role) const
}
bool PropertyItem::setData (const QVariant& value)
{
{
cleared = false;
// This is the basic mechanism to set the value to
@@ -447,12 +447,10 @@ bool PropertyItem::setData (const QVariant& value)
// it delegates it to its parent which sets then the
// property or delegates again to its parent...
if (propertyItems.empty()) {
PropertyItem* parent = this->parent();
if (!parent || !parent->parent())
return false;
parent->setProperty(qPrintable(objectName()),value);
return true;
}
else {
@@ -461,7 +459,6 @@ bool PropertyItem::setData (const QVariant& value)
}
}
Qt::ItemFlags PropertyItem::flags(int column) const
{
Qt::ItemFlags basicFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
@@ -2001,7 +1998,7 @@ void PropertyPlacementItem::setValue(const QVariant& value)
}
QWidget* PropertyPlacementItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const
{
{
PlacementEditor *pe = new PlacementEditor(this->propertyName(), parent);
QObject::connect(pe, SIGNAL(valueChanged(const QVariant &)), receiver, method);
pe->setDisabled(isReadOnly());

View File

@@ -192,9 +192,15 @@ int main( int argc, char ** argv )
catch (const Base::ProgramInformation& e) {
QApplication app(argc,argv);
QString appName = QString::fromLatin1(App::Application::Config()["ExeName"].c_str());
QString msg = QString::fromLatin1(e.what());
QString msg = QString::fromUtf8(e.what());
QString s = QLatin1String("<pre>") + msg + QLatin1String("</pre>");
QMessageBox::information(0, appName, s);
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(appName);
msgBox.setDetailedText(msg);
msgBox.setText(s);
msgBox.exec();
exit(0);
}
catch (const Base::Exception& e) {