Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 25.03.2012, 21:52   #1
Ромео_34
 
Регистрация: 25.03.2012
Сообщений: 7
По умолчанию Ребят нужно написать программу по листингу на Си

Код:
#include <vcl.h>
#pragma hdrstop


#include"Unit1.h";
#include"Unit2.h";
#include"Unit3.h";
#include"Unit4.h";
//-----------------------------------------------------------------------------------------------------------------------------
--
#pragma  package (smart_init)
#pragma link "CSPIN"
#pragma resource "*.dfm"
TForm1 *Form1;
//-----------------------------------------------------------------------------------------------------------------------------
--
__fastcall TForm1: :TForm1 : :TForm1(TComponent* Owner)
                 :   TForm(Owner)
{
}
//-----------------------------------------------------------------------------------------------------------------------------
--

        void TForm1: : EvalMArkedArea(void)
           {  float tmp;
               tmp=(float) sx1/Image1->Width;
               startx=tmp*Image1->Picture->Bitmap->Width;
               tmp=(float) sy1/Image->Height;
               starty=tmp*Image->Picture->Bitmap->Height;
               tmp=(float) sx2/Image->Wigth;
               endx = tmp*Image->Picture->Bitmap->Wugth;
               tmp=(float) sy2/Inage->Height;
               endy = tmp*Image->Picture->Bitmap->Height;
               if (startx>endx)  {tmp=startx; statx=endx; endx=tmp;}
               if (starty>endy)  {tmp=starty;  starty=endy; endy= tmp;}
            }

       float TForm1: :BmpToImageX (float x)
           {
              float tmp=(float)x/Image1->Picture->Bitmap->Wigth;                           
              return  tmp*Image2->Picture->Bitmap->Wigth;
            }

       float TForm1: :ImageToBmpY (float y)
        {
              float tmp=(float)y/Image1->Picture->Bitmap->Height;
              return  tmp*Image2->Picture->Bitmap->Height;
        }
        float  TForm1: :BmpToImageX (float x)
        {
              float tmp=(float)x/Image2->Picture->Bitmap->Wigth;
              return  tmp*Image1->Picture->Bitmap->Wigth;
        }

       float TForm1: :ImageToBmpY (float y)
        {
              float tmp=(float)y/Image2->Picture->Bitmap->Height;
              return  tmp*Image1->Picture->Bitmap->Height;
        }
       float TForm1: : Level (TColor clr)
       {
          int cl=clr, green, blue, red;
          float res;
          blue=(cl&0x00FF0000)>>16;
          green=(cl&0x0000FF00)>>8;
          red=cl&0x000000FF;
          switch(Raidogroup1->ItemIndex)
          {
              case   0:      res=red;
                                    break;
              case   1:      res=blue;
                                    break;
              case   2:      res=green;
                                    break;
              case   3:      res=(blue+green+red)/3;
                                    break;
        }
        res=225-res;
        if (avgbg !=-1)
        {
          switch(Radiogroup2->ItemIndex)
          {
             case   0:      res-=avgbg;
                                    break;
              case   1:      res=res<avgbg   ?   0:     res; 
                                    break;
        }
       }
     //if   (CheckBox1->Checked)     return 255-res;
    //else  return res;
     return res;
}
//----------------------------------------------------------------------------------------------------------------------------
--



