Merge branch 'master' of git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad

This commit is contained in:
jrheinlaender 2012-10-02 17:20:04 +04:30
commit 016571bf25
39 changed files with 387 additions and 178 deletions

View File

@ -77,6 +77,7 @@ ELSE (WIN32)
FIND_LIBRARY(COIN3D_LIBRARY Coin
/usr/lib
/usr/local/lib
PATH_SUFFIXES Coin2 Coin3
)
ENDIF(APPLE)

View File

@ -277,6 +277,9 @@ set(ODE_FOUND TRUE)
# OCC
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(OCC_LIBRARIES
TKFillet
TKMesh
@ -302,7 +305,11 @@ set(OCC_LIBRARIES
TKHLR
TKFeat
)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
set(OCC_OCAF_LIBRARIES
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
)
set(OCC_FOUND TRUE)

View File

@ -283,6 +283,9 @@ set(OPENCV_FOUND TRUE)
# OCC
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(OCC_LIBRARIES
TKFillet
TKMesh
@ -308,8 +311,12 @@ set(OCC_LIBRARIES
TKHLR
TKFeat
)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
set(OCC_OCAF_LIBRARIES
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
)
set(OCC_FOUND TRUE)

View File

@ -283,6 +283,9 @@ set(OPENCV_FOUND TRUE)
# OCC
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(OCC_LIBRARIES
TKFillet
TKMesh
@ -295,14 +298,7 @@ set(OCC_LIBRARIES
TKShHealing
TKXSBase
TKBool
TKXSBase
TKXCAF
TKLCAF
TKCAF
TKSTEP
TKIGES
TKXDESTEP
TKXDEIGES
TKXSBase
TKBO
TKBRep
TKTopAlgo
@ -316,8 +312,12 @@ set(OCC_LIBRARIES
TKHLR
TKFeat
)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
set(OCC_OCAF_LIBRARIES
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
)
set(OCC_FOUND TRUE)

View File

@ -305,7 +305,42 @@ set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib)
set(OPENCV_FOUND TRUE)
# OCC
#set(OCC_INCLUDE_DIR C:/Projects/LibPack/oce-0.10.0/include/oce)
#set(OCC_LIBRARY_DIR C:/Projects/LibPack/oce-0.10.0/Win64/lib)
#set(OCC_LIBRARIES
# ${OCC_LIBRARY_DIR}/TKFillet.lib
# ${OCC_LIBRARY_DIR}/TKMesh.lib
# ${OCC_LIBRARY_DIR}/TKernel.lib
# ${OCC_LIBRARY_DIR}/TKG2d.lib
# ${OCC_LIBRARY_DIR}/TKG3d.lib
# ${OCC_LIBRARY_DIR}/TKMath.lib
# ${OCC_LIBRARY_DIR}/TKIGES.lib
# ${OCC_LIBRARY_DIR}/TKSTL.lib
# ${OCC_LIBRARY_DIR}/TKShHealing.lib
# ${OCC_LIBRARY_DIR}/TKXSBase.lib
# ${OCC_LIBRARY_DIR}/TKBool.lib
# ${OCC_LIBRARY_DIR}/TKBO.lib
# ${OCC_LIBRARY_DIR}/TKBRep.lib
# ${OCC_LIBRARY_DIR}/TKTopAlgo.lib
# ${OCC_LIBRARY_DIR}/TKGeomAlgo.lib
# ${OCC_LIBRARY_DIR}/TKGeomBase.lib
# ${OCC_LIBRARY_DIR}/TKOffset.lib
# ${OCC_LIBRARY_DIR}/TKPrim.lib
# ${OCC_LIBRARY_DIR}/TKSTEP.lib
# ${OCC_LIBRARY_DIR}/TKSTEPBase.lib
# ${OCC_LIBRARY_DIR}/TKSTEPAttr.lib
# ${OCC_LIBRARY_DIR}/TKHLR.lib
# ${OCC_LIBRARY_DIR}/TKFeat.lib
#)
#set(OCC_OCAF_LIBRARIES
# ${OCC_LIBRARY_DIR}/TKCAF.lib
# ${OCC_LIBRARY_DIR}/TKXCAF.lib
# ${OCC_LIBRARY_DIR}/TKLCAF.lib
# ${OCC_LIBRARY_DIR}/TKXDESTEP.lib
# ${OCC_LIBRARY_DIR}/TKXDEIGES.lib
#)
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade-6.3.0)
set(OCC_LIBRARY_DIR ${FREECAD_LIBPACK_DIR}/lib)
set(OCC_LIBRARIES
TKFillet
TKMesh
@ -331,8 +366,12 @@ set(OCC_LIBRARIES
TKHLR
TKFeat
)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
set(OCC_OCAF_LIBRARIES
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
)
set(OCC_FOUND TRUE)

View File

@ -94,6 +94,9 @@ std::string PropertyPythonObject::toString() const
else if (this->object.hasAttr("__dict__")) {
dump = this->object.getAttr("__dict__");
}
else {
dump = this->object;
}
Py::Tuple args(1);
args.setItem(0, dump);
@ -125,9 +128,12 @@ void PropertyPythonObject::fromString(const std::string& repr)
Py::Callable state(this->object.getAttr("__setstate__"));
state.apply(args);
}
else {
else if (this->object.hasAttr("__dict__")) {
this->object.setAttr("__dict__", res);
}
else {
this->object = res;
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
@ -269,6 +275,9 @@ void PropertyPythonObject::Save (Base::Writer &writer) const
<< " class=\"" << (std::string)name << "\"";
}
}
else {
writer.Stream() << " json=\"yes\"";
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
@ -333,6 +342,9 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader)
load_pickle = true;
buffer = std::string(what[2].second, end);
}
else if (reader.hasAttribute("json")) {
load_json = true;
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text

View File

@ -343,15 +343,20 @@ const char* InterpreterSingleton::init(int argc,char *argv[])
Py_Initialize();
PySys_SetArgv(argc, argv);
PythonStdOutput::init_type();
PythonStdOutput* out = new PythonStdOutput();
PySys_SetObject("stdout", out);
PySys_SetObject("stderr", out);
this->_global = PyEval_SaveThread();
}
return Py_GetPath();
}
void InterpreterSingleton::replaceStdOutput()
{
PyGILStateLocker locker;
PythonStdOutput* out = new PythonStdOutput();
PySys_SetObject("stdout", out);
PySys_SetObject("stderr", out);
}
int InterpreterSingleton::cleanup(void (*func)(void))
{
return Py_AtExit( func );

View File

@ -193,6 +193,7 @@ public:
/// init the interpreter and returns the module search path
const char* init(int argc,char *argv[]);
int runCommandLine(const char *prompt);
void replaceStdOutput();
static InterpreterSingleton &Instance(void);
static void Destruct(void);
//@}

View File

@ -1403,6 +1403,7 @@ static void init_resources()
void Application::initApplication(void)
{
try {
Base::Interpreter().replaceStdOutput();
initTypes();
new Base::ScriptProducer( "FreeCADGuiInit", FreeCADGuiInit );
init_resources();

View File

@ -615,7 +615,7 @@ StdCmdPrint::StdCmdPrint()
void StdCmdPrint::activated(int iMsg)
{
if (getMainWindow()->activeWindow()) {
getMainWindow()->statusBar()->showMessage(QObject::tr("Printing..."));
getMainWindow()->showMessage(QObject::tr("Printing..."));
getMainWindow()->activeWindow()->print();
}
}
@ -670,7 +670,7 @@ StdCmdPrintPdf::StdCmdPrintPdf()
void StdCmdPrintPdf::activated(int iMsg)
{
if (getMainWindow()->activeWindow()) {
getMainWindow()->statusBar()->showMessage(QObject::tr("Exporting PDF..."));
getMainWindow()->showMessage(QObject::tr("Exporting PDF..."));
getMainWindow()->activeWindow()->printPdf();
}
}

View File

@ -508,7 +508,7 @@ bool Document::save(void)
/// Save the document under a new file name
bool Document::saveAs(void)
{
getMainWindow()->statusBar()->showMessage(QObject::tr("Save document under new filename..."));
getMainWindow()->showMessage(QObject::tr("Save document under new filename..."));
QString exe = qApp->applicationName();
QString fn = QFileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe),
@ -554,7 +554,7 @@ bool Document::saveAs(void)
return true;
}
else {
getMainWindow()->statusBar()->showMessage(QObject::tr("Saving aborted"), 2000);
getMainWindow()->showMessage(QObject::tr("Saving aborted"), 2000);
return false;
}
}

View File

@ -734,7 +734,7 @@ void MainWindow::addWindow(MDIView* view)
#endif
#endif
connect(view, SIGNAL(message(const QString&, int)),
statusBar(), SLOT(showMessage(const QString&, int)));
this, SLOT(showMessage(const QString&, int)));
connect(this, SIGNAL(windowStateChanged(MDIView*)),
view, SLOT(windowStateChanged(MDIView*)));
@ -799,7 +799,7 @@ void MainWindow::removeWindow(Gui::MDIView* view)
{
// free all connections
disconnect(view, SIGNAL(message(const QString&, int)),
statusBar(), SLOT(message(const QString&, int )));
this, SLOT(showMessage(const QString&, int )));
disconnect(this, SIGNAL(windowStateChanged(MDIView*)),
view, SLOT(windowStateChanged(MDIView*)));
view->removeEventFilter(this);
@ -1552,7 +1552,16 @@ void MainWindow::showMessage (const QString& message, int timeout)
{
QFontMetrics fm(statusBar()->font());
QString msg = fm.elidedText(message, Qt::ElideMiddle, this->width()/2);
#if QT_VERSION != 0x040801
this->statusBar()->showMessage(msg, timeout);
#else
//#0000665: There is a crash under Ubuntu 12.04 (Qt 4.8.1)
QMetaObject::invokeMethod(statusBar(), "showMessage",
Qt::QueuedConnection,
QGenericReturnArgument(),
Q_ARG(QString,msg),
Q_ARG(int, timeout));
#endif
}
// -------------------------------------------------------------

