static SDL_svg_context *internal_SVG_Load(void *arg1, int arg2, int type) { svg_length_t Width; svg_length_t Height; SDL_svg_context *Source; Source = create_SDL_svg_context(); svg_create ((svg_t **)&(Source->SVG)); if(type==LOAD_TYPE_FILE) svg_parse (Source->SVG,(char *)arg1); else svg_parse_buffer(Source->SVG, (char *)arg1, arg2); svg_get_size (Source->SVG,&Width,&Height); Source->w = ConvertLength(&Width); Source->h = ConvertLength(&Height); return Source; }
static svg_status_t _SDL_SVG_RenderRect (void *closure, svg_length_t *x_len, svg_length_t *y_len, svg_length_t *width_len, svg_length_t *height_len, svg_length_t *rx_len, svg_length_t *ry_len) { SDL_svg_context *c=closure; double x, y, width, height, rx, ry; dprintf("svg_RenderRect\n"); x = ConvertLength(x_len); y = ConvertLength(y_len); width = ConvertLength(width_len); height = ConvertLength(height_len); rx = ConvertLength(rx_len); ry = ConvertLength(ry_len); if (rx > width / 2.0) rx = width / 2.0; if (ry > height / 2.0) ry = height / 2.0; if (rx > 0 || ry > 0) { _SDL_SVG_MoveTo (c, x + rx, y); _SDL_SVG_LineTo (c, x + width - rx, y); _SDL_SVG_ArcTo (c, rx, ry, 0, 0, 1, x + width, y + ry); _SDL_SVG_LineTo (c, x + width, y + height - ry); _SDL_SVG_ArcTo (c, rx, ry, 0, 0, 1, x + width - rx, y + height); _SDL_SVG_LineTo (c, x + rx, y + height); _SDL_SVG_ArcTo (c, rx, ry, 0, 0, 1, x, y + height - ry); _SDL_SVG_LineTo (c, x, y + ry); _SDL_SVG_ArcTo (c, rx, ry, 0, 0, 1, x + rx, y); } else { _SDL_SVG_MoveTo (c, x, y); _SDL_SVG_LineTo (c, x + width, y); _SDL_SVG_LineTo (c, x + width, y + height); _SDL_SVG_LineTo (c, x, y + height); } _SDL_SVG_ClosePath (c); _SDL_SVG_RenderPath(closure); return SVG_STATUS_SUCCESS; }
void StructureMgrSingleton::UpdateStructUnit( int new_unit ) { Vehicle* veh = VehicleMgr.GetVehicle(); if ( veh ) { // Update FeaMaterial Units for ( size_t i = 0; i < m_FeaMaterialVec.size(); i++ ) { int density_unit_new, density_unit_old, pressure_unit_new, pressure_unit_old; switch ( new_unit ) { case vsp::SI_UNIT: density_unit_new = vsp::RHO_UNIT_KG_M3; pressure_unit_new = vsp::PRES_UNIT_PA; break; case vsp::CGS_UNIT: density_unit_new = vsp::RHO_UNIT_G_CM3; pressure_unit_new = vsp::PRES_UNIT_BA; break; case vsp::MPA_UNIT: density_unit_new = vsp::RHO_UNIT_TONNE_MM3; pressure_unit_new = vsp::PRES_UNIT_MPA; break; case vsp::BFT_UNIT: density_unit_new = vsp::RHO_UNIT_SLUG_FT3; pressure_unit_new = vsp::PRES_UNIT_PSF; break; case vsp::BIN_UNIT: density_unit_new = vsp::RHO_UNIT_LBFSEC2_IN4; pressure_unit_new = vsp::PRES_UNIT_PSI; break; } switch ( (int)veh->m_StructUnit.GetLastVal() ) { case vsp::SI_UNIT: density_unit_old = vsp::RHO_UNIT_KG_M3; pressure_unit_old = vsp::PRES_UNIT_PA; break; case vsp::CGS_UNIT: density_unit_old = vsp::RHO_UNIT_G_CM3; pressure_unit_old = vsp::PRES_UNIT_BA; break; case vsp::MPA_UNIT: density_unit_old = vsp::RHO_UNIT_TONNE_MM3; pressure_unit_old = vsp::PRES_UNIT_MPA; break; case vsp::BFT_UNIT: density_unit_old = vsp::RHO_UNIT_SLUG_FT3; pressure_unit_old = vsp::PRES_UNIT_PSF; break; case vsp::BIN_UNIT: density_unit_old = vsp::RHO_UNIT_LBFSEC2_IN4; pressure_unit_old = vsp::PRES_UNIT_PSI; break; } m_FeaMaterialVec[i]->m_MassDensity.Set( ConvertDensity( m_FeaMaterialVec[i]->m_MassDensity.Get(), density_unit_old, density_unit_new ) ); m_FeaMaterialVec[i]->m_ElasticModulus.Set( ConvertPressure( m_FeaMaterialVec[i]->m_ElasticModulus.Get(), pressure_unit_old, pressure_unit_new ) ); m_FeaMaterialVec[i]->m_ThermalExpanCoeff.Set( ConvertThermalExpanCoeff( m_FeaMaterialVec[i]->m_ThermalExpanCoeff.Get(), (int)veh->m_StructUnit.GetLastVal(), new_unit ) ); } // Update FeaProperty Units for ( size_t i = 0; i < m_FeaPropertyVec.size(); i++ ) { int length_unit_new, length_unit_old; switch ( new_unit ) { case vsp::SI_UNIT: length_unit_new = vsp::LEN_M; break; case vsp::CGS_UNIT: length_unit_new = vsp::LEN_CM; break; case vsp::MPA_UNIT: length_unit_new = vsp::LEN_MM; break; case vsp::BFT_UNIT: length_unit_new = vsp::LEN_FT; break; case vsp::BIN_UNIT: length_unit_new = vsp::LEN_IN; break; } switch ( (int)veh->m_StructUnit.GetLastVal() ) { case vsp::SI_UNIT: length_unit_old = vsp::LEN_M; break; case vsp::CGS_UNIT: length_unit_old = vsp::LEN_CM; break; case vsp::MPA_UNIT: length_unit_old = vsp::LEN_MM; break; case vsp::BFT_UNIT: length_unit_old = vsp::LEN_FT; break; case vsp::BIN_UNIT: length_unit_old = vsp::LEN_IN; break; } if ( m_FeaPropertyVec[i]->m_FeaPropertyType() == vsp::FEA_SHELL ) { m_FeaPropertyVec[i]->m_Thickness.Set( ConvertLength( m_FeaPropertyVec[i]->m_Thickness.Get(), length_unit_old, length_unit_new ) ); } else if ( m_FeaPropertyVec[i]->m_FeaPropertyType() == vsp::FEA_BEAM ) { if ( m_FeaPropertyVec[i]->m_CrossSectType() == vsp::FEA_XSEC_GENERAL ) { m_FeaPropertyVec[i]->m_CrossSecArea.Set( ConvertLength2( m_FeaPropertyVec[i]->m_CrossSecArea.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Ixx.Set( ConvertLength4( m_FeaPropertyVec[i]->m_Ixx.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Iyy.Set( ConvertLength4( m_FeaPropertyVec[i]->m_Iyy.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Izy.Set( ConvertLength4( m_FeaPropertyVec[i]->m_Izy.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Izz.Set( ConvertLength4( m_FeaPropertyVec[i]->m_Izz.Get(), length_unit_old, length_unit_new ) ); } else { m_FeaPropertyVec[i]->m_Dim1.Set( ConvertLength( m_FeaPropertyVec[i]->m_Dim1.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Dim2.Set( ConvertLength( m_FeaPropertyVec[i]->m_Dim2.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Dim3.Set( ConvertLength( m_FeaPropertyVec[i]->m_Dim3.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Dim4.Set( ConvertLength( m_FeaPropertyVec[i]->m_Dim4.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Dim5.Set( ConvertLength( m_FeaPropertyVec[i]->m_Dim5.Get(), length_unit_old, length_unit_new ) ); m_FeaPropertyVec[i]->m_Dim6.Set( ConvertLength( m_FeaPropertyVec[i]->m_Dim6.Get(), length_unit_old, length_unit_new ) ); } } } // Update Point Mass Units vector < FeaStructure* > struct_vec = GetAllFeaStructs(); for ( size_t i = 0; i < struct_vec.size(); i++ ) { vector < FeaPart* > prt_vec = struct_vec[i]->GetFeaPartVec(); for ( size_t j = 0; j < prt_vec.size(); j++ ) { if ( prt_vec[j]->GetType() == vsp::FEA_FIX_POINT ) { FeaFixPoint* fix_pnt = dynamic_cast<FeaFixPoint*>( prt_vec[j] ); assert( fix_pnt ); if ( fix_pnt->m_FixPointMassFlag() ) { int mass_unit_new = -1; int mass_unit_old = -1; switch ( new_unit ) { case vsp::SI_UNIT: mass_unit_new = vsp::MASS_UNIT_KG; break; case vsp::CGS_UNIT: mass_unit_new = vsp::MASS_UNIT_G; break; case vsp::MPA_UNIT: mass_unit_new = vsp::MASS_UNIT_TONNE; break; case vsp::BFT_UNIT: mass_unit_new = vsp::MASS_UNIT_SLUG; break; case vsp::BIN_UNIT: mass_unit_new = vsp::MASS_LBFSEC2IN; break; } switch ( (int)veh->m_StructUnit.GetLastVal() ) { case vsp::SI_UNIT: mass_unit_old = vsp::MASS_UNIT_KG; break; case vsp::CGS_UNIT: mass_unit_old = vsp::MASS_UNIT_G; break; case vsp::MPA_UNIT: mass_unit_old = vsp::MASS_UNIT_TONNE; break; case vsp::BFT_UNIT: mass_unit_old = vsp::MASS_UNIT_SLUG; break; case vsp::BIN_UNIT: mass_unit_old = vsp::MASS_LBFSEC2IN; break; } fix_pnt->m_FixPointMass.Set( ConvertMass( fix_pnt->m_FixPointMass.Get(), mass_unit_old, mass_unit_new ) ); } } } } } }
static svg_status_t _SDL_SVG_ApplyViewBox (void *closure, svg_view_box_t view_box, svg_length_t *width, svg_length_t *height) { SDL_svg_context *c = closure; double vpar, svgar; double logic_width, logic_height; double logic_x, logic_y; double phys_width, phys_height; dprintf("svg_ApplyViewBox\n"); phys_width = ConvertLength(width); phys_height = ConvertLength(height); vpar = view_box.box.width / view_box.box.height; svgar = phys_width / phys_height; logic_x = view_box.box.x; logic_y = view_box.box.y; logic_width = view_box.box.width; logic_height = view_box.box.height; if (view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_NONE) { _scale (c, phys_width / logic_width, phys_height / logic_height); _translate (c, -logic_x, -logic_y); } else if((vpar < svgar && view_box.meet_or_slice == SVG_MEET_OR_SLICE_MEET) || (vpar >= svgar && view_box.meet_or_slice == SVG_MEET_OR_SLICE_SLICE)) { _scale (c, phys_height / logic_height, phys_height / logic_height); if (view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMIN || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMID || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMAX) _translate (c, -logic_x, -logic_y); else if(view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMIN || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMID || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMAX) _translate (c, -logic_x - (logic_width - phys_width * logic_height / phys_height) / 2, -logic_y); else _translate (c, -logic_x - (logic_width - phys_width * logic_height / phys_height), -logic_y); } else { _scale (c, phys_width / logic_width, phys_width / logic_width); if (view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMIN || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMIN || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMAXYMIN) _translate (c, -logic_x, -logic_y); else if(view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMINYMID || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMIDYMID || view_box.aspect_ratio == SVG_PRESERVE_ASPECT_RATIO_XMAXYMID) _translate (c, -logic_x, -logic_y - (logic_height - phys_height * logic_width / phys_width) / 2); else _translate (c, -logic_x, -logic_y - (logic_height - phys_height * logic_width / phys_width)); } return SVG_STATUS_SUCCESS; }