Exemplo n.º 1
0
void KstImageDialogI::fillFieldsForEdit() {
  fillFieldsForEditNoUpdate();

  KstImagePtr ip = kst_cast<KstImage>(_dp);
  if (!ip) {
    return; // shouldn't be needed
  }
  ip->readLock();
  
  // set the type of image
  _w->_colorOnly->setChecked(ip->hasColorMap() && !ip->hasContourMap());
  _w->_contourOnly->setChecked(ip->hasContourMap() && !ip->hasColorMap());
  _w->_colorAndContour->setChecked(ip->hasColorMap() && ip->hasContourMap());

  // set the matrix
  _w->_matrix->setSelection(ip->matrixTag());

  ip->unlock();

  //update the groups and enables
  // won't call fillFieldsForEditNoUpdate again because
  // fillFieldsForEdit is not called in _editMultipleMode
  updateGroups();
  adjustSize();
  resize(minimumSizeHint());
  setFixedHeight(height());
}
Exemplo n.º 2
0
void KstImageDialogI::fillFieldsForNew() {
  KstImageList images = kstObjectSubList<KstDataObject, KstImage>(KST::dataObjectList);

  // set tag name
  _tagName->setText("<New_Image>");

  _w->_colorPalette->refresh();

  // some default values
  _w->_lowerZ->setText("0");
  _w->_upperZ->setText("100");
  _w->_realTimeAutoThreshold->setChecked(true);

  // let the image be placed in plots
  _w->_curvePlacement->update();

  // for some reason the widgets need to be placed from bottom to top
  _w->_imageTypeGroup->hide();
  _w->_contourMapGroup->hide();
  _w->_colorMapGroup->hide();
  _w->_matrixGroup->hide();
  _w->_curvePlacement->show();
  _w->_contourMapGroup->show();
  _w->_colorMapGroup->show();
  _w->_imageTypeGroup->show();
  _w->_matrixGroup->show();

  // use whatever setting was used last
  updateGroups();
  updateEnables();
  _w->_colorPalette->updatePalette(_w->_colorPalette->selectedPalette());
  adjustSize();
  resize(minimumSizeHint());
  setFixedHeight(height());
}
        void EntityDefinitionManager::setDefinitions(const EntityDefinitionList& newDefinitions) {
            clear();

            m_definitions = newDefinitions;

            updateIndices();
            updateGroups();
            updateCache();
            bindObservers();
        }
Exemplo n.º 4
0
KstImageDialogI::KstImageDialogI(QWidget* parent,
                                 const char* name, bool modal, WFlags fl)
: KstDataDialog(parent, name, modal, fl) {
  _w = new ImageDialogWidget(_contents);
  setMultiple(true);
  connect(_w->_matrix, SIGNAL(newMatrixCreated(const QString&)), this, SIGNAL(modified()));
  connect(_w->_autoThreshold, SIGNAL(clicked()), this, SLOT(calcAutoThreshold()));
  connect(_w->_smartThreshold, SIGNAL(clicked()), this, SLOT(calcSmartThreshold()));
  connect(_w->_colorOnly, SIGNAL(clicked()), this, SLOT(updateGroups()));
  connect(_w->_contourOnly, SIGNAL(clicked()), this, SLOT(updateGroups()));
  connect(_w->_colorAndContour, SIGNAL(clicked()), this, SLOT(updateGroups()));
  connect(_w->_useVariableWeight, SIGNAL(clicked()), this, SLOT(updateEnables()));
  connect(_w->_realTimeAutoThreshold, SIGNAL(clicked()), this, SLOT(updateEnables()));
  
  // for multiple edit mode
  connect(_w->_colorOnly, SIGNAL(clicked()), this, SLOT(setColorOnlyDirty()));
  connect(_w->_contourOnly, SIGNAL(clicked()), this, SLOT(setContourOnlyDirty()));
  connect(_w->_colorAndContour, SIGNAL(clicked()), this, SLOT(setColorAndContourDirty()));
  connect(_w->_realTimeAutoThreshold, SIGNAL(clicked()), this, SLOT(setRealTimeAutoThresholdDirty()));
  connect(_w->_useVariableWeight, SIGNAL(clicked()), this, SLOT(setUseVariableWeightDirty()));
  connect(_w->_contourColor, SIGNAL(clicked()), this, SLOT(setContourColorDirty()));
}
Exemplo n.º 5
0
/** Loads the settings for this page */
void ShareManager::load()
{
    if(isLoading)
        return ;

    isLoading = true;
//    std::cerr << "ShareManager:: In load !!!!!" << std::endl ;

    std::list<SharedDirInfo>::const_iterator it;
    std::list<SharedDirInfo> dirs;
    rsFiles->getSharedDirectories(dirs);

    /* get a link to the table */
    QTableWidget *listWidget = ui.shareddirList;

    /* set new row count */
    listWidget->setRowCount(dirs.size());

    int row=0 ;
    for(it = dirs.begin(); it != dirs.end(); ++it,++row)
    {
        listWidget->setItem(row, COLUMN_PATH, new QTableWidgetItem(QString::fromUtf8((*it).filename.c_str())));
        listWidget->setItem(row, COLUMN_VIRTUALNAME, new QTableWidgetItem(QString::fromUtf8((*it).virtualname.c_str())));

		  GroupFlagsWidget *widget = new GroupFlagsWidget(NULL,(*it).shareflags);

		  listWidget->setRowHeight(row, 32);
		  listWidget->setCellWidget(row, COLUMN_SHARE_FLAGS, widget);

		  listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem()) ;
		  listWidget->item(row,COLUMN_GROUPS)->setBackgroundColor(QColor(183,236,181)) ;

		  //connect(widget,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateFlags())) ;
    }

	 listWidget->setColumnWidth(COLUMN_SHARE_FLAGS,132) ;

    //ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));

    listWidget->update(); /* update display */
    update();

    isLoading = false ;
    updateGroups();
}
/** Tries to load a track from a single directory. Returns true if a track was
 *  successfully loaded.
 *  \param dirname Name of the directory to load the track from.
 */
