Esempio n. 1
0
//---------------------------------------------------------------------------
//Процедура добавления книги выбранному предмету
void __fastcall TMainForm::PutBook(TObject *Sender){
    BookForm->BitBtn2->Visible=true;
    if(BookForm->ShowModal()==mrOk){
        int bkod,sid,upkod,uid;
        AnsiString sql;
        bkod=Tree->Tag;
        sid=(int)Tree->Selected->Data;
        uid=Login->Tag;
        //Проверяем это добавление новой книги или замена
        switch(((TComponent *)Sender)->Tag){
            case 0: sql.printf("insert into spisbook (id,kbook,iduser) values (%d,%d,%d)",sid,bkod,uid);
                    break;
            case 1: upkod=DM->dsTree->FieldByName("KBOOK")->Value;
                    sql.printf("update spisbook set kbook=%d, iduser=%d where id=%d and kbook=%d",bkod,uid,sid,upkod);
        }
        DM->dsTree->First();
        //Проверка если данная книга в выбранном разделе
        while(!DM->dsTree->Eof){
            if(DM->dsTree->FieldByName("KBOOK")->AsInteger==bkod){
                Application->MessageBox("Эта книга здесь уже есть!", "Look", MB_OK);
                return;
            }
            DM->dsTree->Next();
        }
        DM->qInsert->SQL->Clear();
        DM->qInsert->SQL->Add(sql);
        DM->qInsert->Prepare();
        DM->qInsert->ExecQuery();
        DM->dsTree->Close();
        DM->dsTree->Open();
    }
}
Esempio n. 2
0
void TForm_Main::AdjustProperty(float fAmount)
{
	if (!m_hSample)
		return;

	// Get the current value
	float fValue = atof(c_Edit_Value->Text.c_str());
	// Adjust
	fValue += fAmount;
	// Tell Miles
	AIL_set_filter_sample_preference(m_hSample, c_ComboBox_Property->Text.c_str(), &fValue);
	// Get it back out in case we hit a max/min
	fValue = ReadProperty();
	// Put it back in the edit
	AnsiString holdString;
	holdString.printf("%0.4f", fValue);
	c_Edit_Value->Text = holdString;

	// Update the property cache
	int iCurProperty = 0;
	RIB_INTERFACE_ENTRY ribAttrib;
	HINTENUM enumerator(HINTENUM_FIRST);
	while ((iCurProperty < m_iNumProperties) &&
		AIL_enumerate_filter_sample_attributes(m_hCurFilter, &enumerator, &ribAttrib))
	{
		AIL_filter_sample_attribute(m_hSample, ribAttrib.entry_name, &m_fProperties[iCurProperty]);
		++iCurProperty;
	}
}
Esempio n. 3
0
//---------------------------------------------------------------------------
void __fastcall TLogin::BitBtn1Click(TObject *Sender){
AnsiString sql;
int id, ver;
if(RG->ItemIndex==1){
    sql.printf("select id, pass, version from login where login='******'",Name->Text);
    DM->dsLogin->Close();
    DM->dsLogin->SelectSQL->Clear();
    DM->dsLogin->SelectSQL->Add(sql);
    DM->dsLogin->Open();
    sql=DM->dsLogin->FieldByName("PASS")->AsString;
    id=DM->dsLogin->FieldByName("ID")->AsInteger;
    ver=DM->dsLogin->FieldByName("VERSION")->AsInteger;
    if (ver!=104){
        Application->MessageBox("Текущая версия программы устарела. Обновите программу.", "Ошибка", MB_OK);
        return;
    }
    if(Pass->Text==sql){
        Login->Tag=id;
        Hide();
        FirstForm->ShowModal();
        Close();
    }else{
        Application->MessageBox("Неправильный пароль!", "Ошибка", MB_OK);
        return;
    }
}
Hide();
FirstForm->ShowModal();
Close();
}
AnsiString __fastcall TScreenSnapper::JapanDatum(void)
{
	static AnsiString Months[]={"","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"};
	SYSTEMTIME St;
	GetSystemTime(&St);
	AnsiString Tmp;
	Tmp.printf("%d-%s-%d",St.wYear,Months[St.wMonth].c_str(),St.wDay);
	return Tmp;
}
Esempio n. 5
0
//---------------------------------------------------------------------------
void __fastcall TMainForm::GraphMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
  POINT ip = {X, Y};
  TLDPoint ldp;
  static_cast<TGraph2D*>(Sender)->Pixel2Coord(&ip, &ldp, 1);
  AnsiString s;
  s.printf("Mouse at (%.2Lf, %.2Lf)", ldp.x, ldp.y);
  StatusBar->SimpleText = s;
}
Esempio n. 6
0
//---------------------------------------------------------------------------
//При перемещении по древу опеределяем уровень выбранного узла
//и блокуриуем или разблокуруем кнопки панели инструментов
void __fastcall TMainForm::TreeChange(TObject *Sender, TTreeNode *Node){
    AnsiString filter;
    ToolButton2->Enabled=false;
    ToolButton4->Enabled=false;
    ToolButton5->Enabled=false;
    ToolButton6->Enabled=false;
    switch(Node->Level){
        case 4: filter.printf("ID=%d",(int*)Node->Data);
                DM->dsTree->Filter=filter;
                ToolButton4->Enabled=true;
                if(DM->dsTree->RecNo!=0){
                    ToolButton5->Enabled=true;
                    ToolButton6->Enabled=true;
                }
                break;
        case 3: ToolButton2->Enabled=true;
        default:filter.printf("ID=%d",9999);
                DM->dsTree->Filter=filter;
    }
}
static AnsiString kmloutput( Location *outgrid )
{
   AnsiString kml;
   kml.printf(
      "%3.8f,"
      "%3.8f",
      raddeg( outgrid->easting ),
      raddeg( outgrid->northing )
   );
   return kml;

}
Esempio n. 8
0
//---------------------------------------------------------------------------
void __fastcall TMainForm::N5Click(TObject *Sender){
    AnsiString sql;
    sql.printf("delete from spis2 where id=%d",(int)Tree->Selected->Data);
    try{
        DM->qInsert->SQL->Clear();
        DM->qInsert->SQL->Add(sql);
        DM->qInsert->ExecQuery();
        DM->dsSpis->FullRefresh();
        TreePaint();
    }catch(const Exception &E){
        Application->MessageBox("Удалите сначала книги.", "Ошибка", MB_OK);
    }
}
Esempio n. 9
0
//---------------------------------------------------------------------------
void __fastcall TMainForm::DeleteBook(TObject *Sender){
    int id, kbook;
    AnsiString sql;
    id=DM->dsTree->FieldByName("ID")->AsInteger;
    kbook=DM->dsTree->FieldByName("KBOOK")->AsInteger;
    sql.printf("delete from spisbook where id=%d and kbook=%d",id,kbook);
    DM->qInsert->SQL->Clear();
    DM->qInsert->SQL->Add(sql);
    //DM->qInsert->Prepare();
    DM->qInsert->ExecQuery();
    DM->dsTree->FullRefresh();
    //DM->dsTree->Close();
    //DM->dsTree->Open();
}
Esempio n. 10
0
//---------------------------------------------------------------------------
void TGJVEditFrame::setScoreText( int dist, bool partial, bool xband )
{
   AnsiString b;
   AnsiString s;
   s.printf( "%d", dist );

   if ( partial )
      b += "(";
   b += s;
   if ( partial )
      b += ")";
   if ( xband )
      b += "X";
   DistSt->Caption = b;
}
Esempio n. 11
0
//-----------------------------------------------------------------------------------------------
//Функция создания связки предмета с нужной специальностью и курсом
void __fastcall TMainForm::Button3Click(TObject *Sender){
    PredForm->Tag=1;
    PredForm->Button1->Visible=true;
    if(PredForm->ShowModal()==mrOk){
        TTreeNode *Node;
        AnsiString filter;
        int otd,obu,kurs,pred;
        //Выбираем мз выбранного узла древа значения курса, специальности и
        //формы обучения
        otd=PMyRec(Tree->Selected->Data)->otd;
        obu=PMyRec(Tree->Selected->Data)->obu;
        kurs=PMyRec(Tree->Selected->Data)->kurs;
        pred=Tree->Tag;
        Tree->Tag=0;
        //Проверяем нет ли такого предмета на данном курсе выбранной специальности
        filter.printf("KOTD=%d and FOBUCH=%d and KURS=%d and KPRED=%d",otd,obu,kurs,pred);
        DM->dsSpis->Filter=filter;
        //если есть выводим предупреждающее сообщение и завершаем процедуру
        if(DM->dsSpis->RecNo!=0){
            Application->MessageBox("Такая связка уже есть.", "Look", MB_OK);
        }else{
        //если нет - создаем нужную связку в таблице
            AnsiString sql;
            sql.printf("insert into spis2 (kotd,kpred,kurs,fobuch) values (%d,%d,%d,%d)",otd,pred,kurs,obu);
            DM->qInsert->SQL->Clear();
            DM->qInsert->SQL->Add(sql);
            DM->qInsert->Prepare();
            DM->qInsert->ExecQuery();
            DM->dsSpis->Close();
            DM->dsSpis->Open();
            //Добавляем в древо новый узел
            Tree->Items->AddChildObject(Tree->Selected,DM->dsSpis->FieldByName("N_PREDMET")->AsString,\
            (void*)DM->dsSpis->FieldByName("ID")->AsInteger);
        }
    }
}
Esempio n. 12
0
	PTRADE_API void __stdcall get_version( char * name, int name_size,char * version,int version_size)
	{
		lstrcpyn(name,PLUGINNAME,name_size);
		try
		{
			VersionInfo vi("PTrdSQJSF.dll");
			AnsiString strVer;
			strVer.printf("%d.%d.%d.%d",vi.productMajorVersion(),
											 vi.productMinorVersion(),
											 vi.productBuild(),
											 vi.productSubBuild());
			lstrcpyn(version,strVer.c_str(), version_size);
		}
		catch(...)
		{
			lstrcpyn(version,"0.0.0.0", version_size);
		}
	}