View File

@ -778,7 +778,7 @@ void ManualAlignment::continueAlignment()
grp.addToViewer(myViewer->getViewer(0));
grp.setAlignable(true);
Gui::getMainWindow()->statusBar()->showMessage(tr("Please pick points in the left and right view"));
Gui::getMainWindow()->showMessage(tr("Please pick points in the left and right view"));
myViewer->getViewer(0)->setEditingCursor(QCursor(Qt::PointingHandCursor));
myViewer->getViewer(1)->setEditingCursor(QCursor(Qt::PointingHandCursor));
@ -838,7 +838,7 @@ void ManualAlignment::finish()
closeViewer();
reset();
Gui::getMainWindow()->statusBar()->showMessage(tr("The alignment has finished"));
Gui::getMainWindow()->showMessage(tr("The alignment has finished"));
// If an event receiver has been defined send the manual alignment finished event to it
emitFinished();
@ -856,7 +856,7 @@ void ManualAlignment::cancel()
myTransform = Base::Placement();
reset();
Gui::getMainWindow()->statusBar()->showMessage(tr("The alignment has been canceled"));
Gui::getMainWindow()->showMessage(tr("The alignment has been canceled"));
// If an event receiver has been defined send the manual alignment cancelled event to it
emitCanceled();
@ -888,7 +888,7 @@ void ManualAlignment::align()
myAlignModel.activeGroup().removeFromViewer(myViewer->getViewer(0));
myAlignModel.activeGroup().setAlignable(false);
std::vector<App::DocumentObject*> pViews = myAlignModel.activeGroup().getViews();
Gui::getMainWindow()->statusBar()->showMessage(tr("Try to align group of views"));
Gui::getMainWindow()->showMessage(tr("Try to align group of views"));
// Compute alignment
bool ok = computeAlignment(myAlignModel.activeGroup().getPoints(), myFixedGroup.getPoints());
@ -928,17 +928,17 @@ void ManualAlignment::showInstructions()
{
// Now we can start the actual alignment
if (myAlignModel.activeGroup().countPoints() < myPickPoints) {
Gui::getMainWindow()->statusBar()->showMessage(
Gui::getMainWindow()->showMessage(
tr("Too few points picked in the left view."
" At least %1 points are needed.").arg(myPickPoints));
}
else if (myFixedGroup.countPoints() < myPickPoints) {
Gui::getMainWindow()->statusBar()->showMessage(
Gui::getMainWindow()->showMessage(
tr("Too few points picked in the right view."
" At least %1 points are needed.").arg(myPickPoints));
}
else if (myAlignModel.activeGroup().countPoints() != myFixedGroup.countPoints()) {
Gui::getMainWindow()->statusBar()->showMessage(
Gui::getMainWindow()->showMessage(
tr("Different number of points picked in left and right view. "
"On the left view %1 points are picked, "
"on the right view %2 points are picked.")
@ -1146,13 +1146,13 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n)
self->applyPickedProbe(that, point);
const SbVec3f& vec = point->getPoint();
Gui::getMainWindow()->statusBar()->showMessage(
Gui::getMainWindow()->showMessage(
tr("Point picked at (%1,%2,%3)")
.arg(vec[0]).arg(vec[1]).arg(vec[2]));
}
}
else {
Gui::getMainWindow()->statusBar()->showMessage(
Gui::getMainWindow()->showMessage(
tr("No point was picked"));
}
}

View File

@ -252,7 +252,7 @@ void Sequencer::showRemainingTime()
Q_ARG(QString,status));
}
else {
getMainWindow()->statusBar()->showMessage(status);
getMainWindow()->showMessage(status);
}
}
}
@ -285,7 +285,7 @@ void Sequencer::resetData()
d->waitCursor = 0;
d->bar->leaveControlEvents();
getMainWindow()->setPaneText(1, QString());
getMainWindow()->statusBar()->showMessage(QString());
getMainWindow()->showMessage(QString());
}
SequencerBase::resetData();
@ -313,7 +313,7 @@ void Sequencer::setText (const char* pszTxt)
Q_ARG(QString,d->text));
}
else {
getMainWindow()->statusBar()->showMessage(d->text);
getMainWindow()->showMessage(d->text);
}
}

