Esempio n. 1
0
// функция добавляет факт цитирования во множество фактов,
// на вход приходит  ситуация цитирования (VerbCommunic), из которой берется субъект цитирования,
// и QuoteStr - содержимое цитаты
void  CQuotesFinder::AddSimpleQuoteFact(const SValenciesValues& VerbCommunic, CSentenceRusProcessor* pSent,
                                        const Wtroka& QuoteStr, SLeadInfo LeadInfo)
{

    DECLARE_STATIC_RUS_WORD(kOB, "ОБ");
    DECLARE_STATIC_RUS_WORD(kSUB, "СУБ");
    DECLARE_STATIC_RUS_WORD(kPO_SLOVAM, "ПО_СЛОВАМ");

    CFactFields factFields("Quotes");
    factFields.m_LeadInfo = LeadInfo;
    Wtroka ObjStr;
    {
        SWordHomonymNum Obj = VerbCommunic.GetValue(kOB);
        if (Obj.IsValid()) {
            const CHomonym& h = pSent->m_Words[Obj];
            ObjStr = h.GetLemma();
        }

        // фунция берет из ситуации VerbCommunic валентность СУБ и пытается построить по ней строку,
        // если это не выходит, выходим
        SWordHomonymNum Subj = VerbCommunic.GetValue(kSUB);
        if (!Subj.IsValid())
            return;
        else
            CreateTextField("Fio",pSent,Subj, factFields, Wtroka());
    }
    {
        SWordHomonymNum Predic = VerbCommunic.m_NodeWH;
        if (!Predic.IsValid())
            Predic = VerbCommunic.GetValue(kPO_SLOVAM);
        if (Predic.IsValid())
            CreateTextField("QuotePredicate", pSent, Predic, factFields, ObjStr);
    }

    if (!CreateQuoteValue(QuoteStr, factFields))
        return;

    CFactsWS* factWS = new CFactsWS();
    factWS->SetPair(0,0);
    factWS->PutArticle(m_MainArticle);
    factWS->AddFact(factFields);
    pSent->GetWordSequences().push_back(factWS);
};
LandscapeToolsPanelHeightmap::LandscapeToolsPanelHeightmap(LandscapeToolsPanelDelegate *newDelegate, const Rect & rect)
    :   LandscapeToolsPanel(newDelegate, rect)
{
    Rect sizeRect(rect.dx - TEXTFIELD_WIDTH, 
                  0, TEXTFIELD_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2);
    sizeValue = CreateTextField(sizeRect);
    AddControl(sizeValue);
    
    Rect strengthRect(sizeRect);
    strengthRect.y = sizeRect.y + sizeRect.dy;
    strengthValue = CreateTextField(strengthRect);
    AddControl(strengthValue);
    
    Rect lineRect;
    lineRect.x = strengthSlider->GetRect().x + strengthSlider->GetRect().dx/2;
    lineRect.dx = 2;
    lineRect.y = strengthSlider->GetRect().y - 2;
    lineRect.dy = strengthSlider->GetRect().dy + 4;
    line = ControlsFactory::CreateLine(lineRect);
    AddControl(line);

    showGrid = CreateCkeckbox(Rect(0, ControlsFactory::TOOLS_HEIGHT, ControlsFactory::TOOLS_HEIGHT/2, ControlsFactory::TOOLS_HEIGHT/2), 
                              LocalizedString(L"landscapeeditor.showgrid"));
    
    float32 x = 0;
    float32 y = ControlsFactory::TOOLS_HEIGHT + ControlsFactory::TOOLS_HEIGHT/2.f;
    relative = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), 
                              LocalizedString(L"landscapeeditor.relative"));
    x += (ControlsFactory::TOOLS_HEIGHT/2.f + OFFSET + TEXT_WIDTH);
    average = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), 
                              LocalizedString(L"landscapeeditor.average"));
    
    x += (ControlsFactory::TOOLS_HEIGHT/2.f + OFFSET + TEXT_WIDTH);
    absoluteDropper = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), 
                             LocalizedString(L"landscapeeditor.absolutedropper"));

    Rect heightRect;
    heightRect.x = showGrid->GetRect().x + showGrid->GetRect().dx + TEXT_WIDTH + OFFSET;
    heightRect.y = ControlsFactory::TOOLS_HEIGHT;
    heightRect.dx = TEXTFIELD_WIDTH;
    heightRect.dy = average->GetRect().dy;
    heightValue = CreateTextField(Rect(heightRect));
    heightValue->SetText(L"0");
    AddControl(heightValue);
    
    heightRect.x = heightRect.x + heightRect.dx + ControlsFactory::OFFSET/2.f;
    heightRect.dx = TEXT_WIDTH;
    
    UIStaticText *textControl = new UIStaticText(heightRect);
    textControl->SetText(LocalizedString(L"landscapeeditor.height"));
    textControl->SetFont(ControlsFactory::GetFontLight());
    textControl->SetAlign(ALIGN_VCENTER | ALIGN_LEFT);
    AddControl(textControl);
    SafeRelease(textControl);
    
    averageStrength = CreateSlider(Rect(rect.dx - SLIDER_WIDTH, heightRect.y, 
                                        SLIDER_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2));
    averageStrength->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &LandscapeToolsPanelHeightmap::OnAverageSizeChanged));
    AddControl(averageStrength);
    AddSliderHeader(averageStrength, LocalizedString(L"landscapeeditor.averagestrength"));

    
    dropperTool = new LandscapeTool(-1, LandscapeTool::TOOL_DROPPER, "~res:/LandscapeEditor/SpecialTools/dropper.png");
    dropperTool->size = 1.0f;
    dropperTool->height = prevHeightValue = 0.f;
    
    Rect dropperRect = brushIcon->GetRect();
    dropperRect.x = (dropperRect.x + dropperRect.dx + ControlsFactory::OFFSET);
    dropperIcon = new UIControl(dropperRect);
    dropperIcon->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &LandscapeToolsPanelHeightmap::OnDropperTool));
    dropperIcon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL);
    dropperIcon->SetSprite(dropperTool->sprite, 0);
    AddControl(dropperIcon);
    

    copypasteTool = new LandscapeTool(-1, LandscapeTool::TOOL_COPYPASTE, "~res:/LandscapeEditor/SpecialTools/copypaste.png");
    
    Rect copypasteRect = dropperRect;
    copypasteRect.x = (copypasteRect.x + copypasteRect.dx + ControlsFactory::OFFSET);
    copypasteIcon = new UIControl(copypasteRect);
    copypasteIcon->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &LandscapeToolsPanelHeightmap::OnCopypasteTool));
    copypasteIcon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL);
    copypasteIcon->SetSprite(copypasteTool->sprite, 0);
    AddControl(copypasteIcon);
    
    copypasteRect.x = (copypasteRect.x + copypasteRect.dx + ControlsFactory::OFFSET);
    copypasteRect.dx = copypasteRect.dy = ControlsFactory::TOOLS_HEIGHT / 2;
    copyHeightmap = CreateCkeckbox(copypasteRect, L"Height");
    copypasteRect.y += copypasteRect.dy;
    copyTilemask = CreateCkeckbox(copypasteRect, L"Tilemask");
    
    sizeValue->SetText(Format(L"%.3f", LandscapeTool::SizeHeightMax()));
    strengthValue->SetText(Format(L"%.3f", LandscapeTool::StrengthHeightMax()));
    
    relative->SetChecked(true, false);
    average->SetChecked(false, false);
    absoluteDropper->SetChecked(false, false);

    sizeSlider->SetMinMaxValue(0.f, LandscapeTool::SizeHeightMax());
    sizeSlider->SetValue(LandscapeTool::DefaultSizeHeight());

    strengthSlider->SetMinMaxValue(-LandscapeTool::StrengthHeightMax(), LandscapeTool::StrengthHeightMax());
    strengthSlider->SetValue(LandscapeTool::DefaultStrengthHeight());
    
    averageStrength->SetMinMaxValue(0.f, 1.f);
    averageStrength->SetValue(0.5f);
    
    copyHeightmap->SetChecked(true, false);    
    copyTilemask->SetChecked(true, false);    
}