wxString HDimension::MakeText() { wxString text; double units_factor = wxGetApp().m_view_units; switch(m_units) { case DimensionUnitsInches: units_factor = 25.4; break; case DimensionUnitsMM: units_factor = 1.0; break; case DimensionUnitsGlobal: units_factor = wxGetApp().m_view_units; break; } wxString units_str(_T("")); if(fabs(units_factor - 1.0) < 0.0000000001)units_str += wxString(_T(" ")) + _("mm"); else if(fabs(units_factor - 25.4) < 0.000000001)units_str += wxString(_T(" ")) + _("inch"); text = wxString::Format(_T("%lg %s"), A->m_p.Distance(GetB2())/units_factor, units_str.c_str()); return text; }
void HDimension::glCommands(bool select, bool marked, bool no_color) { gp_Pnt b = GetB2(); if(A->m_p.IsEqual(b, wxGetApp().m_geom_tol))return; if(!no_color)wxGetApp().glColorEnsuringContrast(m_color); gp_Dir xdir = gp_Dir(1, 0, 0).Transformed(m_trsf); gp_Dir ydir = gp_Dir(0, 1, 0).Transformed(m_trsf); gp_Dir zdir = gp_Dir(0, 0, 1).Transformed(m_trsf); if(m_mode == TwoPointsDimensionMode || m_mode == TwoPointsXYOnlyDimensionMode || m_mode == TwoPointsXOnlyDimensionMode) { xdir = make_vector(A->m_p, b); if(xdir.IsParallel(zdir,wxGetApp().m_geom_tol)) zdir = xdir ^ ydir; else ydir = zdir ^ xdir; } wxString text = MakeText(); float width, height; if(!wxGetApp().get_text_size(text, &width, &height))return; // draw arrow line draw_arrow_line(m_mode, A->m_p, b, GetC2(), xdir, ydir, width, m_scale); // draw text RenderText(text, GetC2(), xdir, ydir, m_scale); EndedObject::glCommands(select,marked,no_color); }
void JV_SeedRoundKey( uint32_t *pdwRoundKey, // [out] round keys for encryption or decryption uint8_t *pbUserKey) // [in] secret user key { uint32_t A, B, C, D; // Iuput/output values at each rounds uint32_t T0, T1; // Temporary variable uint32_t *K = pdwRoundKey; // Pointer of round keys // Set up input values for Key Schedule A = ((uint32_t *)pbUserKey)[0]; B = ((uint32_t *)pbUserKey)[1]; C = ((uint32_t *)pbUserKey)[2]; D = ((uint32_t *)pbUserKey)[3]; // Reorder for big endian #ifndef BIG_ENDIAN A = EndianChange(A); B = EndianChange(B); C = EndianChange(C); D = EndianChange(D); #endif // i-th round keys( K_i,0 and K_i,1 ) are denoted as K[2*(i-1)] and K[2*i-1], respectively RoundKeyUpdate0(K, A, B, C, D, KC0 ); // K_1,0 and K_1,1 RoundKeyUpdate1(K+ 2, A, B, C, D, KC1 ); // K_2,0 and K_2,1 RoundKeyUpdate0(K+ 4, A, B, C, D, KC2 ); // K_3,0 and K_3,1 RoundKeyUpdate1(K+ 6, A, B, C, D, KC3 ); // K_4,0 and K_4,1 RoundKeyUpdate0(K+ 8, A, B, C, D, KC4 ); // K_5,0 and K_5,1 RoundKeyUpdate1(K+10, A, B, C, D, KC5 ); // K_6,0 and K_6,1 RoundKeyUpdate0(K+12, A, B, C, D, KC6 ); // K_7,0 and K_7,1 RoundKeyUpdate1(K+14, A, B, C, D, KC7 ); // K_8,0 and K_8,1 RoundKeyUpdate0(K+16, A, B, C, D, KC8 ); // K_9,0 and K_9,1 RoundKeyUpdate1(K+18, A, B, C, D, KC9 ); // K_10,0 and K_10,1 RoundKeyUpdate0(K+20, A, B, C, D, KC10); // K_11,0 and K_11,1 RoundKeyUpdate1(K+22, A, B, C, D, KC11); // K_12,0 and K_12,1 RoundKeyUpdate0(K+24, A, B, C, D, KC12); // K_13,0 and K_13,1 RoundKeyUpdate1(K+26, A, B, C, D, KC13); // K_14,0 and K_14,1 RoundKeyUpdate0(K+28, A, B, C, D, KC14); // K_15,0 and K_15,1 T0 = A + C - KC15; T1 = B - D + KC15; K[30] = SS0[GetB0(T0)] ^ SS1[GetB1(T0)] ^ // K_16,0 SS2[GetB2(T0)] ^ SS3[GetB3(T0)]; K[31] = SS0[GetB0(T1)] ^ SS1[GetB1(T1)] ^ // K_16,1 SS2[GetB2(T1)] ^ SS3[GetB3(T1)]; }