int SpeedCurve::mouseClicked(shared_ptr<ViewInterface> v, int button, int state, int x, int y) { glm::vec3 click(x, y, 0); if (!state) { /* get nearby points */ float distance = 30; selection = -1; for ( unsigned int i = 0; i < speed.points.size(); ++i ) { float dt = glm::distance(speed.points.data()[i], glm::vec3(x, y, 0)); if (dt < distance) { selection = i; distance = dt; } } if (selection < 0) { // sort new values, so order has increasing x speed.points.push_back( click ); inplace_merge(begin(speed.points), speed.points.end() - 1, speed.points.end(), vec_comp_x); calculateValues(); } else { dragSelection = true; pmx = x; pmy = y; } return 1; } else { dragSelection = false; calculateValues(); } return 0; }
int main(int argc, char **argv) { std::string folder; int i; omp_set_num_threads(8); //assert(argc == 2); //folder = std::string(argv[1]); folder = std::string("images"); sumPositive = new mpf_class[1024]; sumSqPositive = new mpf_class[1024]; sumNegative = new mpf_class[1024]; sumSqNegative = new mpf_class[1024]; for (i = 0; i < 1024; i++) { sumPositive[i] = mpf_class(0.); sumSqPositive[i] = mpf_class(0.); sumNegative[i] = mpf_class(0.); sumSqNegative[i] = mpf_class(0.); } readDirectory(folder, functionFilePositive, functionFileNegative); calculateValues(sumPositive, sumSqPositive, sumNegative, sumSqNegative, numberOfPositive, numberOfNegatives); std::cout << numberOfPositive << " " << numberOfNegatives << std::endl; return EXIT_SUCCESS; }
void RangeSlider::dragged(const Point& delta, GuiObject* receiver) { if ((receiver == lHandle_) || (receiver == rHandle_)) { restoreConsistency(); calculateValues(); informActionListeners(this); } }
void LightFader::setValueInternal(int value, int channel) { if (m_values.size() < channel) { qCritical() << "Channel bigger than channel size"; return; } m_values[channel] = value; calculateValues(); }
void RangeSlider::mouseClicked(MouseButton b, StateEvent ev, GuiObject* receiver) { if ((ev == GW1K_PRESSED) && ((receiver == this) || (receiver == rangeBar_))) { Point p = WManager::getInstance()->getMousePos() - getGlobalPos(); int hdlWidth = lHandle_->getSize().x; int dl = std::abs(lHandle_->getPos().x + hdlWidth / 2 - p.x); int dr = std::abs(rHandle_->getPos().x + hdlWidth / 2 - p.x); WiBox* closestHandle = dl <= dr ? lHandle_ : rHandle_; setHandlePos(closestHandle, Point(p.x - hdlWidth / 2, 1)); restoreConsistency(); calculateValues(); informActionListeners(this); } }
double SlaterSetTools::calculateMolecularOrbital(const Vector3 &position, int mo) const { if (mo > static_cast<int>(m_basis->molecularOrbitalCount())) return 0.0; vector<double> values(calculateValues(position)); const MatrixX &matrix = m_basis->normalizedMatrix(); int matrixSize(static_cast<int>(matrix.rows())); int indexMO(mo - 1); // Now calculate the value of the density at this point in space double result(0.0); for (int i = 0; i < matrixSize; ++i) result += matrix(i, indexMO) * values[i]; return result; }
double SlaterSetTools::calculateElectronDensity(const Vector3 &position) const { const MatrixX &matrix = m_basis->densityMatrix(); int matrixSize(static_cast<int>(m_basis->normalizedMatrix().rows())); if (matrix.rows() != matrixSize || matrix.cols() != matrixSize) return 0.0; vector<double> values(calculateValues(position)); // Now calculate the value of the density at this point in space double rho(0.0); for (int i = 0; i < matrixSize; ++i) { // Calculate the off-diagonal parts of the matrix for (int j = 0; j < i; ++j) rho += 2.0 * matrix(i, j) * (values[i] * values[j]); // Now calculate the matrix diagonal rho += matrix(i, i) * (values[i] * values[i]); } return rho; }
void LightFader::setMasterValue(int value) { m_masterValue = value; calculateValues(); }