// Get another resource bundle for a subsection of this one. (Icu get.) STDMETHODIMP LgIcuResourceBundle::get_GetSubsection(BSTR bstrSectionName, ILgIcuResourceBundle ** pprb) { BEGIN_COM_METHOD ChkComOutPtr(pprb); StrAnsi staName(bstrSectionName); UErrorCode uerr = U_ZERO_ERROR; ResourceBundle rbt(m_rb.get(staName.Chars(), uerr)); if (U_FAILURE(uerr)) return S_OK; LgIcuResourceBundlePtr qrb; qrb.Attach(NewObj LgIcuResourceBundle(rbt)); *pprb = qrb.Detach(); END_COM_METHOD(g_factRb, IID_ILgIcuResourceBundle); }
void LgIcuResourceBundle::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<LgIcuResourceBundle> qlcpe; StrUtil::InitIcuDataDir(); UErrorCode uerr = U_ZERO_ERROR; ResourceBundle rbt(NULL, Locale("en"), uerr); if (U_FAILURE(uerr)) ThrowHr(E_FAIL); qlcpe.Attach(NewObj LgIcuResourceBundle(rbt)); // ref count initialy 1 CheckHr(qlcpe->QueryInterface(riid, ppv)); }
// Initialize the root resource bundle. The path may be null to use the standard // FieldWorks ICU data directory. STDMETHODIMP LgIcuResourceBundle::Init(BSTR bstrPath, BSTR bstrLocale) { BEGIN_COM_METHOD ChkComBstrArgN(bstrPath); ChkComBstrArg(bstrLocale); StrUtil::InitIcuDataDir(); StrUni stuDir; UnicodeString usDir; if (bstrPath) stuDir = bstrPath; // Otherwise let ICU figure out the right directory usDir = stuDir.Chars(); UErrorCode uerr = U_ZERO_ERROR; StrAnsi staLocale(bstrLocale); ResourceBundle rbt(usDir, Locale(staLocale.Chars()), uerr); if (U_FAILURE(uerr)) ThrowHr(E_FAIL); m_rb = rbt; END_COM_METHOD(g_factRb, IID_ILgIcuResourceBundle); }
#include "dryad_rbt.h" _(logic \bool mutable_rbt(RBTNode * x) = x != NULL ==> \mutable(x) && \writable(x)) _(dryad) int rbt_find_smallest(RBTNode * x) _(requires x != NULL && rbt(x)) _(ensures x != NULL && rbt(x)) _(ensures rbt_reach(x) == \old(rbt_reach(x))) _(ensures rbt_keys(x) == \old(rbt_keys(x))) _(ensures rbt_bh(x) == \old(rbt_bh(x))) _(ensures rbt_black(x) == \old(rbt_black(x))) _(ensures \intset_in(\result, rbt_keys(x))) _(ensures \intset_le_one1(\result, rbt_keys(x))) { _(assume mutable_rbt(x)) if (x->left == NULL) { return x->key; } else { int r = rbt_find_smallest(x->left); return r; } }
// arcball function to do the arcball routine in mouse move void arcball (rbt &O_frame_in_eye, rbt &O_frame, rbt &new_O_frame, rbt &S_frame, rbt &inv_S_frame, int g_width, int g_height, double old_x, double old_y, double new_x, double new_y, int g_manip_object) { // temp variables double dx, dy, dz, mag; bool out_sphere; coords3 v1, v2, a; qrot rot, q1, q2; rbt Q; // first get the center of the arcball coords3 center = O_frame_in_eye.translation; // now set up the projection matrix and variables to hold GetScreenSpaceCircle matrix4 projmat = MakeProjection(FRUST_FOVY, (float)g_width/(float)g_height, FRUST_NEAR, FRUST_FAR); coords3 screencenter; double screenrad; //get the center and radius in pixles GetScreenSpaceCircle(center, arcballradius, projmat, g_width, g_height, screencenter, screenrad); // VECTOR 1 - OLD POINT dx = old_x - screencenter.x; dy = old_y - screencenter.y; mag = (double)sqrt(dx*dx + dy*dy); out_sphere = (mag > screenrad); // if the point is out of the sphere, clamp to edge if(out_sphere == true) { //normalize dx and dy to clamp dz to 0 dx = (dx / mag); dy = (dy / mag); dz = 0.0; } else { //solve for z (in X^2 + Y^2 + Z^2 = r^2) dz = (double)sqrt(screenrad*screenrad - (dx*dx) - (dy*dy)); //normalize mag = (double)sqrt(dx*dx + dy*dy + dz*dz); dx = dx / mag; dy = dy / mag; dz = dz / mag; } v1.SetCoords(dx,dy,dz); //and we have our vector // VECTOR 2 - NEW POINT dx = (double)new_x - screencenter.x; dy = (double)new_y - screencenter.y; mag = (double)sqrt(dx*dx + dy*dy); out_sphere = (mag > screenrad); // if the point is out of the sphere, clamp to edge if(out_sphere == true) { //normalize dx and dy to clamp dz to 0 dx = dx / mag; dy = dy / mag; dz = 0.0; } else { //solve for z (in X^2 + Y^2 + Z^2 = r^2) dz = (double)sqrt(screenrad*screenrad - (dx*dx) - (dy*dy)); //normalize mag = (double)sqrt(dx*dx + dy*dy + dz*dz); dx = dx / mag; dy = dy / mag; dz = dz / mag; } v2.SetCoords(dx,dy,dz); //and we have our vector // find the qrot (from class notes it is [0, v1].[0, v0] hence w = 0) and therefore the rbt Q q1 = qrot(v1.x, v1.y, v1.z, 0.0); q2 = qrot(v2.x, v2.y, v2.z, 0.0); if (g_manip_object == 2) rot = q1*q2; else rot = q2 * q1; Q = rbt(rot); // CARRY OUT THE O' = SQS^(-1)O ROUTINE new_O_frame = S_frame * Q * inv_S_frame * O_frame; }