Gl Graph
Gl Graph Source of drawableset.cpp
#include <vector> #include <drawableset.h> #include <iostream> DrawableSet::DrawableSet() { } DrawableSet::~DrawableSet() { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->stop(); } for (int i = 0; i < size; i++) { data.at(i)->waitUntilLoad(); delete data.at(i); } } int DrawableSet::getElementNb() { return data.size(); } int DrawableSet::getTotalElementNb() { int size = data.size(); int elementNb = 0; for (int i = 0; i < size; i++) elementNb += data.at(i)->getElementNb(); return elementNb; } void DrawableSet::add(DrawableData * obj) { data.push_back(obj); } void DrawableSet::draw() { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->draw(); } } void DrawableSet::init(GlScene * glScene) { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->init(glScene); } } void DrawableSet::onClick(Vec3f &point,Vec3f &xvect,Vec3f &yvect,Vec3f &zvect) { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->onClick(point,xvect,yvect,zvect); } } void DrawableSet::onButtonUp() { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->onButtonUp(); } } void DrawableSet::onButtonDown() { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->onButtonDown(); } } void DrawableSet::onButtonRight() { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->onButtonRight(); } } void DrawableSet::onButtonLeft() { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->onButtonLeft(); } } void DrawableSet::waitUntilLoad() { int size = data.size(); for (int i = 0; i < size; i++) { data.at(i)->waitUntilLoad(); } } float DrawableSet::getMinX() { int size = data.size(); if (size == 0) return 0.0; float min = data.at(0)->getMinX(); for (int i = 1; i < size; i++) { float x = data.at(i)->getMinX(); if (x < min) min = x; } return min; } float DrawableSet::getMaxX() { int size = data.size(); if (size == 0) return 0.0; float max = data.at(0)->getMaxX(); for (int i = 1; i < size; i++) { float x = data.at(i)->getMaxX(); if (x > max) max = x; } return max; } float DrawableSet::getMinY() { int size = data.size(); if (size == 0) return 0.0; float min = data.at(0)->getMinY(); for (int i = 1; i < size; i++) { float y = data.at(i)->getMinY(); if (y < min) min = y; } return min; } float DrawableSet::getMaxY() { int size = data.size(); if (size == 0) return 0.0; float max = data.at(0)->getMaxY(); for (int i = 1; i < size; i++) { float y = data.at(i)->getMaxY(); if (y > max) max = y; } return max; } float DrawableSet::getMinZ() { int size = data.size(); if (size == 0) return 0.0; float min = data.at(0)->getMinZ(); for (int i = 1; i < size; i++) { float y = data.at(i)->getMinZ(); if (y < min) min = y; } return min; } float DrawableSet::getMaxZ() { int size = data.size(); if (size == 0) return 0.0; float max = data.at(0)->getMaxZ(); for (int i = 1; i < size; i++) { float y = data.at(i)->getMaxZ(); if (y > max) max = y; } return max; } bool DrawableSet::isChanged() { const int size = data.size(); for (int i = 0; i < size; i++) if (data.at(i)->isChanged()) return true; return false; } void DrawableSet::consummeChanged() { const int size = data.size(); for (int i = 0; i < size; i++) data.at(i)->consummeChanged(); } float DrawableSet::getMaxSize() { float x = 1.0 / 2.0 * (getMaxX() - getMinX()); float y = 1.0 / 2.0 * (getMaxY() - getMinY()); float z = 1.0 / 2.0 * (getMaxZ() - getMinZ()); float res = sqrt(x * x + y * y + z * z); return res; } Vec3f DrawableSet::getCenter() { float x = (getMaxX() + getMinX()) / 2; float y = (getMaxY() + getMinY()) / 2; float z = (getMaxZ() + getMinZ()) / 2; Vec3f v(x, y, z); return v; }