Exemplo n.º 1
0
bool EdgeArray::hasPrevious(std::vector<EdgeIF*>::const_iterator & iterator,
		Connectivity const connectivity) {
	while (hasPrevious(iterator)
			&& (connectivity != Connectivity::BOTH
					&& !current(iterator)->isInState(connectivity))) {
		previous(iterator);
	}
	return hasPrevious(iterator);
}
Exemplo n.º 2
0
bool EdgeArray::hasPrevious(std::vector<EdgeIF*>::const_iterator & iterator,
		Visibility const visibility) {
	while (hasPrevious(iterator)
			&& (visibility != Visibility::BOTH
					&& current(iterator)->getVisibility() != visibility)) {
		previous(iterator);
	}
	return hasPrevious(iterator);
}
Exemplo n.º 3
0
void networkDialog::refreshButtonClicked(void) {
    QString a=ui->serversComboBox->currentText();
    QHostAddress current(a);
    QHostAddress previous(gpib->getServerAddress());
    gpib->setServerAddress(current);
    gpib->serverGetStatus();
    gpib->serverGetInterval();
    gpib->setServerAddress(previous);
}
 T& peekNext(unsigned int jump = 0) {
     jump++;
     for (unsigned int ij = 1; ij < jump; ij++)
         next();
     T& t = next();
     for (unsigned int ij = 0; ij < jump; ij++)
         previous();
     return t;
 }
Exemplo n.º 5
0
  // 2006-08-24 AF, changed so the function returns a boolean value, true if
  // the cursor is moved.
  bool CellCursor::moveUp()
  {
    // 2006-08-24 AF,
        bool moved( false );

    // 2006-04-27 AF,
    cursorIsMoved();

    if( !hasPrevious() )
    {
      if( parentCell()->hasParentCell() )
      {
        moveBefore( parentCell() );
        moved = true;
      }
    }
    else
    {
      //previous() exists.
      if(previous()->hasChilds())
      {
        if(!previous()->isClosed())
        {
          moveToLastChild(previous());
          moved = true;
        }
        else
        {
          moveBefore(previous());
          moved = true;
        }
      }
      else
      {
        moveBefore(previous());
        moved = true;
      }
    }
    emit positionChanged(x(), y(), 5,5);

    // TMP EMIT
    emit changedPosition();
    return moved;
  }
Exemplo n.º 6
0
void add_package(package_t* package)
{
   variable_t* evar;
   variable_t* vvar;
   list_node* enode;
   list_node* vnode;
   list_node* rnode;
   group_t* group;
   char* name;
   int got_one;
   char* text;
   
   if (package->requires)
   {
      DEBUG(stderr, "(pre-using required packages list)\n");

      for (rnode=list_tail(package->requires) ; rnode ; rnode=previous(rnode))
      {
         name = (char*) get_value(rnode);

         if (group = get_group(name))
            use_group(group);
         else
            use_package(name);
      }
   }

   for (vnode = head(package->variables) ; vnode ; vnode = next(vnode))
   {
      vvar = get_value(vnode);
      got_one = 0;
      for (enode = head(the_environment) ; enode ; enode = next(enode))
      {
         evar = get_value(enode);
         if (!strcmp(vvar->name, evar->name))
         {
            remove_node(the_environment, enode, 0);
            add_to_tail(the_environment, update_var(evar, vvar));
            got_one = 1;
            break;
         }
      }
      if (!got_one)
      {
         enode = get_into_env(vvar);
         evar = get_value(enode);
         set_value(enode, update_var(evar, vvar));
      }
   }
   
   for (vnode = head(package->scripts) ; vnode ; vnode = next(vnode))
   {
      text = ((script_t*) get_value(vnode))->text;
      add_to_tail(the_scripts, (void*) text);
   }   
}
//! returns the previous boundary from given index, including the index in the search.
//! If index is a boundary, it is returned and current is decreased by one,
//! otherwise works as previous()
int MIcuBreakIterator::previousInclusive(int index)
{
    Q_D(MIcuBreakIterator);
    if (isBoundary(index)) {
        d->current = index - 1;
        return index;
    } else {
        return previous(index);
    }
}
Exemplo n.º 8
0
bool EdgeArray::hasPrevious(std::vector<EdgeIF*>::const_iterator & iterator,
		Connectivity const connectivity, Visibility const visibility) {
	while (hasPrevious(iterator)
			&& (((connectivity != Connectivity::BOTH
					&& !current(iterator)->isInState(connectivity)))
					|| (visibility != Visibility::BOTH
							&& current(iterator)->getVisibility() != visibility))) {
		previous(iterator);
	}
	return hasPrevious(iterator);
}
Exemplo n.º 9
0
/**
 * Removes the Object last returned by the next() or previous() methods;
 * @return the removed Object pointer
 **/