View File

@ -960,6 +960,11 @@ PyMethodDef SelectionSingleton::Methods[] = {
"given the complete selection is cleared."},
{"isSelected", (PyCFunction) SelectionSingleton::sIsSelected, 1,
"isSelected(object) -- Check if a given object is selected"},
{"countObjectsOfType", (PyCFunction) SelectionSingleton::sCountObjectsOfType, 1,
"countObjectsOfType(string, [string]) -- Get the number of selected objects\n"
"The first argument defines the object type e.g. \"Part::Feature\" and the\n"
"second argumeht defines the document name. If no document name is given the\n"
"currently active document is used"},
{"getSelection", (PyCFunction) SelectionSingleton::sGetSelection, 1,
"getSelection([string]) -- Return a list of selected objets\n"
"Return a list of selected objects for a given document name. If no\n"
@ -974,13 +979,13 @@ PyMethodDef SelectionSingleton::Methods[] = {
"addObserver(Object) -- Install an observer\n"},
{"removeObserver", (PyCFunction) SelectionSingleton::sRemSelObserver, 1,
"removeObserver(Object) -- Uninstall an observer\n"},
{"addSelectionGate", (PyCFunction) SelectionSingleton::saddSelectionGate, 1,
{"addSelectionGate", (PyCFunction) SelectionSingleton::sAddSelectionGate, 1,
"addSelectionGate(String) -- activate the selection gate.\n"
"The selection gate will prohibit all selections which do not match the\n"
"the given selection filter string. Examples strings are:\n"
"'SELECT Part::Feature SUB Edge',\n"
"'SELECT Robot::RobotObject'\n"},
{"removeSelectionGate", (PyCFunction) SelectionSingleton::sremoveSelectionGate, 1,
{"removeSelectionGate", (PyCFunction) SelectionSingleton::sRemoveSelectionGate, 1,
"removeSelectionGate() -- remove the active slection gate\n"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
@ -1049,6 +1054,17 @@ PyObject *SelectionSingleton::sIsSelected(PyObject * /*self*/, PyObject *args, P
return Py_BuildValue("O", (ok ? Py_True : Py_False));
}
PyObject *SelectionSingleton::sCountObjectsOfType(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
{
char* objecttype;
char* document=0;
if (!PyArg_ParseTuple(args, "s|s", &objecttype, &document))
return NULL;
unsigned int count = Selection().countObjectsOfType(objecttype, document);
return PyInt_FromLong(count);
}
PyObject *SelectionSingleton::sGetSelection(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
{
char *documentName=0;
@ -1116,7 +1132,7 @@ PyObject *SelectionSingleton::sRemSelObserver(PyObject * /*self*/, PyObject *arg
} PY_CATCH;
}
PyObject *SelectionSingleton::saddSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
PyObject *SelectionSingleton::sAddSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
{
char* filter;
if (!PyArg_ParseTuple(args, "s",&filter))
@ -1129,7 +1145,7 @@ PyObject *SelectionSingleton::saddSelectionGate(PyObject * /*self*/, PyObject *a
Py_Return;
}
PyObject *SelectionSingleton::sremoveSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
PyObject *SelectionSingleton::sRemoveSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
{
if (!PyArg_ParseTuple(args, ""))
return NULL; // NULL triggers exception

View File

@ -306,12 +306,13 @@ protected:
static PyObject *sRemoveSelection (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sClearSelection (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sIsSelected (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sCountObjectsOfType (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sGetSelection (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sGetSelectionEx (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sAddSelObserver (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sRemSelObserver (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *saddSelectionGate (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sremoveSelectionGate (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sAddSelectionGate (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject *sRemoveSelectionGate (PyObject *self,PyObject *args,PyObject *kwd);
protected:
/// Construction

View File

@ -568,7 +568,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action)
,pp->getPoint()[1]
,pp->getPoint()[2]);
getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000);
getMainWindow()->showMessage(QString::fromAscii(buf),3000);
}
}
}
@ -602,7 +602,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action)
,pp->getPoint()[1]
,pp->getPoint()[2]);
getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000);
getMainWindow()->showMessage(QString::fromAscii(buf),3000);
}
}

View File

@ -1201,7 +1201,7 @@ void DocumentObjectItem::displayStatusInfo()
QString info = QString::fromAscii(Obj->getStatusString());
if ( Obj->mustExecute() == 1 )
info += QString::fromAscii(" (but must be executed)");
getMainWindow()->statusBar()->showMessage( info );
getMainWindow()->showMessage( info );
}

View File

@ -2081,7 +2081,7 @@ SoPath * View3DInventorViewer::pickFilterCB(void *viewer, const SoPickedPoint *
,pp->getPoint()[1]
,pp->getPoint()[2]);
getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000);
getMainWindow()->showMessage(QString::fromAscii(buf),3000);
}
return pp->getPath();
}

View File

@ -26,6 +26,11 @@
# if defined (_POSIX_C_SOURCE)
# undef _POSIX_C_SOURCE
# endif // (re-)defined in pyconfig.h
#include <cmath>
#ifndef PI
#define PI M_PI
#endif
//Basic Stuff
#include <Base/Console.h>
@ -93,9 +98,6 @@
#include "SpringbackCorrection.h"
using namespace Part;
using namespace Mesh;
using namespace std;

View File

@ -480,20 +480,24 @@ private:
};
/* module functions */
static PyObject * importer(PyObject *self, PyObject *args)
{
const char* Name;
const char* DocName;
if (!PyArg_ParseTuple(args, "ss",&Name,&DocName))
char* Name;
char* DocName=0;
if (!PyArg_ParseTuple(args, "s|s",&Name,&DocName))
return 0;
PY_TRY {
//Base::Console().Log("Insert in Part with %s",Name);
Base::FileInfo file(Name);
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
App::Document *pcDoc = 0;
if (DocName) {
pcDoc = App::GetApplication().getDocument(DocName);
}
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
pcDoc = App::GetApplication().newDocument("Unnamed");
}
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
@ -561,6 +565,11 @@ static PyObject * importer(PyObject *self, PyObject *args)
Py_Return;
}
static PyObject * open(PyObject *self, PyObject *args)
{
return importer(self, args);
}
static PyObject * exporter(PyObject *self, PyObject *args)
{
PyObject* object;
@ -946,6 +955,8 @@ static PyObject * ocaf(PyObject *self, PyObject *args)
/* registration table */
struct PyMethodDef ImportGui_Import_methods[] = {
{"open" ,open ,METH_VARARGS,
"open(string) -- Open the file and create a new document."},
{"insert" ,importer ,METH_VARARGS,
"insert(string,string) -- Insert the file into the given document."},
{"export" ,exporter ,METH_VARARGS,

View File

@ -22,11 +22,7 @@ link_directories(${OCC_LIBRARY_DIR})
set(ImportGui_LIBS
FreeCADGui
PartGui
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
${OCC_OCAF_LIBRARIES}
)
SET(ImportGui_SRCS

View File

@ -29,5 +29,5 @@
# Append the open handler
#FreeCAD.addImportType("STEP 214 (*.step *.stp)","ImportGui")
FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui")
#FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui")
#FreeCAD.addExportType("IGES files (*.iges *.igs)","ImportGui")

View File

@ -1562,7 +1562,10 @@ void ViewProviderMesh::setSelection(const std::vector<unsigned long>& indices)
rMesh.addFacetsToSelection(indices);
// Colorize the selection
highlightSelection();
if (indices.empty())
unhighlightSelection();
else
highlightSelection();
}
void ViewProviderMesh::addSelection(const std::vector<unsigned long>& indices)
@ -1627,7 +1630,7 @@ void ViewProviderMesh::highlightSelection()
const Mesh::MeshObject& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue();
rMesh.getFacetsFromSelection(selection);
if (selection.empty()) {
// If no faces are selected then simply return even without
// If no faces are selected then simply return even
// without calling unhighlightSelection()
return;
}

View File

@ -160,7 +160,12 @@ void ViewProviderMeshFaceSet::updateData(const App::Property* prop)
}
showOpenEdges(OpenEdges.getValue());
highlightSelection();
std::vector<unsigned long> selection;
mesh->getFacetsFromSelection(selection);
if (selection.empty())
unhighlightSelection();
else
highlightSelection();
}
}

View File

@ -92,6 +92,17 @@ void PartExport initPart()
str << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE;
App::Application::Config()["OCC_VERSION"] = str.str();
// see Init.py
#if defined (_OCC64)
#if OCC_VERSION_HEX < 0x060503
App::GetApplication().addImportType("STEP AP203 format (*.step *.stp)","Part");
App::GetApplication().addExportType("STEP AP203 format (*.step *.stp)","Part");
#else
App::GetApplication().addImportType("STEP AP214 format (*.step *.stp)","ImportGui");
App::GetApplication().addExportType("STEP AP214 format (*.step *.stp)","ImportGui");
#endif
#endif
PyObject* partModule = Py_InitModule3("Part", Part_methods, module_part_doc); /* mod name, table ptr */
Base::Console().Log("Loading Part module... done\n");

View File

@ -125,7 +125,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
//Handle_XSControl_TransferReader tr = ws->TransferReader();
std::map<int, Quantity_Color> hash_col;
ReadColors(aReader.WS(), hash_col);
//ReadColors(aReader.WS(), hash_col);
//ReadNames(aReader.WS());
for (Standard_Integer i=1; i<=nbs; i++) {

View File

@ -446,23 +446,20 @@ CmdPartImport::CmdPartImport()
void CmdPartImport::activated(int iMsg)
{
QStringList filter;
filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
filter << QObject::tr("STEP (*.stp *.step)");
filter << QObject::tr("IGES (*.igs *.iges)");
filter << QObject::tr("BREP (*.brp *.brep)");
filter << QObject::tr("All Files (*.*)");
filter << QString::fromAscii("STEP AP203 (*.stp *.step)");
filter << QString::fromAscii("STEP AP214 (*.stp *.step)");
filter << QString::fromAscii("IGES (*.igs *.iges)");
filter << QString::fromAscii("BREP (*.brp *.brep)");
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
QString select;
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")), &select);
if (!fn.isEmpty()) {
Gui::WaitCursor wc;
App::Document* pDoc = getDocument();
if (!pDoc) return; // no document
openCommand("Import Part");
QString ext = QFileInfo(fn).suffix().toLower();
if (ext == QLatin1String("step") ||
ext == QLatin1String("stp") ||
ext == QLatin1String("iges") ||
ext == QLatin1String("igs")) {
if (select == filter[1] ||
select == filter[2]) {
doCommand(Doc, "import ImportGui");
doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName());
}
@ -507,21 +504,18 @@ CmdPartExport::CmdPartExport()
void CmdPartExport::activated(int iMsg)
{
QStringList filter;
filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
filter << QObject::tr("STEP (*.stp *.step)");
filter << QObject::tr("IGES (*.igs *.iges)");
filter << QObject::tr("BREP (*.brp *.brep)");
filter << QObject::tr("All Files (*.*)");
filter << QString::fromAscii("STEP AP203 (*.stp *.step)");
filter << QString::fromAscii("STEP AP214 (*.stp *.step)");
filter << QString::fromAscii("IGES (*.igs *.iges)");
filter << QString::fromAscii("BREP (*.brp *.brep)");
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
QString select;
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")), &select);
if (!fn.isEmpty()) {
App::Document* pDoc = getDocument();
if (!pDoc) return; // no document
QString ext = QFileInfo(fn).suffix().toLower();
if (ext == QLatin1String("step") ||
ext == QLatin1String("stp") ||
ext == QLatin1String("iges") ||
ext == QLatin1String("igs")) {
if (select == filter[1] ||
select == filter[2]) {
Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui");
}
else {

View File

@ -963,7 +963,7 @@ void SoBrepEdgeSet::renderHighlight(SoGLRenderAction *action)
SoLazyElement::setEmissive(state, &this->highlightColor);
SoOverrideElement::setEmissiveColorOverride(state, this, TRUE);
SoLazyElement::setDiffuse(state, this,1, &this->highlightColor,&this->colorpacker);
SoLazyElement::setDiffuse(state, this,1, &this->highlightColor,&this->colorpacker1);
SoOverrideElement::setDiffuseColorOverride(state, this, TRUE);
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
@ -1000,7 +1000,7 @@ void SoBrepEdgeSet::renderSelection(SoGLRenderAction *action)
SoLazyElement::setEmissive(state, &this->selectionColor);
SoOverrideElement::setEmissiveColorOverride(state, this, TRUE);
SoLazyElement::setDiffuse(state, this,1, &this->selectionColor,&this->colorpacker);
SoLazyElement::setDiffuse(state, this,1, &this->selectionColor,&this->colorpacker2);
SoOverrideElement::setDiffuseColorOverride(state, this, TRUE);
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
@ -1178,6 +1178,12 @@ SoBrepPointSet::SoBrepPointSet()
void SoBrepPointSet::GLRender(SoGLRenderAction *action)
{
const SoCoordinateElement* coords = SoCoordinateElement::getInstance(action->getState());
int num = coords->getNum() - this->startIndex.getValue();
if (num < 0) {
// Fixes: #0000545: Undo revolve causes crash 'illegal storage'
return;
}
if (this->selectionIndex.getNum() > 0)
renderSelection(action);
if (this->highlightIndex.getValue() >= 0)

View File

@ -30,7 +30,7 @@
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoIndexedLineSet.h>
#include <Inventor/nodes/SoPointSet.h>
#include <Inventor/elements/SoLazyElement.h>
#include <Inventor/elements/SoLazyElement.h>
#include <Inventor/elements/SoReplacedElement.h>
#include <vector>
@ -56,49 +56,49 @@ protected:
virtual ~SoBrepFaceSet() {};
virtual void GLRender(SoGLRenderAction *action);
virtual void GLRenderBelowPath(SoGLRenderAction * action);
virtual void doAction(SoAction* action);
virtual SoDetail * createTriangleDetail(
SoRayPickAction * action,
const SoPrimitiveVertex * v1,
const SoPrimitiveVertex * v2,
const SoPrimitiveVertex * v3,
virtual void doAction(SoAction* action);
virtual SoDetail * createTriangleDetail(
SoRayPickAction * action,
const SoPrimitiveVertex * v1,
const SoPrimitiveVertex * v2,
const SoPrimitiveVertex * v3,
SoPickedPoint * pp);
virtual void generatePrimitives(SoAction * action);
private:
enum Binding {
OVERALL = 0,
PER_PART,
PER_PART_INDEXED,
PER_FACE,
PER_FACE_INDEXED,
PER_VERTEX,
PER_VERTEX_INDEXED,
NONE = OVERALL
};
Binding findMaterialBinding(SoState * const state) const;
Binding findNormalBinding(SoState * const state) const;
void renderShape(const SoGLCoordinateElement * const vertexlist,
const int32_t *vertexindices,
int num_vertexindices,
const int32_t *partindices,
int num_partindices,
const SbVec3f *normals,
const int32_t *normindices,
SoMaterialBundle *const materials,
const int32_t *matindices,
SoTextureCoordinateBundle * const texcoords,
const int32_t *texindices,
const int nbind,
const int mbind,
const int texture);
void renderHighlight(SoGLRenderAction *action);
void renderSelection(SoGLRenderAction *action);
private:
SbColor selectionColor;
SbColor highlightColor;
SoColorPacker colorpacker;
enum Binding {
OVERALL = 0,
PER_PART,
PER_PART_INDEXED,
PER_FACE,
PER_FACE_INDEXED,
PER_VERTEX,
PER_VERTEX_INDEXED,
NONE = OVERALL
};
Binding findMaterialBinding(SoState * const state) const;
Binding findNormalBinding(SoState * const state) const;
void renderShape(const SoGLCoordinateElement * const vertexlist,
const int32_t *vertexindices,
int num_vertexindices,
const int32_t *partindices,
int num_partindices,
const SbVec3f *normals,
const int32_t *normindices,
SoMaterialBundle *const materials,
const int32_t *matindices,
SoTextureCoordinateBundle * const texcoords,
const int32_t *texindices,
const int nbind,
const int mbind,
const int texture);
void renderHighlight(SoGLRenderAction *action);
void renderSelection(SoGLRenderAction *action);
private:
SbColor selectionColor;
SbColor highlightColor;
SoColorPacker colorpacker;
};
// ---------------------------------------------------------------------
@ -119,24 +119,27 @@ protected:
virtual ~SoBrepEdgeSet() {};
virtual void GLRender(SoGLRenderAction *action);
virtual void GLRenderBelowPath(SoGLRenderAction * action);
virtual void doAction(SoAction* action);
virtual SoDetail * createLineSegmentDetail(
SoRayPickAction *action,
const SoPrimitiveVertex *v1,
const SoPrimitiveVertex *v2,
SoPickedPoint *pp);
private:
void renderShape(const SoGLCoordinateElement * const vertexlist,
const int32_t *vertexindices,
int num_vertexindices);
void renderHighlight(SoGLRenderAction *action);
void renderSelection(SoGLRenderAction *action);
private:
std::vector<int32_t> hl, sl;
SbColor selectionColor;
SbColor highlightColor;
SoColorPacker colorpacker;
virtual void doAction(SoAction* action);
virtual SoDetail * createLineSegmentDetail(
SoRayPickAction *action,
const SoPrimitiveVertex *v1,
const SoPrimitiveVertex *v2,
SoPickedPoint *pp);
private:
void renderShape(const SoGLCoordinateElement * const vertexlist,
const int32_t *vertexindices,
int num_vertexindices);
void renderHighlight(SoGLRenderAction *action);
void renderSelection(SoGLRenderAction *action);
private:
std::vector<int32_t> hl, sl;
SbColor selectionColor;
SbColor highlightColor;
//#0000834: Minor preselection color bug
//To solve this we need a seprate color packer for highlighting and selection
SoColorPacker colorpacker1;
SoColorPacker colorpacker2;
};
// ---------------------------------------------------------------------
@ -157,19 +160,19 @@ protected:
virtual ~SoBrepPointSet() {};
virtual void GLRender(SoGLRenderAction *action);
virtual void GLRenderBelowPath(SoGLRenderAction * action);
virtual void doAction(SoAction* action);
private:
void renderShape(const SoGLCoordinateElement * const vertexlist,
const int32_t *vertexindices,
int num_vertexindices);
void renderHighlight(SoGLRenderAction *action);
void renderSelection(SoGLRenderAction *action);
private:
SbColor selectionColor;
SbColor highlightColor;
SoColorPacker colorpacker;
virtual void doAction(SoAction* action);
private:
void renderShape(const SoGLCoordinateElement * const vertexlist,
const int32_t *vertexindices,
int num_vertexindices);
void renderHighlight(SoGLRenderAction *action);
void renderSelection(SoGLRenderAction *action);
private:
SbColor selectionColor;
SbColor highlightColor;
SoColorPacker colorpacker;
};
} // namespace PartGui

View File

@ -521,6 +521,9 @@ QString SetupResultBase::selectionName(ResultEntry *entry, const TopoDS_Shape &s
TopExp::MapShapes(parentEntry->shape, TopAbs_VERTEX, shapeMap);
stream << "Vertex";
break;
default:
stream << "Unexpected shape type";
break;
}
index = shapeMap.FindIndex(shape);

View File

@ -578,6 +578,7 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape)
faceset ->coordIndex .setNum(0);
faceset ->partIndex .setNum(0);
lineset ->coordIndex .setNum(0);
nodeset ->startIndex .setValue(0);
VisualTouched = false;
return;
}

View File

@ -43,6 +43,20 @@ ParGrp.SetString("WorkBenchName", "Part Design")
ParGrp.SetString("WorkBenchModule", "PartWorkbench.py")
FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
#FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
#FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
FreeCAD.addImportType("BREP format (*.brep *.brp)","Part")
FreeCAD.addExportType("BREP format (*.brep *.brp)","Part")
FreeCAD.addImportType("IGES format (*.iges *.igs)","Part")
FreeCAD.addExportType("IGES format (*.iges *.igs)","Part")
# There is a bug in OCC 6.5.0 64-bit and older which leads to a crash
# The registration of the STEP filetype for 64-bit is handled in initPart()
import platform
if platform.architecture()[0]=='32bit':
FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui")
FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui")
#else:
# FreeCAD.addImportType("STEP AP203 format (*.step *.stp)","Part")
# FreeCAD.addExportType("STEP AP203 format (*.step *.stp)","Part")

View File

@ -21,18 +21,28 @@ libPartDesign_la_SOURCES=\
FeatureGroove.h \
Body.cpp \
Body.h \
FeatureLinearPattern.cpp \
FeatureLinearPattern.h \
FeatureMirrored.cpp \
FeatureMirrored.h \
FeatureMultiTransform.cpp \
FeatureMultiTransform.h \
FeaturePolarPattern.cpp \
FeaturePolarPattern.h \
FeatureScaled.cpp \
FeatureScaled.h \
FeatureSketchBased.cpp \
FeatureSketchBased.h \
FeatureRevolution.cpp \
FeatureRevolution.h \
FeatureAdditive.cpp \
FeatureAdditive.h \
FeaturePatternRectangular.cpp \
FeaturePatternRectangular.h \
FeatureSubtractive.cpp \
FeatureSubtractive.h \
FeatureHole.cpp \
FeatureHole.h \
FeatureTransformed.cpp \
FeatureTransformed.h \
PreCompiled.cpp \
PreCompiled.h

View File

@ -3,62 +3,103 @@ SUBDIRS=Resources
lib_LTLIBRARIES=libPartDesignGui.la PartDesignGui.la
BUILT_SOURCES=\
moc_FeaturePickDialog.cpp \
moc_TaskPadParameters.cpp \
moc_TaskPatternRectangularParameters.cpp \
moc_TaskPocketParameters.cpp \
moc_TaskChamferParameters.cpp \
moc_TaskFilletParameters.cpp \
moc_TaskGrooveParameters.cpp \
moc_TaskHoleParameters.cpp \
moc_TaskLinearPatternParameters.cpp \
moc_TaskMirroredParameters.cpp \
moc_TaskMultiTransformParameters.cpp \
moc_TaskPolarPatternParameters.cpp \
moc_TaskRevolutionParameters.cpp \
moc_TaskScaledParameters.cpp \
moc_TaskTransformedMessages.cpp \
moc_TaskTransformedParameters.cpp \
ui_FeaturePickDialog.h \
ui_TaskGrooveParameters.h \
ui_TaskPadParameters.h \
ui_TaskPatternRectangularParameters.h \
ui_TaskPocketParameters.h \
ui_TaskChamferParameters.h \
ui_TaskFilletParameters.h \
ui_TaskHoleParameters.h \
ui_TaskRevolutionParameters.h
ui_TaskLinearPatternParameters.h \
ui_TaskMirroredParameters.h \
ui_TaskMultiTransformParameters.h \
ui_TaskPolarPatternParameters.h \
ui_TaskRevolutionParameters.h \
ui_TaskScaledParameters.h \
ui_TaskTransformedMessages.h
libPartDesignGui_la_UI=\
FeaturePickDialog.ui \
TaskGrooveParameters.ui \
TaskPadParameters.ui \
TaskPatternRectangularParameters.ui \
TaskPocketParameters.ui \
TaskChamferParameters.ui \
TaskFilletParameters.ui \
TaskHoleParameters.ui \
TaskRevolutionParameters.ui
TaskLinearPatternParameters.ui \
TaskMirroredParameters.ui \
TaskMultiTransformParameters.ui \
TaskPolarPatternParameters.ui \
TaskRevolutionParameters.ui \
TaskScaledParameters.ui \
TaskTransformedMessages.ui
libPartDesignGui_la_SOURCES=\
AppPartDesignGuiPy.cpp \
Command.cpp \
PreCompiled.cpp \
PreCompiled.h \
FeaturePickDialog.cpp \
FeaturePickDialog.h \
TaskGrooveParameters.cpp \
TaskGrooveParameters.h \
TaskPadParameters.cpp \
TaskPadParameters.h \
TaskPatternRectangularParameters.cpp \
TaskPatternRectangularParameters.h \
TaskPocketParameters.cpp \
TaskPocketParameters.h \
TaskChamferParameters.cpp \
TaskChamferParameters.h \
TaskFilletParameters.cpp \
TaskFilletParameters.h \
TaskLinearPatternParameters.cpp \
TaskLinearPatternParameters.h \
TaskMirroredParameters.cpp \
TaskMirroredParameters.h \
TaskMultiTransformParameters.cpp \
TaskMultiTransformParameters.h \
TaskPolarPatternParameters.cpp \
TaskPolarPatternParameters.h \
TaskRevolutionParameters.cpp \
TaskRevolutionParameters.h \
TaskHoleParameters.cpp \
TaskHoleParameters.h \
TaskScaledParameters.cpp \
TaskScaledParameters.h \
TaskTransformedParameters.cpp \
TaskTransformedParameters.h \
TaskTransformedMessages.cpp \
TaskTransformedMessages.h \
ViewProvider.cpp \
ViewProvider.h \
ViewProviderHole.cpp \
ViewProviderHole.h \
ViewProviderLinearPattern.cpp \
ViewProviderLinearPattern.h \
ViewProviderMirrored.cpp \
ViewProviderMirrored.h \
ViewProviderMultiTransform.cpp \
ViewProviderMultiTransform.h \
ViewProviderPad.cpp \
ViewProviderPad.h \
ViewProviderPocket.cpp \
ViewProviderPocket.h \
ViewProviderPolarPattern.cpp \
ViewProviderPolarPattern.h \
ViewProviderChamfer.cpp \
ViewProviderChamfer.h \
ViewProviderFillet.cpp \
@ -67,8 +108,10 @@ libPartDesignGui_la_SOURCES=\
ViewProviderGroove.h \
ViewProviderRevolution.cpp \
ViewProviderRevolution.h \
ViewProviderPatternRectangular.cpp \
ViewProviderPatternRectangular.h \
ViewProviderScaled.cpp \
ViewProviderScaled.h \
ViewProviderTransformed.cpp \
ViewProviderTransformed.h \
Workbench.cpp \
Workbench.h
@ -95,6 +138,10 @@ libPartDesignGui_la_LIBADD = \
-lTKXSBase \
-lTKBRep \
-lTKTopAlgo \
-lTKG2d \
-lTKG3d \
-lTKGeomAlgo \
-lTKGeomBase \
-lPartDesign
#--------------------------------------------------------------------------------------

View File

@ -58,5 +58,9 @@ void ViewProvider::updateData(const App::Property* prop)
strcmp(prop->getName(),"AddShape") == 0) {
return;
}
if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() &&
strcmp(prop->getName(),"SubShape") == 0) {
return;
}
inherited::updateData(prop);
}

View File

@ -51,7 +51,7 @@ ViewProviderChamfer::~ViewProviderChamfer()
void ViewProviderChamfer::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit pocket"), receiver, member);
act = menu->addAction(QObject::tr("Edit chamfer"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
}

View File

@ -51,7 +51,7 @@ ViewProviderFillet::~ViewProviderFillet()
void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit pocket"), receiver, member);
act = menu->addAction(QObject::tr("Edit fillet"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
}

View File

@ -232,7 +232,7 @@ void BrowserView::onLoadStarted()
QProgressBar* bar = Gui::Sequencer::instance()->getProgressBar();
bar->setRange(0, 100);
bar->show();
Gui::getMainWindow()->statusBar()->showMessage(tr("Loading %1...").arg(view->url().toString()));
Gui::getMainWindow()->showMessage(tr("Loading %1...").arg(view->url().toString()));
isLoading = true;
}
@ -248,7 +248,7 @@ void BrowserView::onLoadFinished(bool ok)
QProgressBar* bar = Sequencer::instance()->getProgressBar();
bar->setValue(100);
bar->hide();
getMainWindow()->statusBar()->showMessage(QString());
getMainWindow()->showMessage(QString());
}
isLoading = false;
}