bool TrackManager::loadTrack(const std::string& dirname)
{
    std::string config_file = dirname+"track.xml";
    if(!file_manager->fileExists(config_file))
        return false;

    Track *track;

    try
    {
        track = new Track(config_file);
    }
    catch (std::exception& e)
    {
        Log::error("TrackManager", "Cannot load track <%s> : %s\n",
                dirname.c_str(), e.what());
        return false;
    }

    if (track->getVersion()<stk_config->m_min_track_version ||
        track->getVersion()>stk_config->m_max_track_version)
    {
        Log::warn("TrackManager", "Track '%s' is not supported "
                        "by this binary, ignored. (Track is version %i, this "
                        "executable supports from %i to %i).",
                  track->getIdent().c_str(), track->getVersion(),
                  stk_config->m_min_track_version,
                  stk_config->m_max_track_version);
        delete track;
        return false;
    }
    m_all_track_dirs.push_back(dirname);
    m_tracks.push_back(track);
    m_track_avail.push_back(true);
    updateGroups(track);

    // Populate the texture cache with track screenshots
    // (internal tracks like end cutscene don't have screenshots)
    if (!track->isInternal())
        irr_driver->getTexture(track->getScreenshotFile());

    return true;
}   // loadTrack
Exemplo n.º 7
0
void
fightphase(game *aGame, int phase)
{
  planet         *p;

  pdebug(DFULL, "fightphase\n");
  plog(LFULL, "Checking for battles\n");
  for (p = aGame->planets; p; p = p->next) {
    battle         *b;

    if ((b = isBattle(aGame->players, p))) {
      batstat        *batstats;
      batstat        *aBatstat;
      participant    *part;

      plog(LFULL, "Battle at %s\n", p->name);
      pdebug(DFULL2, "Battle at %s\n", p->name);
      b->phase = phase;
      batstats = NULL;
      for (part = b->participants; part; part = part->next) {
        aBatstat = allocStruct(batstat);

        aBatstat->who = part->who;
        aBatstat->groups = part->groups;
        addList(&batstats, aBatstat);
      }

      allocEnemies(batstats);
      doBattle(batstats, b->protocol, phase);
      addList(&(aGame->battles), b);
      updateGroups(b);

      for (aBatstat = batstats; aBatstat; aBatstat = aBatstat->next) {
        free(aBatstat->enemies);
      }
      freelist(batstats);
    }
  }
}
Exemplo n.º 8
0
void Logstalgia::logic(float t, float dt) {

    float sdt = dt * settings.simulation_speed;

    //increment clock
    elapsed_time += sdt;
    currtime = starttime + (long)(elapsed_time);
   
    if(settings.stop_time && currtime > settings.stop_time) {
        currtime = settings.stop_time;
    }
    
    if(mousehide_timeout>0.0f) {
        mousehide_timeout -= dt;
        if(mousehide_timeout<0.0f) {
            SDL_ShowCursor(false);
        }
    }

    infowindow.hide();

    if(end_reached && balls.empty()) {
        appFinished = true;
        return;
    }

    //if paused, dont move anything, only check what is under mouse
    if(paused) {

        for(auto& it: paddles) {
            Paddle* paddle = it.second;

            if(paddle->mouseOver(infowindow, mousepos)) {
                break;
            }
        }

        for(RequestBall* ball : balls) {
            if(ball->mouseOver(infowindow, mousepos)) {
                break;
            }
        }

        if(!ipSummarizer->mouseOver(infowindow,mousepos)) {
            for(Summarizer* s: summarizers) {
                if(s->mouseOver(infowindow, mousepos)) break;
            }
        }

        return;
    }

    //next will fast forward clock to the time of the next entry,
    //if the next entry is in the future
    if(next || (!settings.disable_auto_skip && balls.empty())) {
        if(!queued_entries.empty()) {
            LogEntry* le = queued_entries.front();

            long entrytime = le->timestamp;
            if(entrytime > currtime) {
                elapsed_time = entrytime - starttime;
                currtime = starttime + (long)(elapsed_time);
            }
        }
        next = false;
    }

    //recalc spawn speed each second by
    if(currtime != lasttime) {

        //dont bother reading the log if we dont need to
        if(queued_entries.empty() || queued_entries.back()->timestamp <= currtime) {
            readLog();
        }

        profile_start("determine new entries");

        int items_to_spawn=0;

        for(LogEntry* le : queued_entries) {

            if(le->timestamp > currtime) break;

            items_to_spawn++;

            addStrings(le);
        }

        profile_stop();

        //debugLog("items to spawn %d\n", items_to_spawn);

        if(items_to_spawn > 0) {

            profile_start("add new strings");

            //re-summarize
            ipSummarizer->summarize();

            for(Summarizer* s : summarizers) {
                s->summarize();
            }

            profile_stop();

            profile_start("add new entries");

            float item_offset = 1.0 / (float) (items_to_spawn);

            int item_no = 0;

            while(!queued_entries.empty()) {

                LogEntry* le = queued_entries.front();

                if(le->timestamp > currtime) break;

                float pos_offset   = item_offset * (float) item_no++;
                float start_offset = std::min(1.0f, pos_offset);

		addBall(le, start_offset);

                queued_entries.pop_front();
            }

        }

        //update date
        if(total_entries>0) {
            char datestr[256];
            char timestr[256];

            struct tm* timeinfo = localtime ( &currtime );
            strftime(datestr, 256, "%A, %B %d, %Y", timeinfo);
            strftime(timestr, 256, "%X", timeinfo);

            displaydate = datestr;
            displaytime = timestr;
        } else {
            displaydate = "";
            displaytime = "";
        }

        lasttime=currtime;

        profile_stop();
    } else {
        //do small reads per frame if we havent buffered the next second
        if(queued_entries.empty() || queued_entries.back()->timestamp <= currtime+1) {
            readLog(50);
        }
    }

    std::list<Paddle*> inactivePaddles;

    //update paddles
    for(auto& it: paddles) {

        std::string paddle_token = it.first;
        Paddle*           paddle = it.second;

        if(settings.paddle_mode > PADDLE_SINGLE && !paddle->moving() && !paddle->visible()) {

            bool token_match = false;

            //are there any requests that will match this paddle?
            for(RequestBall* ball : balls) {

                if(   (settings.paddle_mode == PADDLE_VHOST && ball->le->vhost == paddle_token)
                   || (settings.paddle_mode == PADDLE_PID   && ball->le->pid   == paddle_token)) {
                    token_match = true;
                    break;
                }
            }

            //mark this paddle for deletion, continue
            if(!token_match) {
                inactivePaddles.push_back(paddle);
                continue;
            }
        }

        // find nearest ball to this paddle
        if( (retarget || !paddle->getTarget())) {

            RequestBall* ball = findNearest(paddle, paddle_token);

            if(ball != 0) {
                paddle->setTarget(ball);
            } else if(!paddle->moving()) {
                paddle->setTarget(0);
            }
        }

        paddle->logic(sdt);
    }

    retarget = false;

    profile_start("check ball status");

    // NOTE: special handling for this iterator as items are being removed
    for(auto it = balls.begin(); it != balls.end();) {

        RequestBall* ball = *it;

        highscore += ball->logic(sdt);

        if(ball->isFinished()) {
            it = balls.erase(it);
            removeBall(ball);
        } else {
            it++;
        }
    }

    profile_stop();

    profile_start("ipSummarizer logic");
    ipSummarizer->logic(dt);
    profile_stop();

    profile_start("updateGroups logic");
    updateGroups(dt);
    profile_stop();


    screen_blank_elapsed += dt;

    if(screen_blank_elapsed-screen_blank_interval > screen_blank_period)
        screen_blank_elapsed = 0.0f;

    //update font alpha
    font_alpha = 1.0f;

    if(screen_blank_elapsed>screen_blank_interval) {
        font_alpha = std::min(1.0f, (float) fabs(1.0f - (screen_blank_elapsed-screen_blank_interval)/(screen_blank_period*0.5)));
        font_alpha *= font_alpha;
    }
}
Exemplo n.º 9
0
 list<iMaterialGroup*>* iMaterialResourceFactory::getMaterialGroups()
 {
     updateGroups();
     return &_materials;
 }
