示例#1
0
文件: NHB300.cpp 项目: Raxtion/CT83
//---------------------------------------------------------------------------
double __fastcall CNHB300::GetWeight()
{
        char strReceive[300]={0};
        AnsiString strMsg;
        AnsiString strMsgNew;

        if(ReadSizeData(strReceive))
        {
               AnsiString strMsg=strReceive;

               int nPosStart=strMsg.AnsiPos("ST,");
               int nPosEnd=strMsg.SubString(nPosStart,15).AnsiPos("g")+nPosStart-1;


                if(nPosStart>0 && nPosEnd>0 && (nPosEnd-nPosStart)>5)
                {
                                strMsgNew=strMsg.SubString(nPosEnd-8,8);
                                if(strMsgNew.AnsiPos("-")>0)
                                {
                                        strMsgNew=strMsg.SubString(nPosEnd-7,7);
                                        return strMsgNew.ToDouble()*-1.0;
                                }
                                else return strMsgNew.ToDouble();
                }
                else return -999.0;
        }
        else return -999.0;

}
示例#2
0
//---------------------------------------------------------------------------
void __fastcall TFormReportStudsCandRedDiplom::GetBallsCount(int& countUDOVL,double& percUDOVL,int& countHOR,double& percHOR,int& countOTL,double& percOTL,AnsiString& AvrgBallStr,AnsiString IDStudStr)
{
    ZMySqlQueryAvrgBall->SQL->Clear();
    ZMySqlQueryAvrgBall->SQL->Add("select ball,estimation from "+opts.DBProgress+" where deleted=0 and idstud="+ToStr(IDStudStr)+" and (estimation="+ToStr(AnsiString(OTL))+" or estimation="+ToStr(AnsiString(HOR))+" or estimation="+ToStr(AnsiString(UDOVL))+")");
    ZMySqlQueryAvrgBall->Active=true;
    double SumBall=0.0;
    countUDOVL=countHOR=countOTL=0;
    percUDOVL=percHOR=percOTL=0.0;
    for (int i=0; i<ZMySqlQueryAvrgBall->RecordCount; i++)
    {
        ZMySqlQueryAvrgBall->RecNo=i+1;
        SumBall += ZMySqlQueryAvrgBall->Fields->FieldByNumber(1)->AsString.ToDouble();
        if (ZMySqlQueryAvrgBall->Fields->FieldByNumber(2)->AsString.ToInt()==OTL) countOTL++;
        if (ZMySqlQueryAvrgBall->Fields->FieldByNumber(2)->AsString.ToInt()==HOR) countHOR++;
        if (ZMySqlQueryAvrgBall->Fields->FieldByNumber(2)->AsString.ToInt()==UDOVL) countUDOVL++;
    }
    int NumBalls=countOTL+countHOR+countUDOVL;
    double avrgball=0.0;
    AvrgBallStr="---";
    if (NumBalls>0)
    {
        avrgball = SumBall/double(NumBalls);
        AvrgBallStr = AnsiString(avrgball);
        char str[10];
        sprintf(str,"%4.2lf",AvrgBallStr.ToDouble());
        AvrgBallStr = AnsiString(str);
        percUDOVL=100.0*double(countUDOVL)/double(NumBalls);
        percHOR=100.0*double(countHOR)/double(NumBalls);
        percOTL=100.0*double(countOTL)/double(NumBalls);
    }
}
示例#3
0
//---------------------------------------------------------------------------
bool GetProbalityValue(AnsiString S, double &dRet, AnsiString &strErr)
{
	try
	{
	 AnsiString strComa(0.1);
	 for(int i=0; i< S.Length(); i++)
	 {
	  if(S[i+1] == ',' || S[i+1] == '.')
		S[i+1] = strComa[1+1];
	 }

	 S = S.Trim();


	 dRet = S.ToDouble();
	 if( dRet < 0)
	 {
	  strErr = "«начение не должно быть отрицательным '" + S + "'";
	  return false;
	 }
	}
	catch(EConvertError *EC)
	{
	 strErr = "¬ведено неправильное чиcловое значение '" + S + "'";
	 return false;
	}
	return true;
}
示例#4
0
//---------------------------------------------------------------------------
bool TUtilities::CheckFileDouble(std::ifstream &InFile)
{
try
    {
    AnsiString DoubleString;
    if(!CheckAndReadFileString(InFile, DoubleString)) return false;
    if(InFile.fail()) return false;
    if(DoubleString == "") return false;
    DoubleString.ToDouble(); //throws EConvertError if fails
    return true;
    }
catch (const EConvertError &e)
    {
    return false;
    }
}
示例#5
0
bool TEventLauncher::Load(cParser *parser)
{ // wczytanie wyzwalacza zdarzeñ
    AnsiString str;
    std::string token;
    parser->getTokens();
    *parser >> dRadius; // promieñ dzia³ania
    if (dRadius > 0.0)
        dRadius *= dRadius; // do kwadratu, pod warunkiem, ¿e nie jest ujemne
    parser->getTokens(); // klawisz steruj¹cy
    *parser >> token;
    str = AnsiString(token.c_str());
    if (str != "none")
    {
        if (str.Length() == 1)
            iKey = VkKeyScan(str[1]); // jeden znak jest konwertowany na kod klawisza
        else
            iKey = str.ToIntDef(0); // a jak wiêcej, to jakby numer klawisza jest
    }
    parser->getTokens();
    *parser >> DeltaTime;
    if (DeltaTime < 0)
        DeltaTime = -DeltaTime; // dla ujemnego zmieniamy na dodatni
    else if (DeltaTime > 0)
    { // wartoœæ dodatnia oznacza wyzwalanie o okreœlonej godzinie
        iMinute = int(DeltaTime) % 100; // minuty s¹ najm³odszymi cyframi dziesietnymi
        iHour = int(DeltaTime - iMinute) / 100; // godzina to setki
        DeltaTime = 0; // bez powtórzeñ
        WriteLog("EventLauncher at " + IntToStr(iHour) + ":" +
                 IntToStr(iMinute)); // wyœwietlenie czasu
    }
    parser->getTokens();
    *parser >> token;
    asEvent1Name = AnsiString(token.c_str()); // pierwszy event
    parser->getTokens();
    *parser >> token;
    asEvent2Name = AnsiString(token.c_str()); // drugi event
    if ((asEvent2Name == "end") || (asEvent2Name == "condition"))
    { // drugiego eventu mo¿e nie byæ, bo s¹ z tym problemy, ale ciii...
        str = asEvent2Name; // rozpoznane s³owo idzie do dalszego przetwarzania
        asEvent2Name = "none"; // a drugiego eventu nie ma
    }
    else
    { // gdy s¹ dwa eventy
        parser->getTokens();
        *parser >> token;
        str = AnsiString(token.c_str());
    }
    if (str == AnsiString("condition"))
    { // obs³uga wyzwalania warunkowego
        parser->getTokens();
        *parser >> token;
        asMemCellName = AnsiString(token.c_str());
        parser->getTokens();
        *parser >> token;
        SafeDeleteArray(szText);
        szText = new char[256];
        strcpy(szText, token.c_str());
        if (token.compare("*") != 0) //*=nie braæ command pod uwagê
            iCheckMask |= conditional_memstring;
        parser->getTokens();
        *parser >> token;
        if (token.compare("*") != 0) //*=nie braæ wartoœci 1. pod uwagê
        {
            iCheckMask |= conditional_memval1;
            str = AnsiString(token.c_str());
            fVal1 = str.ToDouble();
        }
        else
            fVal1 = 0;
        parser->getTokens();
        *parser >> token;
        if (token.compare("*") != 0) //*=nie braæ wartoœci 2. pod uwagê
        {
            iCheckMask |= conditional_memval2;
            str = AnsiString(token.c_str());
            fVal2 = str.ToDouble();
        }
        else
            fVal2 = 0;
        parser->getTokens(); // s³owo zamykaj¹ce
        *parser >> token;
    }
示例#6
0
void Global::ConfigParse(TQueryParserComp *qp, cParser *cp)
{ // Ra: trzeba by przerobiæ na cParser, ¿eby to dzia³a³o w scenerii
    pParser = cp;
    qParser = qp;
    AnsiString str;
    int i;
    do
    {
        str = GetNextSymbol().LowerCase();
        if (str == AnsiString("sceneryfile"))
        {
            str = GetNextSymbol().LowerCase();
            strcpy(szSceneryFile, str.c_str());
        }
        else if (str == AnsiString("humanctrlvehicle"))
        {
            str = GetNextSymbol().LowerCase();
            asHumanCtrlVehicle = str;
        }
        else if (str == AnsiString("width"))
            iWindowWidth = GetNextSymbol().ToInt();
        else if (str == AnsiString("height"))
            iWindowHeight = GetNextSymbol().ToInt();
        else if (str == AnsiString("heightbase"))
            fDistanceFactor = GetNextSymbol().ToInt();
        else if (str == AnsiString("bpp"))
            iBpp = ((GetNextSymbol().LowerCase() == AnsiString("32")) ? 32 : 16);
        else if (str == AnsiString("fullscreen"))
            bFullScreen = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("freefly")) // Mczapkie-130302
        {
            bFreeFly = (GetNextSymbol().LowerCase() == AnsiString("yes"));
            pFreeCameraInit[0].x = GetNextSymbol().ToDouble();
            pFreeCameraInit[0].y = GetNextSymbol().ToDouble();
            pFreeCameraInit[0].z = GetNextSymbol().ToDouble();
        }
        else if (str == AnsiString("wireframe"))
            bWireFrame = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("debugmode")) // McZapkie! - DebugModeFlag uzywana w mover.pas,
            // warto tez blokowac cheaty gdy false
            DebugModeFlag = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("soundenabled")) // McZapkie-040302 - blokada dzwieku - przyda
            // sie do debugowania oraz na komp. bez karty
            // dzw.
            bSoundEnabled = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        // else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
        // bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));
        else if (str == AnsiString("physicslog")) // McZapkie-030402 - logowanie parametrow
            // fizycznych dla kazdego pojazdu z maszynista
            WriteLogFlag = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("physicsdeactivation")) // McZapkie-291103 - usypianie fizyki
            PhysicActivationFlag = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("debuglog"))
        { // McZapkie-300402 - wylaczanie log.txt
            str = GetNextSymbol().LowerCase();
            if (str == "yes")
                iWriteLogEnabled = 3;
            else if (str == "no")
                iWriteLogEnabled = 0;
            else
                iWriteLogEnabled = str.ToIntDef(3);
        }
        else if (str == AnsiString("adjustscreenfreq"))
        { // McZapkie-240403 - czestotliwosc odswiezania ekranu
            str = GetNextSymbol();
            bAdjustScreenFreq = (str.LowerCase() == AnsiString("yes"));
        }
        else if (str == AnsiString("mousescale"))
        { // McZapkie-060503 - czulosc ruchu myszy (krecenia glowa)
            str = GetNextSymbol();
            fMouseXScale = str.ToDouble();
            str = GetNextSymbol();
            fMouseYScale = str.ToDouble();
        }
        else if (str == AnsiString("enabletraction"))
        { // Winger 040204 - 'zywe' patyki dostosowujace sie do trakcji; Ra 2014-03: teraz ³amanie
            bEnableTraction = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        }
        else if (str == AnsiString("loadtraction"))
        { // Winger 140404 - ladowanie sie trakcji
            bLoadTraction = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        }
        else if (str == AnsiString("friction")) // mno¿nik tarcia - KURS90
            fFriction = GetNextSymbol().ToDouble();
        else if (str == AnsiString("livetraction"))
        { // Winger 160404 - zaleznosc napiecia loka od trakcji; Ra 2014-03: teraz pr¹d przy braku
            // sieci
            bLiveTraction = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        }
        else if (str == AnsiString("skyenabled"))
        { // youBy - niebo
            if (GetNextSymbol().LowerCase() == AnsiString("yes"))
                asSky = "1";
            else
                asSky = "0";
        }
        else if (str == AnsiString("managenodes"))
        {
            bManageNodes = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        }
        else if (str == AnsiString("decompressdds"))
        {
            bDecompressDDS = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        }
        // ShaXbee - domyslne rozszerzenie tekstur
        else if (str == AnsiString("defaultext"))
        {
            str = GetNextSymbol().LowerCase(); // rozszerzenie
            if (str == "tga")
                szDefaultExt = szTexturesTGA; // domyœlnie od TGA
            // szDefaultExt=std::string(Parser->GetNextSymbol().LowerCase().c_str());
        }
        else if (str == AnsiString("newaircouplers"))
            bnewAirCouplers = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("defaultfiltering"))
            iDefaultFiltering = GetNextSymbol().ToIntDef(-1);
        else if (str == AnsiString("ballastfiltering"))
            iBallastFiltering = GetNextSymbol().ToIntDef(-1);
        else if (str == AnsiString("railprofiltering"))
            iRailProFiltering = GetNextSymbol().ToIntDef(-1);
        else if (str == AnsiString("dynamicfiltering"))
            iDynamicFiltering = GetNextSymbol().ToIntDef(-1);
        else if (str == AnsiString("usevbo"))
            bUseVBO = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("feedbackmode"))
            iFeedbackMode = GetNextSymbol().ToIntDef(1); // domyœlnie 1
        else if (str == AnsiString("feedbackport"))
            iFeedbackPort = GetNextSymbol().ToIntDef(0); // domyœlnie 0
        else if (str == AnsiString("multiplayer"))
            iMultiplayer = GetNextSymbol().ToIntDef(0); // domyœlnie 0
        else if (str == AnsiString("maxtexturesize"))
        { // wymuszenie przeskalowania tekstur
            i = GetNextSymbol().ToIntDef(16384); // domyœlnie du¿e
            if (i <= 64)
                iMaxTextureSize = 64;
            else if (i <= 128)
                iMaxTextureSize = 128;
            else if (i <= 256)
                iMaxTextureSize = 256;
            else if (i <= 512)
                iMaxTextureSize = 512;
            else if (i <= 1024)
                iMaxTextureSize = 1024;
            else if (i <= 2048)
                iMaxTextureSize = 2048;
            else if (i <= 4096)
                iMaxTextureSize = 4096;
            else if (i <= 8192)
                iMaxTextureSize = 8192;
            else
                iMaxTextureSize = 16384;
        }
        else if (str == AnsiString("doubleambient")) // podwójna jasnoœæ ambient
            bDoubleAmbient = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("movelight")) // numer dnia w roku albo -1
        {
            fMoveLight = GetNextSymbol().ToIntDef(-1); // numer dnia 1..365
            if (fMoveLight == 0.0)
            { // pobranie daty z systemu
                unsigned short y, m, d;
                TDate date = Now();
                date.DecodeDate(&y, &m, &d);
                fMoveLight =
                    (double)date - (double)TDate(y, 1, 1) + 1; // numer bie¿¹cego dnia w roku
            }
            if (fMoveLight > 0.0) // tu jest nadal zwiêkszone o 1
            { // obliczenie deklinacji wg:
                // http://naturalfrequency.com/Tregenza_Sharples/Daylight_Algorithms/algorithm_1_11.htm
                // Spencer J W Fourier series representation of the position of the sun Search 2 (5)
                // 172 (1971)
                fMoveLight = M_PI / 182.5 * (Global::fMoveLight - 1.0); // numer dnia w postaci k¹ta
                fSunDeclination = 0.006918 - 0.3999120 * cos(fMoveLight) +
                                  0.0702570 * sin(fMoveLight) - 0.0067580 * cos(2 * fMoveLight) +
                                  0.0009070 * sin(2 * fMoveLight) -
                                  0.0026970 * cos(3 * fMoveLight) + 0.0014800 * sin(3 * fMoveLight);
            }
        }
        else if (str == AnsiString("smoothtraction")) // podwójna jasnoœæ ambient
            bSmoothTraction = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("timespeed")) // przyspieszenie czasu, zmienna do testów
            fTimeSpeed = GetNextSymbol().ToIntDef(1);
        else if (str == AnsiString("multisampling")) // tryb antyaliasingu: 0=brak,1=2px,2=4px
            iMultisampling = GetNextSymbol().ToIntDef(2); // domyœlnie 2
        else if (str == AnsiString("glutfont")) // tekst generowany przez GLUT
            bGlutFont = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("latitude")) // szerokoϾ geograficzna
            fLatitudeDeg = GetNextSymbol().ToDouble();
        else if (str == AnsiString("convertmodels")) // tworzenie plików binarnych
            iConvertModels = GetNextSymbol().ToIntDef(7); // domyœlnie 7
        else if (str == AnsiString("inactivepause")) // automatyczna pauza, gdy okno nieaktywne
            bInactivePause = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("slowmotion")) // tworzenie plików binarnych
            iSlowMotionMask = GetNextSymbol().ToIntDef(-1); // domyœlnie -1
        else if (str == AnsiString("modifytga")) // czy korygowaæ pliki TGA dla szybszego
            // wczytywania
            iModifyTGA = GetNextSymbol().ToIntDef(0); // domyœlnie 0
        else if (str == AnsiString("hideconsole")) // hunter-271211: ukrywanie konsoli
            bHideConsole = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str ==
                 AnsiString(
                     "rollfix")) // Ra: poprawianie przechy³ki, aby wewnêtrzna szyna by³a "pozioma"
            bRollFix = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("fpsaverage")) // oczekiwana wartosæ FPS
            fFpsAverage = GetNextSymbol().ToDouble();
        else if (str == AnsiString("fpsdeviation")) // odchylenie standardowe FPS
            fFpsDeviation = GetNextSymbol().ToDouble();
        else if (str == AnsiString("fpsradiusmax")) // maksymalny promieñ renderowania
            fFpsRadiusMax = GetNextSymbol().ToDouble();
        else if (str == AnsiString("calibratein")) // parametry kalibracji wejϾ
        { //
            i = GetNextSymbol().ToIntDef(-1); // numer wejœcia
            if ((i < 0) || (i > 5))
                i = 5; // na ostatni, bo i tak trzeba pomin¹æ wartoœci
            fCalibrateIn[i][0] = GetNextSymbol().ToDouble(); // wyraz wolny
            fCalibrateIn[i][1] = GetNextSymbol().ToDouble(); // mno¿nik
            fCalibrateIn[i][2] = GetNextSymbol().ToDouble(); // mno¿nik dla kwadratu
            fCalibrateIn[i][3] = GetNextSymbol().ToDouble(); // mno¿nik dla szeœcianu
        }
        else if (str == AnsiString("calibrateout")) // parametry kalibracji wyjϾ
        { //
            i = GetNextSymbol().ToIntDef(-1); // numer wejœcia
            if ((i < 0) || (i > 6))
                i = 6; // na ostatni, bo i tak trzeba pomin¹æ wartoœci
            fCalibrateOut[i][0] = GetNextSymbol().ToDouble(); // wyraz wolny
            fCalibrateOut[i][1] = GetNextSymbol().ToDouble(); // mno¿nik liniowy
            fCalibrateOut[i][2] = GetNextSymbol().ToDouble(); // mno¿nik dla kwadratu
            fCalibrateOut[i][3] = GetNextSymbol().ToDouble(); // mno¿nik dla szeœcianu
        }
        else if (str == AnsiString("brakestep")) // krok zmiany hamulca dla klawiszy [Num3] i [Num9]
            fBrakeStep = GetNextSymbol().ToDouble();
        else if (str ==
                 AnsiString("joinduplicatedevents")) // czy grupowaæ eventy o tych samych nazwach
            bJoinEvents = (GetNextSymbol().LowerCase() == AnsiString("yes"));
        else if (str == AnsiString("hiddenevents")) // czy ³¹czyæ eventy z torami poprzez nazwê toru
            iHiddenEvents = GetNextSymbol().ToIntDef(0);
        else if (str == AnsiString("pause")) // czy po wczytaniu ma byæ pauza?
            iPause |= (GetNextSymbol().LowerCase() == AnsiString("yes")) ? 1 : 0;
        else if (str == AnsiString("lang"))
            asLang = GetNextSymbol(); // domyœlny jêzyk - http://tools.ietf.org/html/bcp47
        else if (str == AnsiString("opengl")) // deklarowana wersja OpenGL, ¿eby powstrzymaæ b³êdy
            fOpenGL = GetNextSymbol().ToDouble(); // wymuszenie wersji OpenGL
    } while (str != "endconfig"); //(!Parser->EndOfFile)
    // na koniec trochê zale¿noœci
    if (!bLoadTraction) // wczytywanie drutów i s³upów
    { // tutaj wy³¹czenie, bo mog¹ nie byæ zdefiniowane w INI
        bEnableTraction = false; // false = pantograf siê nie po³amie
        bLiveTraction = false; // false = pantografy zawsze zbieraj¹ 95% MaxVoltage
    }
    // if (fMoveLight>0) bDoubleAmbient=false; //wtedy tylko jedno œwiat³o ruchome
    // if (fOpenGL<1.3) iMultisampling=0; //mo¿na by z góry wy³¹czyæ, ale nie mamy jeszcze fOpenGL
    if (iMultisampling)
    { // antyaliasing ca³oekranowy wy³¹cza rozmywanie drutów
        bSmoothTraction = false;
    }
    if (iMultiplayer > 0)
    {
        bInactivePause = false; // okno "w tle" nie mo¿e pauzowaæ, jeœli w³¹czona komunikacja
        // pauzowanie jest zablokowane dla (iMultiplayer&2)>0, wiêc iMultiplayer=1 da siê zapauzowaæ
        // (tryb instruktora)
    }
    fFpsMin = fFpsAverage -
              fFpsDeviation; // dolna granica FPS, przy której promieñ scenerii bêdzie zmniejszany
    fFpsMax = fFpsAverage +
              fFpsDeviation; // górna granica FPS, przy której promieñ scenerii bêdzie zwiêkszany
    if (iPause)
        iTextMode = VK_F1; // jak pauza, to pokazaæ zegar
    if (qp)
    { // to poni¿ej wykonywane tylko raz, jedynie po wczytaniu eu07.ini
        Console::ModeSet(iFeedbackMode, iFeedbackPort); // tryb pracy konsoli sterowniczej
        iFpsRadiusMax = 0.000025 * fFpsRadiusMax *
                        fFpsRadiusMax; // maksymalny promieñ renderowania 3000.0 -> 225
        if (iFpsRadiusMax > 400)
            iFpsRadiusMax = 400;
        if (fDistanceFactor > 1.0)
        { // dla 1.0 specjalny tryb bez przeliczania
            fDistanceFactor =
                iWindowHeight /
                fDistanceFactor; // fDistanceFactor>1.0 dla rozdzielczoœci wiêkszych ni¿ bazowa
            fDistanceFactor *=
                (iMultisampling + 1.0) *
                fDistanceFactor; // do kwadratu, bo wiêkszoœæ odleg³oœci to ich kwadraty
        }
    }
}
示例#7
0
bool TAnimModel::Load(cParser *parser, bool ter)
{ // rozpoznanie wpisu modelu i ustawienie �wiate�
    AnsiString str;
    std::string token;
    parser->getTokens(); // nazwa modelu
    *parser >> token;
    str = AnsiString(token.c_str());
    parser->getTokens(1, false); // tekstura (zmienia na ma�e)
    *parser >> token;
    if (!Init(str, AnsiString(token.c_str())))
    {
        if (str != "notload")
        { // gdy brak modelu
            if (ter) // je�li teren
            {
                if (str.SubString(str.Length() - 3, 4) == ".t3d")
                    str[str.Length() - 2] = 'e';
                Global::asTerrainModel = str;
                WriteLog(AnsiString("Terrain model \"" + str + "\" will be created."));
            }
            else
                ErrorLog(AnsiString("Missed file: " + str));
        }
    }
    else
    { // wi�zanie �wiate�, o ile model wczytany
        LightsOn[0] = pModel->GetFromName("Light_On00");
        LightsOn[1] = pModel->GetFromName("Light_On01");
        LightsOn[2] = pModel->GetFromName("Light_On02");
        LightsOn[3] = pModel->GetFromName("Light_On03");
        LightsOn[4] = pModel->GetFromName("Light_On04");
        LightsOn[5] = pModel->GetFromName("Light_On05");
        LightsOn[6] = pModel->GetFromName("Light_On06");
        LightsOn[7] = pModel->GetFromName("Light_On07");
        LightsOff[0] = pModel->GetFromName("Light_Off00");
        LightsOff[1] = pModel->GetFromName("Light_Off01");
        LightsOff[2] = pModel->GetFromName("Light_Off02");
        LightsOff[3] = pModel->GetFromName("Light_Off03");
        LightsOff[4] = pModel->GetFromName("Light_Off04");
        LightsOff[5] = pModel->GetFromName("Light_Off05");
        LightsOff[6] = pModel->GetFromName("Light_Off06");
        LightsOff[7] = pModel->GetFromName("Light_Off07");
    }
    for (int i = 0; i < iMaxNumLights; ++i)
        if (LightsOn[i] || LightsOff[i]) // Ra: zlikwidowa�em wym�g istnienia obu
            iNumLights = i + 1;
    int i = 0;
    int ti;

    parser->getTokens();
    *parser >> token;

    if (token.compare("lights") == 0)
    {
        parser->getTokens();
        *parser >> token;
        str = AnsiString(token.c_str());
        do
        {
            ti = str.ToDouble(); // stan �wiat�a jest liczb� z u�amkiem
            LightSet(i, ti);
            i++;
            parser->getTokens();
            *parser >> token;
            str = AnsiString(token.c_str());
        } while (str != "endmodel");
    }
示例#8
0
//---------------------------------------------------------------------------
void __fastcall TFormReportStudsCandRedDiplom::CreateWordDocument(void)
{
    InitReportQuery();

    if (ZMySqlQuery->RecordCount==0)
        return;

    WordMacros macros;
    macros.BeginMacros();

    macros.InsertLine("ActiveDocument.PageSetup.TopMargin=35");
    macros.InsertLine("ActiveDocument.PageSetup.BottomMargin=35");
    macros.InsertLine("ActiveDocument.PageSetup.LeftMargin=35");
    macros.InsertLine("ActiveDocument.PageSetup.RightMargin=35");

    macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
    macros.SelectionFont("Bold=true");
    macros.SelectionFont("Size=16");
    macros.SelectionText("Список кандидатов на получение красного диплома");
    macros.SelectionTypeParagraph();
    macros.SelectionFont("Size=12");
    macros.SelectionFont("Bold=false");
    macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft");

    int CountTables=0;
    int CountRows;
    for (int i=0; i<ZMySqlQuery->RecordCount; i++)
    {
        ZMySqlQuery->RecNo=i+1;
        int numgroup=ZMySqlQuery->Fields->FieldByNumber(1)->AsString.ToInt();

        // подготавливает запрос на список студенов
        //InitStudentsForGroup(numgroup);
        // получает список студентов на красный диплом
        //CountUsefullStuds=GetCountUsefullStudents(listNumUsefullStuds);
        //if (CountUsefullStuds==0)  continue;
        std::vector<red_student> redStudents = GetRedStudents(numgroup);
        if (redStudents.empty())
            continue;
        int CountUsefullStuds = redStudents.size();

        macros.SelectionTypeParagraph();
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft");
        macros.SelectionText("Группа ");
        macros.SelectionFont("Bold=true");
        macros.SelectionText(WCGetTitleForKeyNum(GROUPS,numgroup));
        macros.SelectionFont("Bold=false");
        macros.SelectionTypeParagraph();

        CountRows=CountUsefullStuds+1;
        macros.TablesAdd(CountRows,7);
        CountTables++;

        macros.TablesColumns(CountTables, 1, "Width = 20");
        macros.TablesColumns(CountTables, 2, "Width = 180");
        macros.TablesColumns(CountTables, 3, "Width = 60");
        macros.TablesColumns(CountTables, 4, "Width = 70");
        macros.TablesColumns(CountTables, 5, "Width = 70");
        macros.TablesColumns(CountTables, 6, "Width = 70");
        macros.TablesColumns(CountTables, 7, "Width = 50");

        macros.TablesColumns(CountTables, 1, "Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphRight");
        macros.TablesColumns(CountTables, 2, "Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft");
        macros.TablesColumns(CountTables, 3, "Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesColumns(CountTables, 4, "Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesColumns(CountTables, 5, "Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesColumns(CountTables, 6, "Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesColumns(CountTables, 7, "Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.SelectionFont("Bold=true");
        macros.InsertLine("ActiveDocument.Tables.Item(" + IntToStr(CountTables) + ").Range.Font.Size = 10");

        macros.InsertLine("ActiveDocument.Tables.Item(" + IntToStr(CountTables) + ").Rows.Item(1).Range.Font.Bold=true");
//    WordDocument->Tables->Item(CountTables)->Range->Select();

        macros.TablesCell(CountTables, 1, 1, "Range.Text = \"№\"");
        macros.TablesCell(CountTables, 1, 1, "Range.Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesCell(CountTables, 1, 2, "Range.Text = \"Фамилия, имя, отчество\"");
        macros.TablesCell(CountTables, 1, 2, "Range.Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesCell(CountTables, 1, 3, "Range.Text = \"№ зач. книжки\"");
        macros.TablesCell(CountTables, 1, 3, "Range.Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesCell(CountTables, 1, 4, "Range.Text = \"Кол-во \"\"удовл.\"\" (%)\"");
        macros.TablesCell(CountTables, 1, 4, "Range.Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesCell(CountTables, 1, 5, "Range.Text = \"Кол-во \"\"хор.\"\" (%)\"");
        macros.TablesCell(CountTables, 1, 5, "Range.Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesCell(CountTables, 1, 6, "Range.Text = \"Кол-во \"\"отл.\"\" (%)\"");
        macros.TablesCell(CountTables, 1, 6, "Range.Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
        macros.TablesCell(CountTables, 1, 7, "Range.Text = \"Средний балл\"");
        macros.TablesCell(CountTables, 1, 7, "Range.Select");
        macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");

        // проходим по списку на красный диплом
        for (int j = 0; j < redStudents.size(); ++j)
        {
            red_student& redStudent = redStudents[j];
            // номер позиции
            macros.TablesCell(CountTables, j+2,1, "Range.Text= \"" + AnsiString(j+1) + "\"");
            // фио
            macros.TablesCell(CountTables, j+2,2, "Range.Text= \"" + redStudent.name + "\"");
            // номер зачетки
            macros.TablesCell(CountTables, j+2,3, "Range.Text= \"" + redStudent.znum + "\"");

            // вычисляет баллы для студента
            //int countUDOVL,countHOR,countOTL;
            //double percUDOVL,percHOR,percOTL;
            //AnsiString AvrgBallStr;
            //GetBallsCount(countUDOVL,percUDOVL,countHOR,percHOR,countOTL,percOTL,AvrgBallStr,ZMySqlQueryStudsOfGrp->Fields->FieldByNumber(1)->AsString);

            AnsiString percUDOVLStr = AnsiString(redStudent.perc_ud);
            AnsiString percHORStr   = AnsiString(redStudent.perc_hor);
            AnsiString percOTLStr   = AnsiString(redStudent.perc_otl);
            char str[10];
            sprintf(str,"%4.2lf",percUDOVLStr.ToDouble());
            percUDOVLStr = AnsiString(str);
            sprintf(str,"%4.2lf",percHORStr.ToDouble());
            percHORStr = AnsiString(str);
            sprintf(str,"%4.2lf",percOTLStr.ToDouble());
            percOTLStr = AnsiString(str);

            AnsiString Str=AnsiString(redStudent.count_ud)+" ("+percUDOVLStr+"%)";
            macros.TablesCell(CountTables, j+2,4, "Range.Text= \"" + Str + "\"");
            Str=AnsiString(redStudent.count_hor)+" ("+percHORStr+"%)";
            macros.TablesCell(CountTables, j+2,5, "Range.Text= \"" + Str+ "\"");
            Str=AnsiString(redStudent.count_otl)+" ("+percOTLStr+"%)";
            macros.TablesCell(CountTables, j+2,6, "Range.Text= \"" + Str+ "\"");
            macros.TablesCell(CountTables, j+2,7, "Range.Text= \"" + redStudent.avrBall + "\"");
        }

        macros.TablesCell(CountTables, CountRows+1, 1, "Range.Select");
        macros.InsertLine("Selection.MoveDown Unit := wdLine");
    }
    //delete listNumUsefullStuds;

    macros.SelectionParagraphFormat("Alignment = wdAlignParagraphRight");
    macros.SelectionFont("Size=8");
    macros.SelectionText("(*)В таблицах не учитываются оценки \"\"зачтено\\"", \"\"незачтено\"\" и \"\"неудовлетворительно\"\".");
    macros.SelectionTypeParagraph();
    macros.SelectionText("(*)Таблицы содержат студентов, имеющих не более одной \"\"удовл\"\" и не менее 75% \"\"отл\"\".");

    macros.EndMacros();
    macros.RunMacros();
}