void AiMainWindow::runGenerator (  )  [private, slot]

slot for running generator

Definition at line 956 of file aimainwindow.cpp.

00957 {
00958     try
00959     {
00960         m_startedThreads = m_currentThreadsNumber;
00961 
00962         if( (m_config->getImageWidth() == 0 || m_config->getImageHeight() == 0) )
00963         {
00964             QMessageBox::warning(this, tr("Config"), tr("Please, setup a fractal config!"), QMessageBox::Ok) ;
00965             this->complexZone();
00966             return;
00967         }
00968 
00969         //check if threads is running
00970         if( m_threads.size() > 0 )
00971         {
00972             if( m_threads[ 0 ]->isRunning() )
00973             {
00974                 QMessageBox::warning(this, tr("Threads"), tr("Current threads is running, please stop them before running a new threads!"), QMessageBox::Ok) ;
00975                 return;
00976             }
00977         }
00978 
00979         //~ start at
00980         this->m_statusbar->start();
00981 
00982         //~ clean before run
00983         for( int index = 0 ; index < m_threads.size() ; index++ )
00984         {
00985             delete m_threads[ index ];
00986         }
00987         m_threads.clear();
00988 
00989         //~ storage
00990         if( m_storage.count() > 0 )
00991         {
00992             m_storage.clear();
00993         }
00994         m_storage = QVector<QImage>( m_startedThreads );
00995 
00996         //creating and calulating threads
00997         for( int index = 0 ; index < m_startedThreads ; index++ )
00998         { 
00999             AiThread *thread = new AiThread(this);
01000             thread->makeZone( m_config->getZoneMinX()   ,
01001                              m_config->getZoneMinY()   ,
01002                              m_config->getZoneWidth()  ,
01003                              m_config->getZoneHeight() ,
01004                              m_config->getImageWidth() ,
01005                              m_config->getImageHeight(),
01006                              index                  , //# start point
01007                              m_startedThreads , //# threads numbers
01008                              m_config->getIterations(),
01009                              m_zoom,
01010                              m_viewX,
01011                              m_viewY);
01012             thread->scriptFile( "scripts/" + m_config->item( m_selectedFractalIndex ) );
01013 
01014             qRegisterMetaType<AiGenerator::AiZone*>("AiGenerator::AiZone");
01015             this->connect( thread, SIGNAL(completed(AiGenerator::AiZone*)) , this, SLOT(completed(AiGenerator::AiZone*)));
01016             this->connect( thread, SIGNAL(snapshot(AiGenerator::AiZone*)) , this, SLOT(snapshot(AiGenerator::AiZone*)));
01017             //~ for first thread *ONLY*
01018             if( index == 0 )
01019             {
01020                 //# theoretically all threads has started in one time,
01021                 //# with very small deference : T0:0 nanos T1:~+1ns etc...
01022                 //# if first thread is finish all threads finished in one time
01023                 this->connect(thread,SIGNAL(progressStatus(int)), m_statusbar, SLOT(setGenStatus(int)));
01024             }
01025 
01026             m_threads.push_back( thread );
01027         }
01028 
01029         for( int index = 0 ; index < m_threads.size() ; index++ )
01030         {
01031             m_threads[ index ]->start();
01032         }
01033 
01034         m_statusbar->startGenerating();
01035         m_statusbar->setInfo(  QString( "[Threads: %1 ]"  ).arg( m_startedThreads ) );
01036 
01037         //# for supporting users *BAD* manipulation =)
01038         this->enabledChilds( false );
01039         this->toolsZoomArea( false );
01040         m_config->disableZoomArea();
01041         //# for supporting users *BAD* manipulation =)
01042     }
01043     catch(const std::exception & exception )
01044     {
01045         QMessageBox::critical(this, tr("Critical Error!"), tr("Please report this problem to adrabi[at]gmail[dot]com =)."));
01046     }
01047 }

 All Classes Namespaces Files Functions Variables Typedefs

Generated on Sat Feb 27 08:33:18 2010 for AiFractals by  doxygen 1.6.1