3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 20:35:29 +02:00

Merge pull request from ctrlaltdavid/clipboard-dimensions

add Clipboard.getContentsDimensions() JavaScript method
This commit is contained in:
Brad Hefta-Gaub 2016-06-06 12:03:10 -07:00
commit b4721ec57e
4 changed files with 13 additions and 0 deletions

View file

@ -14,6 +14,10 @@
ClipboardScriptingInterface::ClipboardScriptingInterface() {
}
glm::vec3 ClipboardScriptingInterface::getContentsDimensions() {
return qApp->getEntityClipboard()->getContentsDimensions();
}
float ClipboardScriptingInterface::getClipboardContentsLargestDimension() {
return qApp->getEntityClipboard()->getContentsLargestDimension();
}

View file

@ -22,6 +22,7 @@ signals:
void readyToImport();
public slots:
glm::vec3 getContentsDimensions(); /// returns the overall dimensions of everything on the blipboard
float getClipboardContentsLargestDimension(); /// returns the largest dimension of everything on the clipboard
bool importEntities(const QString& filename);
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);

View file

@ -1284,6 +1284,7 @@ class ContentsDimensionOperator : public RecurseOctreeOperator {
public:
virtual bool preRecursion(OctreeElementPointer element);
virtual bool postRecursion(OctreeElementPointer element) { return true; }
glm::vec3 getDimensions() const { return _contentExtents.size(); }
float getLargestDimension() const { return _contentExtents.largestDimension(); }
private:
Extents _contentExtents;
@ -1295,6 +1296,12 @@ bool ContentsDimensionOperator::preRecursion(OctreeElementPointer element) {
return true;
}
glm::vec3 EntityTree::getContentsDimensions() {
ContentsDimensionOperator theOperator;
recurseTreeWithOperator(&theOperator);
return theOperator.getDimensions();
}
float EntityTree::getContentsLargestDimension() {
ContentsDimensionOperator theOperator;
recurseTreeWithOperator(&theOperator);

View file

@ -207,6 +207,7 @@ public:
bool skipThoseWithBadParents) override;
virtual bool readFromMap(QVariantMap& entityDescription) override;
glm::vec3 getContentsDimensions();
float getContentsLargestDimension();
virtual void resetEditStats() override {