Exemplo n.º 1
0
/**
 * \brief Refresh the view
 */
void UBLibraryWidget::refreshView()
{
    // Clear the view
    mItems.clear();
    mLabels.clear();
    mItemsPaths.clear();
    mGraphicItems.clear();

    // Generate the graphics items
    generateItems();

    // Set the new items
    setGraphicsItems(mGraphicItems, mItemsPaths, mLabels);

    // Refresh the view
    refreshScene();

    emit navigBarUpdate(mpCrntElem);

    bool bFavorite = false;
    if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
    {
        bFavorite = true;
    }
    emit favoritesEntered(bFavorite);
}
Exemplo n.º 2
0
/*
 * KdmThemer. The main theming interface
 */
KdmThemer::KdmThemer( const QString &_filename, const QString &mode,
                      const QMap<QString, bool> &showTypes, QWidget *w )
	: QObject()
	, m_currentMode( mode )
	, m_showTypes( showTypes )
	, rootItem( 0 )
	, m_geometryOutdated( true )
	, m_geometryInvalid( true )
	, m_widget( 0 )
{
	// read the XML file and create DOM tree
	QString filename = _filename;
	if (!::access( QFile::encodeName( filename + "/KdmGreeterTheme.desktop" ), R_OK )) {
		KConfig _cfg( filename + "/KdmGreeterTheme.desktop", KConfig::SimpleConfig );
		KConfigGroup cfg( &_cfg, "KdmGreeterTheme" );
		filename += '/' + cfg.readEntry( "Greeter" );
	}
	QFile opmlFile( filename );
	if (!opmlFile.open( QIODevice::ReadOnly )) {
		FDialog::box( w, errorbox, i18n( "Cannot open theme file %1" , filename) );
		return;
	}
	QDomDocument domTree;
	if (!domTree.setContent( &opmlFile )) {
		FDialog::box( w, errorbox, i18n( "Cannot parse theme file %1" , filename) );
		return;
	}
	// generate all the items defined in the theme
	const QDomElement &theme = domTree.documentElement();
	// Get its tag, and check it's correct ("greeter")
	if (theme.tagName() != "greeter") {
		FDialog::box( w, errorbox, i18n( "%1 does not seem to be a correct theme file" , filename) );
		return;
	}

	// Set the root (screen) item
	rootItem = new KdmRect( this, theme );

	basedir = QFileInfo( filename ).absolutePath();

	generateItems( rootItem, theme );
	rootItem->updateVisible();

/*	*TODO*
	// Animation timer
	QTimer *time = new QTimer( this );
	time->start( 500 );
	connect( time, SIGNAL(timeout()), SLOT(update()) )
*/
}
Exemplo n.º 3
0
/**
* @brief Verify that the generateItems functio generate enought items (bonus or malus).
*/
void verifyGenerateItems() {
    GRID grid;
    grid.height = 15;
    grid.width = 15;

    int matrix[15][15] = {
        {WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL, VOID, WALL},
        {WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL, WALL},
    };

    grid.matrix = (int**) matrix;

    generateItems(&grid);

    int y = 0;
    int x = 0;
    int nbBonusOrMalus = 0;
    int nbOfUnknownItems = 0;

    for (y = 0; y < grid.height; y++) {
        for (x = 0; x < grid.width; x++) {
            if (grid.matrix[y][x] == BONUS || grid.matrix[y][x] == MALUS) {
                nbBonusOrMalus++;
            }

            if (grid.matrix[y][x] != WALL && grid.matrix[y][x] != VOID && grid.matrix[y][x] != BONUS && grid.matrix[y][x] != MALUS) {
                nbOfUnknownItems++;
            }
        }
    }

    CU_ASSERT(nbBonusOrMalus >= grid.height);
    CU_ASSERT(nbOfUnknownItems == 0);
}
Exemplo n.º 4
0
Mode PlayMode::frame()
{
  if(!paused)
  {
    background->draw();
    if(!handleInput())
      return MENU;
    if(!crashed)
    {
      moveField();
      background->update();
      updatePlayer();
      generateWalls();
      generateObstacles();
      generateItems();
    }
    updatePlayerTail();
    particles->draw(0);
    particles->draw(2);
    drawStuff();
    particles->draw(4);
    drawPlayer();
    particles->draw(1);
    floating->draw();
    collisionDetect();
    obstacleCounter();
    drawScorePanel();
    if(crashed && !gameOverExplosionTime--)
    {
      globalStore->seconds = playtime / 60;
      globalStore->score = score;
      globalStore->obstacles = passed;
      globalStore->stars = collected;
      storage->read();
      storage->insert(score);
      return GAMEOVER;
    }
    particles->update();
    floating->update();
  } else
  {
    drawPauseScreen();
    if(!handleInput())
      return MENU;
  }
  return PLAY;
}
Exemplo n.º 5
0
void Game::reset()
{
    // Reset visited map
    for (int i = 0; i < MAPSIZE; i++)
    {
        for (int j = 0; j < MAPSIZE; j++)
        {
            m_visited[i][j] = false;
        }
    }

    foundKey = false;
    foundChest = false;
    gotKey = false;
    gotChest = false;
    generateItems();
}
Exemplo n.º 6
0
ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocClipBase*> list, QStringList luma_list, QWidget * parent) :
        QDialog(parent)
        , m_requestedSize(0)
        , m_copyJob(NULL)
        , m_name(projectName.section('.', 0, -2))
        , m_doc(doc)
	, m_temp(NULL)
        , m_abortArchive(false)
        , m_extractMode(false)
	, m_progressTimer(NULL)
        , m_extractArchive(NULL)
        , m_missingClips(0)
{
    setAttribute(Qt::WA_DeleteOnClose);
    setupUi(this);
    setWindowTitle(i18n("Archive Project"));
    archive_url->setUrl(KUrl(QDir::homePath()));
    connect(archive_url, SIGNAL(textChanged (const QString &)), this, SLOT(slotCheckSpace()));
    connect(this, SIGNAL(archivingFinished(bool)), this, SLOT(slotArchivingFinished(bool)));
    connect(this, SIGNAL(archiveProgress(int)), this, SLOT(slotArchivingProgress(int)));
    connect(proxy_only, SIGNAL(stateChanged(int)), this, SLOT(slotProxyOnly(int)));

    // Setup categories
    QTreeWidgetItem *videos = new QTreeWidgetItem(files_list, QStringList() << i18n("Video clips"));
    videos->setIcon(0, KIcon("video-x-generic"));
    videos->setData(0, Qt::UserRole, "videos");
    videos->setExpanded(false);
    QTreeWidgetItem *sounds = new QTreeWidgetItem(files_list, QStringList() << i18n("Audio clips"));
    sounds->setIcon(0, KIcon("audio-x-generic"));
    sounds->setData(0, Qt::UserRole, "sounds");
    sounds->setExpanded(false);
    QTreeWidgetItem *images = new QTreeWidgetItem(files_list, QStringList() << i18n("Image clips"));
    images->setIcon(0, KIcon("image-x-generic"));
    images->setData(0, Qt::UserRole, "images");
    images->setExpanded(false);
    QTreeWidgetItem *slideshows = new QTreeWidgetItem(files_list, QStringList() << i18n("Slideshow clips"));
    slideshows->setIcon(0, KIcon("image-x-generic"));
    slideshows->setData(0, Qt::UserRole, "slideshows");
    slideshows->setExpanded(false);
    QTreeWidgetItem *texts = new QTreeWidgetItem(files_list, QStringList() << i18n("Text clips"));
    texts->setIcon(0, KIcon("text-plain"));
    texts->setData(0, Qt::UserRole, "texts");
    texts->setExpanded(false);
    QTreeWidgetItem *playlists = new QTreeWidgetItem(files_list, QStringList() << i18n("Playlist clips"));
    playlists->setIcon(0, KIcon("video-mlt-playlist"));
    playlists->setData(0, Qt::UserRole, "playlist");
    playlists->setExpanded(false);
    QTreeWidgetItem *others = new QTreeWidgetItem(files_list, QStringList() << i18n("Other clips"));
    others->setIcon(0, KIcon("unknown"));
    others->setData(0, Qt::UserRole, "others");
    others->setExpanded(false);
    QTreeWidgetItem *lumas = new QTreeWidgetItem(files_list, QStringList() << i18n("Luma files"));
    lumas->setIcon(0, KIcon("image-x-generic"));
    lumas->setData(0, Qt::UserRole, "lumas");
    lumas->setExpanded(false);
    
    QTreeWidgetItem *proxies = new QTreeWidgetItem(files_list, QStringList() << i18n("Proxy clips"));
    proxies->setIcon(0, KIcon("video-x-generic"));
    proxies->setData(0, Qt::UserRole, "proxy");
    proxies->setExpanded(false);
    
    // process all files
    QStringList allFonts;
    KUrl::List fileUrls;
    QStringList fileNames;
    QStringList extraImageUrls;
    QStringList otherUrls;
    generateItems(lumas, luma_list);

    QMap <QString, QString> slideUrls;
    QMap <QString, QString> audioUrls;
    QMap <QString, QString>videoUrls;
    QMap <QString, QString>imageUrls;
    QMap <QString, QString>playlistUrls;
    QMap <QString, QString>proxyUrls;

    for (int i = 0; i < list.count(); i++) {
        DocClipBase *clip = list.at(i);
        CLIPTYPE t = clip->clipType();
        QString id = clip->getId();
        if (t == SLIDESHOW) {
            KUrl slideUrl = clip->fileURL();
            //TODO: Slideshow files
            slideUrls.insert(id, slideUrl.path());
        }
        else if (t == IMAGE) imageUrls.insert(id, clip->fileURL().path());
        else if (t == TEXT) {
            QStringList imagefiles = TitleWidget::extractImageList(clip->getProperty("xmldata"));
            QStringList fonts = TitleWidget::extractFontList(clip->getProperty("xmldata"));
            extraImageUrls << imagefiles;
            allFonts << fonts;
        } else if (t == PLAYLIST) {
            playlistUrls.insert(id, clip->fileURL().path());
            QStringList files = ProjectSettings::extractPlaylistUrls(clip->fileURL().path());
            otherUrls << files;
        }
        else if (!clip->fileURL().isEmpty()) {
            if (t == AUDIO) audioUrls.insert(id, clip->fileURL().path());
            else {
                videoUrls.insert(id, clip->fileURL().path());
                // Check if we have a proxy
                QString proxy = clip->getProperty("proxy");
                if (!proxy.isEmpty() && proxy != "-" && QFile::exists(proxy)) proxyUrls.insert(id, proxy);
            }
        }
    }

    generateItems(images, extraImageUrls);
    generateItems(sounds, audioUrls);
    generateItems(videos, videoUrls);
    generateItems(images, imageUrls);
    generateItems(slideshows, slideUrls);
    generateItems(playlists, playlistUrls);
    generateItems(others, otherUrls);
    generateItems(proxies, proxyUrls);
    
    allFonts.removeDuplicates();

#if KDE_IS_VERSION(4,7,0)
        m_infoMessage = new KMessageWidget(this);
        QVBoxLayout *s =  static_cast <QVBoxLayout*> (layout());
        s->insertWidget(5, m_infoMessage);
        m_infoMessage->setCloseButtonVisible(false);
        m_infoMessage->setWordWrap(true);
        m_infoMessage->hide();
#endif
        
        // missing clips, warn user
    if (m_missingClips > 0) {
        QString infoText = i18np("You have %1 missing clip in your project.", "You have %1 missing clips in your project.", m_missingClips);
#if KDE_IS_VERSION(4,7,0)
        m_infoMessage->setMessageType(KMessageWidget::Warning);
        m_infoMessage->setText(infoText);
        m_infoMessage->animatedShow();
#else
        KMessageBox::sorry(this, infoText);
#endif
    }

    //TODO: fonts

    // Hide unused categories, add item count
    int total = 0;
    for (int i = 0; i < files_list->topLevelItemCount(); i++) {
        QTreeWidgetItem *parentItem = files_list->topLevelItem(i);
        int items = parentItem->childCount();
        if (items == 0) {
            files_list->topLevelItem(i)->setHidden(true);
        }
        else {
            if (parentItem->data(0, Qt::UserRole).toString() == "slideshows")
            {
                // Special case: slideshows contain several files
                for (int j = 0; j < items; j++) {
                    total += parentItem->child(j)->data(0, Qt::UserRole + 1).toStringList().count();
                }
            }
            else total += items;
            parentItem->setText(0, files_list->topLevelItem(i)->text(0) + ' ' + i18np("(%1 item)", "(%1 items)", items));
        }
    }
    if (m_name.isEmpty()) m_name = i18n("Untitled");
    compressed_archive->setText(compressed_archive->text() + " (" + m_name + ".tar.gz)");
    project_files->setText(i18np("%1 file to archive, requires %2", "%1 files to archive, requires %2", total, KIO::convertSize(m_requestedSize)));
    buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive"));
    connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotStartArchiving()));
    buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
    
    slotCheckSpace();
}
Exemplo n.º 7
0
void WorldPhysics::AI() {
  if (tmp_wait>0) {tmp_wait--;return;}
  if (bulldozer_state==8) speed=0;
  
  const dReal* BPosition=bulldozer->getPosition();
//  const dReal* BRotation=bulldozer->getRotation();
  dReal minDistance=150; //~100 * sqrt(2)

  Item* tmp;
  int currentItemN=-1;
  if (items.size()==0) return;
  for (int i=0;i<items.size();i++) {
    const dReal* ItemPosition=items[i]->getPosition();
    if (ItemPosition[2]<0) items[i]->state=2;
    if (items[i]->state==2) continue;
    if (items[i]->state==1) {currentItemN=i;break;}
    if (items[i]->state==0) {
      dReal tmpmin=sqrt((ItemPosition[0]-BPosition[0])*
            (ItemPosition[0]-BPosition[0]) + 
            (ItemPosition[1]-BPosition[1])*
            (ItemPosition[1]-BPosition[1]));
      if (tmpmin<minDistance) {
        minDistance=tmpmin;
        currentItemN=i;
      }
    }
  }
  if (currentItemN==-1) {
    //bulldozer_state=0;
    generateItems();
    return;
  }
  /*
  for (int i=0;i<items.size();i++) {
    const dReal* tmp_pos=items[i]->getPosition();
    if (tmp_pos[2]<0) items[i]->state=2;

    if (items[i]->state==1) {
      currentItemN=i;
      break;
    }
    if (items[i]->state==2) currentItemN++;
  }
  if (currentItemN>=items.size()) return;
  */
  tmp=items[currentItemN];
  const dReal* ItemPosition=tmp->getPosition();
  switch (tmp->state) {
    case 0: { // Выбрали нужный кубик
      tmp->state=1;
      bulldozer_state=1; // Поворот до кубика
    } break;
    case 1: {  // Надо к нему подъехать
    switch (bulldozer_state) {
        
        case 1:{
          speed=0;
          if (RotateTo(ItemPosition[0]-BPosition[0],ItemPosition[1]-BPosition[1])) bulldozer_state=2;
        } break;
        
        case 2: {
          if (RotateTo(ItemPosition[0]-BPosition[0],ItemPosition[1]-BPosition[1])) {
            speed=3;
            if (((ItemPosition[0]-BPosition[0])*
              (ItemPosition[0]-BPosition[0]) + 
              (ItemPosition[1]-BPosition[1])*
              (ItemPosition[1]-BPosition[1]))<50) {
              speed=0;
              bulldozer_state=3;
              }
                
          } else {
            speed=0;
            bulldozer_state=1;
          }
        } break;
        case 3: {
          cheat_joint=dJointCreateSlider(world,0);
          dJointAttach(cheat_joint,bulldozer->body,tmp->body);
          dJointSetSliderAxis(cheat_joint,0,0,1);
          //dJointSetSliderParam (cheat_joint, dParamCFM, 0.5);
          bulldozer_state=4;
        }break;
        case 4: {
          if (RotateTo(100-BPosition[0],0-BPosition[1])) bulldozer_state=5;
        }break;
        case 5: {
          if (RotateTo(100-BPosition[0],0-BPosition[1])) {
            speed=3;
            if (sqrt((100-BPosition[0])*
                  (100-BPosition[0]) + 
                  (0-BPosition[1])*
                  (0-BPosition[1]))<(sqrt(2)*25+LENGTH/2+RADIUS)) {
              speed=0;
              bulldozer_state=6;
                  }
                
          } else {
            speed=0;
            bulldozer_state=4;
          }
        } break;
        
      case 6: {
        dJointDestroy(cheat_joint);
        dBodyAddForce(tmp->body,100-BPosition[0],0-BPosition[1], 5);
        bulldozer_state=7;
      } break;
      case 7: {
        speed=-10;
        tmp_wait=70;
        bulldozer_state=8;
      } break;
      case 8: {
        speed=0;
        tmp->state=2;
      } break;
        
      
      
      
      }
    } break;
  }
  
}
Exemplo n.º 8
0
WorldPhysics::WorldPhysics() {

  enable_complex=0;
  bulldozer_state=1;
  tmp_scalar=0;
  tmp_wait=0;

  qsrand(QTime::currentTime().msec());

  dInitODE();
  world = dWorldCreate();
  space = dHashSpaceCreate (0);
  contactgroup = dJointGroupCreate (0);
  dWorldSetGravity (world,0,0,-9.81);
  //ground_cheat = dCreatePlane (space,0,0,1,0);
  wall1=dCreatePlane (space,-1,0,0,-100);
  wall2=dCreatePlane (space,1,0,0,0);
  wall3=dCreatePlane (space,0,-1,0,-100);
  wall4=dCreatePlane (space,0,1,0,0);
  
  
  
  // our heightfield floor

  dHeightfieldDataID heightid = dGeomHeightfieldDataCreate();

	// Create an finite heightfield.
  dGeomHeightfieldDataBuildCallback( heightid, NULL, near_heightfield_callback,
                                     HFIELD_WIDTH, HFIELD_DEPTH, HFIELD_WSTEP, HFIELD_DSTEP,
                                     REAL( 1.0 ), REAL( 0.0 ), REAL( 0.0 ), 0 );

	// Give some very bounds which, while conservative,
	// makes AABB computation more accurate than +/-INF.
  //dGeomHeightfieldDataSetBounds( heightid, REAL( -4.0 ), REAL( +6.0 ) );

  gheight = dCreateHeightfield( space, heightid, 1 );
  
  
  
  // Rotate so Z is up, not Y (which is the default orientation)
  dMatrix3 R;
  dRSetIdentity( R );
  dRFromAxisAndAngle( R, 1, 0, 0, DEGTORAD * 90 );
  dGeomSetRotation( gheight, R );
  dGeomSetPosition( gheight, 50,50,0 );

//  for (int  i=0;i<MAX_ITEMS;i++) {
  //  items.push_back(generateItem());
  //}
  generateItems();

  bulldozer_space = dSimpleSpaceCreate(space);
  dSpaceSetCleanup (bulldozer_space,0);
  
  bulldozer=new BoxItem(world,bulldozer_space,LENGTH,WIDTH,HEIGHT,CMASS);
  bulldozer->setPosition(STARTX,STARTY,STARTZ);

  bulldozer_cabin=new BoxItem(world,bulldozer_space,LENGTH/2,WIDTH/2,2*HEIGHT,CMASS/3);
  bulldozer_cabin->setPosition(-LENGTH/4+STARTX,STARTY,3.0/2.0*HEIGHT+STARTZ);

  bulldozer_bucket_c=new BoxItem(world,bulldozer_space,BUCKET_LENGTH,BUCKET_WIDTH,BUCKET_HEIGHT,CMASS/10);
  bulldozer_bucket_c->setPosition(LENGTH/2+BUCKET_LENGTH/2+RADIUS+STARTX,STARTY,STARTZ);
  
  bulldozer_bucket_l=new BoxItem(world,bulldozer_space,BUCKET_WIDTH/5,BUCKET_LENGTH,BUCKET_HEIGHT,CMASS/20);
  bulldozer_bucket_l->setPosition(LENGTH/2+BUCKET_LENGTH+RADIUS+BUCKET_WIDTH/10+STARTX,-BUCKET_WIDTH/2+BUCKET_LENGTH/2+STARTY,STARTZ);
  
  
  bulldozer_bucket_r=new BoxItem(world,bulldozer_space,BUCKET_WIDTH/5,BUCKET_LENGTH,BUCKET_HEIGHT,CMASS/20);
  bulldozer_bucket_r->setPosition(LENGTH/2+BUCKET_LENGTH+RADIUS+BUCKET_WIDTH/10+STARTX,BUCKET_WIDTH/2-BUCKET_LENGTH/2+STARTY,STARTZ);
  
  
  for (int i=0; i<4; i++) {
    dQuaternion q;
    dQFromAxisAndAngle(q,1,0,0,M_PI*0.5);
    wheels[i] = new WheelItem(world,bulldozer_space,q,RADIUS,WMASS);
  }
  dBodySetPosition (wheels[0]->body,0.5*LENGTH+STARTX,WIDTH*0.5+STARTY,STARTZ-HEIGHT*0.5);
  dBodySetPosition (wheels[1]->body,0.5*LENGTH+STARTX,-WIDTH*0.5+STARTY,STARTZ-HEIGHT*0.5);
  dBodySetPosition (wheels[2]->body,-0.5*LENGTH+STARTX, WIDTH*0.5+STARTY,STARTZ-HEIGHT*0.5);
  dBodySetPosition (wheels[3]->body,-0.5*LENGTH+STARTX,-WIDTH*0.5+STARTY,STARTZ-HEIGHT*0.5);

  cabin_joint=dJointCreateSlider(world,0);
  dJointAttach(cabin_joint,bulldozer->body,bulldozer_cabin->body);
  dJointSetSliderAxis(cabin_joint,0,0,1);
  dJointSetSliderParam(cabin_joint,dParamLoStop,0);
  dJointSetSliderParam(cabin_joint,dParamHiStop,0);

  bucket_joint_c=dJointCreateSlider(world,0);
  dJointAttach(bucket_joint_c,bulldozer->body,bulldozer_bucket_c->body);
  dJointSetSliderAxis(bucket_joint_c,0,0,1);
  dJointSetSliderParam(bucket_joint_c,dParamLoStop,0);
  dJointSetSliderParam(bucket_joint_c,dParamHiStop,0);
  
  bucket_joint_l=dJointCreateSlider(world,0);
  dJointAttach(bucket_joint_l,bulldozer->body,bulldozer_bucket_l->body);
  dJointSetSliderAxis(bucket_joint_l,0,0,1);
  dJointSetSliderParam(bucket_joint_l,dParamLoStop,0);
  dJointSetSliderParam(bucket_joint_l,dParamHiStop,0);
  
  bucket_joint_r=dJointCreateSlider(world,0);
  dJointAttach(bucket_joint_r,bulldozer->body,bulldozer_bucket_r->body);
  dJointSetSliderAxis(bucket_joint_r,0,0,1);
  dJointSetSliderParam(bucket_joint_r,dParamLoStop,0);
  dJointSetSliderParam(bucket_joint_r,dParamHiStop,0);

  // front and back wheel hinges
  for (int i=0; i<4; i++) {
    wheelJoints[i] = dJointCreateHinge2 (world,0);
    dJointAttach (wheelJoints[i],bulldozer->body,wheels[i]->body);
    const dReal *a = dBodyGetPosition (wheels[i]->body);
    dJointSetHinge2Anchor (wheelJoints[i],a[0],a[1],a[2]);
    dJointSetHinge2Axis1 (wheelJoints[i],0,0,1);
    dJointSetHinge2Axis2 (wheelJoints[i],0,1,0);
  }
  // seeting ERP & CRM
  for (int i=0; i<4; i++) {
    dJointSetHinge2Param (wheelJoints[i],dParamSuspensionERP,0.5);
    dJointSetHinge2Param (wheelJoints[i],dParamSuspensionCFM,0.8);
  }
  // block back axis !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  for (int i=0; i<2; i++) {
    dJointSetHinge2Param (wheelJoints[i],dParamLoStop,0);
    dJointSetHinge2Param (wheelJoints[i],dParamHiStop,0);
  }

}
Exemplo n.º 9
0
void
KdmThemer::generateItems( KdmItem *parent, const QDomNode &node )
{
	/*
	 * Go through each of the child nodes
	 */
	const QDomNodeList &subnodeList = node.childNodes();
	for (int nod = 0; nod < subnodeList.count(); nod++) {
		QDomNode subnode = subnodeList.item( nod );
		QDomElement el = subnode.toElement();
		QString tagName = el.tagName();

		if (tagName == "item") {
			QString showType;
			bool showTypeInvert = false;

			QDomNode showNode = subnode.namedItem( "show" );
			if (!showNode.isNull()) {
				QDomElement sel = showNode.toElement();

				QString modes = sel.attribute( "modes" );
				if (!modes.isNull() &&
				    (modes == "nowhere" ||
				     (modes != "everywhere" &&
				      !modes.split( ",", QString::SkipEmptyParts ).contains(
				          m_currentMode ))))
					continue;

				showType = sel.attribute( "type" );
				if (!showType.isNull()) {
					if (showType[0] == '!') {
						showType.remove( 0, 1 );
						showTypeInvert = true;
					}
					if (!showType.startsWith( "plugin-" ) &&
					    m_showTypes.contains( showType ) == showTypeInvert)
						continue;
				}
			}

			QString type = el.attribute( "type" );
			KdmItem *newItem;
			if (type == "label")
				newItem = new KdmLabel( parent, subnode );
			else if (type == "pixmap")
				newItem = new KdmPixmap( parent, subnode );
			else if (type == "rect")
				newItem = new KdmRect( parent, subnode );
			else if (type == "entry") {
				//newItem = new KdmEntry( parent, subnode );
				newItem = new KdmRect( parent, subnode );
				newItem->setType( type );
			} else if (type=="list")
				newItem = new KdmList( parent, subnode );
			else if (type == "svg")
				newItem = new KdmPixmap( parent, subnode );
			else
				continue;
			newItem->setIsButton( el.attribute( "button", "false" ) == "true" );
			newItem->setShowType( showType, showTypeInvert );
			connect( newItem, SIGNAL(needUpdate( int, int, int, int )),
			         SLOT(update( int, int, int, int )) );
			connect( newItem, SIGNAL(needPlacement()),
			         SLOT(slotNeedPlacement()) );
			connect( newItem, SIGNAL(needPlugging()),
			         SLOT(slotNeedPlugging()) );
			connect( newItem, SIGNAL(activated( const QString & )),
			         SIGNAL(activated( const QString & )) );
			generateItems( newItem, subnode );
		} else if (tagName == "box") {
			parent->setBoxLayout( subnode );
			generateItems( parent, subnode );
		} else if (tagName == "fixed") {
			parent->setFixedLayout( subnode );
			generateItems( parent, subnode );
		}
	}
}
Exemplo n.º 10
0
bool
DataItem::readData(string &fileName, uint64_t &coprocReq, uint64_t &hostReq)
{
    int64_t                                 t;
    int                                     b;
    int                                     c;
    map<int64_t, DataItem *>::iterator      itr;
    int64_t                                 timeMax;
    unsigned short                          *reqP;
    int                                     cntr = 0;
    size_t                                  pos;
    string                                  fn;

    //
    //  load the data
    //
    pos = fileName.find_last_of("/\\");
    if(pos == string::npos) {
        pos = 0;
    } else {
        pos++;              // skip the /
    }
    hostReq = 0;
    fn = fileName.substr(pos);
    if(fn.compare("__internal1.htmt") == 0) {
        coprocReq = generateItems(1);
    } else if(fn.compare("__internal2.htmt") == 0) {
        coprocReq = generateItems(2);
    } else {
        if(readDataFile(fileName, coprocReq, hostReq) == false) {
            return(false);
        }
    }
    //
    //  Now generate the outstanding request map for the data
    //  NOTE: it is 0 based
    //
    StatusData status("Generating Tables...", 0, CTLR_MAX * BANKS);
    markTime(true, "Table Start");
    timeMax = lastRetire - firstStart + 1;
    for(c=0; c<CTLR_MAX; c++) {                     // controller
        for(b=0; b<BANKS; b++) {                    // bank
            status.setValue(++cntr);
            if((cntr%100)==0 && status.wasCanceled()) {
                status.clear();
                cleanup();                          // remove any data
                return(false);
            }
            unsigned short *sp;
            ctlrBandTimeReq[c][b] = sp = (unsigned short *)calloc(timeMax, sizeof(*reqP));
            map<int64_t, DataItem *>::iterator      itrEnd;
            itrEnd = dataMap[c][b].end();
            
            for(itr = dataMap[c][b].begin(); itr != itrEnd; itr++) {
                int64_t tStart = itr->second->getStartTime();
                int64_t tEnd = itr->second->getRetireTime();
                tStart -= firstStart;
                tEnd -= firstStart;
                for(t=tStart; t<= tEnd; t++) {
                    sp[t]++;
                }
            }
            
#ifdef NEVER
            for(itr = dataMap[c][b].begin(); itr != dataMap[c][b].end(); itr++) {
                for(t=itr->second->getStartTime(); t<= itr->second->getRetireTime(); t++) {
                    ctlrBandTimeReq[c][b][t - firstStart]++;
                }
            }
#endif
        }
    }
    markTime(false, "Table Stop");
    status.clear();
    return(true);
}