+ fix warnings:
-Wsign-compare, -Wunused-variable, -Wunused-function, -Wswitch + fix Qt issues
This commit is contained in:
parent
e3b609b309
commit
5de9696365
|
@ -605,7 +605,7 @@ const string PropertyLinkSubList::getPyReprString()
|
||||||
|
|
||||||
std::stringstream strm;
|
std::stringstream strm;
|
||||||
strm << "[";
|
strm << "[";
|
||||||
for ( int i = 0 ; i < this->_lSubList.size() ; i++) {
|
for (std::size_t i = 0; i < this->_lSubList.size(); i++) {
|
||||||
if (i>0)
|
if (i>0)
|
||||||
strm << ",(";
|
strm << ",(";
|
||||||
else
|
else
|
||||||
|
@ -628,7 +628,7 @@ DocumentObject *PropertyLinkSubList::getValue() const
|
||||||
{
|
{
|
||||||
App::DocumentObject* ret = 0;
|
App::DocumentObject* ret = 0;
|
||||||
//FIXME: cache this to avoid iterating each time, to improve speed
|
//FIXME: cache this to avoid iterating each time, to improve speed
|
||||||
for (int i = 0 ; i < this->_lValueList.size() ; i++){
|
for (std::size_t i = 0; i < this->_lValueList.size(); i++) {
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = this->_lValueList[i];
|
ret = this->_lValueList[i];
|
||||||
if (ret != this->_lValueList[i])
|
if (ret != this->_lValueList[i])
|
||||||
|
|
|
@ -264,7 +264,6 @@ set(Gui_MOC_HDRS
|
||||||
TaskView/TaskView.h
|
TaskView/TaskView.h
|
||||||
DAGView/DAGView.h
|
DAGView/DAGView.h
|
||||||
DAGView/DAGModel.h
|
DAGView/DAGModel.h
|
||||||
DAGView/DAGRectItem.h
|
|
||||||
)
|
)
|
||||||
#qt4_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS})
|
#qt4_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS})
|
||||||
fc_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS})
|
fc_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS})
|
||||||
|
|
|
@ -796,7 +796,6 @@ bool QuarterWidget::viewportEvent(QEvent* event)
|
||||||
}
|
}
|
||||||
else if (event->type() == QEvent::MouseMove ||
|
else if (event->type() == QEvent::MouseMove ||
|
||||||
event->type() == QEvent::MouseButtonRelease) {
|
event->type() == QEvent::MouseButtonRelease) {
|
||||||
QMouseEvent* mouse = static_cast<QMouseEvent*>(event);
|
|
||||||
QGraphicsScene* glScene = this->scene();
|
QGraphicsScene* glScene = this->scene();
|
||||||
if (!(glScene && glScene->mouseGrabberItem())) {
|
if (!(glScene && glScene->mouseGrabberItem())) {
|
||||||
QGraphicsView::viewportEvent(event);
|
QGraphicsView::viewportEvent(event);
|
||||||
|
|
|
@ -399,7 +399,7 @@ int SelectionSingleton::getAsPropertyLinkSubList(App::PropertyLinkSubList &prop)
|
||||||
std::vector<Gui::SelectionObject> sel = this->getSelectionEx();
|
std::vector<Gui::SelectionObject> sel = this->getSelectionEx();
|
||||||
std::vector<App::DocumentObject*> objs; objs.reserve(sel.size()*2);
|
std::vector<App::DocumentObject*> objs; objs.reserve(sel.size()*2);
|
||||||
std::vector<std::string> subs; subs.reserve(sel.size()*2);
|
std::vector<std::string> subs; subs.reserve(sel.size()*2);
|
||||||
for( int iobj = 0 ; iobj < sel.size() ; iobj++ ){
|
for (std::size_t iobj = 0; iobj < sel.size(); iobj++) {
|
||||||
Gui::SelectionObject &selitem = sel[iobj];
|
Gui::SelectionObject &selitem = sel[iobj];
|
||||||
App::DocumentObject* obj = selitem.getObject();
|
App::DocumentObject* obj = selitem.getObject();
|
||||||
const std::vector<std::string> &subnames = selitem.getSubNames();
|
const std::vector<std::string> &subnames = selitem.getSubNames();
|
||||||
|
@ -407,7 +407,7 @@ int SelectionSingleton::getAsPropertyLinkSubList(App::PropertyLinkSubList &prop)
|
||||||
objs.push_back(obj);
|
objs.push_back(obj);
|
||||||
subs.push_back(std::string());
|
subs.push_back(std::string());
|
||||||
} else {
|
} else {
|
||||||
for( int isub = 0 ; isub < subnames.size() ; isub++ ){
|
for (std::size_t isub = 0; isub < subnames.size(); isub++) {
|
||||||
objs.push_back(obj);
|
objs.push_back(obj);
|
||||||
subs.push_back(subnames[isub]);
|
subs.push_back(subnames[isub]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,7 +539,6 @@ void TreeWidget::dropEvent(QDropEvent *event)
|
||||||
// add object to group
|
// add object to group
|
||||||
DocumentObjectItem* targetItemObj = static_cast<DocumentObjectItem*>(targetitem);
|
DocumentObjectItem* targetItemObj = static_cast<DocumentObjectItem*>(targetitem);
|
||||||
Gui::ViewProviderDocumentObject* vp = targetItemObj->object();
|
Gui::ViewProviderDocumentObject* vp = targetItemObj->object();
|
||||||
App::DocumentObject* grp = vp->getObject();
|
|
||||||
if (!vp->canDropObjects()) {
|
if (!vp->canDropObjects()) {
|
||||||
return; // no group like object
|
return; // no group like object
|
||||||
}
|
}
|
||||||
|
@ -548,9 +547,6 @@ void TreeWidget::dropEvent(QDropEvent *event)
|
||||||
dropObjects.reserve(idxs.size());
|
dropObjects.reserve(idxs.size());
|
||||||
|
|
||||||
// Open command
|
// Open command
|
||||||
App::Document* doc = grp->getDocument();
|
|
||||||
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
|
|
||||||
|
|
||||||
for (QList<QTreeWidgetItem*>::Iterator it = items.begin(); it != items.end(); ++it) {
|
for (QList<QTreeWidgetItem*>::Iterator it = items.begin(); it != items.end(); ++it) {
|
||||||
Gui::ViewProviderDocumentObject* vpc = static_cast<DocumentObjectItem*>(*it)->object();
|
Gui::ViewProviderDocumentObject* vpc = static_cast<DocumentObjectItem*>(*it)->object();
|
||||||
App::DocumentObject* obj = vpc->getObject();
|
App::DocumentObject* obj = vpc->getObject();
|
||||||
|
|
|
@ -29,16 +29,16 @@
|
||||||
#include <Base/PyObjectBase.h>
|
#include <Base/PyObjectBase.h>
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
|
||||||
#include <App/PartPy.h>
|
//#include <App/PartPy.h>
|
||||||
|
|
||||||
#include <Gui/Application.h>
|
//#include <Gui/Application.h>
|
||||||
#include <Gui/Document.h>
|
//#include <Gui/Document.h>
|
||||||
#include <Gui/ViewProviderDocumentObject.h>
|
//#include <Gui/ViewProviderDocumentObject.h>
|
||||||
|
|
||||||
#include <Mod/PartDesign/App/BodyPy.h>
|
//#include <Mod/PartDesign/App/BodyPy.h>
|
||||||
|
|
||||||
#include "ViewProviderBody.h"
|
//#include "ViewProviderBody.h"
|
||||||
#include "Utils.h"
|
//#include "Utils.h"
|
||||||
|
|
||||||
|
|
||||||
//static PyObject * setActiveBody(PyObject *self, PyObject *args)
|
//static PyObject * setActiveBody(PyObject *self, PyObject *args)
|
||||||
|
|
|
@ -89,7 +89,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Py::Object importer(const Py::Tuple& args)
|
Py::Object importer(const Py::Tuple& args)
|
||||||
|
|
||||||
{
|
{
|
||||||
char* Name;
|
char* Name;
|
||||||
char* DocName=0;
|
char* DocName=0;
|
||||||
|
@ -410,226 +409,6 @@ static PyObject * importAssembly(PyObject *self, PyObject *args)
|
||||||
Py_Return;
|
Py_Return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static PyObject * importer(PyObject *self, PyObject *args)
|
|
||||||
{
|
|
||||||
char* Name;
|
|
||||||
char* DocName=0;
|
|
||||||
if (!PyArg_ParseTuple(args, "et|s","utf-8",&Name,&DocName))
|
|
||||||
return NULL;
|
|
||||||
std::string Utf8Name = std::string(Name);
|
|
||||||
PyMem_Free(Name);
|
|
||||||
std::string name8bit = Part::encodeFilename(Utf8Name);
|
|
||||||
|
|
||||||
PY_TRY {
|
|
||||||
//Base::Console().Log("Insert in Part with %s",Name);
|
|
||||||
Base::FileInfo file(Utf8Name.c_str());
|
|
||||||
|
|
||||||
App::Document *pcDoc = 0;
|
|
||||||
if (DocName) {
|
|
||||||
pcDoc = App::GetApplication().getDocument(DocName);
|
|
||||||
}
|
|
||||||
if (!pcDoc) {
|
|
||||||
pcDoc = App::GetApplication().newDocument("Unnamed");
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
|
|
||||||
Handle(TDocStd_Document) hDoc;
|
|
||||||
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
|
|
||||||
|
|
||||||
if (file.hasExtension("stp") || file.hasExtension("step")) {
|
|
||||||
try {
|
|
||||||
STEPCAFControl_Reader aReader;
|
|
||||||
aReader.SetColorMode(true);
|
|
||||||
aReader.SetNameMode(true);
|
|
||||||
aReader.SetLayerMode(true);
|
|
||||||
if (aReader.ReadFile((Standard_CString)(name8bit.c_str())) != IFSelect_RetDone) {
|
|
||||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "cannot read STEP file");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle_Message_ProgressIndicator pi = new Part::ProgressIndicator(100);
|
|
||||||
aReader.Reader().WS()->MapReader()->SetProgress(pi);
|
|
||||||
pi->NewScope(100, "Reading STEP file...");
|
|
||||||
pi->Show();
|
|
||||||
aReader.Transfer(hDoc);
|
|
||||||
pi->EndScope();
|
|
||||||
}
|
|
||||||
catch (OSD_Exception) {
|
|
||||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
|
||||||
Base::Console().Error("%s\n", e->GetMessageString());
|
|
||||||
Base::Console().Message("Try to load STEP file without colors...\n");
|
|
||||||
|
|
||||||
Part::ImportStepParts(pcDoc,Utf8Name.c_str());
|
|
||||||
pcDoc->recompute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
|
|
||||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
|
||||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");
|
|
||||||
|
|
||||||
try {
|
|
||||||
IGESControl_Controller::Init();
|
|
||||||
IGESCAFControl_Reader aReader;
|
|
||||||
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
|
|
||||||
aReader.SetReadVisible(hGrp->GetBool("SkipBlankEntities", true)
|
|
||||||
? Standard_True : Standard_False);
|
|
||||||
aReader.SetColorMode(true);
|
|
||||||
aReader.SetNameMode(true);
|
|
||||||
aReader.SetLayerMode(true);
|
|
||||||
if (aReader.ReadFile((Standard_CString)(name8bit.c_str())) != IFSelect_RetDone) {
|
|
||||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "cannot read IGES file");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle_Message_ProgressIndicator pi = new Part::ProgressIndicator(100);
|
|
||||||
aReader.WS()->MapReader()->SetProgress(pi);
|
|
||||||
pi->NewScope(100, "Reading IGES file...");
|
|
||||||
pi->Show();
|
|
||||||
aReader.Transfer(hDoc);
|
|
||||||
pi->EndScope();
|
|
||||||
}
|
|
||||||
catch (OSD_Exception) {
|
|
||||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
|
||||||
Base::Console().Error("%s\n", e->GetMessageString());
|
|
||||||
Base::Console().Message("Try to load IGES file without colors...\n");
|
|
||||||
|
|
||||||
Part::ImportIgesParts(pcDoc,Utf8Name.c_str());
|
|
||||||
pcDoc->recompute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "no supported file format");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
Import::ImportOCAF ocaf(hDoc, pcDoc, file.fileNamePure());
|
|
||||||
ocaf.loadShapes();
|
|
||||||
#else
|
|
||||||
Import::ImportXCAF xcaf(hDoc, pcDoc, file.fileNamePure());
|
|
||||||
xcaf.loadShapes();
|
|
||||||
#endif
|
|
||||||
pcDoc->recompute();
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Standard_Failure) {
|
|
||||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
|
||||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
PY_CATCH
|
|
||||||
|
|
||||||
Py_Return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject * open(PyObject *self, PyObject *args)
|
|
||||||
{
|
|
||||||
return importer(self, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject * exporter(PyObject *self, PyObject *args)
|
|
||||||
{
|
|
||||||
PyObject* object;
|
|
||||||
char* Name;
|
|
||||||
if (!PyArg_ParseTuple(args, "Oet",&object,"utf-8",&Name))
|
|
||||||
return NULL;
|
|
||||||
std::string Utf8Name = std::string(Name);
|
|
||||||
PyMem_Free(Name);
|
|
||||||
std::string name8bit = Part::encodeFilename(Utf8Name);
|
|
||||||
|
|
||||||
PY_TRY {
|
|
||||||
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
|
|
||||||
Handle(TDocStd_Document) hDoc;
|
|
||||||
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
|
|
||||||
Import::ExportOCAF ocaf(hDoc);
|
|
||||||
|
|
||||||
Py::Sequence list(object);
|
|
||||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
|
||||||
PyObject* item = (*it).ptr();
|
|
||||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
|
||||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
|
||||||
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
|
||||||
Part::Feature* part = static_cast<Part::Feature*>(obj);
|
|
||||||
std::vector<App::Color> colors;
|
|
||||||
ocaf.saveShape(part, colors);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Base::Console().Message("'%s' is not a shape, export will be ignored.\n", obj->Label.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (PyTuple_Check(item) && PyTuple_Size(item) == 2) {
|
|
||||||
Py::Tuple tuple(*it);
|
|
||||||
Py::Object item0 = tuple.getItem(0);
|
|
||||||
Py::Object item1 = tuple.getItem(1);
|
|
||||||
if (PyObject_TypeCheck(item0.ptr(), &(App::DocumentObjectPy::Type))) {
|
|
||||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item0.ptr())->getDocumentObjectPtr();
|
|
||||||
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
|
||||||
Part::Feature* part = static_cast<Part::Feature*>(obj);
|
|
||||||
App::PropertyColorList colors;
|
|
||||||
colors.setPyObject(item1.ptr());
|
|
||||||
ocaf.saveShape(part, colors.getValues());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Base::Console().Message("'%s' is not a shape, export will be ignored.\n", obj->Label.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Base::FileInfo file(Utf8Name.c_str());
|
|
||||||
if (file.hasExtension("stp") || file.hasExtension("step")) {
|
|
||||||
//Interface_Static::SetCVal("write.step.schema", "AP214IS");
|
|
||||||
STEPCAFControl_Writer writer;
|
|
||||||
writer.Transfer(hDoc, STEPControl_AsIs);
|
|
||||||
|
|
||||||
// edit STEP header
|
|
||||||
#if OCC_VERSION_HEX >= 0x060500
|
|
||||||
APIHeaderSection_MakeHeader makeHeader(writer.ChangeWriter().Model());
|
|
||||||
#else
|
|
||||||
APIHeaderSection_MakeHeader makeHeader(writer.Writer().Model());
|
|
||||||
#endif
|
|
||||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
|
||||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP");
|
|
||||||
|
|
||||||
makeHeader.SetName(new TCollection_HAsciiString((const Standard_CString)Utf8Name.c_str()));
|
|
||||||
makeHeader.SetAuthorValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Author", "Author").c_str()));
|
|
||||||
makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Company").c_str()));
|
|
||||||
makeHeader.SetOriginatingSystem(new TCollection_HAsciiString(App::GetApplication().getExecutableName()));
|
|
||||||
makeHeader.SetDescriptionValue(1, new TCollection_HAsciiString("FreeCAD Model"));
|
|
||||||
IFSelect_ReturnStatus ret = writer.Write(name8bit.c_str());
|
|
||||||
if (ret == IFSelect_RetError || ret == IFSelect_RetFail || ret == IFSelect_RetStop) {
|
|
||||||
PyErr_Format(PyExc_IOError, "Cannot open file '%s'", Utf8Name.c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
|
|
||||||
IGESControl_Controller::Init();
|
|
||||||
IGESCAFControl_Writer writer;
|
|
||||||
IGESData_GlobalSection header = writer.Model()->GlobalSection();
|
|
||||||
header.SetAuthorName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.author")));
|
|
||||||
header.SetCompanyName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.company")));
|
|
||||||
header.SetSendName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.product")));
|
|
||||||
writer.Model()->SetGlobalSection(header);
|
|
||||||
writer.Transfer(hDoc);
|
|
||||||
Standard_Boolean ret = writer.Write(name8bit.c_str());
|
|
||||||
if (!ret) {
|
|
||||||
PyErr_Format(PyExc_IOError, "Cannot open file '%s'", Utf8Name.c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Standard_Failure) {
|
|
||||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
|
||||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
PY_CATCH
|
|
||||||
|
|
||||||
Py_Return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject* initModule()
|
PyObject* initModule()
|
||||||
{
|
{
|
||||||
return (new Module)->module().ptr();
|
return (new Module)->module().ptr();
|
||||||
|
|
|
@ -46,7 +46,7 @@ TestJtReader::~TestJtReader()
|
||||||
|
|
||||||
void TestJtReader::read(void)
|
void TestJtReader::read(void)
|
||||||
{
|
{
|
||||||
const std::vector<TOC_Entry>& toc = readToc();
|
//const std::vector<TOC_Entry>& toc = readToc();
|
||||||
|
|
||||||
for (std::vector<TOC_Entry>::const_iterator i = TocEntries.begin(); i != TocEntries.end(); ++i){
|
for (std::vector<TOC_Entry>::const_iterator i = TocEntries.begin(); i != TocEntries.end(); ++i){
|
||||||
int segType = i->getSegmentType();
|
int segType = i->getSegmentType();
|
||||||
|
|
|
@ -278,14 +278,14 @@ eMapMode AttachEngine::listMapModes(eSuggestResult& msg,
|
||||||
eMapMode bestMatchType = mmDeactivated;
|
eMapMode bestMatchType = mmDeactivated;
|
||||||
int bestMatchScore = -1;
|
int bestMatchScore = -1;
|
||||||
msg = srNoModesFit;
|
msg = srNoModesFit;
|
||||||
for(int iMode = 0 ; iMode < this->modeRefTypes.size() ; ++iMode){
|
for (std::size_t iMode = 0; iMode < this->modeRefTypes.size(); ++iMode) {
|
||||||
if (! this->modeEnabled[iMode])
|
if (! this->modeEnabled[iMode])
|
||||||
continue;
|
continue;
|
||||||
const refTypeStringList &listStrings = modeRefTypes[iMode];
|
const refTypeStringList &listStrings = modeRefTypes[iMode];
|
||||||
for( int iStr = 0 ; iStr < listStrings.size() ; ++iStr ){
|
for (std::size_t iStr = 0; iStr < listStrings.size(); ++iStr) {
|
||||||
int score = 1; //-1 = topo incompatible, 0 = topo compatible, geom incompatible; 1+ = compatible (the higher - the more specific is the mode for the support)
|
int score = 1; //-1 = topo incompatible, 0 = topo compatible, geom incompatible; 1+ = compatible (the higher - the more specific is the mode for the support)
|
||||||
const refTypeString &str = listStrings[iStr];
|
const refTypeString &str = listStrings[iStr];
|
||||||
for (int iChr = 0 ; iChr < str.size() && iChr < typeStr.size() ; ++iChr ){
|
for (std::size_t iChr = 0; iChr < str.size() && iChr < typeStr.size(); ++iChr) {
|
||||||
int match = AttachEngine::isShapeOfType(typeStr[iChr], str[iChr]);
|
int match = AttachEngine::isShapeOfType(typeStr[iChr], str[iChr]);
|
||||||
switch(match){
|
switch(match){
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -343,7 +343,7 @@ void AttachEngine::EnableAllSupportedModes()
|
||||||
{
|
{
|
||||||
this->modeEnabled.resize(mmDummy_NumberOfModes,false);
|
this->modeEnabled.resize(mmDummy_NumberOfModes,false);
|
||||||
assert(modeRefTypes.size() > 0);
|
assert(modeRefTypes.size() > 0);
|
||||||
for( int i = 0 ; i < this->modeEnabled.size() ; i++ ){
|
for (std::size_t i = 0; i < this->modeEnabled.size(); i++) {
|
||||||
modeEnabled[i] = modeRefTypes[i].size() > 0;
|
modeEnabled[i] = modeRefTypes[i].size() > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,26 +384,20 @@ eRefType AttachEngine::getShapeType(const TopoDS_Shape& sh)
|
||||||
switch(surf.GetType()) {
|
switch(surf.GetType()) {
|
||||||
case GeomAbs_Plane:
|
case GeomAbs_Plane:
|
||||||
return rtFlatFace;
|
return rtFlatFace;
|
||||||
break;
|
|
||||||
case GeomAbs_Cylinder:
|
case GeomAbs_Cylinder:
|
||||||
return rtCylindricalFace;
|
return rtCylindricalFace;
|
||||||
break;
|
|
||||||
case GeomAbs_Cone:
|
case GeomAbs_Cone:
|
||||||
return rtConicalFace;
|
return rtConicalFace;
|
||||||
break;
|
|
||||||
case GeomAbs_Sphere:
|
case GeomAbs_Sphere:
|
||||||
return rtSphericalFace;
|
return rtSphericalFace;
|
||||||
break;
|
|
||||||
case GeomAbs_Torus:
|
case GeomAbs_Torus:
|
||||||
return rtToroidalFace;
|
return rtToroidalFace;
|
||||||
break;
|
|
||||||
case GeomAbs_BezierSurface:
|
case GeomAbs_BezierSurface:
|
||||||
break;
|
break;
|
||||||
case GeomAbs_BSplineSurface:
|
case GeomAbs_BSplineSurface:
|
||||||
break;
|
break;
|
||||||
case GeomAbs_SurfaceOfRevolution:
|
case GeomAbs_SurfaceOfRevolution:
|
||||||
return rtSurfaceRev;
|
return rtSurfaceRev;
|
||||||
break;
|
|
||||||
case GeomAbs_SurfaceOfExtrusion:
|
case GeomAbs_SurfaceOfExtrusion:
|
||||||
break;
|
break;
|
||||||
case GeomAbs_OffsetSurface:
|
case GeomAbs_OffsetSurface:
|
||||||
|
@ -419,32 +413,24 @@ eRefType AttachEngine::getShapeType(const TopoDS_Shape& sh)
|
||||||
switch (crv.GetType()){
|
switch (crv.GetType()){
|
||||||
case GeomAbs_Line:
|
case GeomAbs_Line:
|
||||||
return rtLine;
|
return rtLine;
|
||||||
break;
|
|
||||||
case GeomAbs_Circle:
|
case GeomAbs_Circle:
|
||||||
return rtCircle;
|
return rtCircle;
|
||||||
break;
|
|
||||||
case GeomAbs_Ellipse:
|
case GeomAbs_Ellipse:
|
||||||
return rtEllipse;
|
return rtEllipse;
|
||||||
break;
|
|
||||||
case GeomAbs_Hyperbola:
|
case GeomAbs_Hyperbola:
|
||||||
return rtHyperbola;
|
return rtHyperbola;
|
||||||
break;
|
|
||||||
case GeomAbs_Parabola:
|
case GeomAbs_Parabola:
|
||||||
return rtParabola;
|
return rtParabola;
|
||||||
break;
|
|
||||||
case GeomAbs_BezierCurve:
|
case GeomAbs_BezierCurve:
|
||||||
case GeomAbs_BSplineCurve:
|
case GeomAbs_BSplineCurve:
|
||||||
case GeomAbs_OtherCurve:
|
case GeomAbs_OtherCurve:
|
||||||
return rtCurve;
|
return rtCurve;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case TopAbs_WIRE:
|
case TopAbs_WIRE:
|
||||||
return rtWire;
|
return rtWire;
|
||||||
break;
|
|
||||||
case TopAbs_VERTEX:
|
case TopAbs_VERTEX:
|
||||||
return rtVertex;
|
return rtVertex;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw Base::Exception("AttachEngine::getShapeType: unexpected TopoDS_Shape::ShapeType");
|
throw Base::Exception("AttachEngine::getShapeType: unexpected TopoDS_Shape::ShapeType");
|
||||||
}//switch shapetype
|
}//switch shapetype
|
||||||
|
@ -478,40 +464,31 @@ eRefType AttachEngine::downgradeType(eRefType type)
|
||||||
case rtEdge:
|
case rtEdge:
|
||||||
case rtFace:
|
case rtFace:
|
||||||
return rtAnything;
|
return rtAnything;
|
||||||
break;
|
|
||||||
case rtAnything:
|
case rtAnything:
|
||||||
return rtAnything;
|
return rtAnything;
|
||||||
break;
|
|
||||||
case rtLine:
|
case rtLine:
|
||||||
case rtCurve:
|
case rtCurve:
|
||||||
return rtEdge;
|
return rtEdge;
|
||||||
break;
|
|
||||||
case rtConic:
|
case rtConic:
|
||||||
case rtCircle:
|
case rtCircle:
|
||||||
return rtCurve;
|
return rtCurve;
|
||||||
break;
|
|
||||||
case rtEllipse:
|
case rtEllipse:
|
||||||
case rtParabola:
|
case rtParabola:
|
||||||
case rtHyperbola:
|
case rtHyperbola:
|
||||||
return rtConic;
|
return rtConic;
|
||||||
break;
|
|
||||||
case rtFlatFace:
|
case rtFlatFace:
|
||||||
case rtSphericalFace:
|
case rtSphericalFace:
|
||||||
case rtSurfaceRev:
|
case rtSurfaceRev:
|
||||||
return rtFace;
|
return rtFace;
|
||||||
break;
|
|
||||||
case rtCylindricalFace:
|
case rtCylindricalFace:
|
||||||
case rtToroidalFace:
|
case rtToroidalFace:
|
||||||
case rtConicalFace:
|
case rtConicalFace:
|
||||||
return rtSurfaceRev;
|
return rtSurfaceRev;
|
||||||
break;
|
|
||||||
case rtSolid:
|
case rtSolid:
|
||||||
case rtWire:
|
case rtWire:
|
||||||
return rtPart;
|
return rtPart;
|
||||||
break;
|
|
||||||
case rtPart:
|
case rtPart:
|
||||||
return rtAnything;
|
return rtAnything;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw Base::Exception("AttachEngine::downgradeType: unknown type");
|
throw Base::Exception("AttachEngine::downgradeType: unknown type");
|
||||||
}
|
}
|
||||||
|
@ -534,9 +511,10 @@ int AttachEngine::getTypeRank(eRefType type)
|
||||||
int AttachEngine::isShapeOfType(eRefType shapeType, eRefType requirement)
|
int AttachEngine::isShapeOfType(eRefType shapeType, eRefType requirement)
|
||||||
{
|
{
|
||||||
//first up, check for hasplacement flag
|
//first up, check for hasplacement flag
|
||||||
if (requirement & rtFlagHasPlacement)
|
if (requirement & rtFlagHasPlacement) {
|
||||||
if(! (shapeType & rtFlagHasPlacement))
|
if(! (shapeType & rtFlagHasPlacement))
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//get rid of hasplacement flags, to simplify the rest
|
//get rid of hasplacement flags, to simplify the rest
|
||||||
shapeType = eRefType(shapeType & (rtFlagHasPlacement - 1));
|
shapeType = eRefType(shapeType & (rtFlagHasPlacement - 1));
|
||||||
|
@ -574,7 +552,8 @@ int AttachEngine::isShapeOfType(eRefType shapeType, eRefType requirement)
|
||||||
* \brief AttachEngine3D::readLinks
|
* \brief AttachEngine3D::readLinks
|
||||||
* \param parts
|
* \param parts
|
||||||
* \param shapes
|
* \param shapes
|
||||||
* \param storage is a buffer storing what some of the pointers in shapes point to. It is needed, since subshapes are copied in the process (but copying a whole shape of an object can potentially be slow).
|
* \param storage is a buffer storing what some of the pointers in shapes point to. It is needed, since
|
||||||
|
* subshapes are copied in the process (but copying a whole shape of an object can potentially be slow).
|
||||||
*/
|
*/
|
||||||
void AttachEngine::readLinks(const App::PropertyLinkSubList &references,
|
void AttachEngine::readLinks(const App::PropertyLinkSubList &references,
|
||||||
std::vector<App::GeoFeature*> &geofs,
|
std::vector<App::GeoFeature*> &geofs,
|
||||||
|
@ -588,8 +567,8 @@ void AttachEngine::readLinks(const App::PropertyLinkSubList &references,
|
||||||
storage.reserve(objs.size());
|
storage.reserve(objs.size());
|
||||||
shapes.resize(objs.size());
|
shapes.resize(objs.size());
|
||||||
types.resize(objs.size());
|
types.resize(objs.size());
|
||||||
for( int i = 0 ; i < objs.size() ; i++){
|
for (std::size_t i = 0; i < objs.size(); i++) {
|
||||||
if (!objs[i]->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())){
|
if (!objs[i]->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
|
||||||
throw Base::Exception("AttachEngine3D: link points to something that is not App::GeoFeature");
|
throw Base::Exception("AttachEngine3D: link points to something that is not App::GeoFeature");
|
||||||
}
|
}
|
||||||
App::GeoFeature* geof = static_cast<App::GeoFeature*>(objs[i]);
|
App::GeoFeature* geof = static_cast<App::GeoFeature*>(objs[i]);
|
||||||
|
@ -863,6 +842,8 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP
|
||||||
SketchNormal = dirX;
|
SketchNormal = dirX;
|
||||||
SketchXAxis = gp_Vec(dirY);
|
SketchXAxis = gp_Vec(dirY);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
@ -1073,7 +1054,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP
|
||||||
|
|
||||||
std::vector<gp_Pnt> points;
|
std::vector<gp_Pnt> points;
|
||||||
|
|
||||||
for( int i = 0 ; i < shapes.size() ; i++){
|
for (std::size_t i = 0; i < shapes.size(); i++) {
|
||||||
const TopoDS_Shape &sh = *shapes[i];
|
const TopoDS_Shape &sh = *shapes[i];
|
||||||
if (sh.IsNull())
|
if (sh.IsNull())
|
||||||
throw Base::Exception("Null shape in AttachEngine3D::calculateAttachedPlacement()!");
|
throw Base::Exception("Null shape in AttachEngine3D::calculateAttachedPlacement()!");
|
||||||
|
@ -1211,7 +1192,9 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP
|
||||||
);
|
);
|
||||||
|
|
||||||
gp_Vec norm = dirs[1].Crossed(dirs[2]);
|
gp_Vec norm = dirs[1].Crossed(dirs[2]);
|
||||||
norm.Rotate(gp_Ax1(gp_Pnt(),gp_Dir(dirs[1])),-ang);//rotation direction: when angle is positive, rotation is CCW when observing the vector so that the axis is pointing at you. Hence angle is negated here.
|
//rotation direction: when angle is positive, rotation is CCW when observing the vector so
|
||||||
|
//that the axis is pointing at you. Hence angle is negated here.
|
||||||
|
norm.Rotate(gp_Ax1(gp_Pnt(),gp_Dir(dirs[1])),-ang);
|
||||||
SketchNormal = norm.Reversed();
|
SketchNormal = norm.Reversed();
|
||||||
|
|
||||||
SketchXAxis = dirs[1];
|
SketchXAxis = dirs[1];
|
||||||
|
@ -1255,7 +1238,6 @@ double AttachEngine3D::calculateFoldAngle(gp_Vec axA, gp_Vec axB, gp_Vec edA, gp
|
||||||
if (fabs(ra) < Precision::Confusion())
|
if (fabs(ra) < Precision::Confusion())
|
||||||
throw Base::Exception("calculateFoldAngle: axisA and edgeA are parallel, folding can't be computed.");
|
throw Base::Exception("calculateFoldAngle: axisA and edgeA are parallel, folding can't be computed.");
|
||||||
double b = edB.Dot(axB);
|
double b = edB.Dot(axB);
|
||||||
double rb = edB.Crossed(axB).Magnitude();
|
|
||||||
double costheta = axB.Dot(axA);
|
double costheta = axB.Dot(axA);
|
||||||
double sintheta = axA.Crossed(axB).Dot(norm);
|
double sintheta = axA.Crossed(axB).Dot(norm);
|
||||||
double singama = -costheta;
|
double singama = -costheta;
|
||||||
|
@ -1383,7 +1365,7 @@ Base::Placement AttachEngineLine::calculateAttachedPlacement(Base::Placement ori
|
||||||
case mm1TwoPoints:{
|
case mm1TwoPoints:{
|
||||||
std::vector<gp_Pnt> points;
|
std::vector<gp_Pnt> points;
|
||||||
|
|
||||||
for( int i = 0 ; i < shapes.size() ; i++){
|
for (std::size_t i = 0; i < shapes.size(); i++) {
|
||||||
const TopoDS_Shape &sh = *shapes[i];
|
const TopoDS_Shape &sh = *shapes[i];
|
||||||
if (sh.IsNull())
|
if (sh.IsNull())
|
||||||
throw Base::Exception("Null shape in AttachEngineLine::calculateAttachedPlacement()!");
|
throw Base::Exception("Null shape in AttachEngineLine::calculateAttachedPlacement()!");
|
||||||
|
|
|
@ -316,11 +316,35 @@ public: //members
|
||||||
std::vector<refTypeStringList> modeRefTypes; //a complete data structure, containing info on which modes support what selection
|
std::vector<refTypeStringList> modeRefTypes; //a complete data structure, containing info on which modes support what selection
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
refTypeString cat(eRefType rt1){refTypeString ret; ret.push_back(rt1); return ret;}
|
refTypeString cat(eRefType rt1){
|
||||||
refTypeString cat(eRefType rt1, eRefType rt2){refTypeString ret; ret.push_back(rt1); ret.push_back(rt2); return ret;}
|
refTypeString ret;
|
||||||
refTypeString cat(eRefType rt1, eRefType rt2, eRefType rt3){refTypeString ret; ret.push_back(rt1); ret.push_back(rt2); ret.push_back(rt3); return ret;}
|
ret.push_back(rt1);
|
||||||
refTypeString cat(eRefType rt1, eRefType rt2, eRefType rt3, eRefType rt4){refTypeString ret; ret.push_back(rt1); ret.push_back(rt2); ret.push_back(rt3); ret.push_back(rt4); return ret;}
|
return ret;
|
||||||
static void readLinks(const App::PropertyLinkSubList &references, std::vector<App::GeoFeature *> &geofs, std::vector<const TopoDS_Shape*>& shapes, std::vector<TopoDS_Shape> &storage, std::vector<eRefType> &types);
|
}
|
||||||
|
refTypeString cat(eRefType rt1, eRefType rt2){
|
||||||
|
refTypeString ret;
|
||||||
|
ret.push_back(rt1);
|
||||||
|
ret.push_back(rt2);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
refTypeString cat(eRefType rt1, eRefType rt2, eRefType rt3){
|
||||||
|
refTypeString ret;
|
||||||
|
ret.push_back(rt1);
|
||||||
|
ret.push_back(rt2);
|
||||||
|
ret.push_back(rt3);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
refTypeString cat(eRefType rt1, eRefType rt2, eRefType rt3, eRefType rt4){
|
||||||
|
refTypeString ret;
|
||||||
|
ret.push_back(rt1);
|
||||||
|
ret.push_back(rt2);
|
||||||
|
ret.push_back(rt3);
|
||||||
|
ret.push_back(rt4);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
static void readLinks(const App::PropertyLinkSubList &references, std::vector<App::GeoFeature *> &geofs,
|
||||||
|
std::vector<const TopoDS_Shape*>& shapes, std::vector<TopoDS_Shape> &storage,
|
||||||
|
std::vector<eRefType> &types);
|
||||||
|
|
||||||
static void throwWrongMode(eMapMode mmode);
|
static void throwWrongMode(eMapMode mmode);
|
||||||
|
|
||||||
|
|
|
@ -426,16 +426,16 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||||
// For testing
|
// For testing
|
||||||
else if (prop == &DiffuseColor) {
|
else if (prop == &DiffuseColor) {
|
||||||
const std::vector<App::Color>& c = DiffuseColor.getValues();
|
const std::vector<App::Color>& c = DiffuseColor.getValues();
|
||||||
unsigned int size = (int)c.size();
|
int size = static_cast<int>(c.size());
|
||||||
if (size > 1 && size == this->faceset->partIndex.getNum()) {
|
if (size > 1 && size == this->faceset->partIndex.getNum()) {
|
||||||
pcShapeBind->value = SoMaterialBinding::PER_PART;
|
pcShapeBind->value = SoMaterialBinding::PER_PART;
|
||||||
pcShapeMaterial->diffuseColor.setNum(size);
|
pcShapeMaterial->diffuseColor.setNum(size);
|
||||||
SbColor* ca = pcShapeMaterial->diffuseColor.startEditing();
|
SbColor* ca = pcShapeMaterial->diffuseColor.startEditing();
|
||||||
for (unsigned int i=0; i < size; i++)
|
for (int i=0; i < size; i++)
|
||||||
ca[i].setValue(c[i].r,c[i].g,c[i].b);
|
ca[i].setValue(c[i].r,c[i].g,c[i].b);
|
||||||
pcShapeMaterial->diffuseColor.finishEditing();
|
pcShapeMaterial->diffuseColor.finishEditing();
|
||||||
}
|
}
|
||||||
else if ((int)c.size() == 1) {
|
else if (c.size() == 1) {
|
||||||
pcShapeBind->value = SoMaterialBinding::OVERALL;
|
pcShapeBind->value = SoMaterialBinding::OVERALL;
|
||||||
pcShapeMaterial->diffuseColor.setValue(c[0].r,c[0].g,c[0].b);
|
pcShapeMaterial->diffuseColor.setValue(c[0].r,c[0].g,c[0].b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labelOffset2">
|
<widget class="QLabel" name="labelOffset2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -4489,6 +4489,8 @@ namespace SketcherGui {
|
||||||
case Sketcher::SketchObject::rlOtherPart:
|
case Sketcher::SketchObject::rlOtherPart:
|
||||||
this->notAllowedReason = QT_TR_NOOP("This object belongs to another part or body, can't link. Hold Ctrl to allow crossreferences.");
|
this->notAllowedReason = QT_TR_NOOP("This object belongs to another part or body, can't link. Hold Ctrl to allow crossreferences.");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user