void Raytracer::render(Scene* scene) { _scene = scene; glm::vec3 pixel(_startx, _starty, 0.0); // Fire a ray through every pixel in the image towards the scene for (int row = 0; row < _height; ++row) { pixel.x = _startx; for (int col = 0; col < _width; ++col) { glm::vec3 dir = glm::normalize(pixel - _origin); Ray r(_origin, dir); glm::vec3 color(0.0f); float distance; _raytrace(r, color, distance); pixel.x += _dx; _data[getIndexFor(col, row, _width)] = packVec3IntoInt(color); } pixel.y -= _dy; } writeImageToTGA("out.tga", _data, _width, _height); }
void ClientArea::setTile(const IVec2& pos, TileBase* tile) { int index = getIndexFor(pos); if(_tiles[index]) { delete _tiles[index]; } _tiles[index] = tile; }
ofPoint vectorField::getForceFromPos(float xpos, float ypos){ int pos = getIndexFor(xpos,ypos); if (pos == 0) return ofPoint(0,0); return ofPoint(field[pos].x * 0.1, field[pos].y * 0.1, 0.0 ); // scale here as values are pretty large. }
BOOL ArxDbgUiTdcCloneSet::OnInitDialog() { CAcUiTabChildDialog::OnInitDialog(); m_selectButton.AutoLoad(); displayDbList(); m_lbDbList.SetCurSel(getIndexFor(acdbHostApplicationServices()->workingDatabase())); displayObjList(); return TRUE; }
void ArxDbgUiTdcCloneSet::OnSelect() { // unfortunately, this structure for making this page know about the main // dialog means that we could never use this page within another main dialog // container. So, we have to cast to the known type of our owning main dialog ArxDbgUiTdmTransDbClones* tdmClones = static_cast<ArxDbgUiTdmTransDbClones*>(GetMainDialog()); tdmClones->addToCloneSet(m_cloneSet); // we want them to see the changes they just made, but the list that was current // might not have been from the database they just deal with, so find the current // database and make it show up as current in the list. m_lbDbList.SetCurSel(getIndexFor(acdbHostApplicationServices()->workingDatabase())); OnDatabaseChanged(); }
int main(int argc, char *argv[]) { register int i; register int index; printf(DIST_VERSION "\n\n"); for (i = 1; i < argc; i++) { if ((argv[i][1] == '?') || (strcmpi(argv[i]+1, "HELP") == 0)) { print_usage(); return 0; } else if (strcmpi(argv[i], "ALL") == 0) { display(ALL); } else if (strcmpi(argv[i], "NA") == 0) { display(NA); } else if (strcmpi(argv[i], "INTERNAL") == 0) { display((signed int)INTERNAL); } else if (strcmpi(argv[i], "BETA") == 0) { display(BETA); } else if (strcmpi(argv[i], "BETA6") == 0) { display(BETA6); } else if (strcmpi(argv[i], "BETA7") == 0) { display(BETA7); } else if (strcmpi(argv[i], "BETA8") == 0) { display(BETA8); } else if (strcmpi(argv[i], "BETA9") == 0) { display(BETA9); } else if (strcmpi(argv[i], "1.0") == 0) { display(FINAL10); } #ifdef HOT_RELEASE else if (strcmpi(argv[i], "RIPCORD") == 0) { display(RIPCORD | UPDATED); } else if (strcmpi(argv[i], "UPDATED") == 0) { display(UPDATED); } #endif else /* probably a specific program */ { index = getIndexFor(argv[i]); if ((index >= 0) && (index < NUM_PROGRAMS)) display_info(index); else printf("Unknown program [%s]\n", argv[i]); } } return 0; }
bool CQSpecieDM::specieDataChange( UndoSpeciesData *pUndoSpeciesData, const QVariant &value, int column) { switchToWidget(CCopasiUndoCommand::SPECIES); GET_MODEL_OR(pModel, return false); mpSpecies = dynamic_cast<CMetab*>(pUndoSpeciesData->getObject(pModel)); if (mpSpecies == NULL) return false; const CCompartment * pCompartment = NULL; if (column == COL_COMPARTMENT || column == COL_ICONCENTRATION || column == COL_INUMBER) { try { pCompartment = mpSpecies->getCompartment(); } catch (...) {} } if (column == COL_NAME_SPECIES) { mpSpecies->setObjectName(TO_UTF8(value.toString())); pUndoSpeciesData->setCN(mpSpecies->getCN()); } else if (column == COL_COMPARTMENT) { // This must be set first for setInitialConcentration and // setInitialNumber to work correctly. std::string Compartment(TO_UTF8(value.toString())); if (Compartment != pCompartment->getObjectName()) { std::string CompartmentToRemove = mpSpecies->getCompartment()->getObjectName(); if (!(pModel->getCompartments()[Compartment].addMetabolite(mpSpecies))) { QString msg; msg = "Unable to move species '" + FROM_UTF8(mpSpecies->getObjectName()) + "'\n" + "from compartment '" + FROM_UTF8(CompartmentToRemove) + "' to compartment '" + FROM_UTF8(Compartment) + "'\n" + "since a species with that name already exist in the target compartment."; CQMessageBox::information(NULL, "Unable to move Species", msg, QMessageBox::Ok, QMessageBox::Ok); return false; } else { pModel->getCompartments()[CompartmentToRemove].getMetabolites().remove(mpSpecies->getObjectName()); pModel->setCompileFlag(); pModel->initializeMetabolites(); if (mpSpecies && pCompartment) { C_FLOAT64 Factor = 1.0 / pCompartment->getInitialValue(); Factor *= pCompartment->getInitialValue(); mpSpecies->setInitialValue(Factor * pUndoSpeciesData->getINumber()); mpSpecies->setValue(Factor * mpSpecies->getValue()); } emit notifyGUI(ListViews::METABOLITE, ListViews::CHANGE, mpSpecies->getKey()); emit notifyGUI(ListViews::COMPARTMENT, ListViews::CHANGE, pCompartment->getKey()); } } } else if (column == COL_TYPE_SPECIES) mpSpecies->setStatus((CModelEntity::Status) mItemToType[value.toInt()]); else if (column == COL_ICONCENTRATION) { if (mFlagConc) mpSpecies->setInitialConcentration(value.toDouble()); if (mpSpecies && pCompartment) { const C_FLOAT64 initialValue = CMetab::convertToNumber(pUndoSpeciesData->getIConc(), *pCompartment, *pModel); mpSpecies->setInitialValue(initialValue); } } else if (column == COL_INUMBER) { if (!mFlagConc) mpSpecies->setInitialValue(value.toDouble()); if (mpSpecies && pCompartment) { mpSpecies->setInitialConcentration( CMetab::convertToConcentration(pUndoSpeciesData->getINumber(), *pCompartment, *pModel) ); } } //Save Key std::string key = mpSpecies->getKey(); // ask for refresh this may change the key! QModelIndex index = getIndexFor(mpSpecies, column); emit dataChanged(index, index); if (column == COL_NAME_SPECIES) { emit notifyGUI(ListViews::METABOLITE, ListViews::RENAME, key); } else { emit notifyGUI(ListViews::METABOLITE, ListViews::CHANGE, key); } return true; }