Exemplo n.º 10
0
void ImodvOlist::curGroupChanged(int value)
{
  setFocus();
  Imodv->imod->curObjGroup = value - 1;
  updateGroups(Imodv);
}
Exemplo n.º 11
0
void ImodvOlist::actionButtonClicked(int which)
{
  Imod *imod = Imodv->imod;
  IobjGroup *group, *ogroup;
  int ob, index, changed = 1;

  if (which != OBJGRP_NEW && which != OBJGRP_DELETE) {
    group = (IobjGroup *)ilistItem(imod->groupList, imod->curObjGroup);
    if (!group)
      return;
  }

  switch (which) {
  case OBJGRP_NEW:
    imodvRegisterModelChg();
    group = objGroupListExpand(&imod->groupList);
    if (!group)
      break;
    ogroup = (IobjGroup *)ilistItem(imod->groupList, imod->curObjGroup);
    if (ogroup)
      group->objList = ilistDup(ogroup->objList);
    imod->curObjGroup = ilistSize(imod->groupList) - 1;
    updateGroups(Imodv);
    break;

  case OBJGRP_DELETE:
    if (imod->curObjGroup < 0)
      return;
    imodvRegisterModelChg();
    if (objGroupListRemove(imod->groupList, imod->curObjGroup))
      break;
    imod->curObjGroup = B3DMIN(B3DMAX(0, imod->curObjGroup - 1),
                               ilistSize(imod->groupList) - 1);
    updateGroups(Imodv);
    break;

  case OBJGRP_CLEAR:
    imodvRegisterModelChg();
    ilistTruncate(group->objList, 0);
    updateGroups(Imodv);
    break;

  case OBJGRP_ADDALL:
    imodvRegisterModelChg();
    if (group->objList)
      ilistTruncate(group->objList, 0);
    for (ob = 0; ob < imod->objsize; ob++)
      if (objGroupAppend(group, ob))
        return;
    updateGroups(Imodv);
    break;

  case OBJGRP_SWAP:
    imodvRegisterModelChg();
    for (ob = 0; ob < imod->objsize; ob++) {
      index = objGroupLookup(group, ob);
      if (index >= 0)
        ilistRemove(group->objList, index);
      else
        if (objGroupAppend(group, ob))
          return;
    }
    updateGroups(Imodv);
    break;

  case OBJGRP_TURNON:
  case OBJGRP_TURNOFF:
  case OBJGRP_OTHERSON:
  case OBJGRP_OTHERSOFF:
    changed = 0;
    for (ob = 0; ob < imod->objsize; ob++) {
      index = objGroupLookup(group, ob);
      if (((index >= 0 && which == OBJGRP_TURNON) || 
           (index < 0 && which == OBJGRP_OTHERSON)) && 
          iobjOff(imod->obj[ob].flags)) {
        imodvRegisterObjectChg(ob);
        imod->obj[ob].flags &= ~IMOD_OBJFLAG_OFF;
        changed = 1;
      } else if (((index >= 0 && which == OBJGRP_TURNOFF) ||
                  (index < 0 && which == OBJGRP_OTHERSOFF)) &&
                 !iobjOff(imod->obj[ob].flags)) {
        imodvRegisterObjectChg(ob);
        imod->obj[ob].flags |= IMOD_OBJFLAG_OFF;
        changed = 1;
      }
    }
    imodvDraw(Imodv);
    imodvDrawImodImages();
    imodvObjedNewView();
    break;

  }
  if (changed)
    imodvFinishChgUnit();
}