#pragma once #include #include #include #include #include namespace VCtrl { //////////////////////////////////////////////////////////////////////////////// class FindByNameVisitor final : public osg::NodeVisitor { public: std::vector mNodes; QString mName; explicit FindByNameVisitor(const QString &name) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) , mName(name) {} void apply(osg::Node &node) override; }; //////////////////////////////////////////////////////////////////////////// class FindExactNameVisitor final : public osg::NodeVisitor { public: std::vector mNodes; std::set mNamesToSearch; explicit FindExactNameVisitor(const std::set &namesToSearch) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) , mNamesToSearch(namesToSearch) {} void apply(osg::Node &node) override; }; //////////////////////////////////////////////////////////////////////////// class SplitVisitor final : public osg::NodeVisitor { public: std::vector > _parts; std::vector _heights; SplitVisitor() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} void apply(osg::Group &node) override; }; //////////////////////////////////////////////////////////////////////////////// class FindRoomComponentsVisitor final : public osg::NodeVisitor { public: std::set mNamesFound; FindRoomComponentsVisitor() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} void apply(osg::Group &node) override; }; //////////////////////////////////////////////////////////////////////////////// class FindRoomNamesVisitor final : public osg::NodeVisitor { public: std::vector mNames; // Default constructor - initialize searchForName to "" and // set the traversal mode to TRAVERSE_ALL_CHILDREN FindRoomNamesVisitor() : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) {} void apply(osg::Node &n) override; }; //////////////////////////////////////////////////////////////////////////////// class FindRoomByNumberVisitor final : public osg::NodeVisitor { public: // Default constructor - initialize searchForName to "" and // set the traversal mode to TRAVERSE_ALL_CHILDREN FindRoomByNumberVisitor() : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), searchForName() {} // Constructor that accepts string argument // Initializes searchForName to user string // set the traversal mode to TRAVERSE_ALL_CHILDREN explicit FindRoomByNumberVisitor(const std::string &searchName) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), searchForName(searchName) { } void apply(osg::Node &searchNode) override; // Set the searchForName to user-defined string void setNameToFind(const std::string &searchName) { searchForName = searchName; foundNodeList.clear(); } // Return a pointer to the first node in the list // with a matching name osg::Node *getFirst() { return *(foundNodeList.begin()); } // typedef a vector of node pointers for convenience using NodeList = std::vector; // return a reference to the list of nodes we found NodeList &getNodeList() { return foundNodeList; } private: // the name we are looking for std::string searchForName; // List of nodes with names that match the searchForName string NodeList foundNodeList; }; //////////////////////////////////////////////////////////////////////////////// class ClearVertexColorsVisitor final : public osg::NodeVisitor { public: ClearVertexColorsVisitor() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} void apply(osg::Geode &geode) override; }; //////////////////////////////////////////////////////////////////////////////// class SetWallsTransparentVisitor final : public osg::NodeVisitor { float mTransparency; public: explicit SetWallsTransparentVisitor(float transparency) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) , mTransparency(transparency) { setNodeMaskOverride(0xFFFFFFFF); } void SetAlpha(osg::Node *node, float alpha); void apply(osg::Node &node) override; }; }