Results 1 to 3 of 3

Thread: My gui is taking too much time to plot and during plot time its being freeze…

  1. #1
    Join Date
    Aug 2013
    Location
    India
    Posts
    28
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default My gui is taking too much time to plot and during plot time its being freeze…

    i made a gui in which i am using multiple loops and i am using vector ……every thing fine but its taking too much time to plot and during plot time gui is being freezed……please help me to come out from this hell…….thanks

  2. #2
    Join Date
    Aug 2013
    Location
    India
    Posts
    28
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: My gui is taking too much time to plot and during plot time its being freeze…

    i made a gui in which i am using multiple loops and i am using vector ……every thing fine but its taking too much time to plot and during plot time gui is being freezed……please help me to come out from this hell…….thanks

    This is my code...


    double Nharmonic = 6;
    double Shipspeed = 27.6 ;
    double BladeThick = 0.2;
    double BladeLen = 5;
    double KinematicVis = pow(10,-6.0);
    double ENoPiston = 4;
    double Fbroad = 0;

    double Fpeak = 100 + Shipspeed*10 ;
    double Rnl1hz = 60 + Shipspeed*2 ;

    double ShaftFreq = floor(ui->No_of_Shaft_rpm_lineEdit_7->text().toDouble()/60);
    double BladeFreq = ShaftFreq*ui->No_of_Propeller_Blades_lineEdit_8->text().toDouble();
    double EngineFreq = ShaftFreq*ui->GearBox_Ratio__lineEdit_7->text().toDouble();

    double temp = 0;
    double Coefficientsummation = 0;
    double amp =0;
    double TempRandom = 0.0;


    //Data for plot
    QVector<double> XShaftSignal(T*fs ,0);
    QVector<double> XBladeSignal(T*fs ,0);
    QVector<double> XPropeller(T*fs ,0);
    QVector<double> XCavitation(T*fs ,0);
    QVector<double> XFlow;
    QVector<double> XCylinFiring(T*fs ,0);
    QVector<double> XCrankshaft(T*fs ,0);
    QVector<double> XPistonslap(T*fs ,0);
    QVector<double> XEngineValve(T*fs ,0);
    QVector<double> XPistonRing(T*fs ,0);
    QVector<double> XEngine(T*fs ,0);
    QVector<double> XGearBox;
    QVector<double> Xtotal(T*fs ,0);
    QVector<double> XBroadband(T*fs ,0);

    /* XShaftSignal.clear();
    XBladeSignal.clear();
    XPropeller.clear();
    XCavitation.clear();
    XFlow.clear();
    XCylinFiring.clear();
    XCrankshaft.clear();
    XPistonslap.clear();
    XPistonslap.clear();
    XEngineValve.clear();
    XPistonRing.clear();
    XEngine.clear();
    XGearBox.clear();
    Xtotal.clear();
    XBroadband.clear();
    t.clear();
    f.clear();
    Xfinal.clear();
    FFT_Y.clear();
    FFT_Y2.clear();
    Xfinal1.clear();*/

    for(int j = 0; j < T*fs; j = j + 1)
    {
    t.append(j/fs);
    f.append((j*fs)/(fs*T));


    }


    for (int i = 0 ; i < Nharmonic; i++)
    {
    temp = Rnl1hz + 8 - 2*(i+1) ;

    for (int j = 0; j < t.count(); j++)
    {
    XShaftSignal.replace(j, XShaftSignal.at(j) + pow(10,(temp/20))*cos(2*pi*t.at(j)*ui->No_of_Propellers_lineEdit_6->text().toDouble()*ShaftFreq*(i+1)));


    }

    Coefficientsummation = Coefficientsummation + pow(10,(temp/20)) ;

    }





    for (int i = 0; i < Nharmonic; i++)
    {
    temp = Rnl1hz + 17 - 2*(i+1) ;
    for (int j = 0; j < t.count(); j++)
    {
    XBladeSignal.replace(j,XBladeSignal.at(j) + pow(10,(temp/20))*cos(2*pi*t.at(j)*ui->No_of_Propellers_lineEdit_6->text().toDouble()*BladeFreq*(i+1)));
    }
    Coefficientsummation = Coefficientsummation + pow(10,(temp/20)) ;

    }


    for (int j = 0; j < t.count(); j++)
    {
    XPropeller.replace(j,XShaftSignal.at(j) + XBladeSignal.at(j));

    }

    //////////// Cavitation Noise ///////////////////////


    double Flow_Vel = 4*Shipspeed*0.5144;
    double RenolNo = Flow_Vel*BladeLen/KinematicVis ;

    double CorrectedThick = BladeThick + 0.0297 * BladeLen/pow(RenolNo,(0.2));
    double Tipspeed = (2*pi*BladeLen*ui->No_of_Shaft_rpm_lineEdit_7->text().toDouble())/60;
    double Ls = 175 + 60*log10(Tipspeed/25) + log10(ui->No_of_Propeller_Blades_lineEdit_8->text().toDouble()/4);


    if (ui->checkBox_Cavitation->isChecked())
    {
    for (int i = 99 ; i < 8000; i++)
    {
    temp = Ls + 20*(1 - log10(i+1));


    for (int j = 0; j < t.count(); j++)
    {
    XCavitation.replace(j,XCavitation.at(j) + pow(10,(temp/40))*cos(2*pi*t.at(j)*(i+1)));
    }
    Coefficientsummation = Coefficientsummation + pow(10,(temp*0.025)) ;


    }


    }


    /////////////// Flow Induced Noise ///////////////////////////

    if (ui->checkBox_Flow->isChecked())
    {
    double Fv = 0.18*Flow_Vel/CorrectedThick ;
    if(Shipspeed > 10)
    {
    temp = 1.5 * (Shipspeed - 10);
    for (int j = 0; j < t.count(); j++)
    {
    XFlow.append(pow(10,(temp/20))*cos(2*pi*t.at(j)*Fv));
    }
    Coefficientsummation = Coefficientsummation + pow(10,(temp*0.05)) ;
    }
    else
    {
    XFlow.append(0);
    }


    }


    else
    {
    for (int j = 0; j < t.count(); j++)
    {
    XFlow.append(0);
    }

    }



    for (int i = 0; i< Nharmonic;i++)
    {

    amp = pow(10,((Rnl1hz + 13.5 - 1.5*(i+1))/20));

    for (int j = 0; j < t.count(); j++)
    {
    XCylinFiring.replace(j, XCylinFiring.at(j) + (amp/3)*cos(2*pi*t.at(j)*(i+1)*EngineFreq*(ENoPiston/2)));
    XCrankshaft.replace(j, XCrankshaft.at(j) + (amp/4)*cos(2*pi*t.at(j)*(i+1)*EngineFreq));
    XPistonslap.replace(j, XPistonslap.at(j) + amp*cos(2*pi*t.at(j)*(i+1)*EngineFreq*ENoPiston));
    XEngineValve.replace(j, XEngineValve.at(j) + (amp/2)*cos(2*pi*t.at(j)*(i+1)*EngineFreq*ENoPiston*ui->No_of_Values_per_Piston_lineEdit->text().toDouble()));
    XPistonRing.replace(j,XPistonRing.at(j) + (amp/5)*cos(2*pi*t.at(j)*(i+1)*EngineFreq*ENoPiston*ui->No_of_Rings_per_Piston_lineEdit_5->text().toDouble()));

    }
    Coefficientsummation = Coefficientsummation + (amp/3);

    }

    for (int i = 0; i< Nharmonic;i++)
    {
    amp = pow(10,((Rnl1hz + 13.5 - 1.5*(i+1))/20));

    Coefficientsummation = Coefficientsummation + (amp/4);
    }


    for (int i = 0; i< Nharmonic;i++)
    {
    amp = pow(10,((Rnl1hz + 13.5 - 1.5*(i+1))/20));

    Coefficientsummation = Coefficientsummation + (amp);
    }


    for (int i = 0; i< Nharmonic;i++)
    {
    amp = pow(10,((Rnl1hz + 13.5 - 1.5*(i+1))/20));

    Coefficientsummation = Coefficientsummation + (amp/2);
    }


    for (int i = 0; i< Nharmonic;i++)
    {
    amp = pow(10,((Rnl1hz + 13.5 - 1.5*(i+1))/20));

    Coefficientsummation = Coefficientsummation + (amp/5);
    }

    // if (ui->checkBox_Random->isChecked())
    // {
    for (int j = 0; j < t.count(); j++)
    {
    XEngine.replace(j, XCylinFiring.at(j) + XCrankshaft.at(j) + XPistonslap.at(j) + XEngineValve.at(j) + XPistonRing.at(j));
    XGearBox.append( pow(10,6.0)*pow(10,0.15)*cos(2*pi*t.at(j)*ui->No_of_Gears_lineEdit_8->text().toDouble()*EngineFreq));

    // float r = (float)rand() / (float)RAND_MAX;
    // TempRandom = r * (5.0) * pow(10,7.0);


    Xtotal.replace(j,XPropeller.at(j) + XCavitation.at(j) + XFlow.at(j)+ XEngine.at(j) + XGearBox.at(j) ) ;
    }

    // }



    /* else
    {

    for (int j = 0; j < t.count(); j++)
    {
    XEngine.replace(j, XCylinFiring.at(j) + XCrankshaft.at(j) + XPistonslap.at(j) + XEngineValve.at(j) + XPistonRing.at(j));
    XGearBox.append( pow(10,6.0)*pow(10,0.15)*cos(2*pi*t.at(j)*ui->No_of_Gears_lineEdit_8->text().toDouble()*EngineFreq));
    Xtotal.replace(j,XPropeller.at(j) + XCavitation.at(j) + XFlow.at(j)+ XEngine.at(j) + XGearBox.at(j)) ;
    }


    }*/



    Coefficientsummation = Coefficientsummation + pow(10,6.15);
    Fbroad = fs/2;
    if (ui->checkBox_BroadBand->isChecked())
    {
    for (double i = 0 ; i < Fpeak; i = i+1/T)
    {
    temp = pow(10,(Rnl1hz/20));
    for (int j = 0; j < t.count(); j++)
    {
    XBroadband.replace(j,XBroadband.at(j) + temp*cos(2*pi*t.at(j)*(i+1))) ;
    }
    }

    for (double i = Fpeak ; i < Fbroad; i=i+1/T)
    {
    double exp_broad = exp((i+1)*0.0002);
    double Fpeak_exp = exp(Fpeak*0.0002);
    temp = pow(10,((Rnl1hz - (exp_broad*exp_broad) + (Fpeak_exp*Fpeak_exp))/20));

    for (int j = 0; j < t.count(); j++)
    {
    XBroadband.replace(j, XBroadband.at(j) + temp*cos(2*pi*t.at(j)*(i+1))) ;
    }
    }

    for (int j = 0; j< t.count(); j++)
    {

    Xfinal.replace(j, (Xtotal.at(j) - 5.0*Coefficientsummation)* XBroadband.at(j));
    }
    }
    else
    {
    for (int j = 0; j< t.count(); j++)
    {
    Xfinal.replace(j, (Xtotal.at(j)));
    }
    }

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,396
    Thanks
    37
    Thanked 1,542 Times in 1,493 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: My gui is taking too much time to plot and during plot time its being freeze…

    You have two options:

    - split the painting into smaller chunks and return to event processing in betwee
    - use a thread to paint into a QImage and display that image

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 12th April 2013, 06:18
  2. Replies: 1
    Last Post: 12th May 2012, 23:27
  3. real time graph plot
    By robotics in forum Qt Programming
    Replies: 5
    Last Post: 24th May 2011, 05:04
  4. Replies: 5
    Last Post: 19th November 2010, 02:25
  5. QFileSystemWatcher with a Qwt Real-time plot
    By gen_mass in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2010, 21:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.