Esempio n. 13
0
void __fastcall TMultDispFrame::LocatorMultTreeGetText(
   TBaseVirtualTree */*Sender*/, PVirtualNode Node, TColumnIndex /*Column*/,
   TVSTTextType /*TextType*/, UnicodeString &CellText )
{
   if ( Node->States.Contains( vsHasChildren ) )
      CellText = ct->locs.llist[ Node->Index ] ->loc;
   else
   {
      String dispLine;
      for (int i = 0; ct->locs.llist.size() && i < 10; i++)
      {
         unsigned char *lc = ct->locs.llist[ Node->Parent->Index ] ->map( Node->Index * 10 + i );
         AnsiString disp;
         disp.printf( "%2.2d", Node->Index * 10 + i );
         if ( lc && *lc )
            dispLine += disp + " (" + *lc + ") ";
      }
      CellText = dispLine;
   }
}
Esempio n. 14
0
void __fastcall TForm_About::FormCreate(TObject *Sender)
{
   AnsiString as;
   lb_BuildDate->Caption = "Build date: " + AnsiString( __DATE__ );

   unsigned int major_ver;
   unsigned int minor_ver;
   unsigned int release_num;
   unsigned int build_num;

   // get flash tool (UI) verison
   GetVersion(&major_ver, &minor_ver, &release_num, &build_num);

//   VersionInfo->Caption = "FlashTool v" + IntToStr(major_ver) + "." + IntToStr(minor_ver) + "." + IntToStr(release_num) + "." + IntToStr(build_num);
    as.printf("FlashTool v%u.%04u.%02u.%02u", major_ver, minor_ver, release_num, build_num);
    VersionInfo->Caption = as;

#ifdef _DEBUG
     as = VersionInfo->Caption;
     as = as+" (DEBUG version) ";
     VersionInfo->Caption = as;
#endif /* #ifdef _DEBUG */

   const char *p_version, *p_release_type, *p_build_date;

   // get the brom dll information
   Brom_GetDLLInfo(&p_version, &p_release_type, &p_build_date, NULL);
   as.printf("%s", p_version);
   brom_dll_version->Caption = as;
   as.printf("%s", p_release_type);
   brom_dll_release_type->Caption = as;
   as.printf("(Build-Date: %s)", p_build_date);
   brom_dll_build_date->Caption = as;

   // get the meta dll information
   META_GetDLLInfo(&p_version, &p_release_type, &p_build_date, NULL);
   as.printf("%s", p_version);
   meta_dll_version->Caption = as;
   as.printf("%s", p_release_type);
   meta_dll_release_type->Caption = as;
   as.printf("(Build-Date: %s)", p_build_date);
   meta_dll_build_date->Caption = as;
}
Esempio n. 15
0
void dump(int n1,int n2,int n3,double Re,double ****f1,double ***nut,double t_cur,long count)
{
FILE *fd;                                
AnsiString tmp;
AnsiString tmp2 = NameDumpFile;
tmp.printf("%d",num_dump);
fd = fileopen(tmp2.Insert(tmp,tmp2.Pos(".")),0);
nmessage("dump is done",t_cur);
MainWindow->ChangeStatus("","—брос данных в файл є"+tmp);
fprintf(fd,"current time = %0.10f \ncurrent iteration = %ld\n",t_cur,count);
fprintf(fd,"Number of points along x = %d\n",n1);
fprintf(fd,"Number of points along y = %d\n",n2);
fprintf(fd,"Number of points along z = %d\n",n3);
fprintf(fd,"Reynolds number = %lf\n",Re);
print_array3d(fd,f1[0],0,m1,0,m2,0,m3);
print_array3d(fd,f1[1],0,m1,0,m2,0,m3);
print_array3d(fd,f1[2],0,m1,0,m2,0,m3);
print_array3d(fd,f1[3],0,m1,0,m2,0,m3);
print_array3d(fd,nut,0,m1,0,m2,0,m3);
fclose(fd);
num_dump++;
}
std::string DisplayContestContact::getField( int ACol, const BaseContestLog *const curcon ) const
{
   // only used to get fields for main log display
   std::string res;
   if ( !curcon )
      return res;

   BaseContestLog * clp = contest;

   unsigned short cf = contactFlags.getValue();
   if ( cf & ( LOCAL_COMMENT | COMMENT_ONLY | DONT_PRINT ) )
   {
      switch ( ACol )
      {
         case egTime:
            res = time.getTime( DTGDISP );
            break;
         case egCall:
            res = ( cf & DONT_PRINT ) ? "DELETED" : ( cf & LOCAL_COMMENT ) ? "LOCAL COMMENT" : "COMMENT FOR ADJUDICATOR";
            break;
         case egRSTTx:
            res = comments.getValue();
            break;
      }
   }
   else
   {
      switch ( ACol )
      {
         case egTime:
            res = time.getTime( DTGDISP );
            break;
         case egCall:
            res = cs.fullCall.getValue();
            break;
         case egRSTTx:
            res = reps.getValue();
            break;
         case egSNTx:
            {
               int ss = atoi( serials.getValue().c_str() );
			   AnsiString ssbuff;
               if ( ss )
                  ssbuff.printf( "%03.3d", ss );
               res = ssbuff.c_str();
            }
            break;
         case egRSTRx:
            res = repr.getValue();
            break;
         case egSNRx:
            {
               int sr = atoi( serialr.getValue().c_str() );
			   AnsiString srbuff;
               if ( sr )
				  srbuff.printf( "%03.3d", sr );
               res = srbuff.c_str();
            }
            break;
         case egLoc:
            res = loc.loc.getValue();
            break;
         case egBrg:
            {
			   AnsiString brgbuff;

               if ( contactFlags.getValue() & MANUAL_SCORE )
                  brgbuff = "MAN";
               else
               {
                  if ( loc.valRes == LOC_OK )
                  {
                     if ( contest == curcon )
                     {
                        // use the existing data
						int offset = contest->bearingOffset.getValue();
						brgbuff.printf( "%03.3d\xB0", varBrg( bearing + offset ) );
                     }
                     else
                     {
                        // rework to come from prime contest loc
                        double lon = 0.0;
                        double lat = 0.0;
                        int brg;
                        double dist;
                        if ( lonlat( loc.loc.getValue(), lon, lat ) == LOC_OK )
                        {
                           // we don't have it worked out already...
                           double lon = 0.0;
                           double lat = 0.0;
                           int brg;
                           double dist;

                           if ( lonlat( loc.loc.getValue(), lon, lat ) == LOC_OK )
                           {
                              curcon->disbear( lon, lat, dist, brg );
                           }
						   int offset = curcon->bearingOffset.getValue();
						   brgbuff.printf( "%03.3d\xB0", varBrg( brg + offset ) );
                        }
                     }
                  }
			   }
			   res = brgbuff.c_str();
			}
			break;

		 case egScore:
			{
			   AnsiString scorebuff;

			   if ( contactFlags.getValue() & DONT_PRINT )
				  scorebuff = "DEL";
			   else
				  if ( contactFlags.getValue() & NON_SCORING )
					 scorebuff = "N/S";
				  else
				  {
					 if ( contest == curcon )
					 {
						// use the existing data
						if ( ( cs.valRes == ERR_DUPCS ) && ( curcon == clp ) )
						   scorebuff = "DUP";
						else
						{
						   int temp = contactScore.getValue();
						   if ( temp <= 0 )
							  temp = 0;

                           switch ( contest->scoreMode.getValue() )
                           {
                              case PPKM: 	// needs a valid LOC
                                 if ( !curcon->locatorField.getValue() )
                                 {
                                    if ( temp )
                                       scorebuff = "1";
                                    else
                                       scorebuff = "0";
                                 }
                                 else
                                 {
                                    if ( contactFlags.getValue() & XBAND )
                                    {
									   scorebuff.printf( "%4dXB", temp );
                                    }
                                    else
                                       scorebuff.printf( "%4d", temp );
                                 }
                                 break;

                              case PPQSO:
                                 // actually we would often want the distance here
                                 scorebuff.printf( "%4d", temp );
                                 break;

                           }
                        }
                     }
                     else
                     {
                        // we don't have it worked out already...
                        double lon = 0.0;
                        double lat = 0.0;
                        int brg;
                        double dist = 0.0;

                        if ( lonlat( loc.loc.getValue(), lon, lat ) == LOC_OK )
                        {
                           curcon->disbear( lon, lat, dist, brg );
                        }
                        scorebuff.printf( "%d", ( int ) dist );

                     }
                  }
               res = scorebuff.c_str();
            }
            break;
         case egExchange:
            if ( districtMult )
            {
               if (stricmp(districtMult->districtCode, extraText.getValue()) == 0)
               {
                  res = districtMult->districtCode;
               }
               else
               {
                  res = districtMult->districtCode + "(" + extraText.getValue() + ")";
               }
            }
            else
            {
               res = extraText.getValue();
            }
            break;
         case egComments:
            {
               res = comments.getValue();
            }
            break;
      }
   }
   return res;
}
Esempio n. 17
0
void printing(double ****f1,double dtdid,double t_cur,long count,double en)
{
double temp, div=0;
int i,j,k,l;
double mf, mda, mdr;
double *avervx, *avernu;
AnsiString TempScreen;
FILE *fv,*fnu,*fen,*fkv;
//fnu = fileopen(NameNuFile,count);
if(MainWindow->CheckClear->Checked)
         MainWindow->Screen->Lines->Clear();
boundary_conditions(f1);

for(i=ghost;i<mm1;i++)
   for(j=ghost;j<mm2;j++)
      for(k=ghost;k<mm3;k++) {
           temp=0;
           for(l=0;l<3;l++)
            temp+=dr(f1[l],i,j,k,l+1,0,dx[l],ghost, approx);
           if (fabs(temp)>div) div=fabs(temp);
           }
time(&time_now);
if(MainWindow->CheckScreenOutput->Checked)  {
   TempScreen.printf("program is working %ld seconds",time_now-time_begin);
   MainWindow->Screen->Lines->Append(TempScreen);
   TempScreen.printf("t=%e \tdtdid=%e \tNIter=%d", t_cur, dtdid, count);
   MainWindow->Screen->Lines->Append(TempScreen);
   TempScreen.printf("divergention=%e", div);
   }
for(l=0;l<nvar;l++) {
       mf=mda=mdr=0;
       for(i=ghost;i<mm1;i++)
        for(j=ghost;j<mm2;j++)
         for(k=ghost;k<mm3;k++) {
            temp=fabs(f[l][i][j][k]-f1[l][i][j][k]);
            if (temp>mda) mda=temp;
            if(f1[l][i][j][k]!=0) temp/=f1[l][i][j][k];
            if (temp>mdr) mdr=temp;
            if (fabs(f1[l][i][j][k])>mf) mf=fabs(f1[l][i][j][k]);
          }
          if(MainWindow->CheckScreenOutput->Checked)  {
                TempScreen.printf("%d\t%e\t%e\t%e",l, mf, mda, mdr);
                MainWindow->Screen->Lines->Append(TempScreen);
                }
          }

         if(MainWindow->CheckScreenOutput->Checked)  {
            TempScreen.printf("Energy of pulsations=%g, total energy=%g",en,TotalEnergy);
            MainWindow->Screen->Lines->Append(TempScreen);
            }
         if(MainWindow->CheckFileOutput->Checked)  {
            fen = fileopen(NameEnergyFile,count);
            fprintf(fen,"%0.10f\n",en);
            fclose(fen);
            }
         if(MainWindow->CheckScreenOutput->Checked)  {
            TempScreen.printf("number of runge-kutt calculations=%d",enter);
            MainWindow->Screen->Lines->Append(TempScreen);
            }

if(MainWindow->CheckFileOutput->Checked)  {  //if fileoutput
/*avervx = alloc_mem_1f(m3);
if(avervx == NULL)  nrerror("\nAlloc_mem: insufficient memory!\n\a",t_cur);*/

avernu = alloc_mem_1f(m3);

for(k=ghost;k<mm3;k++)
	{
	/*  avervx[k] =*/ avernu[k] = 0;
          for(i=ghost;i<mm1;i++)
             for(j=ghost;j<mm2;j++)
		 {
	  //	   avervx[k] += f1[0][i][j][k];
                   avernu[k] += nut[i][j][k];
		  }
//	   avervx[k] /= n1*n2;
	   avernu[k] /= n1*n2;
	 }
  //putting velocities to file
        fv = fileopen(NameVFile,count);
        fprintf(fv,"{%-7.5lf}",t_cur);
        print_array1d(fv,f1[0][m1/2][0],ghost,n3);
        fclose(fv);
  //putting viscosities to file
      fnu = fileopen(NameNuFile,count);
        print_array1d(fnu,avernu,ghost,n3);
        fclose(fnu);
  //for(k=0;k<m3;k++) printf("%e\n",f1[0][5][5][k]);
  //putting kaskad variables(log energy combined from them) to file
if(MainWindow->CheckNut->Checked)
  {
  fkv=fileopen(NameKaskadVarFile,count);
  fprintf(fkv,"{");
  for(i=0;i<Ns;i++)
    {
    fprintf(fkv,"{");
    for(k=0;k<n3;k++)
        {
        mf=fabs(sha[k][i]*sha[k][i]+shb[k][i]*shb[k][i]);
        if(mf>1e-300) fprintf(fkv,"%0.10lf",log(mf));
                 else fprintf(fkv,"NAN");
        fprintf(fkv,k<n3-1 ? "," : "}");
        }
    fprintf(fkv,i<Ns-1 ? "," : "}\n");
    }
  fclose(fkv);
  }//if nu_kaskad is used
 free_mem_1f(avernu,m3);
  }//if fileoutput
}
Esempio n. 18
0
//---------------------------------------------------------------------------
//Функция генерации древа с предметами и специальностями.
void __fastcall TMainForm::TreePaint(){
    TTreeNode *Node,*Node1,*Node2,*Node3;
    PMyRec MyRecPtr;
    AnsiString filter;
    int otd,obu;
    Tree->Items->Clear(); // remove any existing nodes
    DM->dsLookup->First();
    //просматриваем таблицу ВУЗов и создаем корневые узлы древа
    while(!DM->dsLookup->Eof){
        Node=Tree->Items->AddObject(NULL,DM->dsLookup->FieldByName("VUZ")->AsString,\
        (void*)DM->dsLookup->FieldByName("ID")->AsInteger);
        DM->dsOtdel->First();
        //просматриваем таблицу специальностей и добавляем в древо специальности
        //соответственно ВУЗам
        while(!DM->dsOtdel->Eof){
            if(DM->dsOtdel->FieldByName("TVUZ")->AsInteger==DM->dsLookup->FieldByName("ID")->AsInteger){
                Node1=Tree->Items->AddChildObject(Node,DM->dsOtdel->FieldByName("N_OTDEL")->AsString,\
                (void*)DM->dsOtdel->FieldByName("KOD")->AsInteger);
                otd=DM->dsOtdel->FieldByName("KOD")->AsInteger;
                //Добавляем дочерний узел к специальности -"Денна форма навяання"
                Node2=Tree->Items->AddChild(Node1,"Денна");
                obu=1;
                for(int i=1;i<7;i++){
                    MyRecPtr=new TMyRec;
                    MyRecPtr->otd=otd;
                    MyRecPtr->obu=obu;
                    MyRecPtr->kurs=i;
                    //Добавляем в древо узлы соответствующие курсам с 1 по 5
                    Node3=Tree->Items->AddChildObject(Node2,"Курс "+AnsiString(i),MyRecPtr);
                    //Отфильтровуем в таблице связей специальностей, курса и предметов
                    //нужные записи
                    filter.printf("KOTD=%d and FOBUCH=%d and KURS=%d",otd,obu,i);
                    DM->dsSpis->Filter=filter;
                    //добавляем оставшиеся записи в древо
                    while(!DM->dsSpis->Eof){
                        Tree->Items->AddChildObject(Node3,DM->dsSpis->FieldByName("N_PREDMET")->AsString,\
                        (void*)DM->dsSpis->FieldByName("ID")->AsInteger);
                        DM->dsSpis->Next();
                    }
                }
                //То же для "Денноъ форми навчання"
                Node2=Tree->Items->AddChild(Node1,"Заочна");
                obu=2;
                for(int i=1;i<7;i++){
                    MyRecPtr=new TMyRec;
                    MyRecPtr->otd=otd;
                    MyRecPtr->obu=obu;
                    MyRecPtr->kurs=i;
                    Node3=Tree->Items->AddChildObject(Node2,"Курс "+AnsiString(i),MyRecPtr);
                    filter.printf("KOTD=%d and FOBUCH=%d and KURS=%d",otd,obu,i);
                    DM->dsSpis->Filter=filter;
                    while(!DM->dsSpis->Eof){
                        Tree->Items->AddChildObject(Node3,DM->dsSpis->FieldByName("N_PREDMET")->AsString,\
                        (void*)DM->dsSpis->FieldByName("ID")->AsInteger);
                        DM->dsSpis->Next();
                    }
                }
            }
            DM->dsOtdel->Next();
        }
        DM->dsLookup->Next();
    }
}
Esempio n. 19
0
void __fastcall TTiffBook::FlipCurPage(int n) {
//-------------------------------------------------------------------------------
//               Переворачивает текущую страницу вверх ногами                   |
// n - номер страницы, который надо нанести. <= 0 - только убрать ном стр       |
//-------------------------------------------------------------------------------
    stop++;
    Gdiplus::Graphics *g32;
    TTiffImage *img = GetImagePage(GetPage());
    Gdiplus::Bitmap *fbm = img->fbm;
    Gdiplus::Rect r;
    int w = fbm->GetWidth(), h = fbm->GetHeight();

    // g = new Gdiplus::Graphics(fbm);

    Gdiplus::Bitmap *b32 = new Gdiplus::Bitmap(w, h, PixelFormat32bppARGB);
    g32 = new Gdiplus::Graphics(b32);

    Gdiplus::Matrix matr;
    matr.Rotate(180.0f);                // поворачиваем его на 270 градусов
    g32->SetTransform(&matr);

    //r.X = 0;
    //r.Y = 0;
    //r.Width = w;
    //r.Height = h;

    //r.X = -SaveBitmapH;
    //r.Y = -30;
    //r.Width = SaveBitmapH - 30;
    //r.Height = SaveBitmapW - 30;

    r.X = -w;
    r.Y = -h;
    r.Width = w;
    r.Height = h;

    sres = g32->DrawImage(fbm, r, 0, 0, w, h, Gdiplus::UnitPixel, 0, 0, 0);

    matr.Reset();
    g32->SetTransform(&matr);

    // Удаляем черные полосы сверху и снизу
    Gdiplus::Pen whitePen2(Gdiplus::Color(255, 255, 255, 255), 2);
    g32->DrawLine(&whitePen2, 0, 0, w, 0);
    g32->DrawLine(&whitePen2, 0, h-1, w, h-1);

    // Удаляем старый номер страницы - он теперь внизу
    // Gdiplus::Pen whitePen40(Gdiplus::Color(255, 0, 0, 0), 45);   // ??? Пока черный - для отладки!
    Gdiplus::Pen whitePen40(Gdiplus::Color(255, 255, 255, 255), 45);
    g32->DrawLine(&whitePen40, 0, h - 50, 200, h - 50);

    if (n > 0) {                        // Здесь выводим номер страницы
        AnsiString snum;
        wchar_t wnum[20];
        snum.printf("%d", n);
        snum.WideChar(wnum, 20);
        Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
        Gdiplus::PointF origin(w - 160, 20.0f);
        Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
        g32->DrawLine(&whitePen40, w - 200, 50, w, 50);
        sres = g32->DrawString(wnum, -1, &myFont, origin, &blackBrush);
    }

    //if (npage > 0) {            // Здесь выводим номер страницы
    //    AnsiString snum;
    //    wchar_t wnum[20];
    //    snum.printf("%d", npage);
    //    snum.WideChar(wnum, 20);
    //    Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
    //    Gdiplus::PointF origin(SaveBitmapW - 160, 20.0f);
    //    Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
    //    SaveBitmap2TiffGraphics->DrawString(wnum, -1, &myFont, origin, &blackBrush);
    //}

    // ------- строим SaveBitmap2TiffBitmap1
    UINT *pix;
    unsigned char byte, bit, *pix1;

    Gdiplus::Bitmap *b1 = new Gdiplus::Bitmap(w, h, PixelFormat1bppIndexed);
    Gdiplus::Rect BitsRect(0, 0, w, h);
    Gdiplus::BitmapData *bits = new Gdiplus::BitmapData;
    Gdiplus::BitmapData *bits1 = new Gdiplus::BitmapData;
    sres = b32->LockBits(&BitsRect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, bits);
    sres = b1->LockBits(&BitsRect, Gdiplus::ImageLockModeWrite, PixelFormat1bppIndexed, bits1);

    for (int y = 0; y < h; y++) {
        pix = (UINT *)((int)bits->Scan0 + bits->Stride * y);
        pix1 = (unsigned char *)((int)bits1->Scan0 + bits1->Stride * y);
        byte = 0;
        for (int x = 0; x < w; x++, pix++) {
            if ((*pix & 0xFF) > 0xD8) {
                bit = 1;
            }
            else bit = 0;
            byte <<= 1; byte |= bit;
            if ((x & 7) == 7) {
                *pix1++ = byte;
                byte = 0;
            }
        }
    }

    b32->UnlockBits(bits); delete bits;
    b1->UnlockBits(bits1); delete bits1;

    delete g32;
    delete b32;

    TTiffPageInfo *pi = GetPageInfo(GetPage());
    if (img->Filn.Length() == 0) {                  // Это уже временный файл!
        delete img->fbm;
        img->fbm = b1;
    } else {                                        // Надо будет заменить страницу на временный файл
        img = new TTiffImage(b1);
        pi->ImageIndex = AppendImage(img);
        pi->PageIndex = 0;
    }

    changed = true;
}
Esempio n. 20
0
void __fastcall TTiffImage::DrawCenter(TCanvas *c, int xc, int yc, int w1, int h1, int PageNumber) {
//-------------------------------------------------------------------------------
//                  Рисует текущую страницу с центром (xc, yc)                  |
// Масштабирует пропроционально, в итоге будет заполнено либо w, либо h         |
//-------------------------------------------------------------------------------
    if (fbm == NULL) return;

    Gdiplus::Graphics *gra, *g32;
    Gdiplus::Bitmap *b32;
    Gdiplus::Rect r;
    int w = fbm->GetWidth(), h = fbm->GetHeight();

    b32 = new Gdiplus::Bitmap(w, h, PixelFormat32bppARGB);
    g32 = new Gdiplus::Graphics(b32);

    r.X = 0;
    r.Y = 0;
    r.Width = w;
    r.Height = h;

    sres = g32->DrawImage(fbm, r, 0, 0, w, h, Gdiplus::UnitPixel, 0, 0, 0);

    if (PageNumber != 0) {                      // Надо выводить номер страницы?
        AnsiString snum;
        wchar_t wnum[20];
        Gdiplus::Pen whitePen40(Gdiplus::Color(255, 255, 255, 255), 45);
        snum.printf("%d", PageNumber);
        snum.WideChar(wnum, 20);
        Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
        Gdiplus::PointF origin(w - 160, 20.0f);
        Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
        g32->DrawLine(&whitePen40, w - 200, 50, w, 50);
        if (PageNumber > 0) {
            sres = g32->DrawString(wnum, -1, &myFont, origin, &blackBrush);
        }
    }


    w = w1; h = h1;
    gra = new Gdiplus::Graphics(c->Handle);

    //if (CanvasHandle != c->Handle) {
    //    if (CanvasHandle != NULL) delete gra;
    //    CanvasHandle = c->Handle;
    //    gra = new Gdiplus::Graphics(CanvasHandle);
    //}


    double scalex = (double)w / GetWidth();
    double scaley = (double)h / GetHeight();
    double scale = scalex < scaley ? scalex : scaley;
    w = round(GetWidth() * scale);
    h = round(GetHeight() * scale);
    xc -= w / 2;
    yc -= h / 2;

    Gdiplus::Rect dst(xc, yc, w, h);

    // gra->DrawImage(fbm, dst, 0, 0, GetWidth(), GetHeight(), Gdiplus::UnitPixel, 0, 0, 0);
    gra->DrawImage(b32, dst, 0, 0, GetWidth(), GetHeight(), Gdiplus::UnitPixel, 0, 0, 0);

    delete gra;
    delete g32;
    delete b32;

}
Esempio n. 21
0
//---------------------------------------------------------------------------
bool TGJVEditFrame::dlgForced()
{
   std::auto_ptr <TForceLogDlg> ForceDlg( new TForceLogDlg( this ) );

   getScreenEntry();
   valid( cmCheckValid );       // This adds errors to the MAIN dialog error list, not our own

   ErrorList &errs = MinosParameters::getMinosParameters() ->getErrorList();
   for ( ErrorIterator i = errs.begin(); i != errs.end(); i++ )
   {
      ForceDlg->ErrList->Items->Add( ( *i ) ->errStr.c_str() );
   }
   ForceDlg->ErrList->ItemIndex = 0;

   int s = screenContact.contactScore;
   if ( s < 0 )
      s = 0;
   AnsiString temp;
   temp.printf( "%d", s );
   ForceDlg->ScoreIl->Text = temp;

   ForceDlg->CheckBox1->Checked = screenContact.contactFlags & TO_BE_ENTERED;
   ForceDlg->CheckBox2->Checked = screenContact.contactFlags & VALID_DUPLICATE;
   ForceDlg->CheckBox3->Checked = screenContact.contactFlags & MANUAL_SCORE;
   ForceDlg->CheckBox4->Checked = screenContact.contactFlags & NON_SCORING;
   ForceDlg->CheckBox5->Checked = screenContact.contactFlags & DONT_PRINT;
   ForceDlg->CheckBox6->Checked = screenContact.contactFlags & COUNTRY_FORCED;
   ForceDlg->CheckBox7->Checked = screenContact.contactFlags & VALID_DISTRICT;
   ForceDlg->CheckBox8->Checked = screenContact.contactFlags & XBAND;

   if ( MinosParameters::getMinosParameters() ->isErrSet( ERR_12 ) ||
        ( screenContact.contactFlags & ( NON_SCORING | MANUAL_SCORE | DONT_PRINT | VALID_DUPLICATE | TO_BE_ENTERED | XBAND ) ) )

   {
      // set nothing! DUPs are dealt with!
   }
   else
      if ( errs.size() != 0 )  				// no errors -> OK
         ForceDlg->CheckBox4->Checked = screenContact.contactFlags | NON_SCORING;

   if ( screenContact.contactFlags & COUNTRY_FORCED )
   {
      ForceDlg->CtryMultIl->Text = screenContact.forcedMult.c_str();
   }
   else
      if ( contest->countryMult.getValue() && screenContact.ctryMult )
      {
         ForceDlg->CtryMultIl->Text = screenContact.ctryMult->basePrefix.c_str();
      }

   bool tryagain = true;
   int res = mrCancel;
   while ( tryagain && ( res = ForceDlg->ShowModal() ) == mrOk )
   {
      if ( contest->countryMult.getValue() )
      {
         temp = ForceDlg->CtryMultIl->Text;
      }
      else
         break;

      if ( !ForceDlg->CheckBox6->Checked )
      {
         tryagain = false;
         screenContact.contactFlags &= ~ COUNTRY_FORCED;
         screenContact.ctryMult = 0;
         screenContact.forcedMult = "";
         break;
      }

      temp = temp.Trim();

      CountryEntry *ctryMult = MultLists::getMultLists() ->getCtryForPrefix( temp.c_str() );
      if ( ctryMult )
      {
         tryagain = false;
         if ( screenContact.ctryMult != ctryMult )
         {
            screenContact.ctryMult = ctryMult;
            screenContact.contactFlags |= COUNTRY_FORCED;
            screenContact.forcedMult = temp.c_str();
         }
      }
      else
      {
         if ( MessageBox( Handle, "Country not in CTY.DAT. Leave for now?", "Force log contact", MB_ICONQUESTION | MB_OKCANCEL ) == mbOK )
         {
            tryagain = false;
            screenContact.contactFlags &= ~COUNTRY_FORCED;
            screenContact.forcedMult = "";
         }
      }
   }
   if ( res == mrOk )
   {
      // save contact...
      screenContact.contactFlags |= FORCE_LOG;
      // here read it all off the dialog

      screenContact.contactFlags &= ~( NON_SCORING | MANUAL_SCORE | DONT_PRINT | VALID_DUPLICATE | TO_BE_ENTERED | VALID_DISTRICT | XBAND );

      if ( ForceDlg->CheckBox1->Checked )
      {
         screenContact.contactFlags |= TO_BE_ENTERED;
      }
      if ( ForceDlg->CheckBox2->Checked )
      {
         screenContact.contactFlags |= VALID_DUPLICATE;
      }
      if ( ForceDlg->CheckBox3->Checked )
      {
         screenContact.contactFlags |= MANUAL_SCORE;
         temp = ForceDlg->ScoreIl->Text.Trim();
         screenContact.contactScore = atoi( temp.c_str() );
      }
      if ( screenContact.contactFlags & ( TO_BE_ENTERED | VALID_DUPLICATE | MANUAL_SCORE ) )
         ForceDlg->CheckBox4->Checked = false;

      if ( ForceDlg->CheckBox4->Checked )
         screenContact.contactFlags |= NON_SCORING;
      if ( ForceDlg->CheckBox5->Checked )
      {
         screenContact.contactFlags |= ( DONT_PRINT | NON_SCORING );
      }
      if ( ForceDlg->CheckBox7->Checked )
         screenContact.contactFlags |= VALID_DISTRICT;
      if ( ForceDlg->CheckBox8->Checked )
         screenContact.contactFlags |= XBAND;

      // make sure marked on main screen

      NonScoreCheckBox->Checked = screenContact.contactFlags & NON_SCORING;
      DeletedCheckBox->Checked = screenContact.contactFlags & DONT_PRINT;
      if ( screenContact.contactFlags & NON_SCORING )
         screenContact.multCount = 0;

      // if no dtg then autofill dtg

      if ( !contest->isPostEntry() && !( screenContact.contactFlags & TO_BE_ENTERED ) )
      {
         int tne = screenContact.time.notEntered(); // partial dtg will give fe
         // full dtg gives -ve, none gives 0
         if ( tne == 0 )
         {
            screenContact.time = dtg( true );
            DateEdit->Text = screenContact.time.getDate( DTGDISP ).c_str();
            TimeEdit->Text = screenContact.time.getTime( DTGDISP ).c_str();
         }
      }

      logCurrentContact( true );
      return true;

   }
   return false;
}
Esempio n. 22
0
//---------------------------------------------------------------------------
void __fastcall TForm_Main::c_ComboBox_PropertyChange(TObject *Sender)
{
	AnsiString holdString;
	holdString.printf("%0.4f", ReadProperty());
	c_Edit_Value->Text = holdString;
}
Esempio n. 23
0
// сигнал от таймера: вывести номер трека
// и время воспроизведения
void __fastcall TForm1::TimerTimer(TObject *Sender)
{
  int trk;          // трек
  int min, sec;     // время
  AnsiString st;

  if ( MediaPlayer->Mode == mpPlaying ) // режим воспроизведения
  {
    // получить номер воспроизводимого трека и
    trk  =  MCI_TMSF_TRACK(MediaPlayer->Position);

    if ( trk != Track ) // произошла смена трека
    {
      TrackInfo();
      Track  =  trk;
      if ( Track > 1 )
          SpeedButton1->Enabled  =  true;  // доступна кнопка "пред.трек"
      if ( Track == MediaPlayer->Tracks)
          SpeedButton3->Enabled  =  false; // кнопка "след.трек" недоступна
    }

    // вывод информации о воспроизводимом треке
    min  =  MCI_TMSF_MINUTE(MediaPlayer->Position);
    sec  =  MCI_TMSF_SECOND(MediaPlayer->Position);
    st.printf("%d:%.2d",min,sec);
    Label2->Caption = st;
    return;
  }

  // Если дисковод открыт или в нем нет
  // AudioCD, то Mode == mpOpen.
  // Ждем диск, т.е. до тех пор пока не будет Mode == mpStopped + кол-во треков > 1
  if ( (MediaPlayer->Mode == mpStopped) &&
     (MediaPlayer->Tracks > 1) )
  {
    // диск вставлен
    Timer->Enabled  =  false;
    SpeedButton2->Enabled = true;;
    SpeedButton2->Tag = 0;
    SpeedButton3->Enabled = true;
    MediaPlayer->Notify  =  true;

    // получить информацию о времени звучания CD
    MediaPlayer->TimeFormat = tfMilliseconds;

    int ms = MediaPlayer->Length;
    AnsiString st = "Audio CD. Время звучания: ";

    st = st +  IntToStr(MINUTE(ms));
    st = st + ":" + IntToStr(SECOND(ms));
    Label1->Caption  =  st;

    MediaPlayer->TimeFormat = tfTMSF;
    Label1->Visible  =  true;
    Track = 0;
    return;
  }

  // дисковод открыт или в дисководе не Audio CD
  if (( MediaPlayer->Mode == mpOpen )||
      (MediaPlayer->Mode == mpStopped) && (MediaPlayer->Tracks == 1))
  {
    Label1->Caption  =  "Вставьте Audio CD";
    if ( Label1->Visible )
          Label1->Visible  =  false;
    else  Label1->Visible  =  true;
  }
}
Esempio n. 24
0
static void __fastcall SaveBitmap2Tiff(Gdiplus::Bitmap *bm, int npage) {
//-------------------------------------------------------------------------------
//                  Выводит очередную страницу в файл *.tif                     |
// Если npage == 0, то не выводит номер страницы                                |
// Полагает, что если это многостраничный файл, то страница уже выбрана         |
//-------------------------------------------------------------------------------
    if (SaveBitmap2TiffState == 0) return;


    // ------------------ для начала строим образ в SaveBitmap2TiffBitmap32 (SaveBitmap2TiffGraphics)
    int x, y, w, h;

    h = bm->GetHeight();
    w = bm->GetWidth();

    Gdiplus::SolidBrush whiteBrush(Gdiplus::Color(255, 255, 255, 255));
    SaveBitmap2TiffGraphics->FillRectangle(&whiteBrush, Gdiplus::Rect(0, 0, SaveBitmapW, SaveBitmapH));

    //Gdiplus::Matrix matr;
    Gdiplus::Rect r;
    //if (w > h) {                            // Если изображение шире, чем выше
    //    matr.Rotate(270.0f);                // поворачиваем его на 270 градусов
    //    SaveBitmap2TiffGraphics->SetTransform(&matr);
    //    r.X = -SaveBitmapH;
    //    r.Y = -30;
    //    r.Width = SaveBitmapH - 30;
    //    r.Height = SaveBitmapW - 30;
    //} else {
    //    r.X = 30;
    //    r.Y = 0;
    //    r.Width = SaveBitmapW - 30;
    //    r.Height = SaveBitmapH - 30;
    //}
    r.X = 0;
    r.Y = 0;
    r.Width = SaveBitmapW;
    r.Height = SaveBitmapH;

    SaveBitmap2TiffGraphics->DrawImage(bm, r, 0, 0, w, h, Gdiplus::UnitPixel, 0, 0, 0);

    // matr.Reset();
    // SaveBitmap2TiffGraphics->SetTransform(&matr);

    if (npage != 0) {            // Здесь выводим номер страницы
        AnsiString snum;
        wchar_t wnum[20];
        Gdiplus::Pen whitePen40(Gdiplus::Color(255, 255, 255, 255), 45);
        snum.printf("%d", npage);
        snum.WideChar(wnum, 20);
        Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
        Gdiplus::PointF origin(SaveBitmapW - 160, 20.0f);
        Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
        SaveBitmap2TiffGraphics->DrawLine(&whitePen40, SaveBitmapW - 200, 50, SaveBitmapW, 50);
        if (npage > 0) {
            SaveBitmap2TiffGraphics->DrawString(wnum, -1, &myFont, origin, &blackBrush);
        }
    }


    // ------- строим SaveBitmap2TiffBitmap1
    UINT *pix;
    unsigned char byte, bit, *pix1;

    w = SaveBitmapW; h = SaveBitmapH;
    Gdiplus::Rect BitsRect(0, 0, SaveBitmapW, SaveBitmapH);
    Gdiplus::BitmapData *bits = new Gdiplus::BitmapData;
    Gdiplus::BitmapData *bits1 = new Gdiplus::BitmapData;
    sres = SaveBitmap2TiffBitmap32->LockBits(&BitsRect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, bits);
    sres = SaveBitmap2TiffBitmap1->LockBits(&BitsRect, Gdiplus::ImageLockModeWrite, PixelFormat1bppIndexed, bits1);

    for (y = 0; y < SaveBitmapH; y++) {
        pix = (UINT *)((int)bits->Scan0 + bits->Stride * y);
        pix1 = (unsigned char *)((int)bits1->Scan0 + bits1->Stride * y);
        byte = 0;
        for (x = 0; x < SaveBitmapW; x++, pix++) {
            if ((*pix & 0xFF) > 0xD8) {
                bit = 1;
            }
            else bit = 0;
            byte <<= 1; byte |= bit;
            if ((x & 7) == 7) {
                *pix1++ = byte;
                byte = 0;
            }
        }
    }

    SaveBitmap2TiffBitmap32->UnlockBits(bits); delete bits;
    SaveBitmap2TiffBitmap1->UnlockBits(bits1); delete bits1;


    // ------- и наконец выводим очередную страницу SaveBitmap2TiffBitmap1
    Gdiplus::EncoderParameters encoderParameters;
    ULONG parameterValue;

    // An EncoderParameters object has an array of
    // EncoderParameter objects. In this case, there is only
    // one EncoderParameter object in the array.
    encoderParameters.Count = 1;
    // Initialize the one EncoderParameter object.
    // encoderParameters.Parameter[0].Guid = Gdiplus::EncoderSaveFlag;
    encoderParameters.Parameter[0].Guid = aEncoderSaveFlag;
    encoderParameters.Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong;
    encoderParameters.Parameter[0].NumberOfValues = 1;
    encoderParameters.Parameter[0].Value = &parameterValue;

    // Get the CLSID of the TIFF encoder.
    CLSID encoderClsid;
    GetEncoderClsid(L"image/tiff", &encoderClsid);

    if (SaveBitmap2TiffState == 1) {                    // Требуется вывести первую страницу
        parameterValue = Gdiplus::EncoderValueMultiFrame;
        sres = SaveBitmap2TiffBitmap1->Save(SaveBitmap2TiffFiln, &encoderClsid, &encoderParameters);
    } else {
        parameterValue = Gdiplus::EncoderValueFrameDimensionPage;
        sres = SaveBitmap2TiffBitmap1->SaveAdd(&encoderParameters);
    }

    SaveBitmap2TiffState = 2;
}
Esempio n. 25
0
//---------------------------------------------------------------------------
void TGJVEditFrame::calcLoc( )
{
   String gridref = LocEdit->Text.Trim();

   if ( stricmp( gridref.c_str(), oldloc.c_str() ) != 0 )
   {
      oldloc = gridref;
      locValid = true;
      double latitude;
      double longitude;
      double dist;
      int brg;

      int locValres = lonlat( gridref.c_str(), longitude, latitude );
      if ( ( locValres ) != LOC_OK )
         locValid = false;

      ScreenContact &sct = screenContact;
      if ( ( sct.contactFlags & MANUAL_SCORE ) &&
           !( sct.contactFlags & DONT_PRINT ) )
      {
         int thisscore = sct.contactScore;
         setScoreText( thisscore, false, sct.contactFlags & XBAND );
         BrgSt->Caption = "MANUAL";

      }
      else
         if ( ( locValid
                || ( locValres == LOC_PARTIAL ) )
              && contest->locValid )
         {
            contest->disbear( longitude, latitude, dist, brg );

            if ( locValid )  	// just 4CHAR not enough
            {
               sct.bearing = brg;

               if ( !( sct.contactFlags & ( MANUAL_SCORE | NON_SCORING | LOCAL_COMMENT | COMMENT_ONLY | DONT_PRINT ) ) )
               {
                  sct.contactScore = dist;
               }

            }

            TEMPBUFF( rev, 10 );
            strcpy( rev, ( MinosParameters::getMinosParameters() ->getMagneticVariation() ) ? "M" : "T" );
            int vb = varBrg( brg );
            if ( TContestApp::getContestApp() ->reverseBearing )
            {
               vb = normBrg( vb - 180 );
               strcat( rev, "R" );
            }
            setScoreText( ( int ) dist, ( locValres == LOC_PARTIAL ), sct.contactFlags & XBAND );
			AnsiString brgbuff;
            if ( locValres == LOC_PARTIAL )
            {
			   brgbuff.printf( "(%d\xB0%s)", vb, rev );
            }
            else
            {
               brgbuff.printf( "%d\xB0%s", vb, rev );
            }
            BrgSt->Caption = brgbuff;
         }
         else
         {
            DistSt->Caption = "";
            BrgSt->Caption = "";
            sct.contactScore = -1;
            sct.bearing = -1;
         }
   }
}