/** Diferentiate data and return the result in a new object. * WARNING: Do not call for recursive functions as it will crash with a stack overflow * \param Var: Variable to differenciate with respect to * \param Trigonometry: Choose to differentiate trigonometric functions as radians or degrees. */ boost::shared_ptr<TFuncData> TFuncData::MakeDif(const TElem &Var, TTrigonometry Trigonometry) const { if(Data.empty()) throw EFuncError(ecNoFunc); if(CheckRecursive()) throw EFuncError(ecRecursiveDif); try { boost::shared_ptr<TFuncData> Temp(new TFuncData); CopyReplaceArgs(Temp->Data, Data.begin(), std::vector<std::vector<TElem> >()); DEBUG_LOG(std::wclog << L"f(x)=" << MakeText(Temp->Data.begin()) << std::endl); boost::shared_ptr<TFuncData> Dest(new TFuncData); Dest->AddDif(Temp->Data.begin(), Var, Trigonometry, 0); //It is sometimes necesarry to optimize. For example d(x^2) needs an ln(x) optimized away DEBUG_LOG(std::wclog << L"Before simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl); Dest->Simplify(); DEBUG_LOG(std::wclog << L"After simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl); Dest->Simplify(); DEBUG_LOG(std::wclog << L"After simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl); return Dest; } catch(boost::bad_any_cast &E) { throw EFuncError(ecInternalError); } }
void HDimension::GetProperties(std::list<Property *> *list) { list->push_back(new PropertyTrsf(_("orientation"), m_trsf, this, on_set_trsf)); std::list< wxString > choices; choices.push_back ( wxString ( _("between two points") ) ); choices.push_back ( wxString ( _("between two points, XY only") ) ); choices.push_back ( wxString ( _("orthogonal") ) ); list->push_back ( new PropertyChoice ( _("mode"), choices, m_mode, this, on_set_mode ) ); list->push_back ( new PropertyDouble ( _("scale"), m_scale, this, on_set_scale ) ); { std::list< wxString > choices; choices.push_back ( wxString ( _("use view units") ) ); choices.push_back ( wxString ( _("inches") ) ); choices.push_back ( wxString ( _("mm") ) ); list->push_back ( new PropertyChoice ( _("units"), choices, m_units, this, on_set_units ) ); } wxString text = MakeText(); list->push_back(new PropertyString(_("dimension value"), text, this, NULL)); EndedObject::GetProperties(list); }
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); }
//******************************************************************** // Конвертирование в один формат на заданной памяти Bool32 ROUT_GetObject ( uint32_t objIndex, // Индекс объекта начиная от 1 Byte *lpMem, // Адрес блока памяти ( 0 - старая память) long *sizeMem // На входе: длина блока памяти // На выходе: длина использованной памяти ) { // DEBUG_PRINT("ROUT_OneFormat"); ClearError(); // Загружена ли страница if ( !gPageHandle ) { PAGE_NOT_LOADED; return FALSE; } // Установить рабочую память INIT_MEMORY(lpMem,*sizeMem); switch(gFormat) { case ROUT_FMT_Text: case ROUT_FMT_SmartText: MakeText(); break; case ROUT_FMT_HOCR: MakeHOCR(); break; case ROUT_FMT_HTML: MakeHTML(); break; case ROUT_FMT_TableText: MakeTableText(); break; case ROUT_FMT_DBF: MakeTableDBF(); break; case ROUT_FMT_CSV: case ROUT_FMT_WKS: default: NOT_IMPLEMENTED; break; } // Сколько использовано памяти *sizeMem = gMemCur - gMemStart; return (gwLowRC_rout?FALSE:TRUE); }
void EngineStatePoolGetPlayerName::SetActive(bool active) { EngineStateEnterText::SetActive(active); if (active) { // No TimerExpired() - don't time out. m_maxTime = 12000.0f; m_time = 0; // Get last player name TODO m_text = "player " + ToString(ThePlayerNames::Instance()->GetNumNames() + 1); m_pos = m_text.size(); MakeText(); m_errorText = ""; m_currentPlayer = 0; } }
void HDimension::GetGripperPositions(std::list<GripData> *list, bool just_for_endof) { wxString text = MakeText(); float width, height; if(!wxGetApp().get_text_size(text, &width, &height))return; gp_Pnt point[4]; point[0] = gp_Pnt(0, 0, 0); point[1] = gp_Pnt(width, 0, 0); point[2] = gp_Pnt(0, -height, 0); point[3] = gp_Pnt(width, -height, 0); for(int i = 0; i<4; i++)point[i].Transform(m_trsf); list->push_back(GripData(GripperTypeTranslate,point[0].X(),point[0].Y(),point[0].Z(),NULL)); list->push_back(GripData(GripperTypeRotateObject,point[1].X(),point[1].Y(),point[1].Z(),NULL)); list->push_back(GripData(GripperTypeRotateObject,point[2].X(),point[2].Y(),point[2].Z(),NULL)); list->push_back(GripData(GripperTypeScale,point[3].X(),point[3].Y(),point[3].Z(),NULL)); EndedObject::GetGripperPositions(list,just_for_endof); list->push_back(GripData(GripperTypeStretch,m_p2->m_p.X(),m_p2->m_p.Y(),m_p2->m_p.Z(),&m_p2)); }
void HDimension::GetBox(CBox &box) { gp_Pnt vt(0, 0, 0); vt.Transform(m_trsf); double p[3]; extract(vt, p); box.Insert(p); wxString text = MakeText(); float width, height; if(!wxGetApp().get_text_size(text, &width, &height))return; gp_Pnt point[3]; point[0] = gp_Pnt(width, 0, 0); point[1] = gp_Pnt(0, -height, 0); point[2] = gp_Pnt(width, -height, 0); for(int i = 0; i<3; i++) { point[i].Transform(m_trsf); extract(point[i], p); box.Insert(p); } }
Resource* CreateTextWidget( XMLIterator i, XMLCreatorEnv *env ) { XMLCreatorEnv ch_env; XMLAttributes attributes; XMLStyle branch_style; CascadeStyles( i, env, attributes, branch_style, ch_env ); std::string font = get_attribute( attributes, "font" ); int bodyAsLink = 0; try_attribute_i( attributes, "body_as_link", &bodyAsLink ); Text text; if ( bodyAsLink ) text = QueryText( make_string( (*i)._value )); else text = MakeText(to_chars( (*i)._value )); Widget *ptr; XMLIterator ch_i = i; int line_spacing = 0; std::string alignment; bool adv_text = try_attribute_i( attributes, "spacing", &line_spacing ); adv_text |= try_attribute( attributes, "align", &alignment ); // create DualText if ( !!ch_i.StepInto() ) { int shift = 2; try_attribute_i( attributes, "shift", &shift ); std::wstring left, right; for ( ; !!ch_i; ++ch_i ) { if ( (*ch_i)._name == "left" ) left = to_chars( (*ch_i)._value ); else if ( (*ch_i)._name == "right" ) right = to_chars( (*ch_i)._value ); } int bodyAsLink = 0; try_attribute_i( attributes, "body_as_link", &bodyAsLink ); Text leftT, rightT; if ( bodyAsLink ) { leftT = QueryText( make_string( left )); rightT = QueryText( make_string( right )); } else { leftT = MakeText(left); rightT = MakeText(right); } DualTextWidget *p_dual; ptr = p_dual = new DualTextWidget( 100, QueryFont(font), leftT, rightT, shift ); std::string dotcode; if ( try_attribute( attributes, "dot", &dotcode ) ) p_dual->SetDotCode( ( dotcode.size()>0 ? dotcode[0] : ' ' ) ); } else if ( adv_text ) { int align = 0; if ( alignment == "left" ) { align = 0; } else if ( alignment == "right" ) { align = 1; } else if ( alignment == "center" ) { align = 2; } if ( (*i)._name == "activetext" ) { ptr = new ActiveText( QueryFont(font), text, line_spacing, align ); } else { ptr = new AdvTextWidget( QueryFont(font), text, line_spacing, align ); } } else { TextWidget *ptrTW = new TextWidget( QueryFont(font), text ); ptr = ptrTW; ptrTW->SetText( text ); } InsertChildWidget( ptr, attributes, env); return new AnyResource<Widget*>( ptr ); }