void  __Fastcall TForm1: :N7Click(TObject   *Sender)
{
   Form3->Show();

Последний раз редактировалось ACE Valery; 25.03.2012 в 22:42.
Ромео_34 вне форума Ответить с цитированием
Старый 25.03.2012, 21:53   #2
Ромео_34
 
Регистрация: 25.03.2012
Сообщений: 7
По умолчанию Вот еще

Код:
void __TForm1: :ClearSelection(void)
{
    delete Image2;
    Image2=new TImage(this);
    Image2->Parent=this;
    Image2->Top=1;
    Image-> Left=1;
    Image2->Left=1;
    Image2->Align=alClient;
    Image2->Transparent=true;
    Image2->OnMouseDown=Image2MouseDown;
    Image2->OnMouseup=Image2MouseUp;
}

void __fastcall TForm: : Image2MouseDown(TObject *Sender,
            TMouseButton Button, TSiftState Shift, int X, int Y)
{
  if(!setbg)
  {
    sx1=X; sy1=Y;
  }
}
//----------------------------------------------------------------------------------------------------------------------------
--
void __fastcall  TForm: :Image2MouseUp(TObject *Sender, TMouseButton,
             TsiftState Shift, int X, int Y)
{
    if(setbg)
    {
      bg[bgb]=Level (Image1->Canvas->Pixels[ImageToBmpX(x)][ImageToBmp(Y)]);
      if(bgb==2)
     { 
        bgb=0; setbg=false;
        avgbg=(bg[0]+bg[1]+bg[2])/3;
        ShowMessage("Фон задан успешно");
        StatusBar1->Panels->Items[1]->Text="";
     }
     else
     {
       sx2=X; sy2=Y;
       DrawSelRect();
     }
 }
//----------------------------------------------------------------------------------------------------------------------------
--

void TForm1: :DrawMaxes(void)
{
   Image2->Canvas->Pen->Style=psSolid;
   Image2->Canvas->Pen->Color=clBlack;
   Image2->Canvas->MoveTo(BmpToImageX(startx), maxy);
   Image2->Canvas->LineTo(BmpToImageX(endx), maxy);
   Image2->Canvas->MoveTo(BmpToImageY(starty));
   Image2->Canvas->LineTo(BmpToImageY(endy));
}
void  __fastcall TForm1: :FormPaint(TObject *Sender)
{
  if(sel)  DrawRect();
  if(eval)  DrawMaxes();
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm1: :OpenSpotExecute(TObject *Sender)
{
  if  (OpenPictureDialog1->Execute())
  {
    ClearSelection();
    Image1->Picture->LoadFormFile(OpenPictureDialog1->FileName);
    CalcIntens->Enabled=true;
    BuildGraph->Enabled=true;
    SetBackgound->Enabled=true;
    StatusBar1->Panels->Items[0]->Text="Изображение готово к работе";
  }
}

Последний раз редактировалось ACE Valery; 25.03.2012 в 22:42.
Ромео_34 вне форума Ответить с цитированием
Старый 25.03.2012, 21:54   #3
Ромео_34
 
Регистрация: 25.03.2012
Сообщений: 7
По умолчанию еще

Код:
void __fastcall TForm1: :BuildGraphExecute(TObject *Sender)
{
  Form2->Series1->Clear();
  Form2->LineSeries1->Clear();
  EvalMarkedArea();
  int hstep=(endx-startx)/CSpinEdit1->Value;
  int vstep=(endy-starty)/CSpinEdit1->Value;
  float val, maxval;

  for(int i=0; <CSpinEdit1->Value;  i++ );
  {
   x=startx+i*hstep;
   maxval=val=0;
   for(y=starty; y<=endy; y++0)
      val+=Level(Image1->Canvas->Pixels[x][y]);
   Form2->Series1->AddXY(x, val, "", clRed);
  }
  for(int i=0; i<CSpinEdit1->Value; i++)
  {
    y=starty+i*vstep;
    maxval=val=0;
    for(x=startx; x<=endx; y++0)
      val+=Level(Image1->Canvas->Pixels[x][y]);
    Form2->Series1->AddXY(y, val, "", clRed);
   }

  maxval=0;
  for(int i=0; i< Form2->Series1->YValues->Count(); i++)
    if(Form2->Series1->YValues->Value[i]>maxval)
    {
      maxval=Form2->Series1->Yvalue->Value[i];
      maxx=Form2->series1->XValues->Value[i];
     }
  maxval=0;
  for(int i=0; i< Form2->LineSeries1->YValues->Count(); i++)
    if(Form2->LineSeries1->YValues->Value[i]>maxval)
    {
      maxval=Form2->LineSeries1->Yvalue->Value[i];
      maxy=Form2->LineSeries1->XValues->Value[i];
     }
 maxx=BmpToImageX(maxx);
 maxy=BmpToImageY(maxy);

 DrawMaxes();
 Form2->Show;
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm1: :CalcIntensExecute(Tobject *Sender)
{
  float sum=0;
  int i, j;
  EvalMarkedArea();
  for (j=starty; j<=endy; j++)
    for(i=startx; i<=endx; i++)
      sum+=Level(Image1->Canvas->Pixels[i][j])/255;
 int nop=(endx-startx)*(endy-starty);
 last_iids=sum;
 Label1->Caption="Общая  интенс.:  "+FloatToStrF(sum, ffGeneral, 3,6);
 Label2->Caption="Средняя интенс.:  "+FloatToStrF(sum/nop, ffGeneral, 3,8);
 Label3->Caption="Число точек:  "+IntToStr(nop);
 PutIntoTable->Enbled=true;
}
//----------------------------------------------------------------------------------------------------------------------------
--

 void __fastcall TForm1: :PutIntoTableExecute(TObject *Sender)
{
  //
  if(CheckBox2->Checked) Form3->AddEtalon(last_iids);
  else Form3->AddSample(last_iids);

Последний раз редактировалось ACE Valery; 25.03.2012 в 22:42.
Ромео_34 вне форума Ответить с цитированием
Старый 25.03.2012, 21:54   #4
Ромео_34
 
Регистрация: 25.03.2012
Сообщений: 7
По умолчанию

Код:
void __fastcall TForm1: :SetBackgroundExecute(TObject *Sender)
 {
   avgbg=-1; setbg=true; bgb=0;
   StatusBar1->Panels->Items[1]->Text= "Задайте 1-ю точку фона(щелкните по изображению)...";
 }
//----------------------------------------------------------------------------------------------------------------------------
--

 void __fastcall TForm1: :ExitExecute(TObject *Sender)
{
  Close();
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm1: :AboutExecute(TObject *Sender)
{
  Form4->ShowModal();
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm1: :ShowTabExecute(TObject *Sender)
{
  Form3->Show();
}

Последний раз редактировалось ACE Valery; 25.03.2012 в 22:43.
Ромео_34 вне форума Ответить с цитированием
Старый 25.03.2012, 21:54   #5
Ромео_34
 
Регистрация: 25.03.2012
Сообщений: 7
По умолчанию Unit2

Код:
#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
        : TForm(Owner)
{

Последний раз редактировалось ACE Valery; 25.03.2012 в 22:43.
Ромео_34 вне форума Ответить с цитированием
Старый 25.03.2012, 21:55   #6
Ромео_34
 
Регистрация: 25.03.2012
Сообщений: 7
По умолчанию Unit3

Код:
#include <vcl.h>
#pragma hdrstop

#include "Unit3.h"
//----------------------------------------------------------------------------------------------------------------------------
--
#pragma package(smart_init)
#pragma resource ".dfm"
TForm3 *TForm3;
//----------------------------------------------------------------------------------------------------------------------------
--
__fastcall TForm2: :TForm2(TComponent* Owner)
                 :   TForm(Owner)
{
}

void TForm3: :AddEtalon(float iids)
{
//

StringGrid1->Cells[0][StringGrid1->RowCount-1]=IntToStr(StringGrid1->RowCount-1);
   StringGrid1->Cells[1][StringGrind1->RowCount-1]=FloatToStr(iids);
   StringGrid1->RowCount++;
 }
 
void TForm3: :AddSample (float iids)
{
//

StringGrid2->Cells[0][StringGrind2->RowCount-1]=IntToStr(StringGrind2->Rowcount-1);
     StringGrid2->Cells[1][StringGrind2->RowCount-1]=FloatToStr(iids);
      StringGrid2->RowCount++;
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm3: :FormCreate (Tobject *Sender)
{
  StringGrid1->Cells[0][0]="Номер";
  StringGrid1->Cells[1][0]="ИИДС";
  StringGrid1->Cells[2][0]="Кол-во";
  StringGrid1->Cells[3][0]="К";

  StringGrid2->Cells[0][0]="Номер";  
  StringGrid2->Cells[1][0]="ИИДСС";
  StringGrid2->Cells[2][0]="Кол-во";
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm3: :BitBtn2Click (TObject *Sender)
{
  int n=0; float sumk=0;
  for(int i=0; i<StringGrid->RowCount; i++)
  {
    if(SAtringGrid1->1->Cells[2][i]!="")
    {
       n++;
   
   StringGrid1->Cells[3][i]=FloatToStr(StrToFloat(StringGrid1->Cells[1][i])/StrToFloat(StringGrid1->Cells[2][i]));
    }
   sumk+=StrToFloat(StringGrid1->Cells[3][i]);
  }
 k_avd=sumk/n;
 Label4->Caption=FloatToStr(k_avg);
}
//----------------------------------------------------------------------------------------------------------------------------
--
void __fastcall TForm3: :BitBtn3Click(TOblect *Sender)
{
  if(OpenDialog1->Execute())
  {
    if(FileExists(OpenDialog1->FileName))
      DeleteFile(OpenDialog1->FileName))
     Table1->Close;
     Table1->TableName=OpenDialog1->FileName;
     Table1->Createble();
     Table1->Open();
     for(int i=1; <StringGrid1->RowCount; i++)
    { 
      Table1->Append();
      Table1->FieldValues["num"]=StringGrid1->Cells[0][i];
      Table1->FieldValues["iids"]=StringGrid1->Cells[1][i];
      Table1->FieldValues["kolvo"]=StringGrid1->Cells[2][i];
      Table1->FieldValues["kkk"]=StringGrid1->Cells[3][i];
   }    
  table->Close();
  }
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm3: :Bitbtn4Click(TObject *Sender)
{
  if(OpenDialog1->Execute())
  {
    Table1->Close;
    Table1->TableName=OpenDialog1->FileName;
    Table1->Open();
    int i=StringGrid1->RowCount-1;
    StringGrid1->RowCount+=Table1->RecordCount;
    while(!Table1->Eof)
    {
       if(!Table1->FiledByName("num")->IsNull)
         StringGrid1->Cells[0][i]=Table1->FieldValues["num"];
       if(!Table1->FiledByName("iids")->IsNull)
         StringGrid1->Cells[1][i]=Table1->FieldValues["iids"]; 
       if(!Table1->FiledByName("kolvo")->IsNull)
         StringGrid1->Cells[2][i]=Table1->FieldByName("kolvo")->AsString;
       if(!Table1->FiledByName("kkk")->IsNull)
         StringGrid1->Cells[3][i]=Table1->FieldByName("kkk")->AsString;
       i++;
      Table1->Next();
    }
    Table->Close();
  }  
}
//----------------------------------------------------------------------------------------------------------------------------
--


void __fastcall TForm3: :BitBtn7Click(TObject *Sender)
{
  for(int i=1; i<StringGrid2->RowCount; i++)
  {
     if(StringGrid2->Cells[1][i]!="")

  StringGrid2->Cells[2][i]=FloatToStr(StrToFloat(StringGrid2->Cells[1][i])/k_avg);
  }
}
//----------------------------------------------------------------------------------------------------------------------------
--

void __fastcall TForm3: :FormResize(TObject *Sender)
{
   Panel1->Width=ClientWidth/2;
}

Последний раз редактировалось ACE Valery; 25.03.2012 в 22:43.
Ромео_34 вне форума Ответить с цитированием
Старый 25.03.2012, 21:55   #7
Ромео_34
 
Регистрация: 25.03.2012
Сообщений: 7
По умолчанию Unit4

Код:
-

#include <vcl.h>
#pragma hdrstop

#include "Unit4.h"
//-----------------------------------------------------------------------------------------------------------------------------
--
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm4 *Form4;
//-----------------------------------------------------------------------------------------------------------------------------
--
__fastcall TForm4: :TForm4(TComponent* Owner)
                  : TForm(Owner)
{
}

Последний раз редактировалось ACE Valery; 25.03.2012 в 22:43.
Ромео_34 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Помите написать программу на C++ по листингу Ромео_34 Фриланс 12 22.09.2012 13:36
кто сможет написать програмку по листингу алексей errrr Фриланс 4 20.11.2011 11:18
Нужно написать программу Июнька Помощь студентам 0 03.04.2011 19:15
ребят нужно написать программу с кнопочками в командной строке на С++ anri1290 Помощь студентам 1 06.05.2010 18:16
Ребят помогите мне написать программу Lena1990 Помощь студентам 1 22.11.2008 19:36