Merge branch 'master' into Crowdin-MeshPart
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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.
+809
-620
File diff suppressed because it is too large
Load Diff
+41
-8
@@ -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 {
|
||||
@@ -526,8 +555,6 @@ private:
|
||||
static void logStatus(void);
|
||||
// the one and only pointer to the application object
|
||||
static Application *_pcSingleton;
|
||||
/// argument helper function
|
||||
static void ParseOptions(int argc, char ** argv);
|
||||
/// checks if the environment is alright
|
||||
//static void CheckEnv(void);
|
||||
/// Search for the FreeCAD home path based on argv[0]
|
||||
@@ -559,13 +586,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;
|
||||
|
||||
@@ -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
@@ -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
@@ -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,
|
||||
|
||||
@@ -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. */
|
||||
@@ -387,6 +395,11 @@ public:
|
||||
bool operator!= (const WeakPtrT<T>& p) const {
|
||||
return ptr != p.ptr;
|
||||
}
|
||||
/*! Get a pointer to the object or 0 if it doesn't exist any more. */
|
||||
T* get() const noexcept
|
||||
{
|
||||
return ptr.get<T>();
|
||||
}
|
||||
|
||||
private:
|
||||
// disable
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <Base/MatrixPy.h>
|
||||
#include <Base/PlacementPy.h>
|
||||
#include <Base/QuantityPy.h>
|
||||
#include <Base/RotationPy.h>
|
||||
|
||||
#include "Document.h"
|
||||
#include "DocumentObject.h"
|
||||
@@ -938,6 +939,183 @@ void PropertyPlacementLink::Paste(const Property &from)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// PropertyRotation
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TYPESYSTEM_SOURCE(App::PropertyRotation , App::Property)
|
||||
|
||||
PropertyRotation::PropertyRotation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
PropertyRotation::~PropertyRotation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PropertyRotation::setValue(const Base::Rotation &rot)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_rot = rot;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
bool PropertyRotation::setValueIfChanged(const Base::Rotation &rot, double atol)
|
||||
{
|
||||
if (_rot.isSame(rot, atol)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setValue(rot);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const Base::Rotation & PropertyRotation::getValue() const
|
||||
{
|
||||
return _rot;
|
||||
}
|
||||
|
||||
void PropertyRotation::getPaths(std::vector<ObjectIdentifier> &paths) const
|
||||
{
|
||||
paths.push_back(ObjectIdentifier(*this)
|
||||
<< ObjectIdentifier::SimpleComponent(ObjectIdentifier::String("Angle")));
|
||||
paths.push_back(ObjectIdentifier(*this)
|
||||
<< ObjectIdentifier::SimpleComponent(ObjectIdentifier::String("Axis"))
|
||||
<< ObjectIdentifier::SimpleComponent(ObjectIdentifier::String("x")));
|
||||
paths.push_back(ObjectIdentifier(*this)
|
||||
<< ObjectIdentifier::SimpleComponent(ObjectIdentifier::String("Axis"))
|
||||
<< ObjectIdentifier::SimpleComponent(ObjectIdentifier::String("y")));
|
||||
paths.push_back(ObjectIdentifier(*this)
|
||||
<< ObjectIdentifier::SimpleComponent(ObjectIdentifier::String("Axis"))
|
||||
<< ObjectIdentifier::SimpleComponent(ObjectIdentifier::String("z")));
|
||||
}
|
||||
|
||||
void PropertyRotation::setPathValue(const ObjectIdentifier &path, const boost::any &value)
|
||||
{
|
||||
if (path.getSubPathStr() == ".Angle") {
|
||||
double avalue;
|
||||
|
||||
if (value.type() == typeid(Base::Quantity))
|
||||
avalue = boost::any_cast<Base::Quantity>(value).getValue();
|
||||
else if (value.type() == typeid(double))
|
||||
avalue = boost::any_cast<double>(value);
|
||||
else if (value.type() == typeid(int))
|
||||
avalue = boost::any_cast<int>(value);
|
||||
else if (value.type() == typeid(unsigned int))
|
||||
avalue = boost::any_cast<unsigned int >(value);
|
||||
else if (value.type() == typeid(short))
|
||||
avalue = boost::any_cast<short>(value);
|
||||
else if (value.type() == typeid(unsigned short))
|
||||
avalue = boost::any_cast<unsigned short>(value);
|
||||
else if (value.type() == typeid(long))
|
||||
avalue = boost::any_cast<long>(value);
|
||||
else if (value.type() == typeid(unsigned long))
|
||||
avalue = boost::any_cast<unsigned long>(value);
|
||||
else
|
||||
throw std::bad_cast();
|
||||
|
||||
Property::setPathValue(path, Base::toRadians(avalue));
|
||||
}
|
||||
else {
|
||||
Property::setPathValue(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
const boost::any PropertyRotation::getPathValue(const ObjectIdentifier &path) const
|
||||
{
|
||||
std::string p = path.getSubPathStr();
|
||||
|
||||
if (p == ".Angle") {
|
||||
// Convert angle to degrees
|
||||
return Base::Quantity(Base::toDegrees(boost::any_cast<double>(Property::getPathValue(path))), Unit::Angle);
|
||||
}
|
||||
else {
|
||||
return Property::getPathValue(path);
|
||||
}
|
||||
}
|
||||
|
||||
bool PropertyRotation::getPyPathValue(const ObjectIdentifier &path, Py::Object &res) const
|
||||
{
|
||||
std::string p = path.getSubPathStr();
|
||||
if (p == ".Angle") {
|
||||
Base::Vector3d axis; double angle;
|
||||
_rot.getValue(axis,angle);
|
||||
res = Py::asObject(new QuantityPy(new Quantity(Base::toDegrees(angle),Unit::Angle)));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
PyObject *PropertyRotation::getPyObject()
|
||||
{
|
||||
return new Base::RotationPy(new Base::Rotation(_rot));
|
||||
}
|
||||
|
||||
void PropertyRotation::setPyObject(PyObject *value)
|
||||
{
|
||||
if (PyObject_TypeCheck(value, &(Base::MatrixPy::Type))) {
|
||||
Base::MatrixPy *object = static_cast<Base::MatrixPy*>(value);
|
||||
Base::Matrix4D mat = object->value();
|
||||
Base::Rotation p;
|
||||
p.setValue(mat);
|
||||
setValue(p);
|
||||
}
|
||||
else if (PyObject_TypeCheck(value, &(Base::RotationPy::Type))) {
|
||||
setValue(*static_cast<Base::RotationPy*>(value)->getRotationPtr());
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Matrix' or 'Rotation', not ");
|
||||
error += value->ob_type->tp_name;
|
||||
throw Base::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyRotation::Save (Base::Writer &writer) const
|
||||
{
|
||||
Vector3d axis;
|
||||
double rfAngle;
|
||||
_rot.getValue(axis, rfAngle);
|
||||
|
||||
writer.Stream() << writer.ind() << "<PropertyRotation";
|
||||
writer.Stream() << " A=\"" << rfAngle << "\""
|
||||
<< " Ox=\"" << axis.x << "\""
|
||||
<< " Oy=\"" << axis.y << "\""
|
||||
<< " Oz=\"" << axis.z << "\""
|
||||
<< "/>\n";
|
||||
}
|
||||
|
||||
void PropertyRotation::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
reader.readElement("PropertyRotation");
|
||||
aboutToSetValue();
|
||||
|
||||
_rot = Rotation(Vector3d(reader.getAttributeAsFloat("Ox"),
|
||||
reader.getAttributeAsFloat("Oy"),
|
||||
reader.getAttributeAsFloat("Oz")),
|
||||
reader.getAttributeAsFloat("A"));
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
Property *PropertyRotation::Copy() const
|
||||
{
|
||||
PropertyRotation *p = new PropertyRotation();
|
||||
p->_rot = _rot;
|
||||
return p;
|
||||
}
|
||||
|
||||
void PropertyRotation::Paste(const Property &from)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_rot = dynamic_cast<const PropertyRotation&>(from)._rot;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(App::PropertyGeometry , App::Property)
|
||||
|
||||
+71
-2
@@ -35,6 +35,7 @@
|
||||
#include "Property.h"
|
||||
#include "PropertyLinks.h"
|
||||
#include "ComplexGeoData.h"
|
||||
#include <FCGlobal.h>
|
||||
|
||||
namespace Base {
|
||||
class Writer;
|
||||
@@ -281,8 +282,9 @@ private:
|
||||
Base::Matrix4D _cMat;
|
||||
};
|
||||
|
||||
/** Vector properties
|
||||
* This is the father of all properties handling Integers.
|
||||
/// Property representing a placement
|
||||
/*!
|
||||
* Encapsulates a Base::Placement in a Property
|
||||
*/
|
||||
class AppExport PropertyPlacement: public Property
|
||||
{
|
||||
@@ -408,6 +410,73 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
/// Property representing a rotation
|
||||
/*!
|
||||
* Encapsulates a Base::Rotation in a Property
|
||||
*/
|
||||
class AppExport PropertyRotation : public Property
|
||||
{
|
||||
TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
||||
|
||||
public:
|
||||
/**
|
||||
* A constructor.
|
||||
* A more elaborate description of the constructor.
|
||||
*/
|
||||
PropertyRotation();
|
||||
|
||||
/**
|
||||
* A destructor.
|
||||
* A more elaborate description of the destructor.
|
||||
*/
|
||||
virtual ~PropertyRotation();
|
||||
|
||||
/** Sets the property
|
||||
*/
|
||||
void setValue(const Base::Rotation &rot);
|
||||
|
||||
/** Sets property only if changed
|
||||
* @param pos: input placement
|
||||
* @param tol: position tolerance
|
||||
* @param atol: angular tolerance
|
||||
*/
|
||||
bool setValueIfChanged(const Base::Rotation &rot, double atol=1e-12);
|
||||
|
||||
/** This method returns a string representation of the property
|
||||
*/
|
||||
const Base::Rotation &getValue() const;
|
||||
|
||||
/// Get valid paths for this property; used by auto completer
|
||||
void getPaths(std::vector<ObjectIdentifier> &paths) const override;
|
||||
|
||||
void setPathValue(const ObjectIdentifier &path, const boost::any &value) override;
|
||||
|
||||
virtual const boost::any getPathValue(const ObjectIdentifier &path) const override;
|
||||
|
||||
virtual bool getPyPathValue(const ObjectIdentifier &path, Py::Object &res) const override;
|
||||
|
||||
const char* getEditorName() const override {
|
||||
return "Gui::PropertyEditor::PropertyRotationItem";
|
||||
}
|
||||
|
||||
virtual PyObject *getPyObject() override;
|
||||
virtual void setPyObject(PyObject *) override;
|
||||
|
||||
virtual void Save (Base::Writer &writer) const override;
|
||||
virtual void Restore(Base::XMLReader &reader) override;
|
||||
|
||||
virtual Property *Copy() const override;
|
||||
virtual void Paste(const Property &from) override;
|
||||
|
||||
virtual unsigned int getMemSize () const override {
|
||||
return sizeof(Base::Placement);
|
||||
}
|
||||
|
||||
private:
|
||||
Base::Rotation _rot;
|
||||
};
|
||||
|
||||
|
||||
/** The base class for all basic geometry properties.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
|
||||
+50
-19
@@ -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;
|
||||
}
|
||||
|
||||
@@ -732,11 +732,8 @@ std::string ParameterGrp::GetASCII(const char* Name, const char * pPreset) const
|
||||
DOMNode *pcElem2 = pcElem->getFirstChild();
|
||||
if (pcElem2)
|
||||
return std::string(StrXUTF8(pcElem2->getNodeValue()).c_str());
|
||||
else if (pPreset==0)
|
||||
return std::string("");
|
||||
|
||||
else
|
||||
return std::string(pPreset);
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
std::vector<std::string> ParameterGrp::GetASCIIs(const char * sFilter) const
|
||||
|
||||
@@ -683,7 +683,7 @@ void Rotation::getYawPitchRoll(double& y, double& p, double& r) const
|
||||
// south pole
|
||||
y = 0.0;
|
||||
p = -D_PI/2.0;
|
||||
r = -2.0 * atan2(quat[0],quat[3]);
|
||||
r = 2.0 * atan2(quat[0],quat[3]);
|
||||
}
|
||||
else {
|
||||
y = atan2(2.0*(q01+q23),(q00+q33)-(q11+q22));
|
||||
|
||||
+24
-3
@@ -83,15 +83,36 @@
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="toEuler" Const="true">
|
||||
<Methode Name="setYawPitchRoll">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
setYawPitchRoll(angle1, angle2, angle3)
|
||||
Set the Euler angles of this rotation
|
||||
as yaw-pitch-roll in XY'Z'' convention.
|
||||
|
||||
NOTE: The angles are in degree
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getYawPitchRoll" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
toEuler() -> list
|
||||
getYawPitchRoll() -> list
|
||||
Get the Euler angles of this rotation
|
||||
as yaw-pitch-roll in XY'Z'' convention
|
||||
</UserDocu>
|
||||
NOTE: The angles are in degree
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setEulerAngles">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
setEulerAngles(seq, angle1, angle2, angle3)
|
||||
Set the Euler angles in a given sequence for this rotation.
|
||||
'seq' is the Euler sequence name. You get all possible values with toEulerAngles()
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="toEulerAngles" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
|
||||
+90
-53
@@ -35,7 +35,7 @@
|
||||
using namespace Base;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string RotationPy::representation(void) const
|
||||
std::string RotationPy::representation() const
|
||||
{
|
||||
RotationPy::PointerType ptr = reinterpret_cast<RotationPy::PointerType>(_pcTwinPointer);
|
||||
Py::Float q0(ptr->getValue()[0]);
|
||||
@@ -44,10 +44,10 @@ std::string RotationPy::representation(void) const
|
||||
Py::Float q3(ptr->getValue()[3]);
|
||||
std::stringstream str;
|
||||
str << "Rotation (";
|
||||
str << (std::string)q0.repr() << ", "
|
||||
<< (std::string)q1.repr() << ", "
|
||||
<< (std::string)q2.repr() << ", "
|
||||
<< (std::string)q3.repr();
|
||||
str << static_cast<std::string>(q0.repr()) << ", "
|
||||
<< static_cast<std::string>(q1.repr()) << ", "
|
||||
<< static_cast<std::string>(q2.repr()) << ", "
|
||||
<< static_cast<std::string>(q3.repr());
|
||||
str << ")";
|
||||
|
||||
return str.str();
|
||||
@@ -60,7 +60,7 @@ PyObject *RotationPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // P
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
int RotationPy::PyInit(PyObject* args, PyObject* kwds)
|
||||
{
|
||||
PyObject* o;
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
@@ -76,10 +76,18 @@ int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyErr_Clear();
|
||||
double angle;
|
||||
if (PyArg_ParseTuple(args, "O!d", &(Base::VectorPy::Type), &o, &angle)) {
|
||||
// NOTE: The last parameter defines the rotation angle in degree.
|
||||
getRotationPtr()->setValue(static_cast<Base::VectorPy*>(o)->value(), Base::toRadians<double>(angle));
|
||||
return 0;
|
||||
static char *kw_deg[] = {"Axis", "Degree", nullptr};
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", kw_deg, &(Base::VectorPy::Type), &o, &angle)) {
|
||||
// NOTE: The last parameter defines the rotation angle in degree.
|
||||
getRotationPtr()->setValue(static_cast<Base::VectorPy*>(o)->value(), Base::toRadians<double>(angle));
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
static char *kw_rad[] = {"Axis", "Radian", nullptr};
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", kw_rad, &(Base::VectorPy::Type), &o, &angle)) {
|
||||
getRotationPtr()->setValue(static_cast<Base::VectorPy*>(o)->value(), angle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
@@ -162,7 +170,7 @@ int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyErr_Clear();
|
||||
PyObject *v3;
|
||||
char *priority = nullptr;
|
||||
const char *priority = nullptr;
|
||||
if (PyArg_ParseTuple(args, "O!O!O!|s", &(Base::VectorPy::Type), &v1,
|
||||
&(Base::VectorPy::Type), &v2,
|
||||
&(Base::VectorPy::Type), &v3,
|
||||
@@ -208,11 +216,11 @@ PyObject* RotationPy::richCompare(PyObject *v, PyObject *w, int op)
|
||||
Base::Rotation r1 = *static_cast<RotationPy*>(v)->getRotationPtr();
|
||||
Base::Rotation r2 = *static_cast<RotationPy*>(w)->getRotationPtr();
|
||||
|
||||
PyObject *res=0;
|
||||
PyObject *res=nullptr;
|
||||
if (op != Py_EQ && op != Py_NE) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"no ordering relation is defined for Rotation");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
else if (op == Py_EQ) {
|
||||
res = (r1 == r2) ? Py_True : Py_False;
|
||||
@@ -235,7 +243,7 @@ PyObject* RotationPy::richCompare(PyObject *v, PyObject *w, int op)
|
||||
PyObject* RotationPy::invert(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
return nullptr;
|
||||
this->getRotationPtr()->invert();
|
||||
Py_Return;
|
||||
}
|
||||
@@ -243,7 +251,7 @@ PyObject* RotationPy::invert(PyObject * args)
|
||||
PyObject* RotationPy::inverted(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
return nullptr;
|
||||
Rotation mult = this->getRotationPtr()->inverse();
|
||||
return new RotationPy(new Rotation(mult));
|
||||
}
|
||||
@@ -252,7 +260,7 @@ PyObject* RotationPy::multiply(PyObject * args)
|
||||
{
|
||||
PyObject *rot;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(RotationPy::Type), &rot))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
Rotation mult = (*getRotationPtr()) * (*static_cast<RotationPy*>(rot)->getRotationPtr());
|
||||
return new RotationPy(new Rotation(mult));
|
||||
}
|
||||
@@ -261,7 +269,7 @@ PyObject* RotationPy::multVec(PyObject * args)
|
||||
{
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
Base::Vector3d vec(static_cast<VectorPy*>(obj)->value());
|
||||
getRotationPtr()->multVec(vec, vec);
|
||||
return new VectorPy(new Vector3d(vec));
|
||||
@@ -279,10 +287,19 @@ PyObject* RotationPy::slerp(PyObject * args)
|
||||
return new RotationPy(new Rotation(sl));
|
||||
}
|
||||
|
||||
PyObject* RotationPy::toEuler(PyObject * args)
|
||||
PyObject* RotationPy::setYawPitchRoll(PyObject * args)
|
||||
{
|
||||
double A,B,C;
|
||||
if (!PyArg_ParseTuple(args, "ddd", &A, &B, &C))
|
||||
return nullptr;
|
||||
this->getRotationPtr()->setYawPitchRoll(A,B,C);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* RotationPy::getYawPitchRoll(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
double A,B,C;
|
||||
this->getRotationPtr()->getYawPitchRoll(A,B,C);
|
||||
|
||||
@@ -293,11 +310,29 @@ PyObject* RotationPy::toEuler(PyObject * args)
|
||||
return Py::new_reference_to(tuple);
|
||||
}
|
||||
|
||||
PyObject* RotationPy::setEulerAngles(PyObject * args)
|
||||
{
|
||||
const char *seq;
|
||||
double A,B,C;
|
||||
if (!PyArg_ParseTuple(args, "sddd", &seq, &A, &B, &C))
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
getRotationPtr()->setEulerAngles(
|
||||
Rotation::eulerSequenceFromName(seq), A, B, C);
|
||||
Py_Return;
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
e.setPyException();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* RotationPy::toEulerAngles(PyObject * args)
|
||||
{
|
||||
const char *seq = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "|s", &seq))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!seq) {
|
||||
Py::List res;
|
||||
for (int i=1; i<Rotation::EulerSequenceLast; ++i)
|
||||
@@ -333,7 +368,7 @@ PyObject* RotationPy::isSame(PyObject *args)
|
||||
PyObject *rot;
|
||||
double tol = 0.0;
|
||||
if (!PyArg_ParseTuple(args, "O!|d", &(RotationPy::Type), &rot, &tol))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
Base::Rotation rot1 = * getRotationPtr();
|
||||
Base::Rotation rot2 = * static_cast<RotationPy*>(rot)->getRotationPtr();
|
||||
bool same = tol > 0.0 ? rot1.isSame(rot2, tol) : rot1.isSame(rot2);
|
||||
@@ -343,7 +378,7 @@ PyObject* RotationPy::isSame(PyObject *args)
|
||||
PyObject* RotationPy::isIdentity(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
bool null = getRotationPtr()->isIdentity();
|
||||
return Py_BuildValue("O", (null ? Py_True : Py_False));
|
||||
}
|
||||
@@ -351,12 +386,12 @@ PyObject* RotationPy::isIdentity(PyObject *args)
|
||||
PyObject* RotationPy::isNull(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
bool null = getRotationPtr()->isNull();
|
||||
return Py_BuildValue("O", (null ? Py_True : Py_False));
|
||||
}
|
||||
|
||||
Py::Tuple RotationPy::getQ(void) const
|
||||
Py::Tuple RotationPy::getQ() const
|
||||
{
|
||||
double q0, q1, q2, q3;
|
||||
this->getRotationPtr()->getValue(q0,q1,q2,q3);
|
||||
@@ -371,14 +406,14 @@ Py::Tuple RotationPy::getQ(void) const
|
||||
|
||||
void RotationPy::setQ(Py::Tuple arg)
|
||||
{
|
||||
double q0 = (double)Py::Float(arg.getItem(0));
|
||||
double q1 = (double)Py::Float(arg.getItem(1));
|
||||
double q2 = (double)Py::Float(arg.getItem(2));
|
||||
double q3 = (double)Py::Float(arg.getItem(3));
|
||||
double q0 = static_cast<double>(Py::Float(arg.getItem(0)));
|
||||
double q1 = static_cast<double>(Py::Float(arg.getItem(1)));
|
||||
double q2 = static_cast<double>(Py::Float(arg.getItem(2)));
|
||||
double q3 = static_cast<double>(Py::Float(arg.getItem(3)));
|
||||
this->getRotationPtr()->setValue(q0,q1,q2,q3);
|
||||
}
|
||||
|
||||
Py::Object RotationPy::getRawAxis(void) const
|
||||
Py::Object RotationPy::getRawAxis() const
|
||||
{
|
||||
Base::Vector3d axis; double angle;
|
||||
this->getRotationPtr()->getRawValue(axis, angle);
|
||||
@@ -400,7 +435,7 @@ void RotationPy::setAxis(Py::Object arg)
|
||||
this->getRotationPtr()->setValue(axis, angle);
|
||||
}
|
||||
|
||||
Py::Float RotationPy::getAngle(void) const
|
||||
Py::Float RotationPy::getAngle() const
|
||||
{
|
||||
Base::Vector3d axis; double angle;
|
||||
this->getRotationPtr()->getValue(axis, angle);
|
||||
@@ -437,7 +472,11 @@ PyObject *RotationPy::getCustomAttributes(const char* attr) const
|
||||
this->getRotationPtr()->getYawPitchRoll(A,B,C);
|
||||
return PyFloat_FromDouble(C);
|
||||
}
|
||||
return 0;
|
||||
else if (strcmp(attr, "toEuler") == 0) {
|
||||
Py::Object self(const_cast<RotationPy*>(this), false);
|
||||
return Py::new_reference_to(self.getAttr("getYawPitchRoll"));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int RotationPy::setCustomAttributes(const char* attr, PyObject* obj)
|
||||
@@ -521,19 +560,17 @@ PyObject* RotationPy::number_multiply_handler(PyObject *self, PyObject *other)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_power_handler (PyObject* self, PyObject* other, PyObject* arg)
|
||||
{
|
||||
if (!PyObject_TypeCheck(self, &(RotationPy::Type)) ||
|
||||
|
||||
!PyLong_Check(other)
|
||||
|| arg != Py_None
|
||||
)
|
||||
!PyLong_Check(other) ||
|
||||
arg != Py_None)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Rotation a = static_cast<RotationPy*>(self)->value();
|
||||
@@ -552,49 +589,49 @@ PyObject * RotationPy::number_power_handler (PyObject* self, PyObject* other, Py
|
||||
PyObject* RotationPy::number_add_handler(PyObject * /*self*/, PyObject * /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* RotationPy::number_subtract_handler(PyObject * /*self*/, PyObject * /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_divide_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_remainder_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_divmod_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_negative_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_positive_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_absolute_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int RotationPy::number_nonzero_handler (PyObject* /*self*/)
|
||||
@@ -605,48 +642,48 @@ int RotationPy::number_nonzero_handler (PyObject* /*self*/)
|
||||
PyObject * RotationPy::number_invert_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_lshift_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_rshift_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_and_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_xor_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_int_handler (PyObject * /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * RotationPy::number_float_handler (PyObject * /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "Translate.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QFileInfo>
|
||||
|
||||
using namespace Base;
|
||||
|
||||
@@ -62,6 +63,12 @@ Translate::Translate()
|
||||
&Translate::trNoop,
|
||||
"QT_TR_NOOP_UTF8(sourcetext)\n"
|
||||
"Same as QT_TR_NOOP");
|
||||
add_varargs_method("installTranslator",
|
||||
&Translate::installTranslator,
|
||||
"Install a translator for testing purposes");
|
||||
add_varargs_method("removeTranslators",
|
||||
&Translate::removeTranslators,
|
||||
"Remove test translators");
|
||||
initialize("This module is the Translate module"); // register with Python
|
||||
}
|
||||
|
||||
@@ -109,3 +116,37 @@ Py::Object Translate::trNoop(const Py::Tuple& args)
|
||||
throw Py::Exception();
|
||||
return Py::Object(arg1);
|
||||
}
|
||||
|
||||
Py::Object Translate::installTranslator(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
|
||||
throw Py::Exception();
|
||||
QString filename = QString::fromUtf8(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
bool ok = false;
|
||||
QFileInfo fi(filename);
|
||||
std::shared_ptr<QTranslator> translator(std::make_shared<QTranslator>(nullptr));
|
||||
translator->setObjectName(fi.fileName());
|
||||
if (translator->load(filename)) {
|
||||
qApp->installTranslator(translator.get());
|
||||
translators.push_back(translator);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
return Py::Boolean(ok);
|
||||
}
|
||||
|
||||
Py::Object Translate::removeTranslators(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
bool ok = true;
|
||||
for (const auto& it : translators) {
|
||||
ok &= QCoreApplication::removeTranslator(it.get());
|
||||
}
|
||||
|
||||
translators.clear();
|
||||
return Py::Boolean(ok);
|
||||
}
|
||||
|
||||
@@ -26,10 +26,14 @@
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
#include <CXX/Objects.hxx>
|
||||
#include <QTranslator>
|
||||
#include <memory>
|
||||
#include <list>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace Base {
|
||||
|
||||
class BaseExport Translate : public Py::ExtensionModule<Translate>
|
||||
@@ -43,6 +47,11 @@ private:
|
||||
Py::Object translateNoop(const Py::Tuple& args);
|
||||
Py::Object translateNoop3(const Py::Tuple& args);
|
||||
Py::Object trNoop(const Py::Tuple& args);
|
||||
Py::Object installTranslator(const Py::Tuple& args);
|
||||
Py::Object removeTranslators(const Py::Tuple& args);
|
||||
|
||||
private:
|
||||
std::list<std::shared_ptr<QTranslator>> translators;
|
||||
};
|
||||
|
||||
} // namespace Base
|
||||
|
||||
@@ -44,93 +44,107 @@ App::DocumentObject *ActiveObjectList::getObject(const ObjectInfo &info, bool re
|
||||
App::DocumentObject **parent,
|
||||
std::string *subname) const
|
||||
{
|
||||
if(parent) *parent = info.obj;
|
||||
if(subname) *subname = info.subname;
|
||||
if (parent)
|
||||
*parent = info.obj;
|
||||
if (subname)
|
||||
*subname = info.subname;
|
||||
auto obj = info.obj;
|
||||
if(!obj || !obj->getNameInDocument())
|
||||
return 0;
|
||||
if(info.subname.size()) {
|
||||
if (!obj || !obj->getNameInDocument())
|
||||
return nullptr;
|
||||
if (!info.subname.empty()) {
|
||||
obj = obj->getSubObject(info.subname.c_str());
|
||||
if(!obj)
|
||||
return 0;
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
}
|
||||
return resolve?obj->getLinkedObject(true):obj;
|
||||
|
||||
return resolve ? obj->getLinkedObject(true) : obj;
|
||||
}
|
||||
|
||||
void ActiveObjectList::setHighlight(const ObjectInfo &info, HighlightMode mode, bool enable)
|
||||
{
|
||||
auto obj = getObject(info,false);
|
||||
if(!obj) return;
|
||||
auto obj = getObject(info, false);
|
||||
if (!obj)
|
||||
return;
|
||||
auto vp = dynamic_cast<ViewProviderDocumentObject*>(Application::Instance->getViewProvider(obj));
|
||||
if(!vp) return;
|
||||
if (!vp)
|
||||
return;
|
||||
|
||||
if (TreeParams::Instance()->TreeActiveAutoExpand()) {
|
||||
vp->getDocument()->signalExpandObject(*vp, enable ? TreeItemMode::ExpandPath : TreeItemMode::CollapseItem,
|
||||
info.obj, info.subname.c_str());
|
||||
}
|
||||
|
||||
vp->getDocument()->signalHighlightObject(*vp, mode,enable,info.obj,info.subname.c_str());
|
||||
vp->getDocument()->signalHighlightObject(*vp, mode, enable, info.obj, info.subname.c_str());
|
||||
}
|
||||
|
||||
Gui::ActiveObjectList::ObjectInfo Gui::ActiveObjectList::getObjectInfo(App::DocumentObject *obj, const char *subname) const
|
||||
{
|
||||
ObjectInfo info;
|
||||
info.obj = 0;
|
||||
if(!obj || !obj->getNameInDocument())
|
||||
info.obj = nullptr;
|
||||
if (!obj || !obj->getNameInDocument())
|
||||
return info;
|
||||
if(subname) {
|
||||
|
||||
if (subname) {
|
||||
info.obj = obj;
|
||||
info.subname = subname;
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
// If the input object is not from this document, it must be brought in
|
||||
// by some link type object of this document. We only accept the object
|
||||
// if we can find such object in the current selection.
|
||||
auto sels = Gui::Selection().getSelection(_Doc->getDocument()->getName(),false);
|
||||
for(auto &sel : sels) {
|
||||
if(sel.pObject == obj || sel.pObject->getLinkedObject(true)==obj) {
|
||||
for (auto &sel : sels) {
|
||||
if (sel.pObject == obj || sel.pObject->getLinkedObject(true)==obj) {
|
||||
info.obj = sel.pObject;
|
||||
break;
|
||||
}
|
||||
for(auto dot=strchr(sel.SubName,'.');dot;dot=strchr(dot+1,'.')) {
|
||||
|
||||
for (auto dot=strchr(sel.SubName,'.');dot;dot=strchr(dot+1,'.')) {
|
||||
std::string subname(sel.SubName,dot-sel.SubName+1);
|
||||
auto sobj = sel.pObject->getSubObject(subname.c_str());
|
||||
if(!sobj) break;
|
||||
if(sobj == obj || sobj->getLinkedObject(true) == obj) {
|
||||
if (!sobj)
|
||||
break;
|
||||
if (sobj == obj || sobj->getLinkedObject(true) == obj) {
|
||||
info.obj = sel.pObject;
|
||||
info.subname = subname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(info.obj) break;
|
||||
|
||||
if (info.obj)
|
||||
break;
|
||||
}
|
||||
if(!info.obj && obj->getDocument()==_Doc->getDocument())
|
||||
|
||||
if (!info.obj && obj->getDocument()==_Doc->getDocument())
|
||||
info.obj = obj;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
bool Gui::ActiveObjectList::hasObject(App::DocumentObject *obj,
|
||||
const char *name, const char *subname) const
|
||||
const char *name, const char *subname) const
|
||||
{
|
||||
auto it = _ObjectMap.find(name);
|
||||
if(it==_ObjectMap.end())
|
||||
if (it == _ObjectMap.end())
|
||||
return false;
|
||||
auto info = getObjectInfo(obj,subname);
|
||||
return info.obj==it->second.obj && info.subname==it->second.subname;
|
||||
auto info = getObjectInfo(obj, subname);
|
||||
return info.obj == it->second.obj && info.subname == it->second.subname;
|
||||
}
|
||||
|
||||
void Gui::ActiveObjectList::setObject(App::DocumentObject* obj, const char* name,
|
||||
const char *subname, const Gui::HighlightMode& mode)
|
||||
const char *subname, const Gui::HighlightMode& mode)
|
||||
{
|
||||
auto it = _ObjectMap.find(name);
|
||||
if(it!=_ObjectMap.end()) {
|
||||
setHighlight(it->second,mode,false);
|
||||
if (it!=_ObjectMap.end()) {
|
||||
setHighlight(it->second, mode, false);
|
||||
_ObjectMap.erase(it);
|
||||
}
|
||||
if(!obj) return;
|
||||
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
auto info = getObjectInfo(obj,subname);
|
||||
if(!info.obj) {
|
||||
if (!info.obj) {
|
||||
FC_ERR("Cannot set active object "
|
||||
<< obj->getFullName() << '.' << (subname?subname:"")
|
||||
<< " in document '" << _Doc->getDocument()->getName()
|
||||
@@ -139,7 +153,7 @@ void Gui::ActiveObjectList::setObject(App::DocumentObject* obj, const char* name
|
||||
}
|
||||
|
||||
_ObjectMap[name] = info;
|
||||
setHighlight(info,mode,true);
|
||||
setHighlight(info, mode, true);
|
||||
}
|
||||
|
||||
bool Gui::ActiveObjectList::hasObject(const char*name)const
|
||||
@@ -149,13 +163,11 @@ bool Gui::ActiveObjectList::hasObject(const char*name)const
|
||||
|
||||
void ActiveObjectList::objectDeleted(const ViewProviderDocumentObject &vp)
|
||||
{
|
||||
//maybe boost::bimap or boost::multi_index
|
||||
for (auto it = _ObjectMap.begin(); it != _ObjectMap.end(); ++it)
|
||||
{
|
||||
if (it->second.obj == vp.getObject())
|
||||
{
|
||||
_ObjectMap.erase(it);
|
||||
return;
|
||||
//maybe boost::bimap or boost::multi_index
|
||||
for (auto it = _ObjectMap.begin(); it != _ObjectMap.end(); ++it) {
|
||||
if (it->second.obj == vp.getObject()) {
|
||||
_ObjectMap.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-78
@@ -170,6 +170,7 @@ struct ApplicationP
|
||||
~ApplicationP()
|
||||
{
|
||||
delete macroMngr;
|
||||
delete prefPackManager;
|
||||
}
|
||||
|
||||
/// list of all handled documents
|
||||
@@ -1954,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);
|
||||
|
||||
@@ -2126,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()) {
|
||||
@@ -2266,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());
|
||||
@@ -2416,80 +2417,8 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
|
||||
|
||||
void Application::checkForPreviousCrashes()
|
||||
{
|
||||
QDir tmp = QString::fromUtf8(App::Application::getTempPath().c_str());
|
||||
tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock"));
|
||||
tmp.setFilter(QDir::Files);
|
||||
|
||||
QList<QFileInfo> restoreDocFiles;
|
||||
QString exeName = QString::fromLatin1(App::GetApplication().getExecutableName());
|
||||
QList<QFileInfo> locks = tmp.entryInfoList();
|
||||
for (QList<QFileInfo>::iterator it = locks.begin(); it != locks.end(); ++it) {
|
||||
QString bn = it->baseName();
|
||||
// ignore the lock file for this instance
|
||||
QString pid = QString::number(QCoreApplication::applicationPid());
|
||||
if (bn.startsWith(exeName) && bn.indexOf(pid) < 0) {
|
||||
QString fn = it->absoluteFilePath();
|
||||
boost::interprocess::file_lock flock((const char*)fn.toLocal8Bit());
|
||||
if (flock.try_lock()) {
|
||||
// OK, this file is a leftover from a previous crash
|
||||
QString crashed_pid = bn.mid(exeName.length()+1);
|
||||
// search for transient directories with this PID
|
||||
QString filter;
|
||||
QTextStream str(&filter);
|
||||
str << exeName << "_Doc_*_" << crashed_pid;
|
||||
tmp.setNameFilters(QStringList() << filter);
|
||||
tmp.setFilter(QDir::Dirs);
|
||||
QList<QFileInfo> dirs = tmp.entryInfoList();
|
||||
if (dirs.isEmpty()) {
|
||||
// delete the lock file immediately if no transient directories are related
|
||||
tmp.remove(fn);
|
||||
}
|
||||
else {
|
||||
int countDeletedDocs = 0;
|
||||
QString recovery_files = QString::fromLatin1("fc_recovery_files");
|
||||
for (QList<QFileInfo>::iterator it = dirs.begin(); it != dirs.end(); ++it) {
|
||||
QDir doc_dir(it->absoluteFilePath());
|
||||
doc_dir.setFilter(QDir::NoDotAndDotDot|QDir::AllEntries);
|
||||
uint entries = doc_dir.entryList().count();
|
||||
if (entries == 0) {
|
||||
// in this case we can delete the transient directory because
|
||||
// we cannot do anything
|
||||
if (tmp.rmdir(it->filePath()))
|
||||
countDeletedDocs++;
|
||||
}
|
||||
// search for the existence of a recovery file
|
||||
else if (doc_dir.exists(QLatin1String("fc_recovery_file.xml"))) {
|
||||
// store the transient directory in case it's not empty
|
||||
restoreDocFiles << *it;
|
||||
}
|
||||
// search for the 'fc_recovery_files' sub-directory and check that it's the only entry
|
||||
else if (entries == 1 && doc_dir.exists(recovery_files)) {
|
||||
// if the sub-directory is empty delete the transient directory
|
||||
QDir rec_dir(doc_dir.absoluteFilePath(recovery_files));
|
||||
rec_dir.setFilter(QDir::NoDotAndDotDot|QDir::AllEntries);
|
||||
if (rec_dir.entryList().isEmpty()) {
|
||||
doc_dir.rmdir(recovery_files);
|
||||
if (tmp.rmdir(it->filePath()))
|
||||
countDeletedDocs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// all directories corresponding to the lock file have been deleted
|
||||
// so delete the lock file, too
|
||||
if (countDeletedDocs == dirs.size()) {
|
||||
tmp.remove(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!restoreDocFiles.isEmpty()) {
|
||||
Gui::Dialog::DocumentRecovery dlg(restoreDocFiles, Gui::getMainWindow());
|
||||
if (dlg.foundDocuments())
|
||||
dlg.exec();
|
||||
}
|
||||
Gui::Dialog::DocumentRecoveryFinder finder;
|
||||
finder.checkForPreviousCrashes();
|
||||
}
|
||||
|
||||
App::Document *Application::reopen(App::Document *doc) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
|
||||
@@ -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/"));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -838,6 +838,8 @@ SET(View3D_CPP_SRCS
|
||||
BlenderNavigationStyle.cpp
|
||||
MayaGestureNavigationStyle.cpp
|
||||
OpenCascadeNavigationStyle.cpp
|
||||
OpenSCADNavigationStyle.cpp
|
||||
TinkerCADNavigationStyle.cpp
|
||||
TouchpadNavigationStyle.cpp
|
||||
GestureNavigationStyle.cpp
|
||||
SplitView3DInventor.cpp
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1574,7 +1574,7 @@ void StdCmdPlacement::activated(int iMsg)
|
||||
|
||||
bool StdCmdPlacement::isActive(void)
|
||||
{
|
||||
return Gui::Selection().countObjectsOfType(App::GeoFeature::getClassTypeId()) == 1;
|
||||
return Gui::Selection().countObjectsOfType(App::GeoFeature::getClassTypeId()) >= 1;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
+11
-11
@@ -502,7 +502,7 @@ StdCmdOnlineHelpWebsite::StdCmdOnlineHelpWebsite()
|
||||
void StdCmdOnlineHelpWebsite::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"http://www.freecadweb.org/wiki/Online_Help_Toc").toStdString();
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"https://wiki.freecad.org/Online_Help_Toc").toStdString();
|
||||
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Websites");
|
||||
std::string url = hURLGrp->GetASCII("OnlineHelp", defaulturl.c_str());
|
||||
hURLGrp->SetASCII("OnlineHelp", url.c_str());
|
||||
@@ -529,9 +529,9 @@ StdCmdFreeCADDonation::StdCmdFreeCADDonation()
|
||||
|
||||
void StdCmdFreeCADDonation::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Q_UNUSED(iMsg);
|
||||
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Websites");
|
||||
std::string url = hURLGrp->GetASCII("DonatePage", "https://wiki.freecadweb.org/Donate");
|
||||
std::string url = hURLGrp->GetASCII("DonatePage", "https://wiki.freecad.org/Donate");
|
||||
hURLGrp->SetASCII("DonatePage", url.c_str());
|
||||
OpenURLInBrowser(url.c_str());
|
||||
}
|
||||
@@ -557,7 +557,7 @@ StdCmdFreeCADWebsite::StdCmdFreeCADWebsite()
|
||||
void StdCmdFreeCADWebsite::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"http://www.freecadweb.org").toStdString();
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"https://www.freecad.org").toStdString();
|
||||
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Websites");
|
||||
std::string url = hURLGrp->GetASCII("WebPage", defaulturl.c_str());
|
||||
hURLGrp->SetASCII("WebPage", url.c_str());
|
||||
@@ -585,7 +585,7 @@ StdCmdFreeCADUserHub::StdCmdFreeCADUserHub()
|
||||
void StdCmdFreeCADUserHub::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"http://www.freecadweb.org/wiki/User_hub").toStdString();
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"https://wiki.freecad.org/User_hub").toStdString();
|
||||
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Websites");
|
||||
std::string url = hURLGrp->GetASCII("Documentation", defaulturl.c_str());
|
||||
hURLGrp->SetASCII("Documentation", url.c_str());
|
||||
@@ -613,7 +613,7 @@ StdCmdFreeCADPowerUserHub::StdCmdFreeCADPowerUserHub()
|
||||
void StdCmdFreeCADPowerUserHub::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"http://www.freecadweb.org/wiki/Power_users_hub").toStdString();
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"https://wiki.freecad.org/Power_users_hub").toStdString();
|
||||
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Websites");
|
||||
std::string url = hURLGrp->GetASCII("PowerUsers", defaulturl.c_str());
|
||||
hURLGrp->SetASCII("PowerUsers", url.c_str());
|
||||
@@ -641,7 +641,7 @@ StdCmdFreeCADForum::StdCmdFreeCADForum()
|
||||
void StdCmdFreeCADForum::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"http://forum.freecadweb.org").toStdString();
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"https://forum.freecad.org").toStdString();
|
||||
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Websites");
|
||||
std::string url = hURLGrp->GetASCII("UserForum", defaulturl.c_str());
|
||||
hURLGrp->SetASCII("UserForum", url.c_str());
|
||||
@@ -669,7 +669,7 @@ StdCmdFreeCADFAQ::StdCmdFreeCADFAQ()
|
||||
void StdCmdFreeCADFAQ::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"http://www.freecadweb.org/wiki/FAQ").toStdString();
|
||||
std::string defaulturl = QCoreApplication::translate(this->className(),"https://wiki.freecad.org/Frequently_asked_questions").toStdString();
|
||||
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Websites");
|
||||
std::string url = hURLGrp->GetASCII("FAQ", defaulturl.c_str());
|
||||
hURLGrp->SetASCII("FAQ", url.c_str());
|
||||
@@ -697,7 +697,7 @@ StdCmdPythonWebsite::StdCmdPythonWebsite()
|
||||
void StdCmdPythonWebsite::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
OpenURLInBrowser("http://python.org");
|
||||
OpenURLInBrowser("https://www.python.org");
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@@ -852,7 +852,7 @@ Gui::Action * StdCmdUserEditMode::createAction(void)
|
||||
pcAction->setDropDownMenu(true);
|
||||
pcAction->setIsMode(true);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
|
||||
for (auto const &uem : Gui::Application::Instance->listUserEditModes()) {
|
||||
QAction* act = pcAction->addAction(QString());
|
||||
auto modeName = QString::fromStdString(uem.second);
|
||||
@@ -860,7 +860,7 @@ Gui::Action * StdCmdUserEditMode::createAction(void)
|
||||
act->setIcon(BitmapFactory().iconFromTheme(qPrintable(QString::fromLatin1("Std_UserEditMode")+modeName)));
|
||||
act->setObjectName(QString::fromLatin1("Std_UserEditMode")+modeName);
|
||||
act->setWhatsThis(QString::fromLatin1(getWhatsThis()));
|
||||
|
||||
|
||||
if (uem.first == 0) {
|
||||
pcAction->setIcon(act->icon());
|
||||
act->setChecked(true);
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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++ ) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
+5
-41
@@ -29,9 +29,7 @@
|
||||
#include "DlgUndoRedo.h"
|
||||
#include "Application.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Document.h"
|
||||
#include "EditorView.h"
|
||||
#include "TextDocumentEditorView.h"
|
||||
#include "MDIView.h"
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
@@ -64,28 +62,11 @@ void UndoDialog::onFetchInfo()
|
||||
clear(); // Remove first all items
|
||||
|
||||
MDIView* mdi = getMainWindow()->activeWindow();
|
||||
EditorView* editview = qobject_cast<EditorView*>(mdi);
|
||||
TextDocumentEditorView* textedit = qobject_cast<TextDocumentEditorView*>(mdi);
|
||||
if (editview) {
|
||||
QStringList vecUndos = editview->undoActions();
|
||||
if (mdi) {
|
||||
QStringList vecUndos = mdi->undoActions();
|
||||
for (QStringList::Iterator i = vecUndos.begin(); i != vecUndos.end(); ++i)
|
||||
addAction(*i, this, SLOT(onSelected()));
|
||||
}
|
||||
else if (textedit) {
|
||||
QStringList vecUndos = textedit->undoActions();
|
||||
for (QStringList::Iterator i = vecUndos.begin(); i != vecUndos.end(); ++i)
|
||||
addAction(*i, this, SLOT(onSelected()));
|
||||
}
|
||||
else if (mdi) {
|
||||
Gui::Document* pcDoc = mdi->getGuiDocument();
|
||||
if (pcDoc) {
|
||||
std::vector<std::string> vecUndos = pcDoc->getUndoVector();
|
||||
for (std::vector<std::string>::iterator i = vecUndos.begin(); i != vecUndos.end(); ++i) {
|
||||
QString text = QCoreApplication::translate("Command", i->c_str());
|
||||
addAction(text, this, SLOT(onSelected()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Closes the dialog and sends the message 'Undo' to the currently active MDI view. */
|
||||
@@ -129,28 +110,11 @@ void RedoDialog::onFetchInfo()
|
||||
clear(); // Remove first all items
|
||||
|
||||
MDIView* mdi = getMainWindow()->activeWindow();
|
||||
EditorView* editview = qobject_cast<EditorView*>(mdi);
|
||||
TextDocumentEditorView* textedit = qobject_cast<TextDocumentEditorView*>(mdi);
|
||||
if (editview) {
|
||||
QStringList vecRedos = editview->redoActions();
|
||||
if (mdi) {
|
||||
QStringList vecRedos = mdi->redoActions();
|
||||
for (QStringList::Iterator i = vecRedos.begin(); i != vecRedos.end(); ++i)
|
||||
addAction(*i, this, SLOT(onSelected()));
|
||||
}
|
||||
else if (textedit) {
|
||||
QStringList vecRedos = textedit->redoActions();
|
||||
for (QStringList::Iterator i = vecRedos.begin(); i != vecRedos.end(); ++i)
|
||||
addAction(*i, this, SLOT(onSelected()));
|
||||
}
|
||||
else if (mdi) {
|
||||
Gui::Document* pcDoc = mdi->getGuiDocument();
|
||||
if (pcDoc) {
|
||||
std::vector<std::string> vecRedos = pcDoc->getRedoVector();
|
||||
for (std::vector<std::string>::iterator i = vecRedos.begin(); i != vecRedos.end(); ++i) {
|
||||
QString text = QCoreApplication::translate("Command", i->c_str());
|
||||
addAction(text, this, SLOT(onSelected()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Closes the dialog and sends the message 'Redo' to the currently active MDI view. */
|
||||
|
||||
+48
-44
@@ -405,13 +405,16 @@ bool Document::setEdit(Gui::ViewProvider* p, int ModNum, const char *subname)
|
||||
d->_editViewProviderParent = vp;
|
||||
d->_editSubElement.clear();
|
||||
d->_editSubname.clear();
|
||||
if(subname) {
|
||||
|
||||
if (subname) {
|
||||
const char *element = Data::ComplexGeoData::findElementName(subname);
|
||||
if(element) {
|
||||
if (element) {
|
||||
d->_editSubname = std::string(subname,element-subname);
|
||||
d->_editSubElement = element;
|
||||
}else
|
||||
}
|
||||
else {
|
||||
d->_editSubname = subname;
|
||||
}
|
||||
}
|
||||
|
||||
auto sobjs = obj->getSubObjectList(subname);
|
||||
@@ -1096,6 +1099,31 @@ static bool checkCanonicalPath(const std::map<App::Document*, bool> &docs)
|
||||
return ret == QMessageBox::Yes;
|
||||
}
|
||||
|
||||
bool Document::askIfSavingFailed(const QString& error)
|
||||
{
|
||||
int ret = QMessageBox::question(
|
||||
getMainWindow(),
|
||||
QObject::tr("Could not save document"),
|
||||
QObject::tr("There was an issue trying to save the file. "
|
||||
"This may be because some of the parent folders do not exist, "
|
||||
"or you do not have sufficient permissions, "
|
||||
"or for other reasons. Error details:\n\n\"%1\"\n\n"
|
||||
"Would you like to save the file with a different name?")
|
||||
.arg(error),
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
|
||||
if (ret == QMessageBox::No) {
|
||||
// TODO: Understand what exactly is supposed to be returned here
|
||||
getMainWindow()->showMessage(QObject::tr("Saving aborted"), 2000);
|
||||
return false;
|
||||
}
|
||||
else if (ret == QMessageBox::Yes) {
|
||||
return saveAs();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Save the document
|
||||
bool Document::save(void)
|
||||
{
|
||||
@@ -1105,7 +1133,7 @@ bool Document::save(void)
|
||||
std::map<App::Document*,bool> dmap;
|
||||
try {
|
||||
docs = getDocument()->getDependentDocuments();
|
||||
for(auto it=docs.begin(); it!=docs.end();) {
|
||||
for (auto it=docs.begin(); it!=docs.end();) {
|
||||
App::Document *doc = *it;
|
||||
if (doc == getDocument()) {
|
||||
dmap[doc] = doc->mustExecute();
|
||||
@@ -1123,18 +1151,21 @@ bool Document::save(void)
|
||||
dmap[doc] = doc->mustExecute();
|
||||
++it;
|
||||
}
|
||||
}catch(const Base::RuntimeError &e) {
|
||||
}
|
||||
catch (const Base::RuntimeError &e) {
|
||||
FC_ERR(e.what());
|
||||
docs = {getDocument()};
|
||||
dmap.clear();
|
||||
dmap[getDocument()] = getDocument()->mustExecute();
|
||||
}
|
||||
if(docs.size()>1) {
|
||||
|
||||
if (docs.size()>1) {
|
||||
int ret = QMessageBox::question(getMainWindow(),
|
||||
QObject::tr("Save dependent files"),
|
||||
QObject::tr("The file contains external dependencies. "
|
||||
"Do you want to save the dependent files, too?"),
|
||||
QMessageBox::Yes,QMessageBox::No);
|
||||
|
||||
if (ret != QMessageBox::Yes) {
|
||||
docs = {getDocument()};
|
||||
dmap.clear();
|
||||
@@ -1147,35 +1178,22 @@ bool Document::save(void)
|
||||
|
||||
Gui::WaitCursor wc;
|
||||
// save all documents
|
||||
for(auto doc : docs) {
|
||||
for (auto doc : docs) {
|
||||
// Changed 'mustExecute' status may be triggered by saving external document
|
||||
if(!dmap[doc] && doc->mustExecute()) {
|
||||
if (!dmap[doc] && doc->mustExecute()) {
|
||||
App::AutoTransaction trans("Recompute");
|
||||
Command::doCommand(Command::Doc,"App.getDocument(\"%s\").recompute()",doc->getName());
|
||||
}
|
||||
|
||||
Command::doCommand(Command::Doc,"App.getDocument(\"%s\").save()",doc->getName());
|
||||
auto gdoc = Application::Instance->getDocument(doc);
|
||||
if(gdoc) gdoc->setModified(false);
|
||||
if (gdoc)
|
||||
gdoc->setModified(false);
|
||||
}
|
||||
}
|
||||
catch (const Base::FileException& e) {
|
||||
int ret = QMessageBox::question(
|
||||
getMainWindow(),
|
||||
QObject::tr("Could not save document"),
|
||||
QObject::tr("There was an issue trying to save the file. "
|
||||
"This may be because some of the parent folders do not exist, "
|
||||
"or you do not have sufficient permissions, "
|
||||
"or for other reasons. Error details:\n\n\"%1\"\n\n"
|
||||
"Would you like to save the file with a different name?")
|
||||
.arg(QString::fromUtf8(e.what())),
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
if (ret == QMessageBox::No) {
|
||||
// TODO: Understand what exactly is supposed to be returned here
|
||||
getMainWindow()->showMessage(QObject::tr("Saving aborted"), 2000);
|
||||
return false;
|
||||
} else if (ret == QMessageBox::Yes) {
|
||||
return saveAs();
|
||||
}
|
||||
e.ReportException();
|
||||
return askIfSavingFailed(QString::fromUtf8(e.what()));
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::critical(getMainWindow(), QObject::tr("Saving document failed"),
|
||||
@@ -1198,6 +1216,7 @@ bool Document::saveAs(void)
|
||||
QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe),
|
||||
QString::fromUtf8(getDocument()->FileName.getValue()),
|
||||
QString::fromLatin1("%1 %2 (*.FCStd)").arg(exe).arg(QObject::tr("Document")));
|
||||
|
||||
if (!fn.isEmpty()) {
|
||||
QFileInfo fi;
|
||||
fi.setFile(fn);
|
||||
@@ -1217,23 +1236,8 @@ bool Document::saveAs(void)
|
||||
getMainWindow()->appendRecentFile(fi.filePath());
|
||||
}
|
||||
catch (const Base::FileException& e) {
|
||||
int ret = QMessageBox::question(
|
||||
getMainWindow(),
|
||||
QObject::tr("Could not save document"),
|
||||
QObject::tr("There was an issue trying to save the file. "
|
||||
"This may be because some of the parent folders do not exist, "
|
||||
"or you do not have sufficient permissions, "
|
||||
"or for other reasons. Error details:\n\n\"%1\"\n\n"
|
||||
"Would you like to save the file with a different name?")
|
||||
.arg(QString::fromUtf8(e.what())),
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
if (ret == QMessageBox::No) {
|
||||
// TODO: Understand what exactly is supposed to be returned here
|
||||
getMainWindow()->showMessage(QObject::tr("Saving aborted"), 2000);
|
||||
return false;
|
||||
} else if (ret == QMessageBox::Yes) {
|
||||
return saveAs();
|
||||
}
|
||||
e.ReportException();
|
||||
return askIfSavingFailed(QString::fromUtf8(e.what()));
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::critical(getMainWindow(), QObject::tr("Saving document failed"),
|
||||
@@ -1495,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)
|
||||
|
||||
@@ -306,6 +306,8 @@ private:
|
||||
|
||||
/// Check other documents for the same transaction ID
|
||||
bool checkTransactionID(bool undo, int iSteps);
|
||||
/// Ask for user interaction if saving has failed
|
||||
bool askIfSavingFailed(const QString&);
|
||||
|
||||
struct DocumentP* d;
|
||||
static int _iDocCount;
|
||||
|
||||
@@ -274,6 +274,11 @@ public:
|
||||
bool operator!= (const WeakPtrT<T>& p) const {
|
||||
return ptr != p.ptr;
|
||||
}
|
||||
/*! Get a pointer to the object or 0 if it doesn't exist any more. */
|
||||
T* get() const noexcept
|
||||
{
|
||||
return ptr.get<T>();
|
||||
}
|
||||
|
||||
private:
|
||||
// disable
|
||||
|
||||
+111
-32
@@ -60,6 +60,7 @@
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <boost/interprocess/sync/file_lock.hpp>
|
||||
@@ -68,6 +69,7 @@ FC_LOG_LEVEL_INIT("Gui",true,true)
|
||||
|
||||
using namespace Gui;
|
||||
using namespace Gui::Dialog;
|
||||
namespace sp = std::placeholders;
|
||||
|
||||
// taken from the script doctools.py
|
||||
std::string DocumentRecovery::doctools =
|
||||
@@ -553,41 +555,20 @@ void DocumentRecovery::on_buttonCleanup_clicked()
|
||||
d_ptr->ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
d_ptr->ui.buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(true);
|
||||
|
||||
QDir tmp = QString::fromUtf8(App::Application::getTempPath().c_str());
|
||||
tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock"));
|
||||
tmp.setFilter(QDir::Files);
|
||||
DocumentRecoveryHandler handler;
|
||||
handler.checkForPreviousCrashes(std::bind(&DocumentRecovery::cleanup, this, sp::_1, sp::_2, sp::_3));
|
||||
QMessageBox::information(this, tr("Finished"), tr("Transient directories deleted."));
|
||||
}
|
||||
|
||||
QString exeName = QString::fromLatin1(App::GetApplication().getExecutableName());
|
||||
QList<QFileInfo> locks = tmp.entryInfoList();
|
||||
for (QList<QFileInfo>::iterator it = locks.begin(); it != locks.end(); ++it) {
|
||||
QString bn = it->baseName();
|
||||
// ignore the lock file for this instance
|
||||
QString pid = QString::number(QCoreApplication::applicationPid());
|
||||
if (bn.startsWith(exeName) && bn.indexOf(pid) < 0) {
|
||||
QString fn = it->absoluteFilePath();
|
||||
boost::interprocess::file_lock flock((const char*)fn.toLocal8Bit());
|
||||
if (flock.try_lock()) {
|
||||
// OK, this file is a leftover from a previous crash
|
||||
QString crashed_pid = bn.mid(exeName.length()+1);
|
||||
// search for transient directories with this PID
|
||||
QString filter;
|
||||
QTextStream str(&filter);
|
||||
str << exeName << "_Doc_*_" << crashed_pid;
|
||||
tmp.setNameFilters(QStringList() << filter);
|
||||
tmp.setFilter(QDir::Dirs);
|
||||
QList<QFileInfo> dirs = tmp.entryInfoList();
|
||||
if (!dirs.isEmpty()) {
|
||||
for (QList<QFileInfo>::iterator jt = dirs.begin(); jt != dirs.end(); ++jt) {
|
||||
clearDirectory(*jt);
|
||||
tmp.rmdir(jt->fileName());
|
||||
}
|
||||
}
|
||||
tmp.remove(it->fileName());
|
||||
}
|
||||
void DocumentRecovery::cleanup(QDir& tmp, const QList<QFileInfo>& dirs, const QString& lockFile)
|
||||
{
|
||||
if (!dirs.isEmpty()) {
|
||||
for (QList<QFileInfo>::const_iterator jt = dirs.cbegin(); jt != dirs.cend(); ++jt) {
|
||||
clearDirectory(*jt);
|
||||
tmp.rmdir(jt->fileName());
|
||||
}
|
||||
}
|
||||
|
||||
QMessageBox::information(this, tr("Finished"), tr("Transient directories deleted."));
|
||||
tmp.remove(lockFile);
|
||||
}
|
||||
|
||||
void DocumentRecovery::clearDirectory(const QFileInfo& dir)
|
||||
@@ -613,4 +594,102 @@ void DocumentRecovery::clearDirectory(const QFileInfo& dir)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void DocumentRecoveryFinder::checkForPreviousCrashes()
|
||||
{
|
||||
DocumentRecoveryHandler handler;
|
||||
handler.checkForPreviousCrashes(std::bind(&DocumentRecoveryFinder::checkDocumentDirs, this, sp::_1, sp::_2, sp::_3));
|
||||
|
||||
showRecoveryDialogIfNeeded();
|
||||
}
|
||||
|
||||
void DocumentRecoveryFinder::checkDocumentDirs(QDir& tmp, const QList<QFileInfo>& dirs, const QString& fn)
|
||||
{
|
||||
if (dirs.isEmpty()) {
|
||||
// delete the lock file immediately if no transient directories are related
|
||||
tmp.remove(fn);
|
||||
}
|
||||
else {
|
||||
int countDeletedDocs = 0;
|
||||
QString recovery_files = QString::fromLatin1("fc_recovery_files");
|
||||
for (QList<QFileInfo>::const_iterator it = dirs.cbegin(); it != dirs.cend(); ++it) {
|
||||
QDir doc_dir(it->absoluteFilePath());
|
||||
doc_dir.setFilter(QDir::NoDotAndDotDot|QDir::AllEntries);
|
||||
uint entries = doc_dir.entryList().count();
|
||||
if (entries == 0) {
|
||||
// in this case we can delete the transient directory because
|
||||
// we cannot do anything
|
||||
if (tmp.rmdir(it->filePath()))
|
||||
countDeletedDocs++;
|
||||
}
|
||||
// search for the existence of a recovery file
|
||||
else if (doc_dir.exists(QLatin1String("fc_recovery_file.xml"))) {
|
||||
// store the transient directory in case it's not empty
|
||||
restoreDocFiles << *it;
|
||||
}
|
||||
// search for the 'fc_recovery_files' sub-directory and check that it's the only entry
|
||||
else if (entries == 1 && doc_dir.exists(recovery_files)) {
|
||||
// if the sub-directory is empty delete the transient directory
|
||||
QDir rec_dir(doc_dir.absoluteFilePath(recovery_files));
|
||||
rec_dir.setFilter(QDir::NoDotAndDotDot|QDir::AllEntries);
|
||||
if (rec_dir.entryList().isEmpty()) {
|
||||
doc_dir.rmdir(recovery_files);
|
||||
if (tmp.rmdir(it->filePath()))
|
||||
countDeletedDocs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// all directories corresponding to the lock file have been deleted
|
||||
// so delete the lock file, too
|
||||
if (countDeletedDocs == dirs.size()) {
|
||||
tmp.remove(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentRecoveryFinder::showRecoveryDialogIfNeeded()
|
||||
{
|
||||
if (!restoreDocFiles.isEmpty()) {
|
||||
Gui::Dialog::DocumentRecovery dlg(restoreDocFiles, Gui::getMainWindow());
|
||||
if (dlg.foundDocuments())
|
||||
dlg.exec();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void DocumentRecoveryHandler::checkForPreviousCrashes(const std::function<void(QDir&, const QList<QFileInfo>&, const QString&)> & callableFunc) const
|
||||
{
|
||||
QDir tmp = QString::fromUtf8(App::Application::getTempPath().c_str());
|
||||
tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock"));
|
||||
tmp.setFilter(QDir::Files);
|
||||
|
||||
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();
|
||||
// ignore the lock file for this instance
|
||||
QString pid = QString::number(QCoreApplication::applicationPid());
|
||||
if (bn.startsWith(exeName) && bn.indexOf(pid) < 0) {
|
||||
QString fn = it->absoluteFilePath();
|
||||
boost::interprocess::file_lock flock((const char*)fn.toLocal8Bit());
|
||||
if (flock.try_lock()) {
|
||||
// OK, this file is a leftover from a previous crash
|
||||
QString crashed_pid = bn.mid(exeName.length()+1);
|
||||
// search for transient directories with this PID
|
||||
QString filter;
|
||||
QTextStream str(&filter);
|
||||
str << exeName << "_Doc_*_" << crashed_pid;
|
||||
tmp.setNameFilters(QStringList() << filter);
|
||||
tmp.setFilter(QDir::Dirs);
|
||||
QList<QFileInfo> dirs = tmp.entryInfoList();
|
||||
|
||||
callableFunc(tmp, dirs, it->fileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DocumentRecovery.cpp"
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QList>
|
||||
#include <QFileInfo>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace Gui { namespace Dialog {
|
||||
|
||||
@@ -53,6 +54,7 @@ protected:
|
||||
void contextMenuEvent(QContextMenuEvent*);
|
||||
QString createProjectFile(const QString&);
|
||||
void clearDirectory(const QFileInfo&);
|
||||
void cleanup(QDir&, const QList<QFileInfo>&, const QString&);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void on_buttonCleanup_clicked();
|
||||
@@ -65,6 +67,23 @@ private:
|
||||
Q_DECLARE_PRIVATE(DocumentRecovery)
|
||||
};
|
||||
|
||||
class DocumentRecoveryFinder {
|
||||
public:
|
||||
void checkForPreviousCrashes();
|
||||
|
||||
private:
|
||||
void checkDocumentDirs(QDir&, const QList<QFileInfo>&, const QString&);
|
||||
void showRecoveryDialogIfNeeded();
|
||||
|
||||
private:
|
||||
QList<QFileInfo> restoreDocFiles;
|
||||
};
|
||||
|
||||
class DocumentRecoveryHandler {
|
||||
public:
|
||||
void checkForPreviousCrashes(const std::function<void(QDir&, const QList<QFileInfo>&, const QString&)> & callableFunc) const;
|
||||
};
|
||||
|
||||
} //namespace Dialog
|
||||
|
||||
} //namespace Gui
|
||||
|
||||
@@ -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")
|
||||
|
||||
+188
-1
@@ -25,9 +25,12 @@
|
||||
#ifndef _PreComp_
|
||||
# include <QAbstractTextDocumentLayout>
|
||||
# include <QApplication>
|
||||
# include <QCheckBox>
|
||||
# include <QClipboard>
|
||||
# include <QDateTime>
|
||||
# include <QHBoxLayout>
|
||||
# include <QVBoxLayout>
|
||||
# include <QLineEdit>
|
||||
# include <QMessageBox>
|
||||
# include <QPainter>
|
||||
# include <QPrinter>
|
||||
@@ -35,10 +38,15 @@
|
||||
# include <QScrollBar>
|
||||
# include <QPlainTextEdit>
|
||||
# include <QPrintPreviewDialog>
|
||||
# include <QSpacerItem>
|
||||
# include <QStyle>
|
||||
# include <QTextBlock>
|
||||
# include <QTextCodec>
|
||||
# include <QTextCursor>
|
||||
# include <QTextDocument>
|
||||
# include <QTextStream>
|
||||
# include <QTimer>
|
||||
# include <QToolButton>
|
||||
#endif
|
||||
|
||||
#include "EditorView.h"
|
||||
@@ -59,6 +67,7 @@ namespace Gui {
|
||||
class EditorViewP {
|
||||
public:
|
||||
QPlainTextEdit* textEdit;
|
||||
SearchBar* searchBar;
|
||||
QString fileName;
|
||||
EditorView::DisplayName displayName;
|
||||
QTimer* activityTimer;
|
||||
@@ -90,19 +99,28 @@ EditorView::EditorView(QPlainTextEdit* editor, QWidget* parent)
|
||||
d->textEdit = editor;
|
||||
d->textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
|
||||
d->searchBar = new SearchBar();
|
||||
d->searchBar->setEditor(editor);
|
||||
|
||||
// update editor actions on request
|
||||
Gui::MainWindow* mw = Gui::getMainWindow();
|
||||
connect(editor, SIGNAL(undoAvailable(bool)), mw, SLOT(updateEditorActions()));
|
||||
connect(editor, SIGNAL(redoAvailable(bool)), mw, SLOT(updateEditorActions()));
|
||||
connect(editor, SIGNAL(copyAvailable(bool)), mw, SLOT(updateEditorActions()));
|
||||
|
||||
connect(editor, SIGNAL(showSearchBar()), d->searchBar, SLOT(activate()));
|
||||
connect(editor, SIGNAL(findNext()), d->searchBar, SLOT(findNext()));
|
||||
connect(editor, SIGNAL(findPrevious()), d->searchBar, SLOT(findPrevious()));
|
||||
|
||||
// Create the layout containing the workspace and a tab bar
|
||||
QFrame* hbox = new QFrame(this);
|
||||
hbox->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->setMargin(1);
|
||||
layout->addWidget(d->textEdit);
|
||||
layout->addWidget(d->searchBar);
|
||||
d->textEdit->setParent(hbox);
|
||||
d->searchBar->setParent(hbox);
|
||||
hbox->setLayout(layout);
|
||||
setCentralWidget(hbox);
|
||||
|
||||
@@ -650,4 +668,173 @@ void PythonEditorView::hideDebugMarker()
|
||||
_pye->hideDebugMarker();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
SearchBar::SearchBar(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, textEditor(nullptr)
|
||||
{
|
||||
horizontalLayout = new QHBoxLayout(this);
|
||||
horizontalLayout->setSpacing(3);
|
||||
|
||||
closeButton = new QToolButton(this);
|
||||
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
|
||||
closeButton->setAutoRaise(true);
|
||||
connect(closeButton, &QToolButton::clicked, this, &SearchBar::deactivate);
|
||||
|
||||
horizontalLayout->addWidget(closeButton);
|
||||
|
||||
searchText = new QLineEdit(this);
|
||||
searchText->setClearButtonEnabled(true);
|
||||
horizontalLayout->addWidget(searchText);
|
||||
connect(searchText, &QLineEdit::returnPressed, this, &SearchBar::findNext);
|
||||
connect(searchText, &QLineEdit::textChanged, this, &SearchBar::findCurrent);
|
||||
connect(searchText, &QLineEdit::textChanged, this, &SearchBar::updateButtons);
|
||||
|
||||
prevButton = new QToolButton(this);
|
||||
prevButton->setIcon(style()->standardIcon(QStyle::SP_ArrowBack));
|
||||
prevButton->setAutoRaise(true);
|
||||
prevButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
horizontalLayout->addWidget(prevButton);
|
||||
connect(prevButton, &QToolButton::clicked, this, &SearchBar::findPrevious);
|
||||
|
||||
nextButton = new QToolButton(this);
|
||||
nextButton->setIcon(style()->standardIcon(QStyle::SP_ArrowForward));
|
||||
nextButton->setAutoRaise(true);
|
||||
nextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
horizontalLayout->addWidget(nextButton);
|
||||
connect(nextButton, &QToolButton::clicked, this, &SearchBar::findNext);
|
||||
|
||||
matchCase = new QCheckBox(this);
|
||||
horizontalLayout->addWidget(matchCase);
|
||||
connect(matchCase, &QCheckBox::toggled, this, &SearchBar::findCurrent);
|
||||
|
||||
matchWord = new QCheckBox(this);
|
||||
horizontalLayout->addWidget(matchWord);
|
||||
connect(matchWord, &QCheckBox::toggled, this, &SearchBar::findCurrent);
|
||||
|
||||
horizontalSpacer = new QSpacerItem(192, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout->addItem(horizontalSpacer);
|
||||
|
||||
retranslateUi();
|
||||
|
||||
setMinimumWidth(minimumSizeHint().width());
|
||||
updateButtons();
|
||||
hide();
|
||||
}
|
||||
|
||||
void SearchBar::setEditor(QPlainTextEdit* textEdit)
|
||||
{
|
||||
textEditor = textEdit;
|
||||
}
|
||||
|
||||
void SearchBar::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void SearchBar::retranslateUi()
|
||||
{
|
||||
prevButton->setText(tr("Previous"));
|
||||
nextButton->setText(tr("Next"));
|
||||
matchCase->setText(tr("Case sensitive"));
|
||||
matchWord->setText(tr("Whole words"));
|
||||
}
|
||||
|
||||
void SearchBar::activate()
|
||||
{
|
||||
show();
|
||||
searchText->selectAll();
|
||||
searchText->setFocus(Qt::ShortcutFocusReason);
|
||||
}
|
||||
|
||||
void SearchBar::deactivate()
|
||||
{
|
||||
if (textEditor)
|
||||
textEditor->setFocus();
|
||||
hide();
|
||||
}
|
||||
|
||||
void SearchBar::findPrevious()
|
||||
{
|
||||
findText(true, false, searchText->text());
|
||||
}
|
||||
|
||||
void SearchBar::findNext()
|
||||
{
|
||||
findText(true, true, searchText->text());
|
||||
}
|
||||
|
||||
void SearchBar::findCurrent()
|
||||
{
|
||||
findText(false, true, searchText->text());
|
||||
}
|
||||
|
||||
void SearchBar::findText(bool skip, bool next, const QString& str)
|
||||
{
|
||||
if (!textEditor)
|
||||
return;
|
||||
|
||||
QTextCursor cursor = textEditor->textCursor();
|
||||
QTextDocument *doc = textEditor->document();
|
||||
if (!doc || cursor.isNull())
|
||||
return;
|
||||
|
||||
if (cursor.hasSelection())
|
||||
cursor.setPosition((skip && next) ? cursor.position() : cursor.anchor());
|
||||
|
||||
bool found = true;
|
||||
QTextCursor newCursor = cursor;
|
||||
if (!str.isEmpty()) {
|
||||
QTextDocument::FindFlags options;
|
||||
if (!next)
|
||||
options |= QTextDocument::FindBackward;
|
||||
if (matchCase->isChecked())
|
||||
options |= QTextDocument::FindCaseSensitively;
|
||||
if (matchWord->isChecked())
|
||||
options |= QTextDocument::FindWholeWords;
|
||||
|
||||
newCursor = doc->find(str, cursor, options);
|
||||
if (newCursor.isNull()) {
|
||||
QTextCursor ac(doc);
|
||||
ac.movePosition(options & QTextDocument::FindBackward ? QTextCursor::End : QTextCursor::Start);
|
||||
newCursor = doc->find(str, ac, options);
|
||||
if (newCursor.isNull()) {
|
||||
found = false;
|
||||
newCursor = cursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isVisible())
|
||||
show();
|
||||
|
||||
textEditor->setTextCursor(newCursor);
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Active, QPalette::Base, found ? Qt::white : QColor(255, 80, 80));
|
||||
searchText->setPalette(palette);
|
||||
}
|
||||
|
||||
void SearchBar::updateButtons()
|
||||
{
|
||||
bool empty = searchText->text().isEmpty();
|
||||
prevButton->setDisabled(empty);
|
||||
nextButton->setDisabled(empty);
|
||||
}
|
||||
|
||||
void SearchBar::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
#include "moc_EditorView.cpp"
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPlainTextEdit;
|
||||
class QPrinter;
|
||||
class QHBoxLayout;
|
||||
class QToolButton;
|
||||
class QCheckBox;
|
||||
class QSpacerItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Gui {
|
||||
@@ -132,6 +136,43 @@ private:
|
||||
PythonEditor* _pye;
|
||||
};
|
||||
|
||||
class SearchBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SearchBar(QWidget* parent = nullptr);
|
||||
|
||||
void setEditor(QPlainTextEdit *textEdit);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
void changeEvent(QEvent*);
|
||||
|
||||
public Q_SLOTS:
|
||||
void activate();
|
||||
void deactivate();
|
||||
void findPrevious();
|
||||
void findNext();
|
||||
void findCurrent();
|
||||
|
||||
private:
|
||||
void retranslateUi();
|
||||
void findText(bool skip, bool next, const QString& str);
|
||||
void updateButtons();
|
||||
|
||||
private:
|
||||
QPlainTextEdit* textEditor;
|
||||
QHBoxLayout* horizontalLayout;
|
||||
QSpacerItem* horizontalSpacer;
|
||||
QToolButton* closeButton;
|
||||
QLineEdit* searchText;
|
||||
QToolButton* prevButton;
|
||||
QToolButton* nextButton;
|
||||
QCheckBox* matchCase;
|
||||
QCheckBox* matchWord;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_EDITORVIEW_H
|
||||
|
||||
@@ -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) |
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -241,6 +241,34 @@ void MDIView::printPreview()
|
||||
std::cerr << "Printing preview not implemented for " << this->metaObject()->className() << std::endl;
|
||||
}
|
||||
|
||||
QStringList MDIView::undoActions() const
|
||||
{
|
||||
QStringList actions;
|
||||
Gui::Document* doc = getGuiDocument();
|
||||
if (doc) {
|
||||
std::vector<std::string> vecUndos = doc->getUndoVector();
|
||||
for (std::vector<std::string>::iterator i = vecUndos.begin(); i != vecUndos.end(); ++i) {
|
||||
actions << QCoreApplication::translate("Command", i->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
QStringList MDIView::redoActions() const
|
||||
{
|
||||
QStringList actions;
|
||||
Gui::Document* doc = getGuiDocument();
|
||||
if (doc) {
|
||||
std::vector<std::string> vecRedos = doc->getRedoVector();
|
||||
for (std::vector<std::string>::iterator i = vecRedos.begin(); i != vecRedos.end(); ++i) {
|
||||
actions << QCoreApplication::translate("Command", i->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
QSize MDIView::minimumSizeHint () const
|
||||
{
|
||||
return QSize(400, 300);
|
||||
|
||||
@@ -95,6 +95,12 @@ public:
|
||||
virtual void printPreview();
|
||||
//@}
|
||||
|
||||
/** @name Undo/Redo actions */
|
||||
//@{
|
||||
virtual QStringList undoActions() const;
|
||||
virtual QStringList redoActions() const;
|
||||
//@}
|
||||
|
||||
QSize minimumSizeHint () const;
|
||||
|
||||
/// MDI view mode enum
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -34,6 +34,7 @@ Q_DECLARE_METATYPE(Base::Vector3d)
|
||||
Q_DECLARE_METATYPE(QList<Base::Vector3d>)
|
||||
Q_DECLARE_METATYPE(Base::Matrix4D)
|
||||
Q_DECLARE_METATYPE(Base::Placement)
|
||||
Q_DECLARE_METATYPE(Base::Rotation)
|
||||
Q_DECLARE_METATYPE(Base::Quantity)
|
||||
Q_DECLARE_METATYPE(QList<Base::Quantity>)
|
||||
Q_DECLARE_METATYPE(App::SubObjectT)
|
||||
|
||||
+148
-50
@@ -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;
|
||||
}
|
||||
|
||||
+46
-23
@@ -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,34 @@ public:
|
||||
|
||||
protected:
|
||||
SbBool processSoEvent(const SoEvent * const ev);
|
||||
};
|
||||
|
||||
private:
|
||||
SoMouseButtonEvent mouseDownConsumedEvent;
|
||||
class GuiExport OpenSCADNavigationStyle : public UserNavigationStyle {
|
||||
typedef UserNavigationStyle inherited;
|
||||
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
OpenSCADNavigationStyle();
|
||||
~OpenSCADNavigationStyle();
|
||||
const char* mouseButtons(ViewerMode);
|
||||
|
||||
protected:
|
||||
SbBool processSoEvent(const SoEvent * const ev);
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
/***************************************************************************
|
||||
* 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::OpenSCADNavigationStyle */
|
||||
|
||||
TYPESYSTEM_SOURCE(Gui::OpenSCADNavigationStyle, Gui::UserNavigationStyle)
|
||||
|
||||
OpenSCADNavigationStyle::OpenSCADNavigationStyle()
|
||||
{
|
||||
}
|
||||
|
||||
OpenSCADNavigationStyle::~OpenSCADNavigationStyle()
|
||||
{
|
||||
}
|
||||
|
||||
const char* OpenSCADNavigationStyle::mouseButtons(ViewerMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case NavigationStyle::SELECTION:
|
||||
return QT_TR_NOOP("Press left mouse button");
|
||||
case NavigationStyle::PANNING:
|
||||
return QT_TR_NOOP("Press right mouse button and move mouse");
|
||||
case NavigationStyle::DRAGGING:
|
||||
return QT_TR_NOOP("Press left mouse button and move mouse");
|
||||
case NavigationStyle::ZOOMING:
|
||||
return QT_TR_NOOP("Press middle mouse button or SHIFT and right mouse button");
|
||||
default:
|
||||
return "No description";
|
||||
}
|
||||
}
|
||||
|
||||
SbBool OpenSCADNavigationStyle::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;
|
||||
|
||||
switch (button) {
|
||||
case SoMouseButtonEvent::BUTTON1:
|
||||
this->lockrecenter = true;
|
||||
this->button1down = press;
|
||||
if (press && (curmode == NavigationStyle::SEEK_WAIT_MODE)) {
|
||||
newmode = NavigationStyle::SEEK_MODE;
|
||||
this->seekToPoint(pos); // implicitly calls interactiveCountInc()
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && (curmode == NavigationStyle::ZOOMING)) {
|
||||
newmode = NavigationStyle::IDLE;
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && (curmode == NavigationStyle::DRAGGING)) {
|
||||
this->setViewing(false);
|
||||
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->lockrecenter = true;
|
||||
this->button2down = press;
|
||||
if (!viewer->isEditing()) {
|
||||
// If we are in zoom or pan mode ignore RMB events otherwise
|
||||
// the canvas doesn't get any release events
|
||||
if (curmode != NavigationStyle::ZOOMING &&
|
||||
curmode != NavigationStyle::PANNING &&
|
||||
curmode != NavigationStyle::DRAGGING) {
|
||||
if (this->isPopupMenuEnabled()) {
|
||||
if (!press) { // release right mouse button
|
||||
this->openPopupMenu(event->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Alternative way of rotating & zooming
|
||||
if (press && (curmode == NavigationStyle::PANNING ||
|
||||
curmode == NavigationStyle::ZOOMING)) {
|
||||
newmode = NavigationStyle::DRAGGING;
|
||||
saveCursorPosition(ev);
|
||||
this->centerTime = ev->getTime();
|
||||
processed = true;
|
||||
}
|
||||
else if (!press && (curmode == NavigationStyle::DRAGGING)) {
|
||||
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());
|
||||
this->lockrecenter = false;
|
||||
}
|
||||
else if (curmode == NavigationStyle::PANNING) {
|
||||
newmode = NavigationStyle::IDLE;
|
||||
processed = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse Movement handling
|
||||
if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) {
|
||||
this->lockrecenter = true;
|
||||
const SoLocation2Event * const event = (const SoLocation2Event *) ev;
|
||||
if (curmode == NavigationStyle::SELECTION) {
|
||||
newmode = NavigationStyle::DRAGGING;
|
||||
saveCursorPosition(ev);
|
||||
this->centerTime = ev->getTime();
|
||||
}
|
||||
else if (curmode == NavigationStyle::ZOOMING) {
|
||||
// OpenSCAD uses vertical mouse position, not horizontal
|
||||
// this->zoomByCursor(posn, prevnormalized);
|
||||
float value = (posn[1] - prevnormalized[1]) * 10.0f;
|
||||
if (this->invertZoom)
|
||||
value = -value;
|
||||
zoom(viewer->getSoRenderManager()->getCamera(), value);
|
||||
processed = true;
|
||||
}
|
||||
else 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:
|
||||
if (newmode != NavigationStyle::DRAGGING)
|
||||
newmode = NavigationStyle::SELECTION;
|
||||
break;
|
||||
case BUTTON2DOWN:
|
||||
newmode = NavigationStyle::PANNING;
|
||||
break;
|
||||
case BUTTON3DOWN:
|
||||
case SHIFTDOWN|BUTTON2DOWN:
|
||||
case SHIFTDOWN|BUTTON3DOWN:
|
||||
newmode = NavigationStyle::ZOOMING;
|
||||
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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
ContextMenu(QuarterWidget * quarterwidget);
|
||||
~ContextMenu();
|
||||
|
||||
QMenu * getMenu(void) const;
|
||||
QMenu * getMenu() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void changeRenderMode(QAction * action);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ using namespace SIM::Coin3D::Quarter;
|
||||
devices.
|
||||
*/
|
||||
|
||||
InputDevice::InputDevice(void) : quarter(nullptr)
|
||||
InputDevice::InputDevice() : quarter(nullptr)
|
||||
{
|
||||
this->mousepos = SbVec2s(0, 0);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ NativeEvent::getEvent() const
|
||||
NativeEvent::NativeEvent()
|
||||
: QEvent(QEvent::User)
|
||||
{
|
||||
this->rawevent = NULL;
|
||||
this->rawevent = nullptr;
|
||||
}
|
||||
|
||||
#endif // !HAVE_SPACENAV_LIB
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -47,7 +47,7 @@ class QuarterWidget;
|
||||
class QUARTER_DLL_API InputDevice {
|
||||
public:
|
||||
InputDevice(QuarterWidget * quarter);
|
||||
InputDevice(void);
|
||||
InputDevice();
|
||||
virtual ~InputDevice() {}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -161,6 +161,7 @@ void Gui::SoFCDB::init()
|
||||
PropertyDirectionItem ::init();
|
||||
PropertyMatrixItem ::init();
|
||||
PropertyPlacementItem ::init();
|
||||
PropertyRotationItem ::init();
|
||||
PropertyEnumItem ::init();
|
||||
PropertyStringListItem ::init();
|
||||
PropertyFloatListItem ::init();
|
||||
@@ -184,6 +185,8 @@ void Gui::SoFCDB::init()
|
||||
TouchpadNavigationStyle ::init();
|
||||
GestureNavigationStyle ::init();
|
||||
OpenCascadeNavigationStyle ::init();
|
||||
OpenSCADNavigationStyle ::init();
|
||||
TinkerCADNavigationStyle ::init();
|
||||
|
||||
GLGraphicsItem ::init();
|
||||
GLFlagWindow ::init();
|
||||
|
||||
@@ -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" ;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -53,8 +53,8 @@ public:
|
||||
|
||||
QPlainTextEdit* getEditor() const { return editor; }
|
||||
App::TextDocument* getTextObject() const { return textDocument; }
|
||||
QStringList undoActions() const;
|
||||
QStringList redoActions() const;
|
||||
QStringList undoActions() const override;
|
||||
QStringList redoActions() const override;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent*) override;
|
||||
|
||||
@@ -48,6 +48,21 @@ TextEdit::TextEdit(QWidget* parent)
|
||||
shortcut->setKey(Qt::CTRL+Qt::Key_Space);
|
||||
shortcut->setContext(Qt::WidgetShortcut);
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(complete()));
|
||||
|
||||
QShortcut* shortcutFind = new QShortcut(this);
|
||||
shortcutFind->setKey(QKeySequence::Find);
|
||||
shortcutFind->setContext(Qt::WidgetShortcut);
|
||||
connect(shortcutFind, SIGNAL(activated()), this, SIGNAL(showSearchBar()));
|
||||
|
||||
QShortcut* shortcutNext = new QShortcut(this);
|
||||
shortcutNext->setKey(QKeySequence::FindNext);
|
||||
shortcutNext->setContext(Qt::WidgetShortcut);
|
||||
connect(shortcutNext, SIGNAL(activated()), this, SIGNAL(findNext()));
|
||||
|
||||
QShortcut* shortcutPrev = new QShortcut(this);
|
||||
shortcutPrev->setKey(QKeySequence::FindPrevious);
|
||||
shortcutPrev->setContext(Qt::WidgetShortcut);
|
||||
connect(shortcutPrev, SIGNAL(activated()), this, SIGNAL(findPrevious()));
|
||||
}
|
||||
|
||||
/** Destroys the object and frees any allocated resources */
|
||||
|
||||
@@ -64,6 +64,11 @@ public:
|
||||
private Q_SLOTS:
|
||||
void complete();
|
||||
|
||||
Q_SIGNALS:
|
||||
void showSearchBar();
|
||||
void findNext();
|
||||
void findPrevious();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+98
-4
@@ -472,6 +472,10 @@ TreeWidget::TreeWidget(const char *name, QWidget* parent)
|
||||
connect(this->finishEditingAction, SIGNAL(triggered()),
|
||||
this, SLOT(onFinishEditing()));
|
||||
|
||||
this->selectDependentsAction = new QAction(this);
|
||||
connect(this->selectDependentsAction, SIGNAL(triggered()),
|
||||
this, SLOT(onSelectDependents()));
|
||||
|
||||
this->closeDocAction = new QAction(this);
|
||||
connect(this->closeDocAction, SIGNAL(triggered()),
|
||||
this, SLOT(onCloseDoc()));
|
||||
@@ -843,6 +847,7 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e)
|
||||
break;
|
||||
}
|
||||
}
|
||||
contextMenu.addAction(this->selectDependentsAction);
|
||||
this->skipRecomputeAction->setChecked(doc->testStatus(App::Document::SkipRecompute));
|
||||
contextMenu.addAction(this->skipRecomputeAction);
|
||||
this->allowPartialRecomputeAction->setChecked(doc->testStatus(App::Document::AllowPartialRecompute));
|
||||
@@ -857,24 +862,43 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e)
|
||||
DocumentObjectItem* objitem = static_cast<DocumentObjectItem*>
|
||||
(this->contextItem);
|
||||
|
||||
// check that the selection is not across several documents
|
||||
bool acrossDocuments = false;
|
||||
auto SelectedObjectsList = Selection().getCompleteSelection();
|
||||
// get the object's document as reference
|
||||
App::Document* doc = objitem->object()->getObject()->getDocument();
|
||||
for (auto it = SelectedObjectsList.begin(); it != SelectedObjectsList.end(); ++it) {
|
||||
if ((*it).pDoc != doc) {
|
||||
acrossDocuments = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
showHiddenAction->setChecked(doc->ShowHidden.getValue());
|
||||
contextMenu.addAction(this->showHiddenAction);
|
||||
|
||||
hideInTreeAction->setChecked(!objitem->object()->showInTree());
|
||||
contextMenu.addAction(this->hideInTreeAction);
|
||||
|
||||
if (objitem->object()->getObject()->isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()))
|
||||
contextMenu.addAction(this->createGroupAction);
|
||||
if (!acrossDocuments) { // is only sensible for selections within one document
|
||||
if (objitem->object()->getObject()->isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()))
|
||||
contextMenu.addAction(this->createGroupAction);
|
||||
// if there are dependent objects in the selection, add context menu to add them to selection
|
||||
if (CheckForDependents())
|
||||
contextMenu.addAction(this->selectDependentsAction);
|
||||
}
|
||||
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(this->markRecomputeAction);
|
||||
contextMenu.addAction(this->recomputeObjectAction);
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(this->relabelObjectAction);
|
||||
|
||||
// relabeling is only possible for a single selected document
|
||||
if (SelectedObjectsList.size() == 1)
|
||||
contextMenu.addAction(this->relabelObjectAction);
|
||||
|
||||
auto selItems = this->selectedItems();
|
||||
// if only one item is selected setup the edit menu
|
||||
// if only one item is selected, setup the edit menu
|
||||
if (selItems.size() == 1) {
|
||||
objitem->object()->setupContextMenu(&editMenu, this, SLOT(onStartEditing()));
|
||||
QList<QAction*> editAct = editMenu.actions();
|
||||
@@ -1037,6 +1061,73 @@ void TreeWidget::onFinishEditing()
|
||||
}
|
||||
}
|
||||
|
||||
// check if selection has dependent objects
|
||||
bool TreeWidget::CheckForDependents()
|
||||
{
|
||||
// if the selected object is a document
|
||||
if (this->contextItem && this->contextItem->type() == DocumentType) {
|
||||
return true;
|
||||
}
|
||||
// it can be an object
|
||||
else {
|
||||
QList<QTreeWidgetItem*> items = this->selectedItems();
|
||||
for (QList<QTreeWidgetItem*>::iterator it = items.begin(); it != items.end(); ++it) {
|
||||
if ((*it)->type() == ObjectType) {
|
||||
DocumentObjectItem* objitem = static_cast<DocumentObjectItem*>(*it);
|
||||
App::DocumentObject* obj = objitem->object()->getObject();
|
||||
// get dependents
|
||||
auto subObjectList = obj->getOutList();
|
||||
if (subObjectList.size() > 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// adds an App::DocumentObject* and its dependent objects to the selection
|
||||
void TreeWidget::addDependentToSelection(App::Document* doc, App::DocumentObject* docObject)
|
||||
{
|
||||
// add the docObject to the selection
|
||||
Selection().addSelection(doc->getName(), docObject->getNameInDocument());
|
||||
// get the dependent
|
||||
auto subObjectList = docObject->getOutList();
|
||||
// the dependent can in turn have dependents, thus add them recursively
|
||||
for (auto itDepend = subObjectList.begin(); itDepend != subObjectList.end(); ++itDepend)
|
||||
addDependentToSelection(doc, (*itDepend));
|
||||
}
|
||||
|
||||
// add dependents of the selected tree object to selection
|
||||
void TreeWidget::onSelectDependents()
|
||||
{
|
||||
// We only have this context menu entry if the selection is within one document but it
|
||||
// might be not the active document. Therefore get the document not here but later by casting.
|
||||
App::Document* doc;
|
||||
|
||||
// if the selected object is a document
|
||||
if (this->contextItem && this->contextItem->type() == DocumentType) {
|
||||
DocumentItem* docitem = static_cast<DocumentItem*>(this->contextItem);
|
||||
doc = docitem->document()->getDocument();
|
||||
std::vector<App::DocumentObject*> obj = doc->getObjects();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it)
|
||||
Selection().addSelection(doc->getName(), (*it)->getNameInDocument());
|
||||
}
|
||||
// it can be an object
|
||||
else {
|
||||
QList<QTreeWidgetItem*> items = this->selectedItems();
|
||||
for (QList<QTreeWidgetItem*>::iterator it = items.begin(); it != items.end(); ++it) {
|
||||
if ((*it)->type() == ObjectType) {
|
||||
DocumentObjectItem* objitem = static_cast<DocumentObjectItem*>(*it);
|
||||
doc = objitem->object()->getObject()->getDocument();
|
||||
App::DocumentObject* obj = objitem->object()->getObject();
|
||||
// the dependents can also have dependents, thus add them recursively via a separate void
|
||||
addDependentToSelection(doc, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TreeWidget::onSkipRecompute(bool on)
|
||||
{
|
||||
// if a document item is selected then touch all objects
|
||||
@@ -2666,6 +2757,9 @@ void TreeWidget::setupText()
|
||||
this->finishEditingAction->setText(tr("Finish editing"));
|
||||
this->finishEditingAction->setStatusTip(tr("Finish editing object"));
|
||||
|
||||
this->selectDependentsAction->setText(tr("Add dependent objects to selection"));
|
||||
this->selectDependentsAction->setStatusTip(tr("Adds all dependent objects to the selection"));
|
||||
|
||||
this->closeDocAction->setText(tr("Close document"));
|
||||
this->closeDocAction->setStatusTip(tr("Close the document"));
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@ protected Q_SLOTS:
|
||||
void onActivateDocument(QAction*);
|
||||
void onStartEditing();
|
||||
void onFinishEditing();
|
||||
void onSelectDependents();
|
||||
void onSkipRecompute(bool on);
|
||||
void onAllowPartialRecompute(bool on);
|
||||
void onReloadDoc();
|
||||
@@ -208,10 +209,14 @@ private:
|
||||
void updateChildren(App::DocumentObject *obj,
|
||||
const std::set<DocumentObjectDataPtr> &data, bool output, bool force);
|
||||
|
||||
bool CheckForDependents();
|
||||
void addDependentToSelection(App::Document* doc, App::DocumentObject* docObject);
|
||||
|
||||
private:
|
||||
QAction* createGroupAction;
|
||||
QAction* relabelObjectAction;
|
||||
QAction* finishEditingAction;
|
||||
QAction* selectDependentsAction;
|
||||
QAction* skipRecomputeAction;
|
||||
QAction* allowPartialRecomputeAction;
|
||||
QAction* markRecomputeAction;
|
||||
|
||||
+72
-49
@@ -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()");
|
||||
@@ -243,7 +245,7 @@ PyObject *View3DInventorPy::method_varargs_ext_handler(PyObject *_self_and_name_
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
}
|
||||
@@ -307,7 +309,7 @@ Py::Object View3DInventorPy::message(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
return Py::None();
|
||||
@@ -328,7 +330,7 @@ Py::Object View3DInventorPy::fitAll(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
return Py::None();
|
||||
@@ -474,7 +476,7 @@ Py::Object View3DInventorPy::viewBottom(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -495,7 +497,7 @@ Py::Object View3DInventorPy::viewFront(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -516,7 +518,7 @@ Py::Object View3DInventorPy::viewLeft(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -537,7 +539,7 @@ Py::Object View3DInventorPy::viewRear(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -558,7 +560,7 @@ Py::Object View3DInventorPy::viewRight(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -579,7 +581,7 @@ Py::Object View3DInventorPy::viewTop(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -600,7 +602,7 @@ Py::Object View3DInventorPy::viewIsometric(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -621,7 +623,7 @@ Py::Object View3DInventorPy::viewDimetric(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -642,7 +644,7 @@ Py::Object View3DInventorPy::viewTrimetric(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -733,7 +735,7 @@ Py::Object View3DInventorPy::viewDefaultOrientation(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -759,7 +761,7 @@ Py::Object View3DInventorPy::viewRotateLeft(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -785,7 +787,7 @@ Py::Object View3DInventorPy::viewRotateRight(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -806,7 +808,7 @@ Py::Object View3DInventorPy::zoomIn(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -827,7 +829,7 @@ Py::Object View3DInventorPy::zoomOut(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
@@ -1073,7 +1092,7 @@ Py::Object View3DInventorPy::getCamera(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
}
|
||||
@@ -1092,7 +1111,7 @@ Py::Object View3DInventorPy::getViewDirection(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
}
|
||||
@@ -1126,7 +1145,7 @@ Py::Object View3DInventorPy::setViewDirection(const Py::Tuple& args)
|
||||
catch (const std::exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch(...) {
|
||||
catch (...) {
|
||||
throw Py::RuntimeError("Unknown C++ exception");
|
||||
}
|
||||
|
||||
@@ -1415,23 +1434,23 @@ Py::Object View3DInventorPy::getObjectInfo(const Py::Tuple& args)
|
||||
Gui::Document* doc = _view->getViewer()->getDocument();
|
||||
ViewProvider *vp = doc ? doc->getViewProviderByPathFromHead(Point->getPath())
|
||||
: _view->getViewer()->getViewProviderByPath(Point->getPath());
|
||||
if(vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
|
||||
if(!vp->isSelectable())
|
||||
if (vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
|
||||
if (!vp->isSelectable())
|
||||
return ret;
|
||||
ViewProviderDocumentObject* vpd = static_cast<ViewProviderDocumentObject*>(vp);
|
||||
if(vp->useNewSelectionModel()) {
|
||||
if (vp->useNewSelectionModel()) {
|
||||
std::string subname;
|
||||
if(!vp->getElementPicked(Point,subname))
|
||||
if (!vp->getElementPicked(Point,subname))
|
||||
return ret;
|
||||
auto obj = vpd->getObject();
|
||||
if(!obj)
|
||||
if (!obj)
|
||||
return ret;
|
||||
if(subname.size()) {
|
||||
if (subname.size()) {
|
||||
std::pair<std::string,std::string> elementName;
|
||||
auto sobj = App::GeoFeature::resolveElement(obj,subname.c_str(),elementName);
|
||||
if(!sobj)
|
||||
if (!sobj)
|
||||
return ret;
|
||||
if(sobj!=obj) {
|
||||
if (sobj != obj) {
|
||||
dict.setItem("ParentObject",Py::Object(obj->getPyObject(),true));
|
||||
dict.setItem("SubName",Py::String(subname));
|
||||
obj = sobj;
|
||||
@@ -1443,7 +1462,8 @@ Py::Object View3DInventorPy::getObjectInfo(const Py::Tuple& args)
|
||||
dict.setItem("Object",
|
||||
Py::String(obj->getNameInDocument()));
|
||||
dict.setItem("Component",Py::String(subname));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dict.setItem("Document",
|
||||
Py::String(vpd->getObject()->getDocument()->getName()));
|
||||
dict.setItem("Object",
|
||||
@@ -1530,19 +1550,19 @@ Py::Object View3DInventorPy::getObjectsInfo(const Py::Tuple& args)
|
||||
if(!vp->isSelectable())
|
||||
continue;
|
||||
ViewProviderDocumentObject* vpd = static_cast<ViewProviderDocumentObject*>(vp);
|
||||
if(vp->useNewSelectionModel()) {
|
||||
if (vp->useNewSelectionModel()) {
|
||||
std::string subname;
|
||||
if(!vp->getElementPicked(point,subname))
|
||||
if (!vp->getElementPicked(point,subname))
|
||||
continue;
|
||||
auto obj = vpd->getObject();
|
||||
if(!obj)
|
||||
if (!obj)
|
||||
continue;
|
||||
if(subname.size()) {
|
||||
if (subname.size()) {
|
||||
std::pair<std::string,std::string> elementName;
|
||||
auto sobj = App::GeoFeature::resolveElement(obj,subname.c_str(),elementName);
|
||||
if(!sobj)
|
||||
if (!sobj)
|
||||
continue;
|
||||
if(sobj!=obj) {
|
||||
if (sobj != obj) {
|
||||
dict.setItem("ParentObject",Py::Object(obj->getPyObject(),true));
|
||||
dict.setItem("SubName",Py::String(subname));
|
||||
obj = sobj;
|
||||
@@ -1554,7 +1574,8 @@ Py::Object View3DInventorPy::getObjectsInfo(const Py::Tuple& args)
|
||||
dict.setItem("Object",
|
||||
Py::String(obj->getNameInDocument()));
|
||||
dict.setItem("Component",Py::String(subname));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dict.setItem("Document",
|
||||
Py::String(vpd->getObject()->getDocument()->getName()));
|
||||
dict.setItem("Object",
|
||||
@@ -2492,21 +2513,23 @@ Py::Object View3DInventorPy::removeDraggerCallback(const Py::Tuple& args)
|
||||
|
||||
Py::Object View3DInventorPy::setActiveObject(const Py::Tuple& args)
|
||||
{
|
||||
PyObject* docObject = Py_None;
|
||||
char* name;
|
||||
PyObject* docObject = Py_None;
|
||||
char* name;
|
||||
char *subname = 0;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "s|Os", &name, &docObject, &subname))
|
||||
throw Py::Exception();
|
||||
throw Py::Exception();
|
||||
|
||||
if (docObject == Py_None)
|
||||
_view->setActiveObject(0, name);
|
||||
else{
|
||||
if(!PyObject_TypeCheck(docObject, &App::DocumentObjectPy::Type))
|
||||
if (docObject == Py_None) {
|
||||
_view->setActiveObject(0, name);
|
||||
}
|
||||
else {
|
||||
if (!PyObject_TypeCheck(docObject, &App::DocumentObjectPy::Type))
|
||||
throw Py::TypeError("Expect the second argument to be a document object or None");
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(docObject)->getDocumentObjectPtr();
|
||||
_view->setActiveObject(obj, name, subname);
|
||||
}
|
||||
return Py::None();
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(docObject)->getDocumentObjectPtr();
|
||||
_view->setActiveObject(obj, name, subname);
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
Py::Object View3DInventorPy::getActiveObject(const Py::Tuple& args)
|
||||
@@ -2519,10 +2542,10 @@ Py::Object View3DInventorPy::getActiveObject(const Py::Tuple& args)
|
||||
App::DocumentObject *parent = 0;
|
||||
std::string subname;
|
||||
App::DocumentObject* obj = _view->getActiveObject<App::DocumentObject*>(name,&parent,&subname);
|
||||
if(!obj)
|
||||
if (!obj)
|
||||
return Py::None();
|
||||
|
||||
if(PyObject_IsTrue(resolve))
|
||||
if (PyObject_IsTrue(resolve))
|
||||
return Py::asObject(obj->getPyObject());
|
||||
|
||||
return Py::TupleN(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user