Merge branch 'master' of github.com:FreeCAD/FreeCAD

This commit is contained in:
Yorik van Havre
2021-11-08 10:51:28 +01:00
176 changed files with 2574 additions and 2097 deletions
@@ -5,25 +5,37 @@ macro(CreatePackagingTargets)
#add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
add_custom_target(dist-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR}
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(distdfsg-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
--dfsg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
if(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX OR MINGW)
add_custom_target(distcheck-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --check
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
--check
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(distcheckdfsg-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg --check
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
--dfsg
--check
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
endif()
endmacro(CreatePackagingTargets)
+3 -3
View File
@@ -23,9 +23,9 @@ if(BUILD_GUI)
elseif(${FREECAD_USE_QTWEBMODULE} MATCHES "Qt WebEngine")
find_package(Qt5WebEngineWidgets REQUIRED)
else() # Automatic
find_package(Qt5WebKitWidgets QUIET)
if(NOT Qt5WebKitWidgets_FOUND)
find_package(Qt5WebEngineWidgets REQUIRED)
find_package(Qt5WebEngineWidgets QUIET)
if(NOT Qt5WebEngineWidgets_FOUND)
find_package(Qt5WebKitWidgets REQUIRED)
endif()
endif()
endif()
Binary file not shown.
+220 -135
View File
@@ -55,6 +55,8 @@
#include <sys/sysctl.h>
#endif
#include <boost/algorithm/string/predicate.hpp>
#include "Application.h"
#include "Document.h"
@@ -99,6 +101,7 @@
#include "Document.h"
#include "DocumentObjectGroup.h"
#include "DocumentObjectFileIncluded.h"
#include "DocumentObserver.h"
#include "InventorObject.h"
#include "VRMLObject.h"
#include "Annotation.h"
@@ -487,6 +490,7 @@ bool Application::closeDocument(const char* name)
setActiveDocument((Document*)0);
std::unique_ptr<Document> delDoc (pos->second);
DocMap.erase( pos );
DocFileMap.erase(FileInfo(delDoc->FileName.getValue()).filePath());
_objCount = -1;
@@ -566,8 +570,10 @@ int Application::addPendingDocument(const char *FileName, const char *objName, b
return -1;
assert(FileName && FileName[0]);
assert(objName && objName[0]);
auto ret = _pendingDocMap.emplace(FileName,std::set<std::string>());
ret.first->second.emplace(objName);
if(!_docReloadAttempts[FileName].emplace(objName).second)
return -1;
auto ret = _pendingDocMap.emplace(FileName,std::vector<std::string>());
ret.first->second.push_back(objName);
if(ret.second) {
_pendingDocs.push_back(ret.first->first.c_str());
return 1;
@@ -623,6 +629,41 @@ Document* Application::openDocument(const char * FileName, bool createView) {
return 0;
}
Document *Application::getDocumentByPath(const char *path, PathMatchMode checkCanonical) const {
if(!path || !path[0])
return nullptr;
if(DocFileMap.empty()) {
for(const auto &v : DocMap) {
const auto &file = v.second->FileName.getStrValue();
if(file.size())
DocFileMap[FileInfo(file.c_str()).filePath()] = v.second;
}
}
auto it = DocFileMap.find(FileInfo(path).filePath());
if(it != DocFileMap.end())
return it->second;
if (checkCanonical == PathMatchMode::MatchAbsolute)
return nullptr;
std::string filepath = FileInfo(path).filePath();
QString canonicalPath = QFileInfo(QString::fromUtf8(path)).canonicalFilePath();
for (const auto &v : DocMap) {
QFileInfo fi(QString::fromUtf8(v.second->FileName.getValue()));
if (canonicalPath == fi.canonicalFilePath()) {
if (checkCanonical == PathMatchMode::MatchCanonical)
return v.second;
bool samePath = (canonicalPath == QString::fromUtf8(filepath.c_str()));
FC_WARN("Identical physical path '" << canonicalPath.toUtf8().constData() << "'\n"
<< (samePath?"":" for file '") << (samePath?"":filepath.c_str()) << (samePath?"":"'\n")
<< " with existing document '" << v.second->Label.getValue()
<< "' in path: '" << v.second->FileName.getValue() << "'");
break;
}
}
return nullptr;
}
std::vector<Document*> Application::openDocuments(const std::vector<std::string> &filenames,
const std::vector<std::string> *paths,
const std::vector<std::string> *labels,
@@ -640,6 +681,7 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
_pendingDocs.clear();
_pendingDocsReopen.clear();
_pendingDocMap.clear();
_docReloadAttempts.clear();
signalStartOpenDocument();
@@ -649,118 +691,162 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
for (auto &name : filenames)
_pendingDocs.push_back(name.c_str());
std::map<Document *, DocTiming> newDocs;
std::map<DocumentT, DocTiming> timings;
FC_TIME_INIT(t);
for (std::size_t count=0;; ++count) {
const char *name = _pendingDocs.front();
_pendingDocs.pop_front();
bool isMainDoc = count < filenames.size();
std::vector<DocumentT> openedDocs;
try {
_objCount = -1;
std::set<std::string> objNames;
if (_allowPartial) {
auto it = _pendingDocMap.find(name);
if (it != _pendingDocMap.end())
objNames.swap(it->second);
}
int pass = 0;
do {
std::set<App::DocumentT> newDocs;
for (std::size_t count=0;; ++count) {
std::string name = std::move(_pendingDocs.front());
_pendingDocs.pop_front();
bool isMainDoc = (pass == 0 && count < filenames.size());
FC_TIME_INIT(t1);
DocTiming timing;
try {
_objCount = -1;
std::vector<std::string> objNames;
if (_allowPartial) {
auto it = _pendingDocMap.find(name);
if (it != _pendingDocMap.end()) {
if(isMainDoc)
it->second.clear();
else
objNames.swap(it->second);
_pendingDocMap.erase(it);
}
}
const char *path = name;
const char *label = 0;
if (isMainDoc) {
if (paths && paths->size()>count)
path = (*paths)[count].c_str();
FC_TIME_INIT(t1);
DocTiming timing;
if (labels && labels->size()>count)
label = (*labels)[count].c_str();
}
const char *path = name.c_str();
const char *label = 0;
if (isMainDoc) {
if (paths && paths->size()>count)
path = (*paths)[count].c_str();
auto doc = openDocumentPrivate(path, name, label, isMainDoc, createView, objNames);
FC_DURATION_PLUS(timing.d1,t1);
if (doc)
newDocs.emplace(doc,timing);
if (labels && labels->size()>count)
label = (*labels)[count].c_str();
}
auto doc = openDocumentPrivate(path, name.c_str(), label, isMainDoc, createView, std::move(objNames));
FC_DURATION_PLUS(timing.d1,t1);
if (doc) {
timings[doc].d1 += timing.d1;
newDocs.emplace(doc);
}
if (isMainDoc)
res[count] = doc;
_objCount = -1;
}
catch (const Base::Exception &e) {
if (!errs && isMainDoc)
throw;
if (errs && isMainDoc)
(*errs)[count] = e.what();
else
Console().Error("Exception opening file: %s [%s]\n", name, e.what());
}
catch (const std::exception &e) {
if (!errs && isMainDoc)
throw;
if (errs && isMainDoc)
(*errs)[count] = e.what();
else
Console().Error("Exception opening file: %s [%s]\n", name, e.what());
}
catch (...) {
if (errs) {
if (isMainDoc)
(*errs)[count] = "unknown error";
res[count] = doc;
_objCount = -1;
}
else {
_pendingDocs.clear();
catch (const Base::Exception &e) {
e.ReportException();
if (!errs && isMainDoc)
throw;
if (errs && isMainDoc)
(*errs)[count] = e.what();
else
Console().Error("Exception opening file: %s [%s]\n", name.c_str(), e.what());
}
catch (const std::exception &e) {
if (!errs && isMainDoc)
throw;
if (errs && isMainDoc)
(*errs)[count] = e.what();
else
Console().Error("Exception opening file: %s [%s]\n", name.c_str(), e.what());
}
catch (...) {
if (errs) {
if (isMainDoc)
(*errs)[count] = "unknown error";
}
else {
_pendingDocs.clear();
_pendingDocsReopen.clear();
_pendingDocMap.clear();
throw;
}
}
if (_pendingDocs.empty()) {
if(_pendingDocsReopen.empty())
break;
_pendingDocs = std::move(_pendingDocsReopen);
_pendingDocsReopen.clear();
_pendingDocMap.clear();
throw;
for(const auto &file : _pendingDocs) {
auto doc = getDocumentByPath(file.c_str());
if(doc)
closeDocument(doc->getName());
}
}
}
if (_pendingDocs.empty()) {
if (_pendingDocsReopen.empty())
break;
_allowPartial = false;
_pendingDocs.swap(_pendingDocsReopen);
++pass;
_pendingDocMap.clear();
std::vector<Document*> docs;
docs.reserve(newDocs.size());
for(const auto &d : newDocs) {
auto doc = d.getDocument();
if(!doc)
continue;
// Notify PropertyXLink to attach newly opened documents and restore
// relevant external links
PropertyXLink::restoreDocument(*doc);
docs.push_back(doc);
}
}
_pendingDocs.clear();
_pendingDocsReopen.clear();
_pendingDocMap.clear();
Base::SequencerLauncher seq("Postprocessing...", docs.size());
Base::SequencerLauncher seq("Postprocessing...", newDocs.size());
std::vector<Document*> docs;
docs.reserve(newDocs.size());
for (auto &v : newDocs) {
// Notify PropertyXLink to attach newly opened documents and restore
// relevant external links
PropertyXLink::restoreDocument(*v.first);
docs.push_back(v.first);
}
// After external links has been restored, we can now sort the document
// according to their dependency order.
docs = Document::getDependentDocuments(docs, true);
for (auto it=docs.begin(); it!=docs.end();) {
Document *doc = *it;
// It is possible that the newly opened document depends on an existing
// document, which will be included with the above call to
// Document::getDependentDocuments(). Make sure to exclude that.
auto dit = newDocs.find(doc);
if (dit == newDocs.end()) {
it = docs.erase(it);
continue;
// After external links has been restored, we can now sort the document
// according to their dependency order.
try {
docs = Document::getDependentDocuments(docs, true);
} catch (Base::Exception &e) {
e.ReportException();
}
++it;
FC_TIME_INIT(t1);
// Finalize document restoring with the correct order
doc->afterRestore(true);
FC_DURATION_PLUS(dit->second.d2,t1);
seq.next();
}
for(auto it=docs.begin(); it!=docs.end();) {
auto doc = *it;
// It is possible that the newly opened document depends on an existing
// document, which will be included with the above call to
// Document::getDependentDocuments(). Make sure to exclude that.
if(!newDocs.count(doc)) {
it = docs.erase(it);
continue;
}
auto &timing = timings[doc];
FC_TIME_INIT(t1);
// Finalize document restoring with the correct order
if(doc->afterRestore(true)) {
openedDocs.push_back(doc);
it = docs.erase(it);
} else {
++it;
// Here means this is a partial loaded document, and we need to
// reload it fully because of touched objects. The reason of
// reloading a partial document with touched object is because
// partial document is supposed to be readonly, while a
// 'touched' object requires recomputation. And an object may
// become touched during restoring if externally linked
// document time stamp mismatches with the stamp saved.
_pendingDocs.push_back(doc->FileName.getValue());
_pendingDocMap.erase(doc->FileName.getValue());
}
FC_DURATION_PLUS(timing.d2,t1);
seq.next();
}
// Close the document for reloading
for(const auto doc : docs)
closeDocument(doc->getName());
}while(!_pendingDocs.empty());
// Set the active document using the first successfully restored main
// document (i.e. documents explicitly asked for by caller).
@@ -771,14 +857,14 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
}
}
for (auto doc : docs) {
auto &timing = newDocs[doc];
FC_DURATION_LOG(timing.d1, doc->getName() << " restore");
FC_DURATION_LOG(timing.d2, doc->getName() << " postprocess");
for (auto &doc : openedDocs) {
auto &timing = timings[doc];
FC_DURATION_LOG(timing.d1, doc.getDocumentName() << " restore");
FC_DURATION_LOG(timing.d2, doc.getDocumentName() << " postprocess");
}
FC_TIME_LOG(t,"total");
_isRestoring = false;
signalFinishOpenDocument();
return res;
}
@@ -786,7 +872,7 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
Document* Application::openDocumentPrivate(const char * FileName,
const char *propFileName, const char *label,
bool isMainDoc, bool createView,
const std::set<std::string> &objNames)
std::vector<std::string> &&objNames)
{
FileInfo File(FileName);
@@ -797,55 +883,51 @@ Document* Application::openDocumentPrivate(const char * FileName,
}
// Before creating a new document we check whether the document is already open
std::string filepath = File.filePath();
QString canonicalPath = QFileInfo(QString::fromUtf8(FileName)).canonicalFilePath();
for (std::map<std::string,Document*>::iterator it = DocMap.begin(); it != DocMap.end(); ++it) {
// get unique path separators
std::string fi = FileInfo(it->second->FileName.getValue()).filePath();
if (filepath != fi) {
if (canonicalPath == QFileInfo(QString::fromUtf8(fi.c_str())).canonicalFilePath()) {
bool samePath = (canonicalPath == QString::fromUtf8(FileName));
FC_WARN("Identical physical path '" << canonicalPath.toUtf8().constData() << "'\n"
<< (samePath?"":" for file '") << (samePath?"":FileName) << (samePath?"":"'\n")
<< " with existing document '" << it->second->Label.getValue()
<< "' in path: '" << it->second->FileName.getValue() << "'");
}
continue;
}
if(it->second->testStatus(App::Document::PartialDoc)
|| it->second->testStatus(App::Document::PartialRestore)) {
auto doc = getDocumentByPath(File.filePath().c_str(), PathMatchMode::MatchCanonicalWarning);
if(doc) {
if(doc->testStatus(App::Document::PartialDoc)
|| doc->testStatus(App::Document::PartialRestore)) {
// Here means a document is already partially loaded, but the document
// is requested again, either partial or not. We must check if the
// document contains the required object
if(isMainDoc) {
// Main document must be open fully, so close and reopen
closeDocument(it->first.c_str());
break;
}
if(_allowPartial) {
closeDocument(doc->getName());
doc = nullptr;
} else if(_allowPartial) {
bool reopen = false;
for(auto &name : objNames) {
auto obj = it->second->getObject(name.c_str());
for(const auto &name : objNames) {
auto obj = doc->getObject(name.c_str());
if(!obj || obj->testStatus(App::PartialObject)) {
reopen = true;
// NOTE: We are about to reload this document with
// extra objects. However, it is possible to repeat
// this process several times, if it is linked by
// multiple documents and each with a different set of
// objects. To partially solve this problem, we do not
// close and reopen the document immediately here, but
// add it to _pendingDocsReopen to delay reloading.
for(auto obj : doc->getObjects())
objNames.push_back(obj->getNameInDocument());
_pendingDocMap[doc->FileName.getValue()] = std::move(objNames);
break;
}
}
if(!reopen)
return 0;
}
auto &names = _pendingDocMap[FileName];
names.clear();
_pendingDocsReopen.push_back(FileName);
return 0;
if(doc) {
_pendingDocsReopen.emplace_back(FileName);
return 0;
}
}
if(!isMainDoc)
return 0;
return it->second;
else if(doc)
return doc;
}
std::string name;
@@ -867,6 +949,8 @@ Document* Application::openDocumentPrivate(const char * FileName,
try {
// read the document
newDoc->restore(File.filePath().c_str(),true,objNames);
if(DocFileMap.size())
DocFileMap[FileInfo(newDoc->FileName.getValue()).filePath()] = newDoc;
return newDoc;
}
// if the project file itself is corrupt then
@@ -956,14 +1040,14 @@ Application::TransactionSignaller::~TransactionSignaller() {
}
}
const char* Application::getHomePath(void) const
std::string Application::getHomePath()
{
return _mConfig["AppHomePath"].c_str();
return mConfig["AppHomePath"];
}
const char* Application::getExecutableName(void) const
std::string Application::getExecutableName()
{
return _mConfig["ExeName"].c_str();
return mConfig["ExeName"];
}
std::string Application::getTempPath()
@@ -1463,6 +1547,7 @@ void Application::slotStartSaveDocument(const App::Document& doc, const std::str
void Application::slotFinishSaveDocument(const App::Document& doc, const std::string& filename)
{
DocFileMap.clear();
this->signalFinishSaveDocument(doc, filename);
}
+41 -6
View File
@@ -120,6 +120,33 @@ public:
App::Document* getActiveDocument(void) const;
/// Retrieve a named document
App::Document* getDocument(const char *Name) const;
/// Path matching mode for getDocumentByPath()
enum class PathMatchMode {
/// Match by resolving to absolute file path
MatchAbsolute = 0,
/** Match by absolute path first. If not found then match by resolving
* to canonical file path where any intermediate '.' '..' and symlinks
* are resolved.
*/
MatchCanonical = 1,
/** Same as MatchCanonical, but if a document is found by canonical
* path match, which means the document can be resolved using two
* different absolute path, a warning is printed and the found document
* is not returned. This is to allow the caller to intentionally load
* the same physical file as separate documents.
*/
MatchCanonicalWarning = 2,
};
/** Retrieve a document based on file path
*
* @param path: file path
* @param checkCanonical: file path matching mode, @sa PathMatchMode.
* @return Return the document found by matching with the given path
*/
App::Document* getDocumentByPath(const char *path,
PathMatchMode checkCanonical = PathMatchMode::MatchAbsolute) const;
/// gets the (internal) name of the document
const char * getDocumentName(const App::Document* ) const;
/// get a list of all documents in the application
@@ -190,6 +217,8 @@ public:
boost::signals2::signal<void (const Document&)> signalStartRestoreDocument;
/// signal on restoring Document
boost::signals2::signal<void (const Document&)> signalFinishRestoreDocument;
/// signal on pending reloading of a partial Document
boost::signals2::signal<void (const Document&)> signalPendingReloadDocument;
/// signal on starting to save Document
boost::signals2::signal<void (const Document&, const std::string&)> signalStartSaveDocument;
/// signal on saved Document
@@ -366,8 +395,8 @@ public:
/** @name Application directories */
//@{
const char* getHomePath(void) const;
const char* getExecutableName(void) const;
static std::string getHomePath();
static std::string getExecutableName();
/*!
Returns the temporary directory. By default, this is set to the
system's temporary directory but can be customized by the user.
@@ -441,7 +470,7 @@ protected:
/// open single document only
App::Document* openDocumentPrivate(const char * FileName, const char *propFileName,
const char *label, bool isMainDoc, bool createView, const std::set<std::string> &objNames);
const char *label, bool isMainDoc, bool createView, std::vector<std::string> &&objNames);
/// Helper class for App::Document to signal on close/abort transaction
class AppExport TransactionSignaller {
@@ -559,13 +588,19 @@ private:
std::vector<FileTypeItem> _mImportTypes;
std::vector<FileTypeItem> _mExportTypes;
std::map<std::string,Document*> DocMap;
mutable std::map<std::string,Document*> DocFileMap;
std::map<std::string,ParameterManager *> mpcPramManager;
std::map<std::string,std::string> &_mConfig;
App::Document* _pActiveDoc;
std::deque<const char *> _pendingDocs;
std::deque<const char *> _pendingDocsReopen;
std::map<std::string,std::set<std::string> > _pendingDocMap;
std::deque<std::string> _pendingDocs;
std::deque<std::string> _pendingDocsReopen;
std::map<std::string,std::vector<std::string> > _pendingDocMap;
// To prevent infinite recursion of reloading a partial document due a truly
// missing object
std::map<std::string,std::set<std::string> > _docReloadAttempts;
bool _isRestoring;
bool _allowPartial;
bool _isClosingAll;
+1 -1
View File
@@ -691,7 +691,7 @@ PyObject* Application::sGetHomePath(PyObject * /*self*/, PyObject *args)
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
return NULL; // NULL triggers exception
Py::String homedir(GetApplication().getHomePath(),"utf-8");
Py::String homedir(Application::getHomePath(),"utf-8");
return Py::new_reference_to(homedir);
}
+12 -10
View File
@@ -1685,7 +1685,7 @@ std::string Document::getTransientDirectoryName(const std::string& uuid, const s
std::stringstream s;
QCryptographicHash hash(QCryptographicHash::Sha1);
hash.addData(filename.c_str(), filename.size());
s << App::Application::getTempPath() << GetApplication().getExecutableName()
s << App::Application::getTempPath() << App::Application::getExecutableName()
<< "_Doc_" << uuid
<< "_" << hash.result().toHex().left(6).constData()
<< "_" << QCoreApplication::applicationPid();
@@ -1866,7 +1866,6 @@ void Document::exportObjects(const std::vector<App::DocumentObject*>& obj, std::
#define FC_ELEMENT_OBJECT_DEPS "ObjectDeps"
#define FC_ATTR_DEP_COUNT "Count"
#define FC_ATTR_DEP_OBJ_NAME "Name"
#define FC_ATTR_DEP_COUNT "Count"
#define FC_ATTR_DEP_ALLOW_PARTIAL "AllowPartial"
#define FC_ELEMENT_OBJECT_DEP "Dep"
@@ -2693,7 +2692,7 @@ bool Document::isAnyRestoring() {
// Open the document
void Document::restore (const char *filename,
bool delaySignal, const std::set<std::string> &objNames)
bool delaySignal, const std::vector<std::string> &objNames)
{
clearUndos();
d->activeObject = 0;
@@ -2752,8 +2751,7 @@ void Document::restore (const char *filename,
d->partialLoadObjects.emplace(name,true);
try {
Document::Restore(reader);
}
catch (const Base::Exception& e) {
} catch (const Base::Exception& e) {
Base::Console().Error("Invalid Document.xml: %s\n", e.what());
setStatus(Document::RestoreError, true);
}
@@ -2777,15 +2775,16 @@ void Document::restore (const char *filename,
afterRestore(true);
}
void Document::afterRestore(bool checkPartial) {
bool Document::afterRestore(bool checkPartial) {
Base::FlagToggler<> flag(_IsRestoring,false);
if(!afterRestore(d->objectArray,checkPartial)) {
FC_WARN("Reload partial document " << getName());
restore();
return;
GetApplication().signalPendingReloadDocument(*this);
return false;
}
GetApplication().signalFinishRestoreDocument(*this);
setStatus(Document::Restoring, false);
return true;
}
bool Document::afterRestore(const std::vector<DocumentObject *> &objArray, bool checkPartial)
@@ -2861,9 +2860,12 @@ bool Document::afterRestore(const std::vector<DocumentObject *> &objArray, bool
std::string errMsg;
if(link && (res=link->checkRestore(&errMsg))) {
d->touchedObjs.insert(obj);
if(res==1)
if(res==1 || checkPartial) {
FC_WARN(obj->getFullName() << '.' << prop->getName() << ": " << errMsg);
else {
setStatus(Document::LinkStampChanged, true);
if(checkPartial)
return false;
} else {
FC_ERR(obj->getFullName() << '.' << prop->getName() << ": " << errMsg);
d->addRecomputeLog(errMsg,obj);
setStatus(Document::PartialRestore, true);
+4 -3
View File
@@ -74,7 +74,8 @@ public:
PartialDoc = 7,
AllowPartialRecompute = 8, // allow recomputing editing object if SkipRecompute is set
TempDoc = 9, // Mark as temporary document without prompt for save
RestoreError = 10
RestoreError = 10,
LinkStampChanged = 11, // Indicates during restore time if any linked document's time stamp has changed
};
/** @name Properties */
@@ -195,8 +196,8 @@ public:
bool saveCopy(const char* file) const;
/// Restore the document from the file in Property Path
void restore (const char *filename=0,
bool delaySignal=false, const std::set<std::string> &objNames={});
void afterRestore(bool checkPartial=false);
bool delaySignal=false, const std::vector<std::string> &objNames={});
bool afterRestore(bool checkPartial=false);
bool afterRestore(const std::vector<App::DocumentObject *> &, bool checkPartial=false);
enum ExportStatus {
NotExporting,
+8
View File
@@ -62,6 +62,14 @@ public:
/*! Assignment operator */
void operator=(const std::string&);
bool operator==(const DocumentT &other) const {
return document == other.document;
}
bool operator<(const DocumentT &other) const {
return document < other.document;
}
/*! Get a pointer to the document or 0 if it doesn't exist any more. */
Document* getDocument() const;
/*! Get the name of the document. */
+50 -19
View File
@@ -2458,6 +2458,7 @@ class App::DocInfo :
public:
typedef boost::signals2::scoped_connection Connection;
Connection connFinishRestoreDocument;
Connection connPendingReloadDocument;
Connection connDeleteDocument;
Connection connSaveDocument;
Connection connDeletedObject;
@@ -2589,6 +2590,7 @@ public:
FC_LOG("deinit " << (pcDoc?pcDoc->getName():filePath()));
assert(links.empty());
connFinishRestoreDocument.disconnect();
connPendingReloadDocument.disconnect();
connDeleteDocument.disconnect();
connSaveDocument.disconnect();
connDeletedObject.disconnect();
@@ -2606,6 +2608,8 @@ public:
App::Application &app = App::GetApplication();
connFinishRestoreDocument = app.signalFinishRestoreDocument.connect(
boost::bind(&DocInfo::slotFinishRestoreDocument,this,bp::_1));
connPendingReloadDocument = app.signalPendingReloadDocument.connect(
boost::bind(&DocInfo::slotFinishRestoreDocument,this,bp::_1));
connDeleteDocument = app.signalDeleteDocument.connect(
boost::bind(&DocInfo::slotDeleteDocument,this,bp::_1));
connSaveDocument = app.signalSaveDocument.connect(
@@ -2617,6 +2621,8 @@ public:
else{
for(App::Document *doc : App::GetApplication().getDocuments()) {
if(getFullPath(doc->getFileName()) == fullpath) {
if(doc->testStatus(App::Document::PartialDoc) && !doc->getObject(objName))
break;
attach(doc);
return;
}
@@ -2642,22 +2648,36 @@ public:
continue;
}
auto obj = doc->getObject(link->objectName.c_str());
if(!obj)
if(obj)
link->restoreLink(obj);
else if (doc->testStatus(App::Document::PartialDoc)) {
App::GetApplication().addPendingDocument(
doc->FileName.getValue(),
link->objectName.c_str(),
false);
FC_WARN("reloading partial document '" << doc->FileName.getValue()
<< "' due to object " << link->objectName);
} else
FC_WARN("object '" << link->objectName << "' not found in document '"
<< doc->getName() << "'");
else
link->restoreLink(obj);
}
for(auto &v : parentLinks) {
v.first->setFlag(PropertyLinkBase::LinkRestoring);
v.first->aboutToSetValue();
for(auto link : v.second) {
auto obj = doc->getObject(link->objectName.c_str());
if(!obj)
if(obj)
link->restoreLink(obj);
else if (doc->testStatus(App::Document::PartialDoc)) {
App::GetApplication().addPendingDocument(
doc->FileName.getValue(),
link->objectName.c_str(),
false);
FC_WARN("reloading partial document '" << doc->FileName.getValue()
<< "' due to object " << link->objectName);
} else
FC_WARN("object '" << link->objectName << "' not found in document '"
<< doc->getName() << "'");
else
link->restoreLink(obj);
}
v.first->hasSetValue();
v.first->setFlag(PropertyLinkBase::LinkRestoring,false);
@@ -2723,16 +2743,17 @@ public:
}
}
// time stamp changed, touch the linking document. Unfortunately, there
// is no way to setModfied() for an App::Document. We don't want to touch
// all PropertyXLink for a document, because the linked object is
// potentially unchanged. So we just touch at most one.
// time stamp changed, touch the linking document.
std::set<Document*> docs;
for(auto link : links) {
auto linkdoc = static_cast<DocumentObject*>(link->getContainer())->getDocument();
auto ret = docs.insert(linkdoc);
if(ret.second && !linkdoc->isTouched())
link->touch();
if(ret.second) {
// This will signal the Gui::Document to call setModified();
FC_LOG("touch document " << linkdoc->getName()
<< " on time stamp change of " << link->getFullName());
linkdoc->Comment.touch();
}
}
}
@@ -3473,7 +3494,12 @@ PropertyXLink::getDocumentOutList(App::Document *doc) {
std::map<App::Document*,std::set<App::Document*> > ret;
for(auto &v : _DocInfoMap) {
for(auto link : v.second->links) {
if(!v.second->pcDoc) continue;
if(!v.second->pcDoc
|| link->getScope() == LinkScope::Hidden
|| link->testStatus(Property::PropTransient)
|| link->testStatus(Property::Transient)
|| link->testStatus(Property::PropNoPersist))
continue;
auto obj = dynamic_cast<App::DocumentObject*>(link->getContainer());
if(!obj || !obj->getNameInDocument() || !obj->getDocument())
continue;
@@ -3493,6 +3519,11 @@ PropertyXLink::getDocumentInList(App::Document *doc) {
continue;
auto &docs = ret[v.second->pcDoc];
for(auto link : v.second->links) {
if(link->getScope() == LinkScope::Hidden
|| link->testStatus(Property::PropTransient)
|| link->testStatus(Property::Transient)
|| link->testStatus(Property::PropNoPersist))
continue;
auto obj = dynamic_cast<App::DocumentObject*>(link->getContainer());
if(obj && obj->getNameInDocument() && obj->getDocument())
docs.insert(obj->getDocument());
@@ -4460,12 +4491,12 @@ void PropertyXLinkContainer::breakLink(App::DocumentObject *obj, bool clear) {
}
int PropertyXLinkContainer::checkRestore(std::string *msg) const {
if(_LinkRestored)
return 1;
for(auto &v : _XLinks) {
int res = v.second->checkRestore(msg);
if(res)
return res;
if(_LinkRestored) {
for(auto &v : _XLinks) {
int res = v.second->checkRestore(msg);
if(res)
return res;
}
}
return 0;
}
+4 -4
View File
@@ -1955,13 +1955,13 @@ void Application::runApplication(void)
mainApp.setApplicationName(QString::fromUtf8(it->second.c_str()));
}
else {
mainApp.setApplicationName(QString::fromUtf8(App::GetApplication().getExecutableName()));
mainApp.setApplicationName(QString::fromStdString(App::Application::getExecutableName()));
}
#ifndef Q_OS_MACX
mainApp.setWindowIcon(Gui::BitmapFactory().pixmap(App::Application::Config()["AppIcon"].c_str()));
#endif
QString plugin;
plugin = QString::fromUtf8(App::GetApplication().getHomePath());
plugin = QString::fromStdString(App::Application::getHomePath());
plugin += QLatin1String("/plugins");
QCoreApplication::addLibraryPath(plugin);
@@ -2127,7 +2127,7 @@ void Application::runApplication(void)
// init the Inventor subsystem
initOpenInventor();
QString home = QString::fromUtf8(App::GetApplication().getHomePath());
QString home = QString::fromStdString(App::Application::getHomePath());
it = cfg.find("WindowTitle");
if (it != cfg.end()) {
@@ -2267,7 +2267,7 @@ void Application::runApplication(void)
try {
std::stringstream s;
s << App::Application::getTempPath() << App::GetApplication().getExecutableName()
s << App::Application::getTempPath() << App::Application::getExecutableName()
<< "_" << QCoreApplication::applicationPid() << ".lock";
// open a lock file with the PID
Base::FileInfo fi(s.str());
+3 -3
View File
@@ -1029,7 +1029,7 @@ PyObject* Application::sAddResPath(PyObject * /*self*/, PyObject *args)
PyMem_Free(filePath);
if (QDir::isRelativePath(path)) {
// Home path ends with '/'
QString home = QString::fromUtf8(App::GetApplication().getHomePath());
QString home = QString::fromStdString(App::Application::getHomePath());
path = home + path;
}
@@ -1048,7 +1048,7 @@ PyObject* Application::sAddLangPath(PyObject * /*self*/, PyObject *args)
PyMem_Free(filePath);
if (QDir::isRelativePath(path)) {
// Home path ends with '/'
QString home = QString::fromUtf8(App::GetApplication().getHomePath());
QString home = QString::fromStdString(App::Application::getHomePath());
path = home + path;
}
@@ -1066,7 +1066,7 @@ PyObject* Application::sAddIconPath(PyObject * /*self*/, PyObject *args)
PyMem_Free(filePath);
if (QDir::isRelativePath(path)) {
// Home path ends with '/'
QString home = QString::fromUtf8(App::GetApplication().getHomePath());
QString home = QString::fromStdString(App::Application::getHomePath());
path = home + path;
}
+4 -4
View File
@@ -85,8 +85,8 @@ bool Assistant::startAssistant()
if (proc->state() != QProcess::Running) {
#ifdef Q_OS_WIN
QString app;
app = QDir::toNativeSeparators(QString::fromUtf8
(App::GetApplication().getHomePath()) + QLatin1String("bin/"));
app = QDir::toNativeSeparators(QString::fromStdString
(App::Application::getHomePath()) + QLatin1String("bin/"));
#elif defined(Q_OS_MAC)
QString app = QCoreApplication::applicationDirPath() + QDir::separator();
#else
@@ -95,8 +95,8 @@ bool Assistant::startAssistant()
app += QLatin1String("assistant");
// get the name of the executable and the doc path
QString exe = QString::fromUtf8(App::GetApplication().getExecutableName());
QString doc = QString::fromUtf8(App::Application::getHelpDir().c_str());
QString exe = QString::fromStdString(App::Application::getExecutableName());
QString doc = QString::fromStdString(App::Application::getHelpDir());
QString qhc = doc + exe.toLower() + QLatin1String(".qhc");
+3 -3
View File
@@ -97,15 +97,15 @@ BitmapFactoryInst& BitmapFactoryInst::instance(void)
std::map<std::string,std::string>::const_iterator it;
it = App::GetApplication().Config().find("ProgramIcons");
if (it != App::GetApplication().Config().end()) {
QString home = QString::fromUtf8(App::GetApplication().getHomePath());
QString home = QString::fromStdString(App::Application::getHomePath());
QString path = QString::fromUtf8(it->second.c_str());
if (QDir(path).isRelative()) {
path = QFileInfo(QDir(home), path).absoluteFilePath();
}
_pcSingleton->addPath(path);
}
_pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromUtf8(App::GetApplication().getHomePath())));
_pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromUtf8(App::GetApplication().Config()["UserAppData"].c_str())));
_pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromStdString(App::Application::getHomePath())));
_pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromStdString(App::Application::getUserAppDataDir())));
_pcSingleton->addPath(QLatin1String(":/icons/"));
_pcSingleton->addPath(QLatin1String(":/Icons/"));
}
+8 -87
View File
@@ -88,12 +88,10 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
@@ -107,15 +105,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
@@ -126,41 +116,8 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::R:
processed = true;
viewer->resetToHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
default:
break;
}
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
@@ -179,10 +136,6 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
this->seekToPoint(pos); // implicitly calls interactiveCountInc()
processed = true;
}
//else if (press && (this->currentmode == NavigationStyle::IDLE)) {
// this->setViewing(true);
// processed = true;
//}
else if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
@@ -193,30 +146,8 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) {
processed = true;
}
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
else if (press) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(ev->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
inherited::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
@@ -328,11 +259,6 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
this->lockButton1 = false;
processed = true;
}
//if (curmode == NavigationStyle::DRAGGING) {
// if (doSpin())
// newmode = NavigationStyle::SPINNING;
//}
break;
case BUTTON1DOWN:
case CTRLDOWN|BUTTON1DOWN:
@@ -354,9 +280,6 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
}
newmode = NavigationStyle::DRAGGING;
break;
//case BUTTON1DOWN|BUTTON2DOWN|BUTTON3DOWN:
// newmode = NavigationStyle::ZOOMING;
// break;
case CTRLDOWN|SHIFTDOWN|BUTTON2DOWN:
case CTRLDOWN|BUTTON3DOWN:
newmode = NavigationStyle::ZOOMING;
@@ -378,10 +301,8 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
// If not handled in this class, pass on upwards in the inheritance
// hierarchy.
if (/*(curmode == NavigationStyle::SELECTION || viewer->isEditing()) && */!processed)
if (!processed)
processed = inherited::processSoEvent(ev);
else
return true;
return processed;
}
+8 -118
View File
@@ -92,12 +92,10 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
@@ -111,15 +109,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
@@ -130,37 +120,8 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
default:
break;
}
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
@@ -174,39 +135,11 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
case SoMouseButtonEvent::BUTTON1:
this->lockrecenter = true;
this->button1down = press;
#if 0 // disable to avoid interferences where this key combination is used, too
if (press && ev->wasShiftDown() &&
(this->currentmode != NavigationStyle::SELECTION)) {
this->centerTime = ev->getTime();
float ratio = vp.getViewportAspectRatio();
SbViewVolume vv = viewer->getCamera()->getViewVolume(ratio);
this->panningplane = vv.getPlane(viewer->getCamera()->focalDistance.getValue());
this->lockrecenter = false;
}
else if (!press && ev->wasShiftDown() &&
(this->currentmode != NavigationStyle::SELECTION)) {
SbTime tmp = (ev->getTime() - this->centerTime);
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// is it just a left click?
if (tmp.getValue() < dci && !this->lockrecenter) {
if (!this->moveToPoint(pos)) {
panToCenter(panningplane, posn);
this->interactiveCountDec();
}
processed = true;
}
}
else
#endif
if (press && (this->currentmode == NavigationStyle::SEEK_WAIT_MODE)) {
newmode = NavigationStyle::SEEK_MODE;
this->seekToPoint(pos); // implicitly calls interactiveCountInc()
processed = true;
}
//else if (press && (this->currentmode == NavigationStyle::IDLE)) {
// this->setViewing(true);
// processed = true;
//}
else if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
@@ -225,30 +158,8 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) {
processed = true;
}
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
else if (press) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(ev->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
inherited::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
@@ -366,11 +277,6 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
this->lockButton1 = false;
processed = true;
}
//if (curmode == NavigationStyle::DRAGGING) {
// if (doSpin())
// newmode = NavigationStyle::SPINNING;
//}
break;
case BUTTON1DOWN:
// make sure not to change the selection when stopping spinning
@@ -403,16 +309,6 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
case CTRLDOWN|SHIFTDOWN|BUTTON2DOWN:
newmode = NavigationStyle::ZOOMING;
break;
//case CTRLDOWN:
//case CTRLDOWN|BUTTON1DOWN:
//case CTRLDOWN|SHIFTDOWN:
//case CTRLDOWN|SHIFTDOWN|BUTTON1DOWN:
// newmode = NavigationStyle::SELECTION;
// break;
//case BUTTON1DOWN|BUTTON3DOWN:
//case CTRLDOWN|BUTTON3DOWN:
// newmode = NavigationStyle::ZOOMING;
// break;
// There are many cases we don't handle that just falls through to
// the default case, like SHIFTDOWN, CTRLDOWN, CTRLDOWN|SHIFTDOWN,
@@ -424,10 +320,6 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
default:
// The default will make a spin stop and otherwise not do
// anything.
//if ((curmode != NavigationStyle::SEEK_WAIT_MODE) &&
// (curmode != NavigationStyle::SEEK_MODE)) {
// newmode = NavigationStyle::IDLE;
//}
break;
}
@@ -443,10 +335,8 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
// If not handled in this class, pass on upwards in the inheritance
// hierarchy.
if (/*(curmode == NavigationStyle::SELECTION || viewer->isEditing()) && */!processed)
if (!processed)
processed = inherited::processSoEvent(ev);
else
return true;
return processed;
}
+1
View File
@@ -839,6 +839,7 @@ SET(View3D_CPP_SRCS
MayaGestureNavigationStyle.cpp
OpenCascadeNavigationStyle.cpp
OpenSCADNavigationStyle.cpp
TinkerCADNavigationStyle.cpp
TouchpadNavigationStyle.cpp
GestureNavigationStyle.cpp
SplitView3DInventor.cpp
+1 -1
View File
@@ -1117,7 +1117,7 @@ void MacroCommand::activated(int iMsg)
d = QDir(QString::fromUtf8(cMacroPath.c_str()));
}
else {
QString dirstr = QString::fromUtf8(App::GetApplication().getHomePath()) + QString::fromUtf8("Macro");
QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
d = QDir(dirstr);
}
+3 -3
View File
@@ -279,11 +279,11 @@ inline void cmdAppObjectShow(const App::DocumentObject* obj) {
* in-place editing an object, which may be brought in through linking to an
* external group.
*/
inline void cmdSetEdit(const App::DocumentObject* obj) {
inline void cmdSetEdit(const App::DocumentObject* obj, int mod = 0) {
if (obj && obj->getNameInDocument()) {
Gui::Command::doCommand(Gui::Command::Gui,
"Gui.ActiveDocument.setEdit(App.getDocument('%s').getObject('%s'))",
obj->getDocument()->getName(), obj->getNameInDocument());
"Gui.ActiveDocument.setEdit(App.getDocument('%s').getObject('%s'), %d)",
obj->getDocument()->getName(), obj->getNameInDocument(), mod);
}
}
+1 -1
View File
@@ -71,7 +71,7 @@ DlgCustomActionsImp::DlgCustomActionsImp( QWidget* parent )
for (unsigned int i=0; i<d.count(); i++ )
ui->actionMacros->insertItem(0,d[i],QVariant(false));
QString systemMacroDirStr = QString::fromUtf8(App::GetApplication().getHomePath()) + QString::fromUtf8("Macro");
QString systemMacroDirStr = QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
d = QDir(systemMacroDirStr, QLatin1String("*.FCMacro *.py"));
if (d.exists()) {
for (unsigned int i=0; i<d.count(); i++ ) {
+3 -3
View File
@@ -121,7 +121,7 @@ void DlgMacroExecuteImp::fillUpList(void)
item->setText(0, dir[i]);
}
QString dirstr = QString::fromUtf8(App::GetApplication().getHomePath()) + QString::fromUtf8("Macro");
QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
dir = QDir(dirstr, QLatin1String("*.FCMacro *.py"));
ui->systemMacroListBox->clear();
@@ -268,7 +268,7 @@ void DlgMacroExecuteImp::accept()
dir =QDir(this->macroPath);
}
else {
QString dirstr = QString::fromUtf8(App::GetApplication().getHomePath()) + QString::fromUtf8("Macro");
QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
dir = QDir(dirstr);
}
@@ -319,7 +319,7 @@ void DlgMacroExecuteImp::on_editButton_clicked()
else {
//index == 1 system-wide
item = ui->systemMacroListBox->currentItem();
dir.setPath(QString::fromUtf8(App::GetApplication().getHomePath()) + QString::fromUtf8("Macro"));
dir.setPath(QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro"));
}
if (!item)
+1 -1
View File
@@ -1499,7 +1499,7 @@ void Document::slotFinishRestoreDocument(const App::Document& doc)
}
// reset modified flag
setModified(false);
setModified(doc.testStatus(App::Document::LinkStampChanged));
}
void Document::slotShowHidden(const App::Document& doc)
+1 -1
View File
@@ -666,7 +666,7 @@ void DocumentRecoveryHandler::checkForPreviousCrashes(const std::function<void(Q
tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock"));
tmp.setFilter(QDir::Files);
QString exeName = QString::fromLatin1(App::GetApplication().getExecutableName());
QString exeName = QString::fromStdString(App::Application::getExecutableName());
QList<QFileInfo> locks = tmp.entryInfoList();
for (QList<QFileInfo>::iterator it = locks.begin(); it != locks.end(); ++it) {
QString bn = it->baseName();
+1 -1
View File
@@ -273,7 +273,7 @@ void DownloadItem::init()
QString DownloadItem::getDownloadDirectory() const
{
QString exe = QString::fromLatin1(App::GetApplication().getExecutableName());
QString exe = QString::fromStdString(App::Application::getExecutableName());
QString path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
QString dirPath = QDir(path).filePath(exe);
Base::Reference<ParameterGrp> hPath = App::GetApplication().GetUserParameter().GetGroup("BaseApp")
+3 -3
View File
@@ -72,6 +72,7 @@
#include "GestureNavigationStyle.h"
#include <App/Application.h>
#include <Base/Interpreter.h>
#include <Base/Console.h>
#include "View3DInventorViewer.h"
#include "Application.h"
@@ -918,9 +919,8 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent* const ev)
//whatever else, we don't track
}
}
this->ctrldown = ev->wasCtrlDown();
this->shiftdown = ev->wasShiftDown();
this->altdown = ev->wasAltDown();
syncModifierKeys(ev);
smev.modifiers =
(this->button1down ? NS::Event::BUTTON1DOWN : 0) |
+1 -1
View File
@@ -177,7 +177,7 @@ public:
, running(false)
{
timer->setSingleShot(true);
std::string exeName = App::GetApplication().getExecutableName();
std::string exeName = App::Application::getExecutableName();
serverName = QString::fromStdString(exeName);
}
+7 -68
View File
@@ -96,12 +96,10 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
@@ -115,15 +113,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
@@ -134,37 +124,8 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
default:
break;
}
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
@@ -218,30 +179,8 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
this->lockrecenter = true;
}
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
else if (press) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(ev->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
inherited::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
+2 -2
View File
@@ -1490,7 +1490,7 @@ QPixmap MainWindow::aboutImage() const
if (!about_path.empty() && about_image.isNull()) {
QString path = QString::fromUtf8(about_path.c_str());
if (QDir(path).isRelative()) {
QString home = QString::fromUtf8(App::GetApplication().getHomePath());
QString home = QString::fromStdString(App::Application::getHomePath());
path = QFileInfo(QDir(home), path).absoluteFilePath();
}
about_image.load(path);
@@ -1517,7 +1517,7 @@ QPixmap MainWindow::splashImage() const
if (splash_image.isNull()) {
QString path = QString::fromUtf8(splash_path.c_str());
if (QDir(path).isRelative()) {
QString home = QString::fromUtf8(App::GetApplication().getHomePath());
QString home = QString::fromStdString(App::Application::getHomePath());
path = QFileInfo(QDir(home), path).absoluteFilePath();
}
+6 -8
View File
@@ -190,9 +190,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
this->ctrldown = ev->wasCtrlDown();
this->shiftdown = ev->wasShiftDown();
this->altdown = ev->wasAltDown();
syncModifierKeys(ev);
//before this block, mouse button states in NavigationStyle::buttonXdown reflected those before current event arrived.
//track mouse button states
if (evIsButton) {
@@ -380,11 +378,11 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
this->mouseMoveThresholdBroken = false;
pan(viewer->getSoRenderManager()->getCamera());//set up panningplane
int &cnt = this->mousedownConsumedCount;
this->mousedownConsumedEvent[cnt] = *event;//hopefully, a shallow copy is enough. There are no pointers stored in events, apparently. Will lose a subclass, though.
this->mousedownConsumedEvents[cnt] = *event;//hopefully, a shallow copy is enough. There are no pointers stored in events, apparently. Will lose a subclass, though.
cnt++;
assert(cnt<=2);
if(cnt>static_cast<int>(sizeof(mousedownConsumedEvent))){
cnt=sizeof(mousedownConsumedEvent);//we are in trouble
if(cnt>static_cast<int>(sizeof(mousedownConsumedEvents))){
cnt=sizeof(mousedownConsumedEvents);//we are in trouble
}
processed = true;//just consume this event, and wait for the move threshold to be broken to start dragging/panning
}
@@ -398,7 +396,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
if(! processed) {
//re-synthesize all previously-consumed mouseDowns, if any. They might have been re-synthesized already when threshold was broken.
for( int i=0; i < this->mousedownConsumedCount; i++ ){
inherited::processSoEvent(& (this->mousedownConsumedEvent[i]));//simulate the previously-comsumed mousedown.
inherited::processSoEvent(& (this->mousedownConsumedEvents[i]));//simulate the previously-comsumed mousedown.
}
this->mousedownConsumedCount = 0;
processed = inherited::processSoEvent(ev);//explicitly, just for clarity that we are sending a full click sequence.
@@ -443,7 +441,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
//no, we are not entering navigation.
//re-synthesize all previously-consumed mouseDowns, if any, and propagate this mousemove.
for( int i=0; i < this->mousedownConsumedCount; i++ ){
inherited::processSoEvent(& (this->mousedownConsumedEvent[i]));//simulate the previously-comsumed mousedown.
inherited::processSoEvent(& (this->mousedownConsumedEvents[i]));//simulate the previously-comsumed mousedown.
}
this->mousedownConsumedCount = 0;
processed = inherited::processSoEvent(ev);//explicitly, just for clarity that we are sending a full click sequence.
+148 -50
View File
@@ -64,7 +64,7 @@ struct NavigationStyleP {
{
this->animationsteps = 0;
this->animationdelta = 0;
this->animsensor = 0;
this->animsensor = nullptr;
this->sensitivity = 2.0f;
this->resetcursorpos = false;
this->rotationCenterFound = false;
@@ -173,7 +173,7 @@ const Base::Type& NavigationStyleEvent::style() const
TYPESYSTEM_SOURCE_ABSTRACT(Gui::NavigationStyle,Base::BaseClass)
NavigationStyle::NavigationStyle() : viewer(0), mouseSelection(0)
NavigationStyle::NavigationStyle() : viewer(nullptr), mouseSelection(nullptr)
{
PRIVATE(this) = new NavigationStyleP();
PRIVATE(this)->animsensor = new SoTimerSensor(NavigationStyleP::viewAnimationCB, this);
@@ -261,17 +261,17 @@ void NavigationStyle::finalize()
delete[] this->log.time;
}
void NavigationStyle::interactiveCountInc(void)
void NavigationStyle::interactiveCountInc()
{
viewer->interactiveCountInc();
}
void NavigationStyle::interactiveCountDec(void)
void NavigationStyle::interactiveCountDec()
{
viewer->interactiveCountDec();
}
int NavigationStyle::getInteractiveCount(void) const
int NavigationStyle::getInteractiveCount() const
{
return viewer->getInteractiveCount();
}
@@ -288,7 +288,7 @@ NavigationStyle::OrbitStyle NavigationStyle::getOrbitStyle() const
return NavigationStyle::OrbitStyle(projector->getOrbitStyle());
}
SbBool NavigationStyle::isViewing(void) const
SbBool NavigationStyle::isViewing() const
{
return viewer->isViewing();
}
@@ -298,7 +298,7 @@ void NavigationStyle::setViewing(SbBool enable)
viewer->setViewing(enable);
}
SbBool NavigationStyle::isSeekMode(void) const
SbBool NavigationStyle::isSeekMode() const
{
return viewer->isSeekMode();
}
@@ -321,7 +321,7 @@ void NavigationStyle::seekToPoint(const SbVec3f& scenepos)
SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos)
{
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
if (cam == 0) return false;
if (cam == nullptr) return false;
SoRayPickAction rpaction(viewer->getSoRenderManager()->getViewportRegion());
rpaction.setPoint(screenpos);
@@ -343,7 +343,7 @@ SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos)
void NavigationStyle::lookAtPoint(const SbVec3f& pos)
{
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
if (cam == 0) return;
if (cam == nullptr) return;
PRIVATE(this)->rotationCenterFound = false;
// Find global coordinates of focal point.
@@ -401,7 +401,7 @@ void NavigationStyle::lookAtPoint(const SbVec3f& pos)
void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToCenter)
{
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
if (cam == 0) return;
if (cam == nullptr) return;
// Find global coordinates of focal point.
SbVec3f direction;
@@ -611,7 +611,7 @@ void NavigationStyle::viewAll()
*/
void NavigationStyle::reorientCamera(SoCamera * cam, const SbRotation & rot)
{
if (cam == NULL) return;
if (cam == nullptr) return;
// Find global coordinates of focal point.
SbVec3f direction;
@@ -630,7 +630,7 @@ void NavigationStyle::reorientCamera(SoCamera * cam, const SbRotation & rot)
void NavigationStyle::panCamera(SoCamera * cam, float aspectratio, const SbPlane & panplane,
const SbVec2f & currpos, const SbVec2f & prevpos)
{
if (cam == NULL) return; // can happen for empty scenegraph
if (cam == nullptr) return; // can happen for empty scenegraph
if (currpos == prevpos) return; // useless invocation
@@ -659,7 +659,7 @@ void NavigationStyle::pan(SoCamera* camera)
// The plane we're projecting the mouse coordinates to get 3D
// coordinates should stay the same during the whole pan
// operation, so we should calculate this value here.
if (camera == NULL) { // can happen for empty scenegraph
if (camera == nullptr) { // can happen for empty scenegraph
this->panningplane = SbPlane(SbVec3f(0, 0, 1), 0);
}
else {
@@ -689,7 +689,7 @@ void NavigationStyle::panToCenter(const SbPlane & pplane, const SbVec2f & currpo
*/
void NavigationStyle::zoom(SoCamera * cam, float diffvalue)
{
if (cam == NULL) return; // can happen for empty scenegraph
if (cam == nullptr) return; // can happen for empty scenegraph
SoType t = cam->getTypeId();
SbName tname = t.getName();
@@ -870,7 +870,7 @@ void NavigationStyle::setRotationCenter(const SbVec3f& cnt)
SbVec3f NavigationStyle::getFocalPoint() const
{
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
if (cam == 0)
if (cam == nullptr)
return SbVec3f(0,0,0);
// Find global coordinates of focal point.
@@ -887,7 +887,7 @@ SbVec3f NavigationStyle::getFocalPoint() const
void NavigationStyle::spin(const SbVec2f & pointerpos)
{
if (this->log.historysize < 2) return;
assert(this->spinprojector != NULL);
assert(this->spinprojector != nullptr);
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
SbVec2s glsize(vp.getViewportSizePixels());
@@ -965,7 +965,7 @@ void NavigationStyle::spin(const SbVec2f & pointerpos)
* \param prevpos previous normalized position of mouse pointer
*/
void NavigationStyle::spin_simplified(SoCamera* cam, SbVec2f curpos, SbVec2f prevpos){
assert(this->spinprojector != NULL);
assert(this->spinprojector != nullptr);
// 0000333: Turntable camera rotation
SbMatrix mat;
@@ -1163,7 +1163,7 @@ NavigationStyle::setAnimationEnabled(const SbBool enable)
*/
SbBool
NavigationStyle::isAnimationEnabled(void) const
NavigationStyle::isAnimationEnabled() const
{
return this->spinanimatingallowed;
}
@@ -1172,7 +1172,7 @@ NavigationStyle::isAnimationEnabled(void) const
Query if the model in the viewer is currently in spinning mode after
a user drag.
*/
SbBool NavigationStyle::isAnimating(void) const
SbBool NavigationStyle::isAnimating() const
{
return this->currentmode == NavigationStyle::SPINNING;
}
@@ -1195,7 +1195,7 @@ void NavigationStyle::startAnimating(const SbVec3f& axis, float velocity)
this->spinRotation = rot;
}
void NavigationStyle::stopAnimating(void)
void NavigationStyle::stopAnimating()
{
if (this->currentmode != NavigationStyle::SPINNING) {
return;
@@ -1321,7 +1321,7 @@ void NavigationStyle::stopSelection()
if (mouseSelection) {
mouseSelection->releaseMouseModel();
delete mouseSelection;
mouseSelection = 0;
mouseSelection = nullptr;
}
}
@@ -1367,11 +1367,26 @@ void NavigationStyle::addToLog(const SbVec2s pos, const SbTime time)
// This method "clears" the mouse location log, used for spin
// animation calculations.
void NavigationStyle::clearLog(void)
void NavigationStyle::clearLog()
{
this->log.historysize = 0;
}
void NavigationStyle::syncModifierKeys(const SoEvent * const ev)
{
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
}
// The viewer is a state machine, and all changes to the current state
// are made through this call.
void NavigationStyle::setViewingMode(const ViewerMode newmode)
@@ -1446,14 +1461,14 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev)
pcPolygon = mouseSelection->getPositions();
selectedRole = mouseSelection->selectedRole();
delete mouseSelection;
mouseSelection = 0;
mouseSelection = nullptr;
syncWithEvent(ev);
return NavigationStyle::processSoEvent(ev);
}
else if (hd==AbstractMouseSelection::Cancel) {
pcPolygon.clear();
delete mouseSelection;
mouseSelection = 0;
mouseSelection = nullptr;
syncWithEvent(ev);
return NavigationStyle::processSoEvent(ev);
}
@@ -1480,27 +1495,19 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev)
SbBool NavigationStyle::processSoEvent(const SoEvent * const ev)
{
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
bool processed = false;
//handle mouse wheel zoom
if(ev->isOfType(SoMouseWheelEvent::getClassTypeId())){
doZoom(
viewer->getSoRenderManager()->getCamera(),
static_cast<const SoMouseWheelEvent*>(ev)->getDelta(),
posn
);
processed = true;
if (ev->isOfType(SoMouseWheelEvent::getClassTypeId())) {
const SoMouseWheelEvent * const event = static_cast<const SoMouseWheelEvent *>(ev);
processed = processWheelEvent(event);
}
if (! processed)
return viewer->processSoEventBase(ev);
else
return processed;
if (!processed) {
processed = viewer->processSoEventBase(ev);
}
return processed;
}
void NavigationStyle::syncWithEvent(const SoEvent * const ev)
@@ -1514,15 +1521,7 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
@@ -1600,12 +1599,111 @@ SbBool NavigationStyle::processMotionEvent(const SoMotion3Event * const ev)
return true;
}
SbBool NavigationStyle::processKeyboardEvent(const SoKeyboardEvent * const event)
{
SbBool processed = false;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::R:
processed = true;
viewer->resetToHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
case SoKeyboardEvent::PAGE_UP:
{
processed = true;
const SbVec2f posn = normalizePixelPos(event->getPosition());
doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn);
break;
}
case SoKeyboardEvent::PAGE_DOWN:
{
processed = true;
const SbVec2f posn = normalizePixelPos(event->getPosition());
doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn);
break;
}
default:
break;
}
return processed;
}
SbBool NavigationStyle::processClickEvent(const SoMouseButtonEvent * const event)
{
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
SbBool processed = false;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
if (press) {
SbTime tmp = (event->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(event->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(event->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
NavigationStyle::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
return processed;
}
SbBool NavigationStyle::processWheelEvent(const SoMouseWheelEvent * const event)
{
const SbVec2s pos(event->getPosition());
const SbVec2f posn = normalizePixelPos(pos);
//handle mouse wheel zoom
doZoom(viewer->getSoRenderManager()->getCamera(),
event->getDelta(), posn);
return true;
}
void NavigationStyle::setPopupMenuEnabled(const SbBool on)
{
this->menuenabled = on;
}
SbBool NavigationStyle::isPopupMenuEnabled(void) const
SbBool NavigationStyle::isPopupMenuEnabled() const
{
return this->menuenabled;
}
+32 -26
View File
@@ -37,9 +37,11 @@
#include <QEvent>
#include <Base/BaseClass.h>
#include <Gui/Namespace.h>
#include <FCGlobal.h>
// forward declarations
class SoEvent;
class SoMouseWheelEvent;
class SoMotion3Event;
class SoQtViewer;
class SoCamera;
@@ -115,11 +117,11 @@ public:
void setViewer(View3DInventorViewer*);
void setAnimationEnabled(const SbBool enable);
SbBool isAnimationEnabled(void) const;
SbBool isAnimationEnabled() const;
void startAnimating(const SbVec3f& axis, float velocity);
void stopAnimating(void);
SbBool isAnimating(void) const;
void stopAnimating();
SbBool isAnimating() const;
void setSensitivity(float);
float getSensitivity() const;
@@ -151,16 +153,19 @@ public:
int getViewingMode() const;
virtual SbBool processEvent(const SoEvent * const ev);
virtual SbBool processMotionEvent(const SoMotion3Event * const ev);
virtual SbBool processKeyboardEvent(const SoKeyboardEvent * const event);
virtual SbBool processClickEvent(const SoMouseButtonEvent * const event);
virtual SbBool processWheelEvent(const SoMouseWheelEvent * const event);
void setPopupMenuEnabled(const SbBool on);
SbBool isPopupMenuEnabled(void) const;
SbBool isPopupMenuEnabled() const;
void startSelection(AbstractMouseSelection*);
void startSelection(SelectionMode = Lasso);
void abortSelection();
void stopSelection();
SbBool isSelecting() const;
const std::vector<SbVec2s>& getPolygon(SelectionRole* role=0) const;
const std::vector<SbVec2s>& getPolygon(SelectionRole* role=nullptr) const;
void setOrbitStyle(OrbitStyle style);
OrbitStyle getOrbitStyle() const;
@@ -169,13 +174,13 @@ protected:
void initialize();
void finalize();
void interactiveCountInc(void);
void interactiveCountDec(void);
int getInteractiveCount(void) const;
void interactiveCountInc();
void interactiveCountDec();
int getInteractiveCount() const;
SbBool isViewing(void) const;
SbBool isViewing() const;
void setViewing(SbBool);
SbBool isSeekMode(void) const;
SbBool isSeekMode() const;
void setSeekMode(SbBool enable);
SbBool seekToPoint(const SbVec2s screenpos);
void seekToPoint(const SbVec3f& scenepos);
@@ -210,9 +215,10 @@ protected:
void syncWithEvent(const SoEvent * const ev);
virtual void openPopupMenu(const SbVec2s& position);
void clearLog(void);
void clearLog();
void addToLog(const SbVec2s pos, const SbTime time);
void syncModifierKeys(const SoEvent * const ev);
protected:
struct { // tracking mouse movement in a log
@@ -224,6 +230,7 @@ protected:
View3DInventorViewer* viewer;
ViewerMode currentmode;
SoMouseButtonEvent mouseDownConsumedEvent;
SbVec2f lastmouseposition;
SbVec2s globalPos;
SbVec2s localPos;
@@ -293,9 +300,6 @@ public:
protected:
SbBool processSoEvent(const SoEvent * const ev);
private:
SoMouseButtonEvent mouseDownConsumedEvent;
};
class GuiExport CADNavigationStyle : public UserNavigationStyle {
@@ -313,7 +317,6 @@ protected:
private:
SbBool lockButton1;
SoMouseButtonEvent mouseDownConsumedEvent;
};
class GuiExport RevitNavigationStyle : public UserNavigationStyle {
@@ -331,7 +334,6 @@ protected:
private:
SbBool lockButton1;
SoMouseButtonEvent mouseDownConsumedEvent;
};
class GuiExport BlenderNavigationStyle : public UserNavigationStyle {
@@ -349,7 +351,6 @@ protected:
private:
SbBool lockButton1;
SoMouseButtonEvent mouseDownConsumedEvent;
};
class GuiExport MayaGestureNavigationStyle : public UserNavigationStyle {
@@ -369,7 +370,7 @@ protected:
short mouseMoveThreshold;//setting. Minimum move required to consider it a move (in pixels).
bool mouseMoveThresholdBroken;//a flag that the move threshold was surpassed since last mousedown.
int mousedownConsumedCount;//a flag for remembering that a mousedown of button1/button2 was consumed.
SoMouseButtonEvent mousedownConsumedEvent[5];//the event that was consumed and is to be refired. 2 should be enough, but just for a case of the maximum 5 buttons...
SoMouseButtonEvent mousedownConsumedEvents[5];//the event that was consumed and is to be refired. 2 should be enough, but just for a case of the maximum 5 buttons...
bool testMoveThreshold(const SbVec2s currentPos) const;
bool thisClickIsComplex;//a flag that becomes set when a complex clicking pattern is detected (i.e., two or more mouse buttons were down at the same time).
@@ -388,9 +389,6 @@ public:
protected:
SbBool processSoEvent(const SoEvent * const ev);
private:
SoMouseButtonEvent mouseDownConsumedEvent;
};
class GuiExport OpenCascadeNavigationStyle : public UserNavigationStyle {
@@ -405,9 +403,6 @@ public:
protected:
SbBool processSoEvent(const SoEvent * const ev);
private:
SoMouseButtonEvent mouseDownConsumedEvent;
};
class GuiExport OpenSCADNavigationStyle : public UserNavigationStyle {
@@ -422,9 +417,20 @@ public:
protected:
SbBool processSoEvent(const SoEvent * const ev);
};
private:
SoMouseButtonEvent mouseDownConsumedEvent;
class GuiExport TinkerCADNavigationStyle : public UserNavigationStyle {
typedef UserNavigationStyle inherited;
TYPESYSTEM_HEADER();
public:
TinkerCADNavigationStyle();
~TinkerCADNavigationStyle();
const char* mouseButtons(ViewerMode);
protected:
SbBool processSoEvent(const SoEvent * const ev);
};
} // namespace Gui
+3 -3
View File
@@ -418,7 +418,7 @@ Action * StdCmdDownloadOnlineHelp::createAction(void)
{
Action *pcAction;
QString exe = QString::fromLatin1(App::GetApplication().getExecutableName());
QString exe = QString::fromStdString(App::Application::getExecutableName());
pcAction = new Action(this,getMainWindow());
pcAction->setText(QCoreApplication::translate(
this->className(), getMenuText()));
@@ -437,7 +437,7 @@ Action * StdCmdDownloadOnlineHelp::createAction(void)
void StdCmdDownloadOnlineHelp::languageChange()
{
if (_pcAction) {
QString exe = QString::fromLatin1(App::GetApplication().getExecutableName());
QString exe = QString::fromStdString(App::Application::getExecutableName());
_pcAction->setText(QCoreApplication::translate(
this->className(), getMenuText()));
_pcAction->setToolTip(QCoreApplication::translate(
@@ -483,7 +483,7 @@ void StdCmdDownloadOnlineHelp::activated(int iMsg)
bool canStart = false;
// set output directory
QString path = QString::fromUtf8(App::GetApplication().getHomePath());
QString path = QString::fromStdString(App::Application::getHomePath());
path += QString::fromLatin1("/doc/");
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/OnlineHelp");
path = QString::fromUtf8(hURLGrp->GetASCII( "DownloadLocation", path.toLatin1() ).c_str());
+8 -71
View File
@@ -88,12 +88,10 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
@@ -107,15 +105,7 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
@@ -126,37 +116,8 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
default:
break;
}
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
@@ -185,30 +146,8 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) {
processed = true;
}
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
else if (press) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(ev->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
inherited::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
@@ -342,10 +281,8 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
// If not handled in this class, pass on upwards in the inheritance
// hierarchy.
if (/*(curmode == NavigationStyle::SELECTION || viewer->isEditing()) && */!processed)
if (!processed)
processed = inherited::processSoEvent(ev);
else
return true;
return processed;
}
+8 -69
View File
@@ -69,7 +69,7 @@ const char* OpenSCADNavigationStyle::mouseButtons(ViewerMode mode)
case NavigationStyle::DRAGGING:
return QT_TR_NOOP("Press left mouse button and move mouse");
case NavigationStyle::ZOOMING:
return QT_TR_NOOP("Press SHIFT and middle or right mouse button");
return QT_TR_NOOP("Press middle mouse button or SHIFT and right mouse button");
default:
return "No description";
}
@@ -88,12 +88,10 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
@@ -107,15 +105,7 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
@@ -126,37 +116,8 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
default:
break;
}
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
@@ -185,30 +146,8 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (viewer->isEditing() && (curmode == NavigationStyle::SPINNING)) {
processed = true;
}
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
else if (press) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(ev->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
inherited::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
+4 -4
View File
@@ -58,9 +58,9 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget)
SoRenderManager * sorendermanager = quarterwidget->getSoRenderManager();
QActionGroup * rendermodegroup = NULL;
QActionGroup * stereomodegroup = NULL;
QActionGroup * transparencytypegroup = NULL;
QActionGroup * rendermodegroup = nullptr;
QActionGroup * stereomodegroup = nullptr;
QActionGroup * transparencytypegroup = nullptr;
foreach (QAction * action, quarterwidget->renderModeActions()) {
if (!rendermodegroup) {
@@ -138,7 +138,7 @@ ContextMenu::~ContextMenu()
}
QMenu *
ContextMenu::getMenu(void) const
ContextMenu::getMenu() const
{
return this->contextmenu;
}
+1 -1
View File
@@ -48,7 +48,7 @@ public:
ContextMenu(QuarterWidget * quarterwidget);
~ContextMenu();
QMenu * getMenu(void) const;
QMenu * getMenu() const;
public Q_SLOTS:
void changeRenderMode(QAction * action);
+2 -2
View File
@@ -50,7 +50,7 @@
#include <Inventor/nodes/SoSeparator.h>
#include <Quarter/QuarterWidget.h>
#include <stdlib.h>
#include <cstdlib>
namespace SIM { namespace Coin3D { namespace Quarter {
@@ -152,7 +152,7 @@ DragDropHandlerP::dropEvent(QDropEvent * event)
// attempt to import it
root = SoDB::readAll(&in);
if (root == NULL) return;
if (root == nullptr) return;
// set new scenegraph
this->quarterwidget->setSceneGraph(root);
+1 -1
View File
@@ -177,7 +177,7 @@ EventFilter::eventFilter(QObject * obj, QEvent * qevent)
Returns mouse position in global coordinates
*/
const QPoint &
EventFilter::globalMousePosition(void) const
EventFilter::globalMousePosition() const
{
return PRIVATE(this)->globalmousepos;
}
+2 -2
View File
@@ -39,12 +39,12 @@
using namespace SIM::Coin3D::Quarter;
ImageReader::ImageReader(void)
ImageReader::ImageReader()
{
SbImage::addReadImageCB(ImageReader::readImageCB, this);
}
ImageReader::~ImageReader(void)
ImageReader::~ImageReader()
{
SbImage::removeReadImageCB(ImageReader::readImageCB, this);
}
+2 -2
View File
@@ -43,8 +43,8 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class ImageReader {
public:
ImageReader(void);
~ImageReader(void);
ImageReader();
~ImageReader();
SbBool readImage(const SbString & filename, SbImage & image) const;
+1 -1
View File
@@ -48,7 +48,7 @@ using namespace SIM::Coin3D::Quarter;
devices.
*/
InputDevice::InputDevice(void) : quarter(nullptr)
InputDevice::InputDevice() : quarter(nullptr)
{
this->mousepos = SbVec2s(0, 0);
}
+2 -2
View File
@@ -34,7 +34,7 @@ InteractionMode::setEnabled(bool yes)
}
bool
InteractionMode::enabled(void) const
InteractionMode::enabled() const
{
return this->isenabled;
}
@@ -62,7 +62,7 @@ InteractionMode::setOn(bool on)
}
bool
InteractionMode::on(void) const
InteractionMode::on() const
{
return this->altkeydown;
}
+2 -2
View File
@@ -54,10 +54,10 @@ public:
virtual ~InteractionMode();
void setEnabled(bool yes);
bool enabled(void) const;
bool enabled() const;
void setOn(bool on);
bool on(void) const;
bool on() const;
protected:
virtual bool eventFilter(QObject *, QEvent * event);
+2 -2
View File
@@ -55,7 +55,7 @@ using namespace SIM::Coin3D::Quarter;
#define PRIVATE(obj) obj->pimpl
Keyboard::Keyboard(void)
Keyboard::Keyboard()
{
PRIVATE(this) = new KeyboardP(this);
}
@@ -81,7 +81,7 @@ Keyboard::translateEvent(QEvent * event)
case QEvent::KeyRelease:
return PRIVATE(this)->keyEvent((QKeyEvent *) event);
default:
return NULL;
return nullptr;
}
}
+5 -5
View File
@@ -44,7 +44,7 @@ KeyboardP::KeyboardP(Keyboard * publ)
PUBLIC(this) = publ;
this->keyboard = new SoKeyboardEvent;
if (keyboardmap == NULL) {
if (keyboardmap == nullptr) {
keyboardmap = new KeyMap;
keypadmap = new KeyMap;
this->initKeyMap();
@@ -57,7 +57,7 @@ KeyboardP::~KeyboardP()
}
bool
KeyboardP::debugKeyEvents(void)
KeyboardP::debugKeyEvents()
{
const char * env = coin_getenv("QUARTER_DEBUG_KEYEVENTS");
return env && (atoi(env) > 0);
@@ -103,11 +103,11 @@ KeyboardP::keyEvent(QKeyEvent * qevent)
return this->keyboard;
}
KeyboardP::KeyMap * KeyboardP::keyboardmap = NULL;
KeyboardP::KeyMap * KeyboardP::keypadmap = NULL;
KeyboardP::KeyMap * KeyboardP::keyboardmap = nullptr;
KeyboardP::KeyMap * KeyboardP::keypadmap = nullptr;
void
KeyboardP::initKeyMap(void)
KeyboardP::initKeyMap()
{
// keyboard
keyboardmap->insert(Qt::Key_Shift, SoKeyboardEvent::LEFT_SHIFT);
+2 -2
View File
@@ -49,8 +49,8 @@ public:
~KeyboardP();
const SoEvent * keyEvent(QKeyEvent * event);
void initKeyMap(void);
static bool debugKeyEvents(void);
void initKeyMap();
static bool debugKeyEvents();
typedef QMap<Qt::Key, SoKeyboardEvent::Key> KeyMap;
static KeyMap * keyboardmap;
+3 -3
View File
@@ -95,7 +95,7 @@ using namespace SIM::Coin3D::Quarter;
#define PRIVATE(obj) obj->pimpl
#define PUBLIC(obj) obj->publ
Mouse::Mouse(void)
Mouse::Mouse()
{
PRIVATE(this) = new MouseP(this);
}
@@ -131,9 +131,9 @@ Mouse::translateEvent(QEvent * event)
return PRIVATE(this)->mouseWheelEvent((QWheelEvent *) event);
case QEvent::Resize:
PRIVATE(this)->resizeEvent((QResizeEvent *) event);
return NULL;
return nullptr;
default:
return NULL;
return nullptr;
}
}
+1 -1
View File
@@ -55,7 +55,7 @@ NativeEvent::getEvent() const
NativeEvent::NativeEvent()
: QEvent(QEvent::User)
{
this->rawevent = NULL;
this->rawevent = nullptr;
}
#endif // !HAVE_SPACENAV_LIB
+1 -1
View File
@@ -22,7 +22,7 @@ QtCoinCompatibility::QImageToSbImage(const QImage & image, SbImage & sbimage)
}
SbVec2s size((short) w, (short) h);
sbimage.setValue(size, c, NULL);
sbimage.setValue(size, c, nullptr);
unsigned char * buffer = sbimage.getValue(size, c);
if (c == 1) {
+3 -3
View File
@@ -152,7 +152,7 @@
using namespace SIM::Coin3D::Quarter;
static QuarterP * self = NULL;
static QuarterP * self = nullptr;
/*!
initialize Quarter, and implicitly Coin
@@ -182,14 +182,14 @@ Quarter::init(bool initCoin)
clean up resources
*/
void
Quarter::clean(void)
Quarter::clean()
{
COMPILE_ONLY_BEFORE(2,0,0,"Should not be encapsulated in double Quarter namespace");
assert(self);
bool initCoin = self->initCoin;
delete self;
self = NULL;
self = nullptr;
if (initCoin) {
// SoDB::finish() will clean up everything that has been
+1 -1
View File
@@ -39,7 +39,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
namespace Quarter {
void QUARTER_DLL_API init(bool initCoin = true);
void QUARTER_DLL_API clean(void);
void QUARTER_DLL_API clean();
void QUARTER_DLL_API setTimerEpsilon(double sec);
}
+7 -7
View File
@@ -4,13 +4,13 @@
#include "KeyboardP.h"
using namespace SIM::Coin3D::Quarter;
QuarterP::StateCursorMap * QuarterP::statecursormap = NULL;
QuarterP::StateCursorMap * QuarterP::statecursormap = nullptr;
QuarterP::QuarterP(void)
QuarterP::QuarterP()
{
this->sensormanager = new SensorManager;
this->imagereader = new ImageReader;
assert(QuarterP::statecursormap == NULL);
assert(QuarterP::statecursormap == nullptr);
QuarterP::statecursormap = new StateCursorMap;
}
@@ -20,17 +20,17 @@ QuarterP::~QuarterP()
delete this->imagereader;
delete this->sensormanager;
assert(QuarterP::statecursormap != NULL);
assert(QuarterP::statecursormap != nullptr);
delete QuarterP::statecursormap;
// FIXME: Why not use an atexit mechanism for this?
if (KeyboardP::keyboardmap != NULL) {
if (KeyboardP::keyboardmap != nullptr) {
KeyboardP::keyboardmap->clear();
KeyboardP::keypadmap->clear();
delete KeyboardP::keyboardmap;
delete KeyboardP::keypadmap;
KeyboardP::keyboardmap = NULL;
KeyboardP::keypadmap = NULL;
KeyboardP::keyboardmap = nullptr;
KeyboardP::keypadmap = nullptr;
}
+50 -50
View File
@@ -52,7 +52,7 @@
#pragma warning(disable : 4267)
#endif
#include <assert.h>
#include <cassert>
#include <Quarter/QuarterWidget.h>
#include <Quarter/eventhandlers/EventFilter.h>
@@ -152,7 +152,7 @@ class CustomGLWidget : public QOpenGLWidget {
public:
QSurfaceFormat myFormat;
CustomGLWidget(const QSurfaceFormat& format, QWidget* parent = 0, const QOpenGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags())
CustomGLWidget(const QSurfaceFormat& format, QWidget* parent = nullptr, const QOpenGLWidget* shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
: QOpenGLWidget(parent, f), myFormat(format)
{
Q_UNUSED(shareWidget);
@@ -308,7 +308,7 @@ QuarterWidget::constructor(const QtGLFormat & format, const QtGLWidget * sharewi
PRIVATE(this)->eventfilter = new EventFilter(this);
PRIVATE(this)->interactionmode = new InteractionMode(this);
PRIVATE(this)->currentStateMachine = NULL;
PRIVATE(this)->currentStateMachine = nullptr;
PRIVATE(this)->headlight = new SoDirectionalLight;
PRIVATE(this)->headlight->ref();
@@ -364,10 +364,10 @@ QuarterWidget::~QuarterWidget()
delete PRIVATE(this)->currentStateMachine;
}
PRIVATE(this)->headlight->unref();
PRIVATE(this)->headlight = NULL;
this->setSceneGraph(NULL);
this->setSoRenderManager(NULL);
this->setSoEventManager(NULL);
PRIVATE(this)->headlight = nullptr;
this->setSceneGraph(nullptr);
this->setSoRenderManager(nullptr);
this->setSoEventManager(nullptr);
delete PRIVATE(this)->eventfilter;
delete PRIVATE(this);
}
@@ -418,7 +418,7 @@ QuarterWidget::setHeadlightEnabled(bool onoff)
Returns true if the headlight is on, false if it is off
*/
bool
QuarterWidget::headlightEnabled(void) const
QuarterWidget::headlightEnabled() const
{
return PRIVATE(this)->headlight->on.getValue();
}
@@ -427,7 +427,7 @@ QuarterWidget::headlightEnabled(void) const
Returns the light used for the headlight.
*/
SoDirectionalLight *
QuarterWidget::getHeadlight(void) const
QuarterWidget::getHeadlight() const
{
return PRIVATE(this)->headlight;
}
@@ -452,7 +452,7 @@ QuarterWidget::setClearZBuffer(bool onoff)
Returns true if the z buffer is cleared before rendering.
*/
bool
QuarterWidget::clearZBuffer(void) const
QuarterWidget::clearZBuffer() const
{
return PRIVATE(this)->clearzbuffer;
}
@@ -477,7 +477,7 @@ QuarterWidget::setClearWindow(bool onoff)
Returns true if the rendering buffer is cleared before rendering.
*/
bool
QuarterWidget::clearWindow(void) const
QuarterWidget::clearWindow() const
{
return PRIVATE(this)->clearwindow;
}
@@ -503,7 +503,7 @@ QuarterWidget::setInteractionModeEnabled(bool onoff)
Returns true if interaction mode is enabled, false otherwise.
*/
bool
QuarterWidget::interactionModeEnabled(void) const
QuarterWidget::interactionModeEnabled() const
{
return PRIVATE(this)->interactionmode->enabled();
}
@@ -527,7 +527,7 @@ QuarterWidget::setInteractionModeOn(bool onoff)
Returns true if interaction mode is on.
*/
bool
QuarterWidget::interactionModeOn(void) const
QuarterWidget::interactionModeOn() const
{
return PRIVATE(this)->interactionmode->on();
}
@@ -536,7 +536,7 @@ QuarterWidget::interactionModeOn(void) const
Returns the Coin cache context id for this widget.
*/
uint32_t
QuarterWidget::getCacheContextId(void) const
QuarterWidget::getCacheContextId() const
{
return PRIVATE(this)->getCacheContextId();
}
@@ -562,7 +562,7 @@ QuarterWidget::setTransparencyType(TransparencyType type)
\retval The current \ref TransparencyType
*/
QuarterWidget::TransparencyType
QuarterWidget::transparencyType(void) const
QuarterWidget::transparencyType() const
{
assert(PRIVATE(this)->sorendermanager);
SoGLRenderAction * action = PRIVATE(this)->sorendermanager->getGLRenderAction();
@@ -590,7 +590,7 @@ QuarterWidget::setRenderMode(RenderMode mode)
\retval The current \ref RenderMode
*/
QuarterWidget::RenderMode
QuarterWidget::renderMode(void) const
QuarterWidget::renderMode() const
{
assert(PRIVATE(this)->sorendermanager);
return static_cast<RenderMode>(PRIVATE(this)->sorendermanager->getRenderMode());
@@ -618,7 +618,7 @@ QuarterWidget::setStereoMode(StereoMode mode)
\retval The current \ref StereoMode
*/
QuarterWidget::StereoMode
QuarterWidget::stereoMode(void) const
QuarterWidget::stereoMode() const
{
assert(PRIVATE(this)->sorendermanager);
return static_cast<StereoMode>(PRIVATE(this)->sorendermanager->getStereoMode());
@@ -636,7 +636,7 @@ the widget is located within, and updated whenever any change occurs, emitting a
*/
qreal
QuarterWidget::devicePixelRatio(void) const
QuarterWidget::devicePixelRatio() const
{
return PRIVATE(this)->device_pixel_ratio;
}
@@ -653,11 +653,11 @@ QuarterWidget::setSceneGraph(SoNode * node)
if (PRIVATE(this)->scene) {
PRIVATE(this)->scene->unref();
PRIVATE(this)->scene = NULL;
PRIVATE(this)->scene = nullptr;
}
SoCamera * camera = NULL;
SoSeparator * superscene = NULL;
SoCamera * camera = nullptr;
SoSeparator * superscene = nullptr;
bool viewall = false;
if (node) {
@@ -690,7 +690,7 @@ QuarterWidget::setSceneGraph(SoNode * node)
Returns pointer to root of scene graph
*/
SoNode *
QuarterWidget::getSceneGraph(void) const
QuarterWidget::getSceneGraph() const
{
return PRIVATE(this)->scene;
}
@@ -702,10 +702,10 @@ void
QuarterWidget::setSoRenderManager(SoRenderManager * manager)
{
bool carrydata = false;
SoNode * scene = NULL;
SoCamera * camera = NULL;
SoNode * scene = nullptr;
SoCamera * camera = nullptr;
SbViewportRegion vp;
if (PRIVATE(this)->sorendermanager && (manager != NULL)) {
if (PRIVATE(this)->sorendermanager && (manager != nullptr)) {
scene = PRIVATE(this)->sorendermanager->getSceneGraph();
camera = PRIVATE(this)->sorendermanager->getCamera();
vp = PRIVATE(this)->sorendermanager->getViewportRegion();
@@ -735,7 +735,7 @@ QuarterWidget::setSoRenderManager(SoRenderManager * manager)
Returns a pointer to the render manager.
*/
SoRenderManager *
QuarterWidget::getSoRenderManager(void) const
QuarterWidget::getSoRenderManager() const
{
return PRIVATE(this)->sorendermanager;
}
@@ -747,10 +747,10 @@ void
QuarterWidget::setSoEventManager(SoEventManager * manager)
{
bool carrydata = false;
SoNode * scene = NULL;
SoCamera * camera = NULL;
SoNode * scene = nullptr;
SoCamera * camera = nullptr;
SbViewportRegion vp;
if (PRIVATE(this)->soeventmanager && (manager != NULL)) {
if (PRIVATE(this)->soeventmanager && (manager != nullptr)) {
scene = PRIVATE(this)->soeventmanager->getSceneGraph();
camera = PRIVATE(this)->soeventmanager->getCamera();
vp = PRIVATE(this)->soeventmanager->getViewportRegion();
@@ -780,7 +780,7 @@ QuarterWidget::setSoEventManager(SoEventManager * manager)
Returns a pointer to the event manager
*/
SoEventManager *
QuarterWidget::getSoEventManager(void) const
QuarterWidget::getSoEventManager() const
{
return PRIVATE(this)->soeventmanager;
}
@@ -789,7 +789,7 @@ QuarterWidget::getSoEventManager(void) const
Returns a pointer to the event filter
*/
EventFilter *
QuarterWidget::getEventFilter(void) const
QuarterWidget::getEventFilter() const
{
return PRIVATE(this)->eventfilter;
}
@@ -798,7 +798,7 @@ QuarterWidget::getEventFilter(void) const
Reposition the current camera to display the entire scene
*/
void
QuarterWidget::viewAll(void)
QuarterWidget::viewAll()
{
const SbName viewallevent("sim.coin3d.coin.navigation.ViewAll");
for (int c = 0; c < PRIVATE(this)->soeventmanager->getNumSoScXMLStateMachines(); ++c) {
@@ -816,7 +816,7 @@ QuarterWidget::viewAll(void)
Camera typically seeks towards what the mouse is pointing at.
*/
void
QuarterWidget::seek(void)
QuarterWidget::seek()
{
const SbName seekevent("sim.coin3d.coin.navigation.Seek");
for (int c = 0; c < PRIVATE(this)->soeventmanager->getNumSoScXMLStateMachines(); ++c) {
@@ -830,10 +830,10 @@ QuarterWidget::seek(void)
}
bool
QuarterWidget::updateDevicePixelRatio(void) {
QuarterWidget::updateDevicePixelRatio() {
qreal dev_pix_ratio = 1.0;
QWidget* winwidg = window();
QWindow* win = NULL;
QWindow* win = nullptr;
if(winwidg) {
win = winwidg->windowHandle();
}
@@ -1023,7 +1023,7 @@ bool QuarterWidget::viewportEvent(QEvent* event)
render manager and render the scene by calling this method.
*/
void
QuarterWidget::redraw(void)
QuarterWidget::redraw()
{
// we're triggering the next paintGL(). Set a flag to remember this
// to avoid that we process the delay queue in paintGL()
@@ -1050,7 +1050,7 @@ QuarterWidget::redraw(void)
Overridden from QGLWidget to render the scenegraph
*/
void
QuarterWidget::actualRedraw(void)
QuarterWidget::actualRedraw()
{
PRIVATE(this)->sorendermanager->render(PRIVATE(this)->clearwindow,
PRIVATE(this)->clearzbuffer);
@@ -1102,7 +1102,7 @@ QuarterWidget::setBackgroundColor(const QColor & color)
rendering the scene.
*/
QColor
QuarterWidget::backgroundColor(void) const
QuarterWidget::backgroundColor() const
{
SbColor4f bg = PRIVATE(this)->sorendermanager->getBackgroundColor();
@@ -1116,7 +1116,7 @@ QuarterWidget::backgroundColor(void) const
Returns the context menu used by the widget.
*/
QMenu *
QuarterWidget::getContextMenu(void) const
QuarterWidget::getContextMenu() const
{
return PRIVATE(this)->contextMenu();
}
@@ -1125,7 +1125,7 @@ QuarterWidget::getContextMenu(void) const
\retval Is context menu enabled?
*/
bool
QuarterWidget::contextMenuEnabled(void) const
QuarterWidget::contextMenuEnabled() const
{
return PRIVATE(this)->contextmenuenabled;
}
@@ -1175,8 +1175,8 @@ void
QuarterWidget::removeStateMachine(SoScXMLStateMachine * statemachine)
{
SoEventManager * em = this->getSoEventManager();
statemachine->setSceneGraphRoot(NULL);
statemachine->setActiveCamera(NULL);
statemachine->setSceneGraphRoot(nullptr);
statemachine->setActiveCamera(nullptr);
em->removeSoScXMLStateMachine(statemachine);
}
@@ -1184,7 +1184,7 @@ QuarterWidget::removeStateMachine(SoScXMLStateMachine * statemachine)
See \ref QWidget::minimumSizeHint
*/
QSize
QuarterWidget::minimumSizeHint(void) const
QuarterWidget::minimumSizeHint() const
{
return QSize(50, 50);
}
@@ -1195,7 +1195,7 @@ QuarterWidget::minimumSizeHint(void) const
QuarterWidget, add these actions to the menu.
*/
QList<QAction *>
QuarterWidget::transparencyTypeActions(void) const
QuarterWidget::transparencyTypeActions() const
{
return PRIVATE(this)->transparencyTypeActions();
}
@@ -1206,7 +1206,7 @@ QuarterWidget::transparencyTypeActions(void) const
QuarterWidget, add these actions to the menu.
*/
QList<QAction *>
QuarterWidget::stereoModeActions(void) const
QuarterWidget::stereoModeActions() const
{
return PRIVATE(this)->stereoModeActions();
}
@@ -1217,7 +1217,7 @@ QuarterWidget::stereoModeActions(void) const
QuarterWidget, add these actions to the menu.
*/
QList<QAction *>
QuarterWidget::renderModeActions(void) const
QuarterWidget::renderModeActions() const
{
return PRIVATE(this)->renderModeActions();
}
@@ -1239,7 +1239,7 @@ QuarterWidget::renderModeActions(void) const
Removes any navigationModeFile set.
*/
void
QuarterWidget::resetNavigationModeFile(void) {
QuarterWidget::resetNavigationModeFile() {
this->setNavigationModeFile(QUrl());
}
@@ -1276,7 +1276,7 @@ QuarterWidget::setNavigationModeFile(const QUrl & url)
if (PRIVATE(this)->currentStateMachine) {
this->removeStateMachine(PRIVATE(this)->currentStateMachine);
delete PRIVATE(this)->currentStateMachine;
PRIVATE(this)->currentStateMachine = NULL;
PRIVATE(this)->currentStateMachine = nullptr;
PRIVATE(this)->navigationModeFile = url;
}
return;
@@ -1287,7 +1287,7 @@ QuarterWidget::setNavigationModeFile(const QUrl & url)
}
QByteArray filenametmp = filename.toLocal8Bit();
ScXMLStateMachine * stateMachine = NULL;
ScXMLStateMachine * stateMachine = nullptr;
if (filenametmp.startsWith("coin:")){
stateMachine = ScXML::readFile(filenametmp.data());
@@ -1350,7 +1350,7 @@ QuarterWidget::setNavigationModeFile(const QUrl & url)
\retval The current navigationModeFile
*/
const QUrl &
QuarterWidget::navigationModeFile(void) const
QuarterWidget::navigationModeFile() const
{
return PRIVATE(this)->navigationModeFile;
}
+32 -32
View File
@@ -81,9 +81,9 @@ class QUARTER_DLL_API QuarterWidget : public QGraphicsView {
public:
explicit QuarterWidget(QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
explicit QuarterWidget(QtGLContext * context, QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
explicit QuarterWidget(const QtGLFormat & format, QWidget * parent = 0, const QtGLWidget * shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
explicit QuarterWidget(QWidget * parent = nullptr, const QtGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit QuarterWidget(QtGLContext * context, QWidget * parent = nullptr, const QtGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit QuarterWidget(const QtGLFormat & format, QWidget * parent = nullptr, const QtGLWidget * shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~QuarterWidget();
enum TransparencyType {
@@ -117,70 +117,70 @@ public:
INTERLEAVED_COLUMNS = SoRenderManager::INTERLEAVED_COLUMNS
};
TransparencyType transparencyType(void) const;
RenderMode renderMode(void) const;
StereoMode stereoMode(void) const;
TransparencyType transparencyType() const;
RenderMode renderMode() const;
StereoMode stereoMode() const;
void setBackgroundColor(const QColor & color);
QColor backgroundColor(void) const;
QColor backgroundColor() const;
qreal devicePixelRatio(void) const;
qreal devicePixelRatio() const;
void resetNavigationModeFile(void);
void resetNavigationModeFile();
void setNavigationModeFile(const QUrl & url = QUrl(QString::fromLatin1(DEFAULT_NAVIGATIONFILE)));
const QUrl & navigationModeFile(void) const;
const QUrl & navigationModeFile() const;
void setContextMenuEnabled(bool yes);
bool contextMenuEnabled(void) const;
QMenu * getContextMenu(void) const;
bool contextMenuEnabled() const;
QMenu * getContextMenu() const;
bool headlightEnabled(void) const;
bool headlightEnabled() const;
void setHeadlightEnabled(bool onoff);
SoDirectionalLight * getHeadlight(void) const;
SoDirectionalLight * getHeadlight() const;
bool clearZBuffer(void) const;
bool clearZBuffer() const;
void setClearZBuffer(bool onoff);
bool clearWindow(void) const;
bool clearWindow() const;
void setClearWindow(bool onoff);
bool interactionModeEnabled(void) const;
bool interactionModeEnabled() const;
void setInteractionModeEnabled(bool onoff);
bool interactionModeOn(void) const;
bool interactionModeOn() const;
void setInteractionModeOn(bool onoff);
void setStateCursor(const SbName & state, const QCursor & cursor);
QCursor stateCursor(const SbName & state);
uint32_t getCacheContextId(void) const;
uint32_t getCacheContextId() const;
virtual void setSceneGraph(SoNode * root);
virtual SoNode * getSceneGraph(void) const;
virtual SoNode * getSceneGraph() const;
void setSoEventManager(SoEventManager * manager);
SoEventManager * getSoEventManager(void) const;
SoEventManager * getSoEventManager() const;
void setSoRenderManager(SoRenderManager * manager);
SoRenderManager * getSoRenderManager(void) const;
SoRenderManager * getSoRenderManager() const;
EventFilter * getEventFilter(void) const;
EventFilter * getEventFilter() const;
void addStateMachine(SoScXMLStateMachine * statemachine);
void removeStateMachine(SoScXMLStateMachine * statemachine);
virtual bool processSoEvent(const SoEvent * event);
virtual QSize minimumSizeHint(void) const;
virtual QSize minimumSizeHint() const;
QList<QAction *> transparencyTypeActions(void) const;
QList<QAction *> stereoModeActions(void) const;
QList<QAction *> renderModeActions(void) const;
QList<QAction *> transparencyTypeActions() const;
QList<QAction *> stereoModeActions() const;
QList<QAction *> renderModeActions() const;
public Q_SLOTS:
virtual void viewAll(void);
virtual void seek(void);
virtual void viewAll();
virtual void seek();
void redraw(void);
void redraw();
void setRenderMode(RenderMode mode);
void setStereoMode(StereoMode mode);
@@ -197,8 +197,8 @@ protected:
virtual void paintEvent(QPaintEvent*);
virtual void resizeEvent(QResizeEvent*);
virtual bool viewportEvent(QEvent* event);
virtual void actualRedraw(void);
virtual bool updateDevicePixelRatio(void);
virtual void actualRedraw();
virtual bool updateDevicePixelRatio();
private:
void constructor(const QtGLFormat& format, const QtGLWidget* sharewidget);
+17 -17
View File
@@ -57,7 +57,7 @@
#include "ContextMenu.h"
#include "QuarterP.h"
#include <stdlib.h>
#include <cstdlib>
using namespace SIM::Coin3D::Quarter;
@@ -67,19 +67,19 @@ public:
SbList <const QtGLWidget *> widgetlist;
};
static SbList <QuarterWidgetP_cachecontext *> * cachecontext_list = NULL;
static SbList <QuarterWidgetP_cachecontext *> * cachecontext_list = nullptr;
QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sharewidget)
: master(masterptr),
scene(NULL),
eventfilter(NULL),
interactionmode(NULL),
sorendermanager(NULL),
soeventmanager(NULL),
scene(nullptr),
eventfilter(nullptr),
interactionmode(nullptr),
sorendermanager(nullptr),
soeventmanager(nullptr),
initialsorendermanager(false),
initialsoeventmanager(false),
headlight(NULL),
cachecontext(NULL),
headlight(nullptr),
cachecontext(nullptr),
contextmenuenabled(true),
autoredrawenabled(true),
interactionmodeenabled(false),
@@ -87,7 +87,7 @@ QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sha
clearwindow(true),
addactions(true),
device_pixel_ratio(1.0),
contextmenu(NULL)
contextmenu(nullptr)
{
this->cachecontext = findCacheContext(masterptr, sharewidget);
@@ -121,11 +121,11 @@ QuarterWidgetP::searchForCamera(SoNode * root)
return (SoCamera *) node;
}
}
return NULL;
return nullptr;
}
uint32_t
QuarterWidgetP::getCacheContextId(void) const
QuarterWidgetP::getCacheContextId() const
{
return this->cachecontext->id;
}
@@ -133,7 +133,7 @@ QuarterWidgetP::getCacheContextId(void) const
QuarterWidgetP_cachecontext *
QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget)
{
if (cachecontext_list == NULL) {
if (cachecontext_list == nullptr) {
// FIXME: static memory leak
cachecontext_list = new SbList <QuarterWidgetP_cachecontext*>;
}
@@ -257,7 +257,7 @@ QuarterWidgetP::statechangecb(void * userdata, ScXMLStateMachine * statemachine,
QList<QAction *>
QuarterWidgetP::transparencyTypeActions(void) const
QuarterWidgetP::transparencyTypeActions() const
{
if (this->transparencytypeactions.isEmpty()) {
this->transparencytypegroup = new QActionGroup(this->master);
@@ -277,7 +277,7 @@ QuarterWidgetP::transparencyTypeActions(void) const
}
QList<QAction *>
QuarterWidgetP::stereoModeActions(void) const
QuarterWidgetP::stereoModeActions() const
{
if (this->stereomodeactions.isEmpty()) {
this->stereomodegroup = new QActionGroup(this->master);
@@ -291,7 +291,7 @@ QuarterWidgetP::stereoModeActions(void) const
}
QList<QAction *>
QuarterWidgetP::renderModeActions(void) const
QuarterWidgetP::renderModeActions() const
{
if (this->rendermodeactions.isEmpty()) {
this->rendermodegroup = new QActionGroup(this->master);
@@ -308,7 +308,7 @@ QuarterWidgetP::renderModeActions(void) const
#undef ADD_ACTION
QMenu *
QuarterWidgetP::contextMenu(void)
QuarterWidgetP::contextMenu()
{
if (!this->contextmenu) {
this->contextmenu = new ContextMenu(this->master);
+5 -5
View File
@@ -66,12 +66,12 @@ public:
~QuarterWidgetP();
SoCamera * searchForCamera(SoNode * root);
uint32_t getCacheContextId(void) const;
QMenu * contextMenu(void);
uint32_t getCacheContextId() const;
QMenu * contextMenu();
QList<QAction *> transparencyTypeActions(void) const;
QList<QAction *> renderModeActions(void) const;
QList<QAction *> stereoModeActions(void) const;
QList<QAction *> transparencyTypeActions() const;
QList<QAction *> renderModeActions() const;
QList<QAction *> stereoModeActions() const;
QuarterWidget * const master;
SoNode * scene;
+6 -6
View File
@@ -43,7 +43,7 @@
using namespace SIM::Coin3D::Quarter;
SensorManager::SensorManager(void)
SensorManager::SensorManager()
: inherited()
{
this->mainthreadid = cc_thread_id();
@@ -74,7 +74,7 @@ SensorManager::SensorManager(void)
SensorManager::~SensorManager()
{
// remove the Coin callback before shutting down
SoDB::getSensorManager()->setChangedCallback(NULL, NULL);
SoDB::getSensorManager()->setChangedCallback(nullptr, nullptr);
if (this->signalthread->isRunning()) {
this->signalthread->stopThread();
@@ -104,7 +104,7 @@ SensorManager::sensorQueueChangedCB(void * closure)
}
void
SensorManager::sensorQueueChanged(void)
SensorManager::sensorQueueChanged()
{
SoSensorManager * sensormanager = SoDB::getSensorManager();
assert(sensormanager);
@@ -144,7 +144,7 @@ SensorManager::sensorQueueChanged(void)
}
void
SensorManager::idleTimeout(void)
SensorManager::idleTimeout()
{
SoDB::getSensorManager()->processTimerQueue();
SoDB::getSensorManager()->processDelayQueue(true);
@@ -152,14 +152,14 @@ SensorManager::idleTimeout(void)
}
void
SensorManager::timerQueueTimeout(void)
SensorManager::timerQueueTimeout()
{
SoDB::getSensorManager()->processTimerQueue();
this->sensorQueueChanged();
}
void
SensorManager::delayTimeout(void)
SensorManager::delayTimeout()
{
SoDB::getSensorManager()->processTimerQueue();
SoDB::getSensorManager()->processDelayQueue(false);
+5 -5
View File
@@ -45,14 +45,14 @@ class SensorManager : public QObject {
Q_OBJECT
typedef QObject inherited;
public:
SensorManager(void);
SensorManager();
~SensorManager();
public Q_SLOTS:
void idleTimeout(void);
void delayTimeout(void);
void timerQueueTimeout(void);
void sensorQueueChanged(void);
void idleTimeout();
void delayTimeout();
void timerQueueTimeout();
void sensorQueueChanged();
void setTimerEpsilon(double sec);
private:
+4 -4
View File
@@ -36,7 +36,7 @@
using namespace SIM::Coin3D::Quarter;
SignalThread::SignalThread(void)
SignalThread::SignalThread()
: isstopped(false)
{
}
@@ -46,7 +46,7 @@ SignalThread::~SignalThread()
}
void
SignalThread::trigger(void)
SignalThread::trigger()
{
// lock first to make sure the QThread is actually waiting for a signal
QMutexLocker ml(&this->mutex);
@@ -54,7 +54,7 @@ SignalThread::trigger(void)
}
void
SignalThread::stopThread(void)
SignalThread::stopThread()
{
QMutexLocker ml(&this->mutex);
this->isstopped = true;
@@ -63,7 +63,7 @@ SignalThread::stopThread(void)
void
SignalThread::run(void)
SignalThread::run()
{
QMutexLocker ml(&this->mutex);
while (!this->isstopped) {
+5 -5
View File
@@ -44,16 +44,16 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class SignalThread : public QThread {
Q_OBJECT
public:
SignalThread(void);
SignalThread();
virtual ~SignalThread();
virtual void run(void);
void trigger(void);
void stopThread(void);
virtual void run();
void trigger();
void stopThread();
Q_SIGNALS:
void triggerSignal(void);
void triggerSignal();
private:
QWaitCondition waitcond;
+15 -15
View File
@@ -168,7 +168,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::init()
m_seekdistanceabs = false;
m_seekperiod = 2.0f;
m_inseekmode = false;
m_storedcamera = 0;
m_storedcamera = nullptr;
m_viewingflag = false;
pickRadius = 5.0;
@@ -298,12 +298,12 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertPerspective2Ortho(const So
out->height = 2.0f * focaldist * (float)tan(in->heightAngle.getValue() / 2.0);
}
SoCamera* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getCamera(void) const
SoCamera* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getCamera() const
{
return getSoRenderManager()->getCamera();
}
const SbViewportRegion & SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getViewportRegion(void) const
const SbViewportRegion & SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getViewportRegion() const
{
return getSoRenderManager()->getViewportRegion();
}
@@ -318,17 +318,17 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setViewing(SbBool enable)
if(m_viewingflag) {
SoGLRenderAction* action = getSoRenderManager()->getGLRenderAction();
if(action != NULL)
if(action != nullptr)
SoLocateHighlight::turnOffCurrentHighlight(action);
}
}
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isViewing(void) const
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isViewing() const
{
return m_viewingflag;
}
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountInc(void)
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountInc()
{
// Catch problems with missing interactiveCountDec() calls.
assert(m_interactionnesting < 100);
@@ -338,7 +338,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountInc(void)
}
}
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountDec(void)
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountDec()
{
if(--m_interactionnesting <= 0) {
m_interactionEndCallback.invokeCallbacks(this);
@@ -346,7 +346,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountDec(void)
}
}
int SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getInteractiveCount(void) const
int SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getInteractiveCount() const
{
return m_interactionnesting;
}
@@ -372,22 +372,22 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::removeFinishCallback(SIM::Coin3D:
}
float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekDistance(void) const
float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekDistance() const
{
return m_seekdistance;
}
float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekTime(void) const
float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekTime() const
{
return m_seekperiod;
}
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekMode(void) const
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekMode() const
{
return m_inseekmode;
}
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekValuePercentage(void) const
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekValuePercentage() const
{
return m_seekdistanceabs ? false : true;
}
@@ -541,7 +541,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seeksensorCB(void* data, SoSensor
if(end) thisp->setSeekMode(false);
}
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition(void)
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition()
{
SoCamera* cam = getSoRenderManager()->getCamera();
if (!cam) {
@@ -562,7 +562,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition(void)
m_storedcamera->copyFieldValues(getSoRenderManager()->getCamera());
}
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetToHomePosition(void)
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetToHomePosition()
{
SoCamera* cam = getSoRenderManager()->getCamera();
if (!cam) {
@@ -724,7 +724,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::paintEvent(QPaintEvent* event)
this->framesPerSecond = addFrametime(start);
}
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetFrameCounter(void)
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetFrameCounter()
{
this->framecount = 0;
this->frametime = 0.0f;
+22 -22
View File
@@ -47,9 +47,9 @@ typedef void SoQTQuarterAdaptorCB(void* data, SoQTQuarterAdaptor* viewer);
class QUARTER_DLL_API SoQTQuarterAdaptor : public QuarterWidget {
public:
explicit SoQTQuarterAdaptor(QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
explicit SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent = 0, const QtGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
explicit SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
explicit SoQTQuarterAdaptor(QWidget* parent = nullptr, const QtGLWidget* sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent = nullptr, const QtGLWidget* shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent = nullptr, const QtGLWidget* sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~SoQTQuarterAdaptor();
//the functions available in soqtviewer but missing in quarter
@@ -59,38 +59,38 @@ public:
QWidget* getGLWidget() const;
virtual void setCameraType(SoType type);
SoCamera * getCamera(void) const;
SoCamera * getCamera() const;
const SbViewportRegion & getViewportRegion(void) const;
const SbViewportRegion & getViewportRegion() const;
virtual void setViewing(SbBool enable);
SbBool isViewing(void) const;
SbBool isViewing() const;
void interactiveCountInc(void);
void interactiveCountDec(void);
int getInteractiveCount(void) const;
void interactiveCountInc();
void interactiveCountDec();
int getInteractiveCount() const;
void addStartCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
void addFinishCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
void removeStartCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
void removeFinishCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
void addStartCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr);
void addFinishCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr);
void removeStartCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr);
void removeFinishCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr);
virtual void setSeekMode(SbBool enable);
SbBool isSeekMode(void) const;
SbBool isSeekMode() const;
SbBool seekToPoint(const SbVec2s screenpos);
void seekToPoint(const SbVec3f& scenepos);
void setSeekTime(const float seconds);
float getSeekTime(void) const;
float getSeekTime() const;
void setSeekDistance(const float distance);
float getSeekDistance(void) const;
float getSeekDistance() const;
void setSeekValueAsPercentage(const SbBool on);
SbBool isSeekValuePercentage(void) const;
SbBool isSeekValuePercentage() const;
virtual float getPickRadius(void) const {return this->pickRadius;}
virtual float getPickRadius() const {return this->pickRadius;}
virtual void setPickRadius(float pickRadius);
virtual void saveHomePosition(void);
virtual void resetToHomePosition(void);
virtual void saveHomePosition();
virtual void resetToHomePosition();
virtual void setSceneGraph(SoNode* root) {
QuarterWidget::setSceneGraph(root);
@@ -100,7 +100,7 @@ public:
virtual void paintEvent(QPaintEvent*);
//this functions still need to be ported
virtual void afterRealizeHook(void) {} //enables spacenav and joystick in soqt, dunno if this is needed
virtual void afterRealizeHook() {} //enables spacenav and joystick in soqt, dunno if this is needed
private:
void init();
@@ -109,7 +109,7 @@ private:
void getCameraCoordinateSystem(SoCamera * camera, SoNode * root, SbMatrix & matrix, SbMatrix & inverse);
static void seeksensorCB(void * data, SoSensor * s);
void moveCameraScreen(const SbVec2f & screenpos);
void resetFrameCounter(void);
void resetFrameCounter();
SbVec2f addFrametime(double ft);
bool m_viewingflag;
+1 -1
View File
@@ -128,7 +128,7 @@ const SoEvent *
SpaceNavigatorDevice::translateEvent(QEvent * event)
{
Q_UNUSED(event);
SoEvent * ret = NULL;
SoEvent * ret = nullptr;
#ifdef HAVE_SPACENAV_LIB
NativeEvent * ce = dynamic_cast<NativeEvent *>(event);
+1 -1
View File
@@ -47,7 +47,7 @@ class QuarterWidget;
class QUARTER_DLL_API InputDevice {
public:
InputDevice(QuarterWidget * quarter);
InputDevice(void);
InputDevice();
virtual ~InputDevice() {}
/*!
+1 -1
View File
@@ -44,7 +44,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class QUARTER_DLL_API Keyboard : public InputDevice {
public:
Keyboard(QuarterWidget* quarter);
Keyboard(void);
Keyboard();
virtual ~Keyboard();
virtual const SoEvent * translateEvent(QEvent * event);
+1 -1
View File
@@ -44,7 +44,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class QUARTER_DLL_API Mouse : public InputDevice {
public:
Mouse(QuarterWidget* quarter);
Mouse(void);
Mouse();
virtual ~Mouse();
virtual const SoEvent * translateEvent(QEvent * event);
@@ -43,7 +43,7 @@ namespace SIM { namespace Coin3D { namespace Quarter {
class QUARTER_DLL_API SpaceNavigatorDevice : public InputDevice {
public:
SpaceNavigatorDevice(QuarterWidget* quarter);
SpaceNavigatorDevice(void);
SpaceNavigatorDevice();
virtual ~SpaceNavigatorDevice();
virtual const SoEvent * translateEvent(QEvent * event);
+1 -1
View File
@@ -53,7 +53,7 @@ public:
void registerInputDevice(InputDevice * device);
void unregisterInputDevice(InputDevice * device);
const QPoint & globalMousePosition(void) const;
const QPoint & globalMousePosition() const;
protected:
bool eventFilter(QObject * obj, QEvent * event);
+8 -84
View File
@@ -88,12 +88,10 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
@@ -107,15 +105,7 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
@@ -126,37 +116,8 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
default:
break;
}
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
@@ -175,10 +136,6 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
this->seekToPoint(pos); // implicitly calls interactiveCountInc()
processed = true;
}
//else if (press && (this->currentmode == NavigationStyle::IDLE)) {
// this->setViewing(true);
// processed = true;
//}
else if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
@@ -189,30 +146,8 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) {
processed = true;
}
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
else if (press) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(ev->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
inherited::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
@@ -322,11 +257,6 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
this->lockButton1 = false;
processed = true;
}
//if (curmode == NavigationStyle::DRAGGING) {
// if (doSpin())
// newmode = NavigationStyle::SPINNING;
//}
break;
case BUTTON1DOWN:
case CTRLDOWN|BUTTON1DOWN:
@@ -348,9 +278,6 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
}
newmode = NavigationStyle::DRAGGING;
break;
//case BUTTON1DOWN|BUTTON2DOWN|BUTTON3DOWN:
// newmode = NavigationStyle::ZOOMING;
// break;
case CTRLDOWN|SHIFTDOWN|BUTTON2DOWN:
case CTRLDOWN|BUTTON3DOWN:
newmode = NavigationStyle::ZOOMING;
@@ -372,10 +299,7 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
// If not handled in this class, pass on upwards in the inheritance
// hierarchy.
if (/*(curmode == NavigationStyle::SELECTION || viewer->isEditing()) && */!processed)
if (!processed)
processed = inherited::processSoEvent(ev);
else
return true;
return processed;
}
+1
View File
@@ -186,6 +186,7 @@ void Gui::SoFCDB::init()
GestureNavigationStyle ::init();
OpenCascadeNavigationStyle ::init();
OpenSCADNavigationStyle ::init();
TinkerCADNavigationStyle ::init();
GLGraphicsItem ::init();
GLFlagWindow ::init();
+2 -2
View File
@@ -166,7 +166,7 @@ void SoFCOffscreenRenderer::writeToImageFile(const char* filename, const char* c
img.setText(QLatin1String("Description"), QString::fromUtf8(comment));
img.setText(QLatin1String("Creation Time"), QDateTime::currentDateTime().toString());
img.setText(QLatin1String("Software"),
QString::fromUtf8(App::GetApplication().getExecutableName()));
QString::fromStdString(App::Application::getExecutableName()));
}
QFile f(QString::fromUtf8(filename));
@@ -296,7 +296,7 @@ std::string SoFCOffscreenRenderer::createMIBA(const SbMatrix& mat) const
com << " <Source>\n" ;
com << " <Creator>Unknown</Creator>\n" ;
com << " <CreationDate>" << QDateTime::currentDateTime().toString().toLatin1().constData() << "</CreationDate>\n" ;
com << " <CreatingSystem>" << App::GetApplication().getExecutableName() << " " << major << "." << minor << "</CreatingSystem>\n" ;
com << " <CreatingSystem>" << App::Application::getExecutableName() << " " << major << "." << minor << "</CreatingSystem>\n" ;
com << " <PartNumber>Unknown</PartNumber>\n";
com << " <Revision>1.0</Revision>\n";
com << " </Source>\n" ;
+1 -1
View File
@@ -680,7 +680,7 @@ void AboutDialog::on_copyButton_clicked()
QTextStream str(&data);
std::map<std::string, std::string>& config = App::Application::Config();
std::map<std::string,std::string>::iterator it;
QString exe = QString::fromLatin1(App::GetApplication().getExecutableName());
QString exe = QString::fromStdString(App::Application::getExecutableName());
QString major = QString::fromLatin1(config["BuildVersionMajor"].c_str());
QString minor = QString::fromLatin1(config["BuildVersionMinor"].c_str());
+263
View File
@@ -0,0 +1,263 @@
/***************************************************************************
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cfloat>
# include "InventorAll.h"
# include <QAction>
# include <QActionGroup>
# include <QApplication>
# include <QByteArray>
# include <QCursor>
# include <QList>
# include <QMenu>
# include <QMetaObject>
# include <QRegExp>
#endif
#include <App/Application.h>
#include "NavigationStyle.h"
#include "View3DInventorViewer.h"
#include "Application.h"
#include "MenuManager.h"
#include "MouseSelection.h"
using namespace Gui;
// ----------------------------------------------------------------------------------
/* TRANSLATOR Gui::TinkerCADNavigationStyle */
TYPESYSTEM_SOURCE(Gui::TinkerCADNavigationStyle, Gui::UserNavigationStyle)
TinkerCADNavigationStyle::TinkerCADNavigationStyle()
{
}
TinkerCADNavigationStyle::~TinkerCADNavigationStyle()
{
}
const char* TinkerCADNavigationStyle::mouseButtons(ViewerMode mode)
{
switch (mode) {
case NavigationStyle::SELECTION:
return QT_TR_NOOP("Press left mouse button");
case NavigationStyle::PANNING:
return QT_TR_NOOP("Press middle mouse button");
case NavigationStyle::DRAGGING:
return QT_TR_NOOP("Press right mouse button");
case NavigationStyle::ZOOMING:
return QT_TR_NOOP("Scroll middle mouse button");
default:
return "No description";
}
}
SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev)
{
// Events when in "ready-to-seek" mode are ignored, except those
// which influence the seek mode itself -- these are handled further
// up the inheritance hierarchy.
if (this->isSeekMode()) { return inherited::processSoEvent(ev); }
// Switch off viewing mode
if (!this->isSeekMode() && !this->isAnimating() && this->isViewing())
this->setViewing(false); // by default disable viewing mode to render the scene
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s pos(ev->getPosition());
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
// necessary to restrict ourselves to only do one "action" for an
// event, we only need this flag to see if any processing happened
// at all.
SbBool processed = false;
const ViewerMode curmode = this->currentmode;
ViewerMode newmode = curmode;
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
processed = handleEventInForeground(ev);
if (processed)
return true;
}
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
const int button = event->getButton();
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
SbBool canOpenPopupMenu = false;
switch (button) {
case SoMouseButtonEvent::BUTTON1:
this->button1down = press;
if (press && (curmode == NavigationStyle::SEEK_WAIT_MODE)) {
newmode = NavigationStyle::SEEK_MODE;
this->seekToPoint(pos); // implicitly calls interactiveCountInc()
processed = true;
}
else if (viewer->isEditing() && (curmode == NavigationStyle::SPINNING)) {
processed = true;
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
// If we are in edit mode then simply ignore the RMB events
// to pass the event to the base class.
this->button2down = press;
if (press) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
}
else if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON2) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = float(QApplication::doubleClickInterval())/1000.0f;
// time between press and release event
if (tmp.getValue() < dci) {
canOpenPopupMenu = true;
}
}
// About to start rotating
if (press && (curmode == NavigationStyle::IDLE)) {
// Use this variable to spot move events
saveCursorPosition(ev);
this->centerTime = ev->getTime();
processed = true;
}
else if (!press && (curmode == NavigationStyle::DRAGGING)) {
if (!viewer->isEditing() && canOpenPopupMenu) {
// If we are in drag mode but mouse hasn't been moved open the context-menu
if (this->isPopupMenuEnabled()) {
this->openPopupMenu(event->getPosition());
}
}
newmode = NavigationStyle::IDLE;
processed = true;
}
break;
case SoMouseButtonEvent::BUTTON3:
this->button3down = press;
if (press) {
this->centerTime = ev->getTime();
float ratio = vp.getViewportAspectRatio();
SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(ratio);
this->panningplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue());
}
else if (curmode == NavigationStyle::PANNING) {
newmode = NavigationStyle::IDLE;
processed = true;
}
break;
default:
break;
}
}
// Mouse Movement handling
if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) {
const SoLocation2Event * const event = (const SoLocation2Event *) ev;
if (curmode == NavigationStyle::PANNING) {
float ratio = vp.getViewportAspectRatio();
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized);
processed = true;
}
else if (curmode == NavigationStyle::DRAGGING) {
this->addToLog(event->getPosition(), event->getTime());
this->spin(posn);
moveCursorPosition();
processed = true;
}
}
// Spaceball & Joystick handling
if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) {
const SoMotion3Event * const event = static_cast<const SoMotion3Event *>(ev);
if (event)
this->processMotionEvent(event);
processed = true;
}
enum {
BUTTON1DOWN = 1 << 0,
BUTTON3DOWN = 1 << 1,
CTRLDOWN = 1 << 2,
SHIFTDOWN = 1 << 3,
BUTTON2DOWN = 1 << 4
};
unsigned int combo =
(this->button1down ? BUTTON1DOWN : 0) |
(this->button2down ? BUTTON2DOWN : 0) |
(this->button3down ? BUTTON3DOWN : 0) |
(this->ctrldown ? CTRLDOWN : 0) |
(this->shiftdown ? SHIFTDOWN : 0);
switch (combo) {
case 0:
if (curmode == NavigationStyle::SPINNING) { break; }
newmode = NavigationStyle::IDLE;
break;
case BUTTON1DOWN:
newmode = NavigationStyle::SELECTION;
break;
case BUTTON2DOWN:
newmode = NavigationStyle::DRAGGING;
break;
case BUTTON3DOWN:
newmode = NavigationStyle::PANNING;
break;
default:
break;
}
if (newmode != curmode) {
this->setViewingMode(newmode);
}
// If not handled in this class, pass on upwards in the inheritance
// hierarchy.
if (!processed)
processed = inherited::processSoEvent(ev);
return processed;
}
+7 -79
View File
@@ -88,12 +88,10 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = normalizePixelPos(pos);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
// Set to true if any event processing happened. Note that it is not
@@ -107,15 +105,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
// Mismatches in state of the modifier keys happens if the user
// presses or releases them outside the viewer window.
if (this->ctrldown != ev->wasCtrlDown()) {
this->ctrldown = ev->wasCtrlDown();
}
if (this->shiftdown != ev->wasShiftDown()) {
this->shiftdown = ev->wasShiftDown();
}
if (this->altdown != ev->wasAltDown()) {
this->altdown = ev->wasAltDown();
}
syncModifierKeys(ev);
// give the nodes in the foreground root the chance to handle events (e.g color bar)
if (!viewer->isEditing()) {
@@ -126,45 +116,8 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
// Keyboard handling
if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
switch (event->getKey()) {
case SoKeyboardEvent::LEFT_CONTROL:
case SoKeyboardEvent::RIGHT_CONTROL:
this->ctrldown = press;
break;
case SoKeyboardEvent::LEFT_SHIFT:
case SoKeyboardEvent::RIGHT_SHIFT:
this->shiftdown = press;
break;
case SoKeyboardEvent::LEFT_ALT:
case SoKeyboardEvent::RIGHT_ALT:
this->altdown = press;
break;
case SoKeyboardEvent::H:
processed = true;
viewer->saveHomePosition();
break;
case SoKeyboardEvent::S:
case SoKeyboardEvent::HOME:
case SoKeyboardEvent::LEFT_ARROW:
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
case SoKeyboardEvent::PAGE_UP:
doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn);
processed = true;
break;
case SoKeyboardEvent::PAGE_DOWN:
doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn);
processed = true;
break;
default:
break;
}
const SoKeyboardEvent * const event = static_cast<const SoKeyboardEvent *>(ev);
processed = processKeyboardEvent(event);
}
// Mouse Button / Spaceball Button handling
@@ -193,30 +146,8 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) {
processed = true;
}
// issue #0002433: avoid to swallow the UP event if down the
// scene graph somewhere a dialog gets opened
else if (press) {
SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime());
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// a double-click?
if (tmp.getValue() < dci) {
mouseDownConsumedEvent = *event;
mouseDownConsumedEvent.setTime(ev->getTime());
processed = true;
}
else {
mouseDownConsumedEvent.setTime(ev->getTime());
// 'ANY' is used to mark that we don't know yet if it will
// be a double-click event.
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
}
else if (!press) {
if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) {
// now handle the postponed event
inherited::processSoEvent(&mouseDownConsumedEvent);
mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY);
}
else {
processed = processClickEvent(event);
}
break;
case SoMouseButtonEvent::BUTTON2:
@@ -346,8 +277,5 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
// hierarchy.
if (!processed)
processed = inherited::processSoEvent(ev);
else
return true;
return processed;
}
+19
View File
@@ -115,6 +115,8 @@ void View3DInventorPy::init_type()
add_varargs_method("stopAnimating",&View3DInventorPy::stopAnimating,"stopAnimating()");
add_varargs_method("setAnimationEnabled",&View3DInventorPy::setAnimationEnabled,"setAnimationEnabled()");
add_varargs_method("isAnimationEnabled",&View3DInventorPy::isAnimationEnabled,"isAnimationEnabled()");
add_varargs_method("setPopupMenuEnabled",&View3DInventorPy::setPopupMenuEnabled,"setPopupMenuEnabled()");
add_varargs_method("isPopupMenuEnabled",&View3DInventorPy::isPopupMenuEnabled,"isPopupMenuEnabled()");
add_varargs_method("dump",&View3DInventorPy::dump,"dump(filename, [onlyVisible=False])");
add_varargs_method("dumpNode",&View3DInventorPy::dumpNode,"dumpNode(node)");
add_varargs_method("setStereoType",&View3DInventorPy::setStereoType,"setStereoType()");
@@ -953,6 +955,23 @@ Py::Object View3DInventorPy::isAnimationEnabled(const Py::Tuple& args)
return Py::Boolean(ok ? true : false);
}
Py::Object View3DInventorPy::setPopupMenuEnabled(const Py::Tuple& args)
{
int ok;
if (!PyArg_ParseTuple(args.ptr(), "i", &ok))
throw Py::Exception();
_view->getViewer()->setPopupMenuEnabled(ok!=0);
return Py::None();
}
Py::Object View3DInventorPy::isPopupMenuEnabled(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
SbBool ok = _view->getViewer()->isPopupMenuEnabled();
return Py::Boolean(ok ? true : false);
}
Py::Object View3DInventorPy::saveImage(const Py::Tuple& args)
{
char *cFileName,*cColor="Current",*cComment="$MIBA";
+2
View File
@@ -87,6 +87,8 @@ public:
Py::Object stopAnimating(const Py::Tuple&);
Py::Object setAnimationEnabled(const Py::Tuple&);
Py::Object isAnimationEnabled(const Py::Tuple&);
Py::Object setPopupMenuEnabled(const Py::Tuple&);
Py::Object isPopupMenuEnabled(const Py::Tuple&);
Py::Object dump(const Py::Tuple&);
Py::Object dumpNode(const Py::Tuple&);
Py::Object setStereoType(const Py::Tuple&);
+16 -6
View File
@@ -196,12 +196,19 @@ void ViewProviderDocumentObject::onChanged(const App::Property* prop)
// this is undesired behaviour. So, if this change marks the document as
// modified then it must be be reversed.
if (!testStatus(Gui::ViewStatus::TouchDocument)) {
bool mod = false;
if (pcDocument)
mod = pcDocument->isModified();
// Note: reverting document modified status like that is not
// appropriate because we can't tell if there is any other
// property being changed due to the change of Visibility here.
// Temporary setting the Visibility property as 'NoModify' is
// the proper way.
Base::ObjectStatusLocker<App::Property::Status,App::Property> guard(
App::Property::NoModify, &Visibility);
// bool mod = false;
// if (pcDocument)
// mod = pcDocument->isModified();
getObject()->Visibility.setValue(Visibility.getValue());
if (pcDocument)
pcDocument->setModified(mod);
// if (pcDocument)
// pcDocument->setModified(mod);
}
else {
getObject()->Visibility.setValue(Visibility.getValue());
@@ -215,7 +222,10 @@ void ViewProviderDocumentObject::onChanged(const App::Property* prop)
}
}
if (pcDocument && !pcDocument->isModified() && testStatus(Gui::ViewStatus::TouchDocument)) {
if (prop && !prop->testStatus(App::Property::NoModify)
&& pcDocument
&& !pcDocument->isModified()
&& testStatus(Gui::ViewStatus::TouchDocument)) {
if (prop)
FC_LOG(prop->getFullName() << " changed");
pcDocument->setModified(true);
+1 -1
View File
@@ -431,7 +431,7 @@ void PyResource::load(const char* name)
// checks whether it's a relative path
if (fi.isRelative()) {
QString cwd = QDir::currentPath ();
QString home= QDir(QString::fromUtf8(App::GetApplication().getHomePath())).path();
QString home= QDir(QString::fromStdString(App::Application::getHomePath())).path();
// search in cwd and home path for the file
//
+143 -97
View File
@@ -2094,13 +2094,110 @@ void PropertyMatrixItem::setA44(double A44)
// ---------------------------------------------------------------
PROPERTYITEM_SOURCE(Gui::PropertyEditor::PropertyRotationItem)
PropertyRotationItem::PropertyRotationItem()
RotationHelper::RotationHelper()
: init_axis(false)
, changed_value(false)
, rot_angle(0)
, rot_axis(0,0,1)
{
}
void RotationHelper::setChanged(bool value)
{
changed_value = value;
}
bool RotationHelper::hasChangedAndReset()
{
if (!changed_value)
return false;
changed_value = false;
return true;
}
bool RotationHelper::isAxisInitialized() const
{
return init_axis;
}
void RotationHelper::setValue(const Base::Vector3d& axis, double angle)
{
rot_axis = axis;
rot_angle = angle;
init_axis = true;
}
void RotationHelper::getValue(Base::Vector3d& axis, double& angle) const
{
axis = rot_axis;
angle = rot_angle;
}
double RotationHelper::getAngle(const Base::Rotation& val) const
{
double angle;
Base::Vector3d dir;
val.getRawValue(dir, angle);
if (dir * this->rot_axis < 0.0)
angle = -angle;
return angle;
}
Base::Rotation RotationHelper::setAngle(double angle)
{
Base::Rotation rot;
rot.setValue(this->rot_axis, Base::toRadians<double>(angle));
changed_value = true;
rot_angle = angle;
return rot;
}
Base::Vector3d RotationHelper::getAxis() const
{
// We must store the rotation axis in a member because
// if we read the value from the property we would always
// get a normalized vector which makes it quite unhandy
// to work with
return this->rot_axis;
}
Base::Rotation RotationHelper::setAxis(const Base::Rotation& value, const Base::Vector3d& axis)
{
this->rot_axis = axis;
Base::Rotation rot = value;
Base::Vector3d dummy; double angle;
rot.getValue(dummy, angle);
if (dummy * axis < 0.0)
angle = -angle;
rot.setValue(axis, angle);
changed_value = true;
return rot;
}
void RotationHelper::assignProperty(const Base::Rotation& value, double eps)
{
double angle;
Base::Vector3d dir;
value.getRawValue(dir, angle);
Base::Vector3d cross = this->rot_axis.Cross(dir);
double len2 = cross.Sqr();
if (angle != 0) {
// vectors are not parallel
if (len2 > eps)
this->rot_axis = dir;
// vectors point into opposite directions
else if (this->rot_axis.Dot(dir) < 0)
this->rot_axis = -this->rot_axis;
}
this->rot_angle = Base::toDegrees(angle);
}
// ---------------------------------------------------------------
PROPERTYITEM_SOURCE(Gui::PropertyEditor::PropertyRotationItem)
PropertyRotationItem::PropertyRotationItem()
{
m_a = static_cast<PropertyUnitItem*>(PropertyUnitItem::create());
m_a->setParent(this);
@@ -2122,12 +2219,9 @@ Base::Quantity PropertyRotationItem::getAngle() const
QVariant value = data(1, Qt::EditRole);
if (!value.canConvert<Base::Rotation>())
return Base::Quantity(0.0);
const Base::Rotation& val = value.value<Base::Rotation>();
double angle;
Base::Vector3d dir;
val.getRawValue(dir, angle);
if (dir * this->rot_axis < 0.0)
angle = -angle;
double angle = h.getAngle(val);
return Base::Quantity(Base::toDegrees<double>(angle), Base::Unit::Angle);
}
@@ -2137,20 +2231,13 @@ void PropertyRotationItem::setAngle(Base::Quantity angle)
if (!value.canConvert<Base::Rotation>())
return;
Base::Rotation rot;
rot.setValue(this->rot_axis, Base::toRadians<double>(angle.getValue()));
changed_value = true;
rot_angle = angle.getValue();
Base::Rotation rot = h.setAngle(angle.getValue());
setValue(QVariant::fromValue(rot));
}
Base::Vector3d PropertyRotationItem::getAxis() const
{
// We must store the rotation axis in a member because
// if we read the value from the property we would always
// get a normalized vector which makes it quite unhandy
// to work with
return this->rot_axis;
return h.getAxis();
}
void PropertyRotationItem::setAxis(const Base::Vector3d& axis)
@@ -2158,14 +2245,9 @@ void PropertyRotationItem::setAxis(const Base::Vector3d& axis)
QVariant value = data(1, Qt::EditRole);
if (!value.canConvert<Base::Rotation>())
return;
this->rot_axis = axis;
Base::Rotation rot = value.value<Base::Rotation>();
Base::Vector3d dummy; double angle;
rot.getValue(dummy, angle);
if (dummy * axis < 0.0)
angle = -angle;
rot.setValue(axis, angle);
changed_value = true;
rot = h.setAxis(rot, axis);
setValue(QVariant::fromValue(rot));
}
@@ -2176,20 +2258,7 @@ void PropertyRotationItem::assignProperty(const App::Property* prop)
double eps = std::pow(10.0, -2*(decimals()+1));
if (prop->getTypeId().isDerivedFrom(App::PropertyRotation::getClassTypeId())) {
const Base::Rotation& value = static_cast<const App::PropertyRotation*>(prop)->getValue();
double angle;
Base::Vector3d dir;
value.getRawValue(dir, angle);
Base::Vector3d cross = this->rot_axis.Cross(dir);
double len2 = cross.Sqr();
if (angle != 0) {
// vectors are not parallel
if (len2 > eps)
this->rot_axis = dir;
// vectors point into opposite directions
else if (this->rot_axis.Dot(dir) < 0)
this->rot_axis = -this->rot_axis;
}
this->rot_angle = Base::toDegrees(angle);
h.assignProperty(value, eps);
}
}
@@ -2201,13 +2270,13 @@ QVariant PropertyRotationItem::value(const App::Property* prop) const
double angle;
Base::Vector3d dir;
value.getRawValue(dir, angle);
if (!init_axis) {
if (!h.isAxisInitialized()) {
if (m_a->hasExpression()) {
QString str = m_a->expressionAsString();
const_cast<PropertyRotationItem*>(this)->rot_angle = str.toDouble();
angle = str.toDouble();
}
else {
const_cast<PropertyRotationItem*>(this)->rot_angle = Base::toDegrees(angle);
angle = Base::toDegrees(angle);
}
PropertyItem* x = m_d->child(0);
@@ -2225,8 +2294,7 @@ QVariant PropertyRotationItem::value(const App::Property* prop) const
QString str = z->expressionAsString();
dir.z = str.toDouble();
}
const_cast<PropertyRotationItem*>(this)->rot_axis = dir;
const_cast<PropertyRotationItem*>(this)->init_axis = true;
h.setValue(dir, angle);
}
return QVariant::fromValue<Base::Rotation>(value);
}
@@ -2274,16 +2342,18 @@ void PropertyRotationItem::setValue(const QVariant& value)
return;
// Accept this only if the user changed the axis, angle or position but
// not if >this< item loses focus
if (!changed_value)
if (!h.hasChangedAndReset())
return;
changed_value = false;
Base::Vector3d axis;
double angle;
h.getValue(axis, angle);
Base::QuantityFormat format(Base::QuantityFormat::Fixed, decimals());
QString data = QString::fromLatin1("App.Rotation(App.Vector(%1,%2,%3),%4)")
.arg(Base::UnitsApi::toNumber(rot_axis.x, format))
.arg(Base::UnitsApi::toNumber(rot_axis.y, format))
.arg(Base::UnitsApi::toNumber(rot_axis.z, format))
.arg(Base::UnitsApi::toNumber(rot_angle, format));
.arg(Base::UnitsApi::toNumber(axis.x, format))
.arg(Base::UnitsApi::toNumber(axis.y, format))
.arg(Base::UnitsApi::toNumber(axis.z, format))
.arg(Base::UnitsApi::toNumber(angle, format));
setPropertyValue(data);
}
@@ -2394,7 +2464,7 @@ void PlacementEditor::updateValue(const QVariant& v, bool incr, bool data)
PROPERTYITEM_SOURCE(Gui::PropertyEditor::PropertyPlacementItem)
PropertyPlacementItem::PropertyPlacementItem() : init_axis(false), changed_value(false), rot_angle(0), rot_axis(0,0,1)
PropertyPlacementItem::PropertyPlacementItem()
{
m_a = static_cast<PropertyUnitItem*>(PropertyUnitItem::create());
m_a->setParent(this);
@@ -2421,12 +2491,9 @@ Base::Quantity PropertyPlacementItem::getAngle() const
QVariant value = data(1, Qt::EditRole);
if (!value.canConvert<Base::Placement>())
return Base::Quantity(0.0);
const Base::Placement& val = value.value<Base::Placement>();
double angle;
Base::Vector3d dir;
val.getRotation().getRawValue(dir, angle);
if (dir * this->rot_axis < 0.0)
angle = -angle;
double angle = h.getAngle(val.getRotation());
return Base::Quantity(Base::toDegrees<double>(angle), Base::Unit::Angle);
}
@@ -2437,21 +2504,14 @@ void PropertyPlacementItem::setAngle(Base::Quantity angle)
return;
Base::Placement val = value.value<Base::Placement>();
Base::Rotation rot;
rot.setValue(this->rot_axis, Base::toRadians<double>(angle.getValue()));
Base::Rotation rot = h.setAngle(angle.getValue());
val.setRotation(rot);
changed_value = true;
rot_angle = angle.getValue();
setValue(QVariant::fromValue(val));
}
Base::Vector3d PropertyPlacementItem::getAxis() const
{
// We must store the rotation axis in a member because
// if we read the value from the property we would always
// get a normalized vector which makes it quite unhandy
// to work with
return this->rot_axis;
return h.getAxis();
}
void PropertyPlacementItem::setAxis(const Base::Vector3d& axis)
@@ -2459,16 +2519,11 @@ void PropertyPlacementItem::setAxis(const Base::Vector3d& axis)
QVariant value = data(1, Qt::EditRole);
if (!value.canConvert<Base::Placement>())
return;
this->rot_axis = axis;
Base::Placement val = value.value<Base::Placement>();
Base::Rotation rot = val.getRotation();
Base::Vector3d dummy; double angle;
rot.getValue(dummy, angle);
if (dummy * axis < 0.0)
angle = -angle;
rot.setValue(axis, angle);
rot = h.setAxis(rot, axis);
val.setRotation(rot);
changed_value = true;
setValue(QVariant::fromValue(val));
}
@@ -2486,9 +2541,10 @@ void PropertyPlacementItem::setPosition(const Base::Vector3d& pos)
QVariant value = data(1, Qt::EditRole);
if (!value.canConvert<Base::Placement>())
return;
Base::Placement val = value.value<Base::Placement>();
val.setPosition(pos);
changed_value = true;
h.setChanged(true);
setValue(QVariant::fromValue(val));
}
@@ -2499,20 +2555,7 @@ void PropertyPlacementItem::assignProperty(const App::Property* prop)
double eps = std::pow(10.0, -2*(decimals()+1));
if (prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) {
const Base::Placement& value = static_cast<const App::PropertyPlacement*>(prop)->getValue();
double angle;
Base::Vector3d dir;
value.getRotation().getRawValue(dir, angle);
Base::Vector3d cross = this->rot_axis.Cross(dir);
double len2 = cross.Sqr();
if (angle != 0) {
// vectors are not parallel
if (len2 > eps)
this->rot_axis = dir;
// vectors point into opposite directions
else if (this->rot_axis.Dot(dir) < 0)
this->rot_axis = -this->rot_axis;
}
this->rot_angle = Base::toDegrees(angle);
h.assignProperty(value.getRotation(), eps);
}
}
@@ -2524,13 +2567,13 @@ QVariant PropertyPlacementItem::value(const App::Property* prop) const
double angle;
Base::Vector3d dir;
value.getRotation().getRawValue(dir, angle);
if (!init_axis) {
if (!h.isAxisInitialized()) {
if (m_a->hasExpression()) {
QString str = m_a->expressionAsString();
const_cast<PropertyPlacementItem*>(this)->rot_angle = str.toDouble();
angle = str.toDouble();
}
else {
const_cast<PropertyPlacementItem*>(this)->rot_angle = Base::toDegrees(angle);
angle = Base::toDegrees(angle);
}
PropertyItem* x = m_d->child(0);
@@ -2548,8 +2591,7 @@ QVariant PropertyPlacementItem::value(const App::Property* prop) const
QString str = z->expressionAsString();
dir.z = str.toDouble();
}
const_cast<PropertyPlacementItem*>(this)->rot_axis = dir;
const_cast<PropertyPlacementItem*>(this)->init_axis = true;
h.setValue(dir, angle);
}
return QVariant::fromValue<Base::Placement>(value);
}
@@ -2606,12 +2648,16 @@ void PropertyPlacementItem::setValue(const QVariant& value)
return;
// Accept this only if the user changed the axis, angle or position but
// not if >this< item loses focus
if (!changed_value)
if (!h.hasChangedAndReset())
return;
changed_value = false;
const Base::Placement& val = value.value<Base::Placement>();
Base::Vector3d pos = val.getPosition();
Base::Vector3d axis;
double angle;
h.getValue(axis, angle);
Base::QuantityFormat format(Base::QuantityFormat::Fixed, decimals());
QString data = QString::fromLatin1("App.Placement("
"App.Vector(%1,%2,%3),"
@@ -2619,10 +2665,10 @@ void PropertyPlacementItem::setValue(const QVariant& value)
.arg(Base::UnitsApi::toNumber(pos.x, format))
.arg(Base::UnitsApi::toNumber(pos.y, format))
.arg(Base::UnitsApi::toNumber(pos.z, format))
.arg(Base::UnitsApi::toNumber(rot_axis.x, format))
.arg(Base::UnitsApi::toNumber(rot_axis.y, format))
.arg(Base::UnitsApi::toNumber(rot_axis.z, format))
.arg(Base::UnitsApi::toNumber(rot_angle, format));
.arg(Base::UnitsApi::toNumber(axis.x, format))
.arg(Base::UnitsApi::toNumber(axis.y, format))
.arg(Base::UnitsApi::toNumber(axis.z, format))
.arg(Base::UnitsApi::toNumber(angle, format));
setPropertyValue(data);
}
+25 -8
View File
@@ -40,6 +40,7 @@
#include <Gui/Widgets.h>
#include <Gui/ExpressionBinding.h>
#include <Gui/MetaTypes.h>
#include <FCGlobal.h>
#ifdef Q_MOC_RUN
Q_DECLARE_METATYPE(Base::Vector3f)
@@ -657,6 +658,28 @@ private:
PropertyFloatItem* m_a44;
};
class RotationHelper
{
public:
RotationHelper();
void setChanged(bool);
bool hasChangedAndReset();
bool isAxisInitialized() const;
void setValue(const Base::Vector3d& axis, double angle);
void getValue(Base::Vector3d& axis, double& angle) const;
double getAngle(const Base::Rotation& val) const;
Base::Rotation setAngle(double);
Base::Vector3d getAxis() const;
Base::Rotation setAxis(const Base::Rotation& value, const Base::Vector3d& axis);
void assignProperty(const Base::Rotation& value, double eps);
private:
bool init_axis;
bool changed_value;
double rot_angle;
Base::Vector3d rot_axis;
};
/**
* Edit properties of rotation type.
* \author Werner Mayer
@@ -689,10 +712,7 @@ protected:
virtual void setValue(const QVariant&);
private:
bool init_axis;
bool changed_value;
double rot_angle;
Base::Vector3d rot_axis;
mutable RotationHelper h;
PropertyUnitItem * m_a;
PropertyVectorItem* m_d;
};
@@ -752,10 +772,7 @@ protected:
virtual void setValue(const QVariant&);
private:
bool init_axis;
bool changed_value;
double rot_angle;
Base::Vector3d rot_axis;
mutable RotationHelper h;
PropertyUnitItem * m_a;
PropertyVectorItem* m_d;
PropertyVectorDistanceItem* m_p;
+1 -1
View File
@@ -108,7 +108,7 @@ int main( int argc, char ** argv )
std::string appName = App::Application::Config()["ExeName"];
std::stringstream msg;
msg << "While initializing " << appName << " the following exception occurred: '" << e.what() << "'\n\n";
msg << "Python is searching for its runtime files in the following directories:\n" << Py_GetPath() << "\n\n";
msg << "Python is searching for its runtime files in the following directories:\n" << Py_EncodeLocale(Py_GetPath(),nullptr) << "\n\n";
msg << "Python version information:\n" << Py_GetVersion() << "\n";
const char* pythonhome = getenv("PYTHONHOME");
if ( pythonhome ) {
+9 -9
View File
@@ -652,14 +652,14 @@ class Plane:
if not geom_is_shape:
FreeCAD.Console.PrintError(translate(
"draft",
"Object without Part.Shape geometry:'{}'\n".format(
obj.ObjectName)))
"Object without Part.Shape geometry:'{}'".format(
obj.ObjectName)) + "\n")
return False
if geom.isNull():
FreeCAD.Console.PrintError(translate(
"draft",
"Object with null Part.Shape geometry:'{}'\n".format(
obj.ObjectName)))
"Object with null Part.Shape geometry:'{}'".format(
obj.ObjectName)) + "\n")
return False
if obj.HasSubObjects:
shapes.extend(obj.SubObjects)
@@ -672,7 +672,7 @@ class Plane:
for n in range(len(shapes)):
if not DraftGeomUtils.is_planar(shapes[n]):
FreeCAD.Console.PrintError(translate(
"draft","'{}' object is not planar\n".format(names[n])))
"draft", "'{}' object is not planar".format(names[n])) + "\n")
return False
if not normal:
normal = DraftGeomUtils.get_normal(shapes[n])
@@ -683,8 +683,8 @@ class Plane:
for n in range(len(shapes)):
if not DraftGeomUtils.are_coplanar(shapes[shape_ref], shapes[n]):
FreeCAD.Console.PrintError(translate(
"draft","{} and {} aren't coplanar\n".format(
names[shape_ref],names[n])))
"draft", "{} and {} aren't coplanar".format(
names[shape_ref],names[n])) + "\n")
return False
else:
# suppose all geometries are straight lines or points
@@ -693,7 +693,7 @@ class Plane:
poly = Part.makePolygon(points)
if not DraftGeomUtils.is_planar(poly):
FreeCAD.Console.PrintError(translate(
"draft","All Shapes must be coplanar\n"))
"draft", "All Shapes must be coplanar") + "\n")
return False
normal = DraftGeomUtils.get_normal(poly)
else:
@@ -701,7 +701,7 @@ class Plane:
if not normal:
FreeCAD.Console.PrintError(translate(
"draft","Selected Shapes must define a plane\n"))
"draft", "Selected Shapes must define a plane") + "\n")
return False
# set center of mass
+11 -4
View File
@@ -106,7 +106,7 @@ class Dimension(gui_base_original.Creator):
self.arctrack = trackers.arcTracker()
self.link = None
self.edges = []
self.pts = []
self.angles = []
self.angledata = None
self.indices = []
self.center = None
@@ -397,7 +397,7 @@ class Dimension(gui_base_original.Creator):
r = self.point.sub(self.center)
self.arctrack.setRadius(r.Length)
a = self.arctrack.getAngle(self.point)
pair = DraftGeomUtils.getBoundaryAngles(a, self.pts)
pair = DraftGeomUtils.getBoundaryAngles(a, self.angles)
if not (pair[0] < a < pair[1]):
self.angledata = [4 * math.pi - pair[0],
2 * math.pi - pair[1]]
@@ -504,8 +504,15 @@ class Dimension(gui_base_original.Creator):
self.arctrack.setCenter(self.center)
self.arctrack.on()
for e in self.edges:
for v in e.Vertexes:
self.pts.append(self.arctrack.getAngle(v.Point))
if e.Length < 0.00003: # Edge must be long enough for the tolerance of 0.00001mm to make sense.
_msg(translate("draft", "Edge too short!"))
self.finish()
return
for i in [0, 1]:
pt = e.Vertexes[i].Point
if pt.isEqual(self.center, 0.00001): # A relatively high tolerance is required.
pt = e.Vertexes[i - 1].Point # Use the other point instead.
self.angles.append(self.arctrack.getAngle(pt))
self.link = [self.link[0], ob]
else:
_msg(translate("draft", "Edges don't intersect!"))
+8 -4
View File
@@ -100,13 +100,15 @@ def make_sketch(objects_list, autoconstraints=False, addTo=None,
if isinstance(obj,Part.Shape):
shape = obj
elif not hasattr(obj,'Shape'):
App.Console.PrintError(translate("draft","No shape found\n"))
App.Console.PrintError(translate("draft",
"No shape found")+"\n")
return None
else:
shape = obj.Shape
if not DraftGeomUtils.is_planar(shape, tol):
App.Console.PrintError(translate("draft","All Shapes must be planar\n"))
App.Console.PrintError(translate("draft",
"All Shapes must be planar")+"\n")
return None
if DraftGeomUtils.get_normal(shape, tol):
@@ -121,7 +123,8 @@ def make_sketch(objects_list, autoconstraints=False, addTo=None,
if len(shape_norm_yes) >= 1:
for shape in shapes_list[1:]:
if not DraftGeomUtils.are_coplanar(shapes_list[0], shape, tol):
App.Console.PrintError(translate("draft","All Shapes must be coplanar\n"))
App.Console.PrintError(translate("draft",
"All Shapes must be coplanar")+"\n")
return None
# define sketch normal
normal = DraftGeomUtils.get_normal(shapes_list[0], tol)
@@ -132,7 +135,8 @@ def make_sketch(objects_list, autoconstraints=False, addTo=None,
if len(points) >= 2:
poly = Part.makePolygon(points)
if not DraftGeomUtils.is_planar(poly, tol):
App.Console.PrintError(translate("draft","All Shapes must be coplanar\n"))
App.Console.PrintError(translate("draft",
"All Shapes must be coplanar")+"\n")
return None
normal = DraftGeomUtils.get_normal(poly, tol)
if not normal:
+2 -2
View File
@@ -287,7 +287,7 @@ class Array(DraftLink):
_tip = QT_TRANSLATE_NOOP("App::Property",
"A parameter that determines "
"how many symmetry planes "
" the circular array will have.")
"the circular array will have.")
obj.addProperty("App::PropertyInteger",
"Symmetry",
"Circular array",
@@ -380,7 +380,7 @@ class Array(DraftLink):
obj.setPropertyStatus(pr, "Hidden")
def execute(self, obj):
"""Execture when the object is created or recomputed."""
"""Execute when the object is created or recomputed."""
if not obj.Base:
return
+1 -1
View File
@@ -163,7 +163,7 @@ class DimensionBase(DraftAnnotation):
"There are various possibilities:\n"
"- An object, and one of its edges.\n"
"- An object, and two of its vertices.\n"
"- An arc object, and its edge.\n")
"- An arc object, and its edge.")
obj.addProperty("App::PropertyLinkSubList",
"LinkedGeometry",
"Dimension",
+50 -53
View File
@@ -1,6 +1,7 @@
# ***************************************************************************
# * Copyright (c) 2014 Yorik van Havre <[email protected]> *
# * Copyright (c) 2020 Eliud Cabrera Castillo <[email protected]> *
# * Copyright (c) 2021 FreeCAD Developers *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -37,7 +38,7 @@ import FreeCAD as App
import FreeCADGui as Gui
from draftutils.messages import _msg
from draftutils.translate import translate
from draftutils.translate import _tr
from draftobjects.layer import Layer
@@ -355,13 +356,13 @@ class ViewProviderLayer:
def setupContextMenu(self, vobj, menu):
"""Set up actions to perform in the context menu."""
action1 = QtGui.QAction(QtGui.QIcon(":/icons/button_right.svg"),
translate("draft", "Activate this layer"),
_tr("Activate this layer"),
menu)
action1.triggered.connect(self.activate)
menu.addAction(action1)
action2 = QtGui.QAction(QtGui.QIcon(":/icons/Draft_SelectGroup.svg"),
translate("draft", "Select layer contents"),
_tr("Select layer contents"),
menu)
action2.triggered.connect(self.select_contents)
menu.addAction(action2)
@@ -399,80 +400,76 @@ class ViewProviderLayerContainer:
def setupContextMenu(self, vobj, menu):
"""Set up actions to perform in the context menu."""
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Draft_Layer.svg"),
translate("Draft", "Merge layer duplicates"),
_tr("Merge layer duplicates"),
menu)
action1.triggered.connect(self.merge_by_name)
menu.addAction(action1)
action2 = QtGui.QAction(QtGui.QIcon(":/icons/Draft_NewLayer.svg"),
translate("Draft", "Add new layer"),
_tr("Add new layer"),
menu)
action2.triggered.connect(self.add_layer)
menu.addAction(action2)
def merge_by_name(self):
"""Merge the layers that have the same name."""
"""Merge the layers that have the same base label."""
if not hasattr(self, "Object") or not hasattr(self.Object, "Group"):
return
obj = self.Object
doc = App.ActiveDocument
doc.openTransaction(_tr("Merge layer duplicates"))
layers = list()
for iobj in obj.Group:
if hasattr(iobj, "Proxy") and isinstance(iobj.Proxy, Layer):
layers.append(iobj)
layer_container = self.Object
layers = []
for obj in layer_container.Group:
if hasattr(obj, "Proxy") and isinstance(obj.Proxy, Layer):
layers.append(obj)
to_delete = list()
to_delete = []
for layer in layers:
# Test the last three characters of the layer's Label to see
# if it's a number, like `'Layer017'`
if (layer.Label[-1].isdigit()
and layer.Label[-2].isdigit()
and layer.Label[-3].isdigit()):
# If the object inside the layer has the same Label
# as the layer, save this object
orig = None
for ol in layer.OutList:
if ol.Label == layer.Label[:-3].strip():
orig = ol
break
# Remove trailing digits (usually 3 but there might be more) and
# trailing spaces from Label before comparing:
base_label = layer.Label.rstrip("0123456789 ")
# Go into the objects that reference this layer object
# and set the layer property with the previous `orig`
# object found
# Editor: when is this possible? Maybe if a layer is inside
# another layer? Currently the code doesn't allow this
# so maybe this was a previous behavior that was disabled
# in `ViewProviderLayer`.
if orig:
for par in layer.InList:
for prop in par.PropertiesList:
if getattr(par, prop) == layer:
_msg("Changed property '" + prop
+ "' of object " + par.Label
+ " from " + layer.Label
+ " to " + orig.Label)
setattr(par, prop, orig)
to_delete.append(layer)
# Try to find the `'base'` layer:
base = None
for other_layer in layers:
if ((not other_layer in to_delete) # Required if there are duplicate labels.
and other_layer != layer
and other_layer.Label.upper() == base_label.upper()):
base = other_layer
break
if base:
if layer.Group:
base_group = base.Group
for obj in layer.Group:
if not obj in base_group:
base_group.append(obj)
base.Group = base_group
to_delete.append(layer)
elif layer.Label != base_label:
_msg(_tr("Relabeling layer:")
+ " '{}' -> '{}'".format(layer.Label, base_label))
layer.Label = base_label
for layer in to_delete:
if not layer.InList:
_msg("Merging duplicate layer: " + layer.Label)
App.ActiveDocument.removeObject(layer.Name)
elif len(layer.InList) == 1:
first = layer.InList[0]
_msg(_tr("Merging layer:") + " '{}'".format(layer.Label))
doc.removeObject(layer.Name)
if first.isDerivedFrom("App::DocumentObjectGroup"):
_msg("Merging duplicate layer: " + layer.Label)
App.ActiveDocument.removeObject(layer.Name)
else:
_msg("InList not empty. "
"Unable to delete layer: " + layer.Label)
doc.recompute()
doc.commitTransaction()
def add_layer(self):
"""Creates a new layer"""
import Draft
doc = App.ActiveDocument
doc.openTransaction(_tr("Add new layer"))
Draft.make_layer()
App.ActiveDocument.recompute()
doc.recompute()
doc.commitTransaction()
def __getstate__(self):
"""Return a tuple of objects to save or None."""
+341 -91
View File
@@ -31,17 +31,21 @@ __url__ = "https://www.freecadweb.org"
import FreeCAD
import FreeCADGui
from FreeCAD import Qt
from .manager import CommandManager
from femtools.femutils import is_of_type
# Python command definitions
# Python command definitions:
# for C++ command definitions see src/Mod/Fem/Command.cpp
# TODO, may be even more generic class creation
# with type() and identifier instead of class for
# the commands which add new document objects.
# see https://www.python-course.eu/python3_classes_and_type.php
# Translation:
# some information in the regard of translation can be found in forum post
# https://forum.freecadweb.org/viewtopic.php?f=18&t=62449&p=543845#p543593
class _Analysis(CommandManager):
@@ -49,9 +53,12 @@ class _Analysis(CommandManager):
def __init__(self):
super(_Analysis, self).__init__()
self.menutext = "Analysis container"
self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_Analysis", "Analysis container")
self.accel = "S, A"
self.tooltip = "Creates an analysis container with standard solver CalculiX"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_Analysis",
"Creates an analysis container with standard solver CalculiX"
)
self.is_active = "with_document"
def Activated(self):
@@ -74,8 +81,11 @@ class _ClippingPlaneAdd(CommandManager):
def __init__(self):
super(_ClippingPlaneAdd, self).__init__()
self.menutext = "Clipping plane on face"
self.tooltip = "Add a clipping plane on a selected face"
self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_ClippingPlaneAdd", "Clipping plane on face")
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ClippingPlaneAdd",
"Add a clipping plane on a selected face"
)
self.is_active = "with_document"
def Activated(self):
@@ -123,8 +133,14 @@ class _ClippingPlaneRemoveAll(CommandManager):
def __init__(self):
super(_ClippingPlaneRemoveAll, self).__init__()
self.menutext = "Remove all clipping planes"
self.tooltip = "Remove all clipping planes"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ClippingPlaneRemoveAll",
"Remove all clipping planes"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ClippingPlaneRemoveAll",
"Remove all clipping planes"
)
self.is_active = "with_document"
def Activated(self):
@@ -143,8 +159,14 @@ class _ConstantVacuumPermittivity(CommandManager):
def __init__(self):
super(_ConstantVacuumPermittivity, self).__init__()
self.pixmap = "fem-solver-analysis-thermomechanical.svg"
self.menutext = "Constant vacuum permittivity"
self.tooltip = "Creates a FEM constant vacuum permittivity to overwrite standard value"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstantVacuumPermittivity",
"Constant vacuum permittivity"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstantVacuumPermittivity",
"Creates a FEM constant vacuum permittivity to overwrite standard value"
)
self.is_active = "with_document"
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -156,8 +178,14 @@ class _ConstraintBodyHeatSource(CommandManager):
def __init__(self):
super(_ConstraintBodyHeatSource, self).__init__()
self.pixmap = "FEM_ConstraintHeatflux" # the heatflux icon is used
self.menutext = "Constraint body heat source"
self.tooltip = "Creates a FEM constraint body heat source"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintBodyHeatSource",
"Constraint body heat source"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintBodyHeatSource",
"Creates a FEM constraint body heat source"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -167,8 +195,14 @@ class _ConstraintCentrif(CommandManager):
def __init__(self):
super(_ConstraintCentrif, self).__init__()
self.menutext = "Constraint centrif"
self.tooltip = "Creates a FEM constraint centrif"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintCentrif",
"Constraint centrif"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintCentrif",
"Creates a FEM constraint centrif"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -178,8 +212,14 @@ class _ConstraintElectrostaticPotential(CommandManager):
def __init__(self):
super(_ConstraintElectrostaticPotential, self).__init__()
self.menutext = "Constraint electrostatic potential"
self.tooltip = "Creates a FEM constraint electrostatic potential"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintElectrostaticPotential",
"Constraint electrostatic potential"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintElectrostaticPotential",
"Creates a FEM constraint electrostatic potential"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -189,8 +229,14 @@ class _ConstraintFlowVelocity(CommandManager):
def __init__(self):
super(_ConstraintFlowVelocity, self).__init__()
self.menutext = "Constraint flow velocity"
self.tooltip = "Creates a FEM constraint flow velocity"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintFlowVelocity",
"Constraint flow velocity"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintFlowVelocity",
"Creates a FEM constraint flow velocity"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -200,8 +246,14 @@ class _ConstraintInitialFlowVelocity(CommandManager):
def __init__(self):
super(_ConstraintInitialFlowVelocity, self).__init__()
self.menutext = "Constraint initial flow velocity"
self.tooltip = "Creates a FEM constraint initial flow velocity"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintInitialFlowVelocity",
"Constraint initial flow velocity"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintInitialFlowVelocity",
"Creates a FEM constraint initial flow velocity"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -211,8 +263,14 @@ class _ConstraintSectionPrint(CommandManager):
def __init__(self):
super(_ConstraintSectionPrint, self).__init__()
self.menutext = "Constraint sectionprint"
self.tooltip = "Creates a FEM constraint sectionprint"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintSectionPrint",
"Constraint sectionprint"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintSectionPrint",
"Creates a FEM constraint sectionprint"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -222,8 +280,14 @@ class _ConstraintSelfWeight(CommandManager):
def __init__(self):
super(_ConstraintSelfWeight, self).__init__()
self.menutext = "Constraint self weight"
self.tooltip = "Creates a FEM constraint self weight"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintSelfWeight",
"Constraint self weight"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintSelfWeight",
"Creates a FEM constraint self weight"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -233,8 +297,14 @@ class _ConstraintTie(CommandManager):
def __init__(self):
super(_ConstraintTie, self).__init__()
self.menutext = "Constraint tie"
self.tooltip = "Creates a FEM constraint tie"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintTie",
"Constraint tie"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ConstraintTie",
"Creates a FEM constraint tie"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -244,8 +314,14 @@ class _ElementFluid1D(CommandManager):
def __init__(self):
super(_ElementFluid1D, self).__init__()
self.menutext = "Fluid section for 1D flow"
self.tooltip = "Creates a FEM fluid section for 1D flow"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementFluid1D",
"Fluid section for 1D flow"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementFluid1D",
"Creates a FEM fluid section for 1D flow"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -255,8 +331,14 @@ class _ElementGeometry1D(CommandManager):
def __init__(self):
super(_ElementGeometry1D, self).__init__()
self.menutext = "Beam cross section"
self.tooltip = "Creates a FEM beam cross section"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementGeometry1D",
"Beam cross section"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementGeometry1D",
"Creates a FEM beam cross section"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -266,8 +348,14 @@ class _ElementGeometry2D(CommandManager):
def __init__(self):
super(_ElementGeometry2D, self).__init__()
self.menutext = "Shell plate thickness"
self.tooltip = "Creates a FEM shell plate thickness"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementGeometry2D",
"Shell plate thickness"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementGeometry2D",
"Creates a FEM shell plate thickness"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -277,8 +365,14 @@ class _ElementRotation1D(CommandManager):
def __init__(self):
super(_ElementRotation1D, self).__init__()
self.menutext = "Beam rotation"
self.tooltip = "Creates a FEM beam rotation"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementRotation1D",
"Beam rotation"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ElementRotation1D",
"Creates a FEM beam rotation"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -288,8 +382,14 @@ class _EquationElectrostatic(CommandManager):
def __init__(self):
super(_EquationElectrostatic, self).__init__()
self.menutext = "Electrostatic equation"
self.tooltip = "Creates a FEM equation for electrostatic"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationElectrostatic",
"Electrostatic equation"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationElectrostatic",
"Creates a FEM equation for electrostatic"
)
self.is_active = "with_solver_elmer"
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
@@ -299,8 +399,14 @@ class _EquationElasticity(CommandManager):
def __init__(self):
super(_EquationElasticity, self).__init__()
self.menutext = "Elasticity equation"
self.tooltip = "Creates a FEM equation for elasticity"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationElasticity",
"Elasticity equation"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationElasticity",
"Creates a FEM equation for elasticity"
)
self.is_active = "with_solver_elmer"
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
@@ -310,8 +416,14 @@ class _EquationFlow(CommandManager):
def __init__(self):
super(_EquationFlow, self).__init__()
self.menutext = "Flow equation"
self.tooltip = "Creates a FEM equation for flow"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationFlow",
"Flow equation"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationFlow",
"Creates a FEM equation for flow"
)
self.is_active = "with_solver_elmer"
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
@@ -321,8 +433,14 @@ class _EquationFlux(CommandManager):
def __init__(self):
super(_EquationFlux, self).__init__()
self.menutext = "Flux equation"
self.tooltip = "Creates a FEM equation for flux"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationFlux",
"Flux equation"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationFlux",
"Creates a FEM equation for flux"
)
self.is_active = "with_solver_elmer"
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
@@ -332,8 +450,14 @@ class _EquationElectricforce(CommandManager):
def __init__(self):
super(_EquationElectricforce, self).__init__()
self.menutext = "Electricforce equation"
self.tooltip = "Creates a FEM equation for electric forces"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationElectricforce",
"Electricforce equation"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationElectricforce",
"Creates a FEM equation for electric forces"
)
self.is_active = "with_solver_elmer"
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
@@ -343,8 +467,14 @@ class _EquationHeat(CommandManager):
def __init__(self):
super(_EquationHeat, self).__init__()
self.menutext = "Heat equation"
self.tooltip = "Creates a FEM equation for heat"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationHeat",
"Heat equation"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_EquationHeat",
"Creates a FEM equation for heat"
)
self.is_active = "with_solver_elmer"
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
@@ -355,8 +485,14 @@ class _Examples(CommandManager):
def __init__(self):
super(_Examples, self).__init__()
self.pixmap = "FemWorkbench"
self.menutext = "Open FEM examples"
self.tooltip = "Open FEM examples"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_Examples",
"Open FEM examples"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_Examples",
"Open FEM examples"
)
self.is_active = "always"
def Activated(self):
@@ -370,8 +506,14 @@ class _MaterialEditor(CommandManager):
def __init__(self):
super(_MaterialEditor, self).__init__()
self.pixmap = "Arch_Material_Group"
self.menutext = "Material editor"
self.tooltip = "Opens the FreeCAD material editor"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialEditor",
"Material editor"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialEditor",
"Opens the FreeCAD material editor"
)
self.is_active = "always"
def Activated(self):
@@ -384,8 +526,14 @@ class _MaterialFluid(CommandManager):
def __init__(self):
super(_MaterialFluid, self).__init__()
self.menutext = "Material for fluid"
self.tooltip = "Creates a FEM material for fluid"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialFluid",
"Material for fluid"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialFluid",
"Creates a FEM material for fluid"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -395,8 +543,14 @@ class _MaterialMechanicalNonlinear(CommandManager):
def __init__(self):
super(_MaterialMechanicalNonlinear, self).__init__()
self.menutext = "Nonlinear mechanical material"
self.tooltip = "Creates a nonlinear mechanical material"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialMechanicalNonlinear",
"Nonlinear mechanical material"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialMechanicalNonlinear",
"Creates a nonlinear mechanical material"
)
self.is_active = "with_material_solid"
def Activated(self):
@@ -459,8 +613,14 @@ class _MaterialReinforced(CommandManager):
def __init__(self):
super(_MaterialReinforced, self).__init__()
self.menutext = "Reinforced material (concrete)"
self.tooltip = "Creates a material for reinforced matrix material such as concrete"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialReinforced",
"Reinforced material (concrete)"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialReinforced",
"Creates a material for reinforced matrix material such as concrete"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -470,9 +630,15 @@ class _MaterialSolid(CommandManager):
def __init__(self):
super(_MaterialSolid, self).__init__()
self.menutext = "Material for solid"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialSolid",
"Material for solid"
)
self.accel = "M, S"
self.tooltip = "Creates a FEM material for solid"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MaterialSolid",
"Creates a FEM material for solid"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
@@ -482,8 +648,14 @@ class _FEMMesh2Mesh(CommandManager):
def __init__(self):
super(_FEMMesh2Mesh, self).__init__()
self.menutext = "FEM mesh to mesh"
self.tooltip = "Convert the surface of a FEM mesh to a mesh"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_FEMMesh2Mesh",
"FEM mesh to mesh"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_FEMMesh2Mesh",
"Convert the surface of a FEM mesh to a mesh"
)
self.is_active = "with_femmesh_andor_res"
def Activated(self):
@@ -523,8 +695,14 @@ class _MeshBoundaryLayer(CommandManager):
def __init__(self):
super(_MeshBoundaryLayer, self).__init__()
self.menutext = "FEM mesh boundary layer"
self.tooltip = "Creates a FEM mesh boundary layer"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshBoundaryLayer",
"FEM mesh boundary layer"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshBoundaryLayer",
"Creates a FEM mesh boundary layer"
)
self.is_active = "with_gmsh_femmesh"
self.do_activated = "add_obj_on_gui_selobj_set_edit"
@@ -534,8 +712,14 @@ class _MeshClear(CommandManager):
def __init__(self):
super(_MeshClear, self).__init__()
self.menutext = "Clear FEM mesh"
self.tooltip = "Clear the Mesh of a FEM mesh object"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshClear",
"Clear FEM mesh"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshClear",
"Clear the Mesh of a FEM mesh object"
)
self.is_active = "with_femmesh"
def Activated(self):
@@ -553,8 +737,14 @@ class _MeshDisplayInfo(CommandManager):
def __init__(self):
super(_MeshDisplayInfo, self).__init__()
self.menutext = "Display FEM mesh info"
self.tooltip = "Display FEM mesh info"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshDisplayInfo",
"Display FEM mesh info"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshDisplayInfo",
"Display FEM mesh info"
)
self.is_active = "with_femmesh"
def Activated(self):
@@ -576,8 +766,14 @@ class _MeshGmshFromShape(CommandManager):
def __init__(self):
super(_MeshGmshFromShape, self).__init__()
self.menutext = "FEM mesh from shape by Gmsh"
self.tooltip = "Create a FEM mesh from a shape by Gmsh mesher"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshGmshFromShape",
"FEM mesh from shape by Gmsh"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshGmshFromShape",
"Create a FEM mesh from a shape by Gmsh mesher"
)
self.is_active = "with_part_feature"
def Activated(self):
@@ -615,8 +811,14 @@ class _MeshGroup(CommandManager):
def __init__(self):
super(_MeshGroup, self).__init__()
self.menutext = "FEM mesh group"
self.tooltip = "Creates a FEM mesh group"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshGroup",
"FEM mesh group"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshGroup",
"Creates a FEM mesh group"
)
self.is_active = "with_gmsh_femmesh"
self.do_activated = "add_obj_on_gui_selobj_set_edit"
@@ -626,8 +828,14 @@ class _MeshNetgenFromShape(CommandManager):
def __init__(self):
super(_MeshNetgenFromShape, self).__init__()
self.menutext = "FEM mesh from shape by Netgen"
self.tooltip = "Create a FEM mesh from a solid or face shape by Netgen internal mesher"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshNetgenFromShape",
"FEM mesh from shape by Netgen"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshNetgenFromShape",
"Create a FEM mesh from a solid or face shape by Netgen internal mesher"
)
self.is_active = "with_part_feature"
def Activated(self):
@@ -665,8 +873,14 @@ class _MeshRegion(CommandManager):
def __init__(self):
super(_MeshRegion, self).__init__()
self.menutext = "FEM mesh region"
self.tooltip = "Creates a FEM mesh region"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshRegion",
"FEM mesh region"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_MeshRegion",
"Creates a FEM mesh region"
)
self.is_active = "with_gmsh_femmesh"
self.do_activated = "add_obj_on_gui_selobj_set_edit"
@@ -676,9 +890,15 @@ class _ResultShow(CommandManager):
def __init__(self):
super(_ResultShow, self).__init__()
self.menutext = "Show result"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ResultShow",
"Show result"
)
self.accel = "R, S"
self.tooltip = "Shows and visualizes selected result data"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ResultShow",
"Shows and visualizes selected result data"
)
self.is_active = "with_selresult"
def Activated(self):
@@ -690,9 +910,15 @@ class _ResultsPurge(CommandManager):
def __init__(self):
super(_ResultsPurge, self).__init__()
self.menutext = "Purge results"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_ResultsPurge",
"Purge results"
)
self.accel = "R, P"
self.tooltip = "Purges all results from active analysis"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_ResultsPurge",
"Purges all results from active analysis"
)
self.is_active = "with_results"
def Activated(self):
@@ -706,9 +932,15 @@ class _SolverCxxtools(CommandManager):
def __init__(self):
super(_SolverCxxtools, self).__init__()
self.pixmap = "FEM_SolverStandard"
self.menutext = "Solver CalculiX Standard"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverCxxtools",
"Solver CalculiX Standard"
)
self.accel = "S, X"
self.tooltip = "Creates a standard FEM solver CalculiX with ccx tools"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverCxxtools",
"Creates a standard FEM solver CalculiX with ccx tools"
)
self.is_active = "with_analysis"
def Activated(self):
@@ -741,9 +973,15 @@ class _SolverCalculix(CommandManager):
def __init__(self):
super(_SolverCalculix, self).__init__()
self.pixmap = "FEM_SolverStandard"
self.menutext = "Solver CalculiX (new framework)"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverCalculix",
"Solver CalculiX (new framework)"
)
self.accel = "S, C"
self.tooltip = "Creates a FEM solver CalculiX new framework (less result error handling)"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverCalculix",
"Creates a FEM solver CalculiX new framework (less result error handling)"
)
self.is_active = "with_analysis"
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -754,9 +992,15 @@ class _SolverControl(CommandManager):
def __init__(self):
super(_SolverControl, self).__init__()
self.menutext = "Solver job control"
self.menutext = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverControl",
"Solver job control"
)
self.accel = "S, T"
self.tooltip = "Changes solver attributes and runs the calculations for the selected solver"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverControl",
"Changes solver attributes and runs the calculations for the selected solver"
)
self.is_active = "with_solver"
def Activated(self):
@@ -768,9 +1012,12 @@ class _SolverElmer(CommandManager):
def __init__(self):
super(_SolverElmer, self).__init__()
self.menutext = "Solver Elmer"
self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_SolverElmer", "Solver Elmer")
self.accel = "S, E"
self.tooltip = "Creates a FEM solver Elmer"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverElmer",
"Creates a FEM solver Elmer"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -781,9 +1028,9 @@ class _SolverMystran(CommandManager):
def __init__(self):
super(_SolverMystran, self).__init__()
self.pixmap = "FEM_SolverStandard"
self.menutext = "Solver Mystran"
self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_SolverMystran", "Solver Mystran")
self.accel = "S, M"
self.tooltip = "Creates a FEM solver Mystran"
self.tooltip = Qt.QT_TRANSLATE_NOOP("FEM_SolverMystran", "Creates a FEM solver Mystran")
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -793,9 +1040,12 @@ class _SolverRun(CommandManager):
def __init__(self):
super(_SolverRun, self).__init__()
self.menutext = "Run solver calculations"
self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_SolverRun", "Run solver calculations")
self.accel = "S, R"
self.tooltip = "Runs the calculations for the selected solver"
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"FEM_SolverRun",
"Runs the calculations for the selected solver"
)
self.is_active = "with_solver"
def Activated(self):
@@ -810,9 +1060,9 @@ class _SolverZ88(CommandManager):
def __init__(self):
super(_SolverZ88, self).__init__()
self.menutext = "Solver Z88"
self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_SolverZ88", "Solver Z88")
self.accel = "S, Z"
self.tooltip = "Creates a FEM solver Z88"
self.tooltip = Qt.QT_TRANSLATE_NOOP("FEM_SolverZ88", "Creates a FEM solver Z88")
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_noset_edit"
@@ -549,7 +549,7 @@ class _TaskPanel:
# for example PoissonRatio
value = Units.Quantity(inputfield_text).Value
old_value = Units.Quantity(self.material[matProperty]).Value
# value = float(inputfield_text) # this fails on locale with komma
# value = float(inputfield_text) # this fails on locale with comma
# https://forum.freecadweb.org/viewtopic.php?f=18&t=56912&p=523313#p523313
if value:
if not (1 - variation < float(old_value) / value < 1 + variation):
+1 -1
View File
@@ -368,7 +368,7 @@ private:
//makeHeader.SetName(new TCollection_HAsciiString((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.SetOriginatingSystem(new TCollection_HAsciiString(App::Application::getExecutableName().c_str()));
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) {
+1 -1
View File
@@ -668,7 +668,7 @@ private:
//makeHeader.SetName(new TCollection_HAsciiString((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.SetOriginatingSystem(new TCollection_HAsciiString(App::Application::getExecutableName().c_str()));
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) {
+1 -1
View File
@@ -514,7 +514,7 @@ public:
dKoeff[ ct ] = pKoef[ ct ];
}
/**
* Destruktor. Deletes the ImpicitSurface instance
* Destructor. Deletes the ImpicitSurface instance
* of the WildMagic library
*/
~FunctionContainer(){ delete pImplSurf; }
+12 -12
View File
@@ -180,22 +180,22 @@ MeshFacetArray& MeshFacetArray::operator = (const MeshFacetArray &rclFAry)
bool MeshGeomEdge::ContainedByOrIntersectBoundingBox ( const Base::BoundBox3f &rclBB ) const
{
// Test, ob alle Eckpunkte der Edge sich auf einer der 6 Seiten der BB befinden
// Test whether all corner points of the Edge are on one of the 6 sides of the BB
if ((GetBoundBox() && rclBB) == false)
return false;
// Test, ob Edge-BB komplett in BB liegt
// Test whether Edge-BB is completely in BB
if (rclBB.IsInBox(GetBoundBox()))
return true;
// Test, ob einer der Eckpunkte in BB liegt
// Test whether one of the corner points is in BB
for (int i=0;i<2;i++)
{
if (rclBB.IsInBox(_aclPoints[i]))
return true;
}
// "echter" Test auf Schnitt
// "real" test for cut
if (IntersectBoundingBox(rclBB))
return true;
@@ -487,7 +487,7 @@ bool MeshGeomFacet::IsPointOf (const Base::Vector3f &rclPoint, float fDistance)
clProjPt.ProjectToPlane(_aclPoints[0], clNorm);
// Kante P0 --> P1
// Edge P0 --> P1
clEdge = clP1 - clP0;
fLP = clProjPt.DistanceToLine(clP0, clEdge);
if (fLP > 0.0f)
@@ -500,9 +500,9 @@ bool MeshGeomFacet::IsPointOf (const Base::Vector3f &rclPoint, float fDistance)
}
else
return false;
}
}
// Kante P0 --> P2
// Edge P0 --> P2
clEdge = clP2 - clP0;
fLP = clProjPt.DistanceToLine(clP0, clEdge);
if (fLP > 0.0f)
@@ -515,9 +515,9 @@ bool MeshGeomFacet::IsPointOf (const Base::Vector3f &rclPoint, float fDistance)
}
else
return false;
}
}
// Kante P1 --> P2
// Edge P1 --> P2
clEdge = clP2 - clP1;
fLP = clProjPt.DistanceToLine(clP1, clEdge);
if (fLP > 0.0f)
@@ -537,7 +537,7 @@ bool MeshGeomFacet::IsPointOf (const Base::Vector3f &rclPoint, float fDistance)
bool MeshGeomFacet::IsPointOfFace (const Base::Vector3f& rclP, float fDistance) const
{
// effektivere Implementierung als in MeshGeomFacet::IsPointOf
// more effective implementation than in MeshGeomFacet::IsPointOf
//
Base::Vector3f a(_aclPoints[0].x, _aclPoints[0].y, _aclPoints[0].z);
Base::Vector3f b(_aclPoints[1].x, _aclPoints[1].y, _aclPoints[1].z);
@@ -907,7 +907,7 @@ bool MeshGeomFacet::Foraminate (const Base::Vector3f &P, const Base::Vector3f &d
bool MeshGeomFacet::IntersectPlaneWithLine (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes) const
{
// berechne den Schnittpunkt Gerade <-> Ebene
// calculate the intersection of the straight line <-> plane
if ( fabs(rclDir * GetNormal()) < 1e-3f )
return false; // line and plane are parallel
@@ -979,7 +979,7 @@ void MeshGeomFacet::SubSample (float fStep, std::vector<Base::Vector3f> &rclPoin
Base::Vector3f clVecAC(C - A);
Base::Vector3f clVecBC(C - B);
// laengste Achse entspricht AB
// longest axis corresponds to AB
float fLenAB = clVecAB.Length();
float fLenAC = clVecAC.Length();
float fLenBC = clVecBC.Length();
+2
View File
@@ -42,6 +42,8 @@
<file>icons/RegularSolids/Mesh_Ellipsoid.svg</file>
<file>icons/RegularSolids/Mesh_Sphere.svg</file>
<file>icons/RegularSolids/Mesh_Torus.svg</file>
</qresource>
<qresource>
<file>translations/Mesh_af.qm</file>
<file>translations/Mesh_de.qm</file>
<file>translations/Mesh_fi.qm</file>
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
* Copyright (c) 2008 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
* Copyright (c) 2008 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Juergen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2008 Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Juergen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2008 Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Juergen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2008 Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Juergen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2008 Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *

Some files were not shown because too many files have changed in this diff Show More