Beispiel #1
0
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;
}
 inline
 std::basic_ostream<CharType>& 
 operator <<  (std::basic_ostream<CharType>& os,
                 mathematic_angle<Extent,Value_type> const & r)
 {
      typedef std::ctype<CharType> ct;
      auto & facet = std::use_facet<ct>(std::locale());
      std::string str = units_str(r);
      std::basic_string<CharType> str1;
      for ( std::size_t i = 0; i < str.length();++i){
       str1 += facet.widen(str[i]);
      }
      os << r.numeric_value() << facet.widen(' ') << str1;
     return os;
  }
 inline
 std::basic_ostream<CharType> & 
 operator << (
     std::basic_ostream<CharType>& os,
     fraction_of_revolution<
         Extent,
         ReciprocalFraction,
         Value_type
     > const& ang)
 {
      typedef std::ctype<CharType> ct;
      auto & facet = std::use_facet<ct>(std::locale());
      std::string str = units_str(ang);
      std::basic_string<CharType> str1;
      for ( std::size_t i = 0; i < str.length();++i){
       str1 += facet.widen(str[i]);
      }
      os << ang.numeric_value() << facet.widen(' ') << str1;
      return os;
 }
Beispiel #4
0
        std::basic_istream<CharType>& is,
        Angle& angle
    )
    {
        typename Angle::value_type numeric_value;
        is >> numeric_value;
        
//        typedef std::ctype<CharType> ct;
//        auto & facet = std::use_facet<ct>(std::locale());
//        std::string units_str_c = units_str(angle);
//        std::basic_string<CharType> units_str_w;
//        for ( auto i = 0U ; i < units_str_c.length();++i){
//          units_str_w += facet.widen(units_str_c[i]);
//        }
        std::basic_string<CharType> units_str_cmp 
           = quan::convert<CharType>(units_str(angle));
        std::basic_string<CharType> units_str_in;
        is >> units_str_in;
        if (units_str_in != units_str_cmp){
            is.clear(std::ios_base::badbit);
            return is;
        }
        if (is){
            angle = Angle{numeric_value};
        }
        return is;
        
    }

}//quan
#endif