void UIFont::initText(void) { // Create the font //Check if I have a FilePathAttachment const BoostPath* FilePath(FilePathAttachment::getFilePath(UIFontRefPtr(this))); if(FilePath != NULL) { //Create the font from a file _face = TextTXFFace::createFromFile(FilePath->string().c_str()); } else { TextTXFParam param; param.size = getGlyphPixelSize(); param.gap = getGap(); param.textureWidth = getTextureWidth(); //Use my Family Field to create font texture _face = TextTXFFace::create(getFamily(), static_cast<TextFace::Style>(getStyle()), param); } TextureObjChunkUnrecPtr TheChunk(TextureObjChunk::create()); setTexture(TheChunk); if (_face != NULL) { ImageRefPtr image = _face->getTexture(); getTexture()->setImage(image); getTexture()->setWrapS(GL_CLAMP); getTexture()->setWrapT(GL_CLAMP); //if(getAntiAliasing()) //{ getTexture()->setMinFilter(GL_LINEAR_MIPMAP_NEAREST); getTexture()->setMagFilter(GL_LINEAR); //} //else //{ //getTexture()->setMinFilter(GL_NEAREST); //getTexture()->setMagFilter(GL_NEAREST); //} //getTexture()->setEnvMode(GL_MODULATE); } // We failed to create the font - fallback to the default font //if (_face == NULL) //{ // _face = getStatisticsDefaultFont(); // getTexture() = getStatisticsDefaultFontTexture(); //} }
Residuals(const Problem& problem, const Omega& omega, const Psi& psi) : normOfC{problem.c.norm()}, normOfB{problem.b.norm()}, AXPlusS{problem.A * omega.x + psi.s}, ATransposeY{problem.A.transpose() * omega.y}, cTransposeX{problem.c.transpose() * omega.x}, bTranspoesY{problem.b.transpose() * omega.y}, primal{getPrimal(problem, omega, psi)}, dual{getDual(problem, omega)}, primalDualGap{getGap(problem, omega)}, unbounded{cTransposeX < 0 ? AXPlusS.norm() * normOfC / -cTransposeX : NAN}, infeasible{bTranspoesY < 0 ? ATransposeY.norm() * normOfB / -bTranspoesY : NAN} {}
bool ItemListSelectUserInterface::processMenuSpecificKeys(InputCode inputCode) { string inputString = InputCodeManager::inputCodeToPrintableChar(inputCode); if(inputString == "") return false; mNameSoFar.append(inputString); string mNameSoFarLc = lcase(mNameSoFar); if(stringContainsAllTheSameCharacter(mNameSoFarLc)) { mSelectedIndex = getIndexOfNext(mNameSoFarLc.substr(0, 1)); if(mNameSoFar.size() > 1 && lcase(getMenuItem(mSelectedIndex)->getValue()).substr(0, mNameSoFar.length()) != mNameSoFarLc) mNameSoFar = mNameSoFar.substr(0, mNameSoFar.length() - 1); // Remove final char, the one we just added above } else mSelectedIndex = getIndexOfNext(mNameSoFarLc); mStillTypingNameTimer.reset(); mItemSelectedWithMouse = false; // Move the mouse to the new selection to make things "feel better" MenuItemSize size = getMenuItem(mFirstVisibleItem)->getSize(); S32 y = getYStart(); for(S32 j = mFirstVisibleItem; j < mSelectedIndex; j++) { size = getMenuItem(j)->getSize(); y += getTextSize(size) + getGap(size); } y += getTextSize(size) / 2; // WarpMouse fires a mouse event, which will cause the cursor to become visible, which we don't want. Therefore, // we must resort to the kind of gimicky/hacky method of setting a flag, telling us that we should ignore the // next mouse event that comes our way. It might be better to handle this at the Event level, by creating a custom // method called WarpMouse that adds the suppression. At this point, however, the only place we care about this // is here so... well... this works. SDL_WarpMouseInWindow(DisplayManager::getScreenInfo()->sdlWindow, (S32)DisplayManager::getScreenInfo()->getMousePos()->x, y); Cursor::disableCursor(); mIgnoreNextMouseEvent = true; playBoop(); return true; }
ble_error_t BLE::shutdown() { if (initialization_status != INITIALIZED) { return BLE_ERROR_INITIALIZATION_INCOMPLETE; } initialization_status = NOT_INITIALIZED; _hci_driver->terminate(); #if BLE_FEATURE_GATT_SERVER getGattServer().reset(); #endif #if BLE_FEATURE_GATT_CLIENT getGattClient().reset(); #endif // BLE_FEATURE_GATT_CLIENT getGap().reset(); _event_queue.clear(); return BLE_ERROR_NONE; }
int PySimple1::setTrialStrain (double newy, double yRate) { // Set trial values for displacement and load in the material // based on the last Tangent modulus. // double dy = newy - Ty; double dp = Ttangent * dy; TyRate = yRate; // Limit the size of step (dy or dp) that can be imposed. Prevents // numerical difficulties upon load reversal at high loads // where a soft loading modulus becomes a stiff unloading modulus. // int numSteps = 1; double stepSize = 1.0; if(fabs(dp/pult) > 0.5) numSteps = 1 + int(fabs(dp/(0.5*pult))); if(fabs(dy/y50) > 1.0 ) numSteps = 1 + int(fabs(dy/(1.0*y50))); stepSize = 1.0/float(numSteps); if(numSteps > 100) numSteps = 100; dy = stepSize * dy; // Main loop over the required number of substeps // for(int istep=1; istep <= numSteps; istep++) { Ty = Ty + dy; dp = Ttangent * dy; // May substep within Gap or NearField element if oscillating, which can happen // when they jump from soft to stiff. // double dy_gap_old = ((Tp + dp) - TGap_p)/TGap_tang; double dy_nf_old = ((Tp + dp) - TNF_p) /TNF_tang; // Iterate to distribute displacement among the series components. // Use the incremental iterative strain & iterate at this strain. // for (int j=1; j < PYmaxIterations; j++) { Tp = Tp + dp; // Stress & strain update in Near Field element double dy_nf = (Tp - TNF_p)/TNF_tang; getNearField(TNF_y,dy_nf,dy_nf_old); // Residuals in Near Field element double p_unbalance = Tp - TNF_p; double yres_nf = (Tp - TNF_p)/TNF_tang; dy_nf_old = dy_nf; // Stress & strain update in Gap element double dy_gap = (Tp - TGap_p)/TGap_tang; getGap(TGap_y,dy_gap,dy_gap_old); // Residuals in Gap element double p_unbalance2 = Tp - TGap_p; double yres_gap = (Tp - TGap_p)/TGap_tang; dy_gap_old = dy_gap; // Stress & strain update in Far Field element double dy_far = (Tp - TFar_p)/TFar_tang; TFar_y = TFar_y + dy_far; getFarField(TFar_y); // Residuals in Far Field element double p_unbalance3 = Tp - TFar_p; double yres_far = (Tp - TFar_p)/TFar_tang; // Update the combined tangent modulus Ttangent = pow(1.0/TGap_tang + 1.0/TNF_tang + 1.0/TFar_tang, -1.0); // Residual deformation across combined element double dv = Ty - (TGap_y + yres_gap) - (TNF_y + yres_nf) - (TFar_y + yres_far); // Residual "p" increment dp = Ttangent * dv; // Test for convergence double psum = fabs(p_unbalance) + fabs(p_unbalance2) + fabs(p_unbalance3); if(psum/pult < PYtolerance) break; } } return 0; }
int QzSimple2::setTrialStrain (double newz, double zRate) { // Set trial values for displacement and load in the material // based on the last Tangent modulus. // double dz = newz - Tz; double dQ = Ttangent * dz; TzRate = zRate; // Limit the size of step (dz or dQ) that can be imposed. Prevents // numerical difficulties upon load reversal at high loads // where a soft loading modulus becomes a stiff unloading modulus. // int numSteps = 1; double stepSize = 1.0; if(fabs(dQ/Qult) > 0.5) numSteps = 1 + int(fabs(dQ/(0.5*Qult))); if(fabs(dz/z50) > 1.0 ) numSteps = 1 + int(fabs(dz/(1.0*z50))); stepSize = 1.0/float(numSteps); if(numSteps > 100) numSteps = 100; dz = stepSize * dz; // Main loop over the required number of substeps // for(int istep=1; istep <= numSteps; istep++) { Tz = Tz + dz; dQ = Ttangent * dz; // May substep within Gap or NearField element if oscillating, which can happen // when they jump from soft to stiff. Initialize history terms here. // double dz_gap_old = ((TQ + dQ) - TGap_Q)/TGap_tang; double dz_nf_old = ((TQ + dQ) - TNF_Q) /TNF_tang; // Iterate to distribute displacement among the series components. // Use the incremental iterative strain & iterate at this strain. // for (int j=1; j < QZmaxIterations; j++) { TQ = TQ + dQ; if(fabs(TQ) >(1.0-QZtolerance)*Qult) TQ=(1.0-QZtolerance)*Qult*(TQ/fabs(TQ)); // Stress & strain update in Near Field element double dz_nf = (TQ - TNF_Q)/TNF_tang; getNearField(TNF_z,dz_nf,dz_nf_old); // Residuals in Near Field element double Q_unbalance = TQ - TNF_Q; double zres_nf = (TQ - TNF_Q)/TNF_tang; dz_nf_old = dz_nf; // Stress & strain update in Gap element double dz_gap = (TQ - TGap_Q)/TGap_tang; getGap(TGap_z,dz_gap,dz_gap_old); // Residuals in Gap element double Q_unbalance2 = TQ - TGap_Q; double zres_gap = (TQ - TGap_Q)/TGap_tang; dz_gap_old = dz_gap; // Stress & strain update in Far Field element double dz_far = (TQ - TFar_Q)/TFar_tang; TFar_z = TFar_z + dz_far; getFarField(TFar_z); // Residuals in Far Field element double Q_unbalance3 = TQ - TFar_Q; double zres_far = (TQ - TFar_Q)/TFar_tang; // Update the combined tangent modulus Ttangent = pow(1.0/TGap_tang + 1.0/TNF_tang + 1.0/TFar_tang, -1.0); // Residual deformation across combined element double dv = Tz - (TGap_z + zres_gap) - (TNF_z + zres_nf) - (TFar_z + zres_far); // Residual "Q" increment dQ = Ttangent * dv; // Test for convergence double Qsum = (fabs(Q_unbalance) + fabs(Q_unbalance2) + fabs(Q_unbalance3))/3.0; if(Qsum/Qult < QZtolerance) break; } } return 0; }