void* txListIterator::remove() {
  void* obj = 0;
  if (currentItem) {
    obj = currentItem->objPtr;
    txList::ListItem* item = currentItem;
    previous();  //-- make previous item the current item
    list->remove(item);
    delete item;
  }
  return obj;
}  //-- remove
Exemplo n.º 10
0
void InterlinearChunkEditor::keyReleaseEvent(QKeyEvent *event)
{
    if( event->key() == Qt::Key_PageDown )
    {
        next();
    } else if ( event->key() == Qt::Key_PageUp )
    {
        previous();
    }
    QWidget::keyReleaseEvent(event);
}
Exemplo n.º 11
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent)
{
    QLabel *nameLabel = new QLabel(tr("Name:"));
    nameLine = new QLineEdit;
    nameLine->setReadOnly(true);

    QLabel *addressLabel = new QLabel(tr("Address:"));
    addressText = new QTextEdit;
    addressText->setReadOnly(true);
    
    addButton = new QPushButton(tr("&Add"));
    addButton->show();
    submitButton = new QPushButton(tr("&Submit"));
    submitButton->hide();
    cancelButton = new QPushButton(tr("&Cancel"));
    cancelButton->hide();
//! [navigation pushbuttons]
    nextButton = new QPushButton(tr("&Next"));
    nextButton->setEnabled(false);
    previousButton = new QPushButton(tr("&Previous"));
    previousButton->setEnabled(false);
//! [navigation pushbuttons]

    connect(addButton, SIGNAL(clicked()), this, SLOT(addContact()));
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact()));
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
//! [connecting navigation signals]    
    connect(nextButton, SIGNAL(clicked()), this, SLOT(next()));
    connect(previousButton, SIGNAL(clicked()), this, SLOT(previous()));
//! [connecting navigation signals]

    QVBoxLayout *buttonLayout1 = new QVBoxLayout;
    buttonLayout1->addWidget(addButton, Qt::AlignTop);
    buttonLayout1->addWidget(submitButton);
    buttonLayout1->addWidget(cancelButton);
    buttonLayout1->addStretch();
//! [navigation layout]
    QHBoxLayout *buttonLayout2 = new QHBoxLayout;
    buttonLayout2->addWidget(previousButton);
    buttonLayout2->addWidget(nextButton);
//! [ navigation layout]
    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameLine, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
    mainLayout->addWidget(addressText, 1, 1);
    mainLayout->addLayout(buttonLayout1, 1, 2);
//! [adding navigation layout]
    mainLayout->addLayout(buttonLayout2, 3, 1);
//! [adding navigation layout]
    setLayout(mainLayout);
    setWindowTitle(tr("Simple Address Book"));
}
Exemplo n.º 12
0
void OutfitWindow::wearPreviousOutfit(const bool all)
{
    previous();
    if (!all && mCurrentOutfit >= 0 && mCurrentOutfit
        < static_cast<int>(OUTFITS_COUNT))
    {
        bool fromStart = false;
        while (!mItemsUnequip[mCurrentOutfit])
        {
            previous();
            if (mCurrentOutfit == 0)
            {
                if (!fromStart)
                    fromStart = true;
                else
                    return;
            }
        }
    }
    wearOutfit(mCurrentOutfit);
}
Exemplo n.º 13
0
/**
 * Advances the iterator either forward or backward the specified number of steps.
 * Negative values move backward, and positive values move forward.  This is
 * equivalent to repeatedly calling next() or previous().
 * @param n The number of steps to move.  The sign indicates the direction
 * (negative is backwards, and positive is forwards).
 * @return The character offset of the boundary position n boundaries away from
 * the current one.
 */
