diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 42c48bc397..71b63e8593 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -249,6 +249,7 @@ Application::~Application() { _audio.shutdown(); + VoxelNode::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown delete Menu::getInstance(); delete _oculusProgram; diff --git a/interface/src/Application.h b/interface/src/Application.h index d6814139e1..61a65747af 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -170,6 +170,8 @@ public: PointShader& getPointShader() { return _pointShader; } glm::vec2 getViewportDimensions() const{ return glm::vec2(_glWidget->width(),_glWidget->height()); } + NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; } + public slots: void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data); diff --git a/interface/src/ui/VoxelStatsDialog.cpp b/interface/src/ui/VoxelStatsDialog.cpp index 47bcbf4c64..ab1371f53f 100644 --- a/interface/src/ui/VoxelStatsDialog.cpp +++ b/interface/src/ui/VoxelStatsDialog.cpp @@ -23,6 +23,11 @@ VoxelStatsDialog::VoxelStatsDialog(QWidget* parent, NodeToVoxelSceneStats* model _model(model) { _statCount = 0; + _voxelServerLabelsCount = 0; + + for (int i = 0; i < MAX_VOXEL_SERVERS; i++) { + _voxelServerLables[i] = 0; + } for (int i = 0; i < MAX_STATS; i++) { _labels[i] = NULL; @@ -51,9 +56,19 @@ VoxelStatsDialog::VoxelStatsDialog(QWidget* parent, NodeToVoxelSceneStats* model **/ } +void VoxelStatsDialog::RemoveStatItem(int item) { + QLabel* myLabel = _labels[item]; + QWidget* automaticLabel = _form->labelForField(myLabel); + _form->removeWidget(myLabel); + _form->removeWidget(automaticLabel); + automaticLabel->deleteLater(); + myLabel->deleteLater(); + _labels[item] = NULL; +} + int VoxelStatsDialog::AddStatItem(const char* caption, unsigned colorRGBA) { char strBuf[64]; - const int STATS_LABEL_WIDTH = 550; + const int STATS_LABEL_WIDTH = 900; _statCount++; // increment our current stat count @@ -183,10 +198,85 @@ void VoxelStatsDialog::paintEvent(QPaintEvent* event) { "Leaves: " << serversLeavesString.toLocal8Bit().constData() << ""; label->setText(statsValue.str().c_str()); + showAllVoxelServers(); + this->QDialog::paintEvent(event); //this->setFixedSize(this->width(), this->height()); } +void VoxelStatsDialog::showAllVoxelServers() { + int serverNumber = 0; + int serverCount = 0; + NodeList* nodeList = NodeList::getInstance(); + for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { + // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER + if (node->getType() == NODE_TYPE_VOXEL_SERVER) { + serverNumber++; + serverCount++; + + if (serverCount > _voxelServerLabelsCount) { + char label[128] = { 0 }; + sprintf(label, "Voxel Server %d",serverCount); + _voxelServerLables[serverCount-1] = AddStatItem(label, GREENISH); + _voxelServerLabelsCount++; + } + + std::stringstream serverDetails(""); + + if (nodeList->getNodeActiveSocketOrPing(&(*node))) { + serverDetails << "active "; + } else { + serverDetails << "inactive "; + } + + QUuid nodeUUID = node->getUUID(); + serverDetails << " " << nodeUUID.toString().toLocal8Bit().constData() << " "; + + NodeToJurisdictionMap& voxelServerJurisdictions = Application::getInstance()->getVoxelServerJurisdictions(); + + // lookup our nodeUUID in the jurisdiction map, if it's missing then we're + // missing at least one jurisdiction + if (voxelServerJurisdictions.find(nodeUUID) == voxelServerJurisdictions.end()) { + serverDetails << " unknown jurisdiction "; + } else { + const JurisdictionMap& map = voxelServerJurisdictions[nodeUUID]; + + unsigned char* rootCode = map.getRootOctalCode(); + + if (rootCode) { + QString rootCodeHex = octalCodeToHexString(rootCode); + + VoxelPositionSize rootDetails; + voxelDetailsForCode(rootCode, rootDetails); + AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); + serverBounds.scale(TREE_SCALE); + serverDetails << " jurisdiction: " + << rootCodeHex.toLocal8Bit().constData() + << " [" + << rootDetails.x << ", " + << rootDetails.y << ", " + << rootDetails.z << ": " + << rootDetails.s << "] "; + } else { + serverDetails << " jurisdiction has no rootCode"; + } // root code + } // jurisdiction + + _labels[_voxelServerLables[serverCount - 1]]->setText(serverDetails.str().c_str()); + + } // is VOXEL_SERVER + } // Node Loop + + if (_voxelServerLabelsCount > serverCount) { + for (int i = serverCount; i < _voxelServerLabelsCount; i++) { + int serverLabel = _voxelServerLables[i]; + RemoveStatItem(serverLabel); + _voxelServerLables[i] = 0; + } + _voxelServerLabelsCount = serverCount; + } +} + void VoxelStatsDialog::reject() { // Just regularly close upon ESC this->QDialog::close(); diff --git a/interface/src/ui/VoxelStatsDialog.h b/interface/src/ui/VoxelStatsDialog.h index b76d4d58dd..cee6c47a11 100644 --- a/interface/src/ui/VoxelStatsDialog.h +++ b/interface/src/ui/VoxelStatsDialog.h @@ -15,7 +15,8 @@ #include -#define MAX_STATS 40 +#define MAX_STATS 100 +#define MAX_VOXEL_SERVERS 50 class VoxelStatsDialog : public QDialog { Q_OBJECT @@ -38,6 +39,8 @@ protected: void closeEvent(QCloseEvent*); int AddStatItem(const char* caption, unsigned colorRGBA); + void RemoveStatItem(int item); + void showAllVoxelServers(); private: QFormLayout* _form; @@ -50,6 +53,8 @@ private: int _localVoxels; int _localVoxelsMemory; int _voxelsRendered; + int _voxelServerLables[MAX_VOXEL_SERVERS]; + int _voxelServerLabelsCount; }; #endif /* defined(__interface__VoxelStatsDialog__) */