int32_t BreakIterator::next(int32_t n) {
    int32_t result = current();
    while (n > 0) {
        result = next();
        --n;
    }
    while (n < 0) {
        result = previous();
        ++n;
    }
    return result;
}
Exemplo n.º 14
0
  void CellCursor::removeFromCurrentPosition()
  {
    //remove all widgets from parents layout.
    Cell *par = parentCell();
    par->removeCellWidgets();

    if(parentCell()->child() == this)
      parentCell()->setChild(next());

    if(parentCell()->last() == this)
      parentCell()->setLast(previous());

    if(hasNext())
      next()->setPrevious(previous());

    if(hasPrevious())
      previous()->setNext(next());

    //Insert all widgets again.
    par->addCellWidgets();
  }
//! returns the previous boundary including the current index in the search.
//! If current index is a boundary, it is returned and current is decreased by one,
//! otherwise works as previous()
int MIcuBreakIterator::previousInclusive()
{
    Q_D(MIcuBreakIterator);
    if (isBoundary()) {
        int result = d->current;
        --d->current;
        return result;

    } else {
        return previous();
    }
}
void MusicWidget::setupSensors()
{
    QSensorGestureManager manager;
    QStringList gestureIds = manager.gestureIds();
    qDebug() << gestureIds;
    if(gestureIds.contains("QtSensors.shake2"))
    {
        qDebug() << "setup shake 2 sensor";
        m_shakeGesture = new QSensorGesture(
                    QStringList() << "QtSensors.shake2"
                    , this);
        connect(m_shakeGesture, SIGNAL(shakeUp()),
                m_playlist, SLOT(previous()));
        connect(m_shakeGesture, SIGNAL(shakeDown()),
                m_playlist, SLOT(next()));
        connect(m_shakeGesture, SIGNAL(shakeLeft()),
                m_playlist, SLOT(previous()));
        connect(m_shakeGesture, SIGNAL(shakeRight()),
                m_playlist, SLOT(next()));

    }
    else if(gestureIds.contains("QtSensors.shake"))
    {
        qDebug() << "setup shake sensor";
        m_shakeGesture = new QSensorGesture(
                    QStringList() << "QtSensors.shake"
                    , this);
        connect(m_shakeGesture, SIGNAL(shake()),
                m_playlist, SLOT(next()));
    }
    if(gestureIds.contains("QtSensors.turnover"))
    {
        m_turnoverGesture = new QSensorGesture(
                    QStringList("QtSensors.turnover")
                    ,this
                    );
        connect(m_turnoverGesture, SIGNAL(turnover()),
                this, SLOT(onTurnover()));
    }
}
Exemplo n.º 17
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    m_areaMode( Default ),
    m_extractor(new VideoExtractor() ),
    m_isHandleActived(true),
    m_isPlay(false),
    m_subImage(nullptr),
    m_subImageSource1(nullptr),
    m_subImageSource2(nullptr),
    m_subResults(nullptr),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->mdiArea->setMainWindow(this);

    connect(ui->actionQuitter, SIGNAL(triggered()), qApp, SLOT( quit() ) );

    connect(ui->buttonPrevious, SIGNAL(clicked()), m_extractor, SLOT(previous()));
    connect(ui->buttonNext, SIGNAL(clicked()), m_extractor, SLOT(next()));

    ui->mdiAreaMode->addItem("Default", Default);
    ui->mdiAreaMode->addItem("Tabulation", Tabulation);
    ui->mdiAreaMode->addItem("Libre", Free);

    int max = 1<<(sizeof(int)*8-2) ;

    m_extractor->changeHandleParameters( new ComboBox("Traitement", VirtualHandle::getAllHandleName(),
                                                      MainHandle),
                                            ui->parametersArea );
    m_extractor->changePeriodeParameters( new Slider("Time", 200000000, 0, max) ,
                                          ui->parametersArea );

    /* obligatoire, à n'appeler qu'une unique fois et dans une fonction /!\ */
    qRegisterMetaType<ImageDataPtr>("ImageDataPtr");
    connect( m_extractor, SIGNAL(imageHandled(ImageDataPtr,ImageDataPtr,ImageDataPtr) ),
             this, SLOT(setImage(ImageDataPtr,ImageDataPtr,ImageDataPtr) ) );
    connect( m_extractor, SIGNAL(streamFinished()), this, SLOT(playPause()));

    VideoReader * cam1 = new VideoReader();
    cam1->useCamera(); //or FolderReader * cam1 = new FolderReader("img/");

    m_extractor->useSource(cam1, 0);
    m_extractor->showParameters( ui->parametersArea );

    ui->mdiAreaMode->setCurrentIndex( ui->mdiAreaMode->findData(m_areaMode) );
    VirtualHandle::setView(ui->mdiArea);

    ui->sliderCurseur->setTracking(true);

    m_extractor->start();
    updateSeek();
}
Exemplo n.º 18
0
void EPGRuler::paintEvent( QPaintEvent *event )
{
    Q_UNUSED( event );
    const QSize margin( 0, contentsMargins().top() );
    const QSize header( 0, maximumHeight() - contentsMargins().top() );
    const int spacing = m_scale * 3600;
    QPainter p( this );

    QDateTime localStartTime;
    localStartTime = m_startTime.addSecs( m_offset / m_scale );

    QDateTime diff( localStartTime );
    diff.setTime( QTime( localStartTime.time().hour(), 0, 0, 0 ) );

    int secondsToHour = localStartTime.secsTo( diff );

    /* draw hour blocks, with right bound being hourmark */
    QPoint here( secondsToHour * m_scale, margin.height() );
    QPoint previous( -1, 0 );
    QDateTime current( localStartTime.addSecs( secondsToHour ) );
    current = current.addSecs( -3600 );

    QColor fillColor;
    while ( here.rx() < width() + spacing )
    {
        QRect area( QPoint( previous.x() + 1, margin.height() ), here );
        area.adjust( 0, 0, 0, header.height() );
        QString timeString = current.toString( "hh'h'" );
        /* Show Day */
        if ( current.time().hour() == 0 )
            timeString += current.date().toString( " ddd dd" );

        if ( m_startTime.date().daysTo( current.date() ) % 2 == 0 )
            fillColor = palette().color( QPalette::Window );
        else
            fillColor = palette().color( QPalette::Dark );
        p.fillRect( area, fillColor );
        p.drawLine( area.topRight(), area.bottomRight() );
        p.drawText( area, Qt::AlignLeft, timeString );
        previous = here;
        here.rx() += spacing;
        current = current.addSecs( 3600 );
    }

    /* draw current time line */
    here.rx() = localStartTime.secsTo( QDateTime::currentDateTime() ) * m_scale;
    if ( here.x() <= width() && here.x() >= 0 )
    {
        p.setPen( QPen( QColor( 255, 0 , 0, 128 ) ) );
        p.drawLine( here, QPoint( here.x(), here.y() + header.height() ) );
    }
}
Exemplo n.º 19
0
DialogNewB::DialogNewB(QWidget *parent, MainWindow *_mw, QString _num, QString _code,
                       QString _ville, QString _type, int _piece, double _surfaceT, double _surfaceH,
                       QString _nom, QString _prenom, QString _mail, QString _tel, QString _typeV, double _prix,
                       QString _titre, QString _descr, QString _image1, QString _image2, QString _image3, QString _image4) :
    QDialog(parent),
    ui(new Ui::DialogNewB)
{
    ui->setupUi(this);

    /* récupération des données entre les pages */
    mw=_mw;
    num = _num;
    code = _code;
    ville = _ville;
    type = _type;
    piece = _piece;
    surfaceT = _surfaceT;
    surfaceH = _surfaceH;
    nom = _nom;
    prenom = _prenom;
    mail = _mail;
    tel = _tel;
    typeV = _typeV;
    prix = _prix;
    titre = _titre;
    descr = _descr;
    image1 = _image1;
    image2 = _image2;
    image3 = _image3;
    image4 = _image4;

    /* réaffichage des données entre les pages */
    ui->lineEdit_Titre->insert(titre);
    ui->plainTextEdit_Description->insertPlainText(descr);
    actualiseImgs(image1, image2, image3, image4);


    /* PushButtons: Insérer l'image 1, 2, 3 et 4 */
    QObject::connect(ui->pushButton_ImgSelect,SIGNAL(clicked()),this,SLOT(addImg1()));
    QObject::connect(ui->pushButton_ImgSelect_2,SIGNAL(clicked()),this,SLOT(addImg2()));
    QObject::connect(ui->pushButton_ImgSelect_3,SIGNAL(clicked()),this,SLOT(addImg3()));
    QObject::connect(ui->pushButton_ImgSelect_4,SIGNAL(clicked()),this,SLOT(addImg4()));

    /* PushButton: Précédent */
    QObject::connect(ui->pushButton_Precedent_2,SIGNAL(clicked()),this,SLOT(previous()));

    /* PushButton: Valider */
    QObject::connect(ui->pushButton_Valid_2,SIGNAL(clicked()),this,SLOT(add()));

    /* PushButton: Annuler */
    QObject::connect(ui->pushButton_Annuler_2,SIGNAL(clicked()),this,SLOT(close()));
}
Exemplo n.º 20
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent)
{
    QLabel *nameLabel = new QLabel(tr("Name:"));         // создаем объект  QLabel nameLabel
    nameLine = new QLineEdit;
    nameLine->setReadOnly(true);    // устанавливаем в режим только для чтения

    QLabel *addressLabel = new QLabel(tr("Address:"));  // создаем объект  QLabel addressLabel
    addressText = new QTextEdit;
    addressText->setReadOnly(true); // устанавливаем в режим только для чтения

    addButton = new QPushButton(tr("&Add"));        //  создаем экземпляр кнопоки
    addButton->show();                              //  устанавливаем ее отображение на экране после вызова функции show
    submitButton = new QPushButton(tr("&Submit"));  //  создаем экземпляр кнопоки
    submitButton->hide();                           //  устанавливаем ее отображение на экране после вызова функции hide(после нажатия кнопки "Add")
    cancelButton = new QPushButton(tr("&Cancel"));  //  создаем экземпляр кнопоки
    cancelButton->hide();                           //  устанавливаем ее отображение на экране после вызова функции hide(после нажатия кнопки "Add")

    nextButton = new QPushButton(tr("&Next"));      //  создаем экземпляр кнопки
    nextButton->setEnabled(false);                  //  отключаем ее
    previousButton = new QPushButton(tr("&Previous"));
    previousButton->setEnabled(false);

    connect(addButton, SIGNAL(clicked()), this, SLOT(addContact()));            //
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact()));      // Соединяем кнопки с соответствующими им слотами
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));             //

    connect(nextButton, SIGNAL(clicked()), this, SLOT(next()));
    connect(previousButton, SIGNAL(clicked()), this, SLOT(previous()));

    QVBoxLayout *buttonLayout1 = new QVBoxLayout;       //
    buttonLayout1->addWidget(addButton, Qt::AlignTop);  //  Расположение кнопок виджета
    buttonLayout1->addWidget(submitButton);             //
    buttonLayout1->addWidget(cancelButton);             //
    buttonLayout1->addStretch();                        //  чтобы расположить кнопки ближе к верхней части виджета

    QHBoxLayout *buttonLayout2 = new QHBoxLayout;
    buttonLayout2->addWidget(previousButton);
    buttonLayout2->addWidget(nextButton);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameLine, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
    mainLayout->addWidget(addressText, 1, 1);
    mainLayout->addLayout(buttonLayout1, 1, 2);
    mainLayout->addLayout(buttonLayout2, 3, 1);

    setLayout(mainLayout);
    setWindowTitle(tr("Simple Address Book"));

}
Exemplo n.º 21
0
int main(void)
{
	int one  = head(my_array);
	int prev = previous(&my_array[1]);
	int two = f2()(my_array);
	f();
	f_pointer()();
	printf("Head of array => %d\n", one);
	printf("Head of array => %d\n", prev);
	printf("Head of array => %d\n", two);

	return 0;
}
Exemplo n.º 22
0
void MainWindow::changePlayerConnections(bool connected)
{
    if(connected)
    {
        nextConnection = connect(bar,SIGNAL(nextClicked()),&player,SLOT(next()));
        previousConnection =  connect(bar,SIGNAL(previousClicked()),&player,SLOT(previous()));
    }
    else
    {
        disconnect(nextConnection);
        disconnect(previousConnection);
    }
}
Exemplo n.º 23
0
bool ImageFileParser::previous(cv::Mat& image) {
	if (index <= 0) {
		return false;
	}

	image = cv::imread(files[--index], CV_LOAD_IMAGE_UNCHANGED);

	if (!image.data) {
		std::cout << "Not an image : " << files[index] << std::endl;
		return previous(image);
	}

	std::cout << "Loaded : " << files[index] << std::endl;
	return true;
}
Exemplo n.º 24
0
void Calibrador::loadMatrix(String fileName) {
	bool ok1 = false;
	bool ok2 = false;
	bool ok3 = false;
	//	ofLogNotice("LOAD HOMOGR");
	// load the previous homography if it's available
	ofFile previous(fileName+"_homography.yml");
	if(previous.exists()) {
		FileStorage fs(ofToDataPath(fileName+"_homography.yml"), FileStorage::READ);
		fs["homography"] >> homography;
		//		calcHomography();
		homographyReady = true;
		
		ok1 = true;
	}
Exemplo n.º 25
0
bool OsmAnd::ResolvedMapStyle_P::collectConstants()
{
    // Process styles chain in reverse order, top-most parent is the last element
    auto citUnresolvedMapStyle = iteratorOf(owner->unresolvedMapStylesChain);
    citUnresolvedMapStyle.toBack();
    while (citUnresolvedMapStyle.hasPrevious())
    {
        const auto& unresolvedMapStyle = citUnresolvedMapStyle.previous();

        for (const auto& constantEntry : rangeOf(constOf(unresolvedMapStyle->constants)))
            _constants[constantEntry.key()] = constantEntry.value();
    }

    return true;
}
Exemplo n.º 26
0
void Selection::handleButtonSelection(){
	timeSinceLastInput=Min(timeSinceLastInput+1,16);
	
	if (key[KEY_UP])
		if (timeSinceLastInput>15){
			previous();
			timeSinceLastInput=0;
	}
	if (key[KEY_DOWN])
		if (timeSinceLastInput>15){
			next();
			timeSinceLastInput=0;
	}

}
Exemplo n.º 27
0
bool lemur::file::Keyfile::previous( int& key, char* value, int& valueLength ) {
  char keyBuf[KEYFILE_KEYBUF_SIZE];
  int keyLength = 6;
  bool result = false;

  try {
    result = previous( keyBuf, keyLength, value, valueLength ); 
  } catch (lemur::api::Exception &e) {
    key = _decodeKey( keyBuf );
    LEMUR_RETHROW( e, "Caught an internal error while trying to fetch previous record with an int key." );
  }
  
  if( result )
    key = _decodeKey( keyBuf );
  return result;
}
Exemplo n.º 28
0
void remove(List*list, Position position)
{
	if (position == nullptr)
	{
		std::cout << "Error" << std::endl;
		return;
	}
	if (position == head(list))
	{
		list->head = position->next;
		return;
	}
	Position temp = previous(list, position);
	temp->next = position->next;
	delete position;
}
Exemplo n.º 29
0
/** Compute the Cij
 *
 */
void GeneralisedSecondDifference::computePrefactors() {
  int zz = 0;
  int max_index_prev = 1;
  int n_el_prev = 3;
  std::vector<double> previous(n_el_prev);
  previous[0] = 1;
  previous[1] = -2;
  previous[2] = 1;

  if (m_z == 0) //
  {
    m_Cij.resize(3);
    std::copy(previous.begin(), previous.end(), m_Cij.begin());
    m_Cij2.resize(3);
    std::transform(m_Cij.begin(), m_Cij.end(), m_Cij2.begin(),
                   VectorHelper::Squares<double>());
    return;
  }
  std::vector<double> next;
  // Calculate the Cij iteratively.
  do {
    zz++;
    int max_index = zz * m_m + 1;
    int n_el = 2 * max_index + 1;
    next.resize(n_el);
    std::fill(next.begin(), next.end(), 0.0);
    for (int i = 0; i < n_el; ++i) {
      int delta = -max_index + i;
      for (int l = delta - m_m; l <= delta + m_m; l++) {
        int index = l + max_index_prev;
        if (index >= 0 && index < n_el_prev)
          next[i] += previous[index];
      }
    }
    previous.resize(n_el);
    std::copy(next.begin(), next.end(), previous.begin());
    max_index_prev = max_index;
    n_el_prev = n_el;
  } while (zz != m_z);

  m_Cij.resize(2 * m_z * m_m + 3);
  std::copy(previous.begin(), previous.end(), m_Cij.begin());
  m_Cij2.resize(2 * m_z * m_m + 3);
  std::transform(m_Cij.begin(), m_Cij.end(), m_Cij2.begin(),
                 VectorHelper::Squares<double>());
  return;
}
Exemplo n.º 30
0
/*! Create buttons 
 * 
 * This function creates all the buttons needed by the user and connects them to the appropriate functions
 */
void MainWindow::createButtons()
{
    
    window = new QGraphicsView(this); // QWidget(this);
    window->resize(WIDTH /* * 9 / 10*/, MENUWIDTH);

    //Creating the required buttons
    preB = new QPushButton("Previous", this);
    preB->resize(80, 80); //,102);
    undoB = new QPushButton("Undo", this);
    redoB = new QPushButton("Redo", this);
    nextB = new QPushButton("Next", this);
    writeB = new QPushButton("Write", this);
    eraseB = new QPushButton("Erase", this);
    //penColorB = new QPushButton("Pen Color", this);
    //penWidthB = new QPushButton("Pen Width", this);
    clearAllB = new QPushButton("Clear all", this);

    //connecting buttons to actions
    connect(preB, SIGNAL(clicked()), this, SLOT(previous()));
    connect(undoB, SIGNAL(clicked()), this, SLOT(undo()));
    connect(redoB, SIGNAL(clicked()), this, SLOT(redo()));
    connect(nextB, SIGNAL(clicked()), this, SLOT(next()));
    connect(writeB, SIGNAL(clicked()), this, SLOT(write()));
    connect(eraseB, SIGNAL(clicked()), this, SLOT(erase()));
    //connect(penColorB, SIGNAL(clicked()), this, SLOT(penColor()));
    //connect(penWidthB, SIGNAL(clicked()), this, SLOT(penWidth()));
    connect(clearAllB, SIGNAL(clicked()), this, SLOT(clearAll()));

    //Creating a box layout and placing all the buttons in it
    layout = new QHBoxLayout; 
    layout->addWidget(preB);
    layout->addWidget(undoB);
    layout->addWidget(redoB);
    layout->addWidget(writeB);
    layout->addWidget(eraseB);
    layout->addWidget(clearAllB);
    //layout->addWidget(penColorB);
    //layout->addWidget(penWidthB);
    layout->addWidget(nextB);

    window->setBackgroundRole(QPalette::Shadow);
    //displaying buttons
    window->setLayout(layout);
    
    window->show();
}