示例#1
0
void PointPropertyView::updateProperty(Member *m, const QByteArray &array)
{
    MatrixEdit *e = findChild<MatrixEdit*>(QLatin1String("inputLoads"));
    QVBoxLayout *v = findChild<QVBoxLayout*>(QLatin1String("index"));
    QVBoxLayout *u = findChild<QVBoxLayout*>(QLatin1String("insert"));
    QVBoxLayout *w = findChild<QVBoxLayout*>(QLatin1String("remove"));
    if (array.startsWith('i'))
    {
        e->insertRow(array.right(array.size()-1).toInt());
        for (int i=0;i<6;++i)
            e->setText(array.right(array.size()-1).toInt(),i,QString::number(static_cast<Point*>(m)->loads.at(array.right(array.size()-1).toInt())[i]));
        v->addWidget(new QLabel(QString::number(v->count()+1).prepend(QLatin1String("No."))));
        static_cast<QLabel*>(v->itemAt(v->count()-1)->widget())->setFrameShape(QFrame::StyledPanel);
        u->addWidget(new QToolButton);
        static_cast<QToolButton*>(u->itemAt(u->count()-1)->widget())->setText(QLatin1String("+"));
        connect(u->itemAt(u->count()-1)->widget(),SIGNAL(clicked()),SLOT(addLoad()));
        w->addWidget(new QToolButton);
        static_cast<QToolButton*>(w->itemAt(w->count()-1)->widget())->setText(QLatin1String("-"));
        connect(w->itemAt(w->count()-1)->widget(),SIGNAL(clicked()),SLOT(removeLoad()));
    }
    else if (array.startsWith('r'))
    {
        e->removeRow(array.right(array.size()-1).toInt());
        delete v->takeAt(v->count()-1)->widget();
        delete u->takeAt(u->count()-1)->widget();
        delete w->takeAt(w->count()-1)->widget();
    }
    else if (array.startsWith('s'))
    {
        e->insertColumns(0,6);
        e->insertRows(0,static_cast<Point*>(m)->loads.size());
        for (int i=0,j;i<static_cast<Point*>(m)->loads.size();)
        {
            for (j=0;j<6;++j)
                e->setText(i,j,QString::number(static_cast<Point*>(m)->loads.at(i)[j]));
            u->addWidget(new QToolButton);
            static_cast<QToolButton*>(u->itemAt(i)->widget())->setText(QLatin1String("+"));
            connect(u->itemAt(i)->widget(),SIGNAL(clicked()),SLOT(addLoad()));
            w->addWidget(new QToolButton);
            static_cast<QToolButton*>(w->itemAt(w->count()-1)->widget())->setText(QLatin1String("-"));
            connect(w->itemAt(w->count()-1)->widget(),SIGNAL(clicked()),SLOT(removeLoad()));
            v->addWidget(new QLabel(QString::number(++i).prepend(QLatin1String("No."))));
            static_cast<QLabel*>(v->itemAt(i-1)->widget())->setFrameShape(QFrame::StyledPanel);
        }
    }
    else
        e->setText(array.split(' ').first().toInt(),array.split(' ').last().toInt(),QString::number(static_cast<Point*>(m)->loads.at(array.split(' ').first().toInt())[array.split(' ').last().toInt()]));
}
示例#2
0
文件: loadQ.c 项目: odeke-em/utils
void registerLoad(Heap *loadHeap, Load *l) {
  if (l != NULL) { 
    unsigned int loadId = addLoad(loadHeap, l);
    l->id = loadId;
    l->srcHeap = loadHeap;
  }
}
示例#3
0
//-------------------------------------------------------------------------
// @brief 
//-------------------------------------------------------------------------
Material::TextureSlotMapping TextureManager::deserialise( const DeviceManager& deviceManager, const tinyxml2::XMLElement* node )
{
    (void*)node;
    const char* fileName = node->Attribute("file_name");
    if (fileName)
    {
        addLoad(deviceManager, fileName);
        Material::TextureSlotMapping::TextureSlot textureSlot = Material::TextureSlotMapping::Diffuse0;
        const tinyxml2::XMLAttribute* attribute = node->FindAttribute("texture_slot");
        if (attribute != nullptr)
        {
            textureSlot = static_cast<Material::TextureSlotMapping::TextureSlot>(attribute->UnsignedValue());
        }
        return Material::TextureSlotMapping(hashString(getTextureNameFromFileName(fileName)), textureSlot);
    }

    return Material::TextureSlotMapping(hashString(""), Material::TextureSlotMapping::Invalid);
}
示例#4
0
文件: loadQ.c 项目: odeke-em/utils
void produce(unsigned int n, void *(*func)(void *)) {
  int maxHandle = 8, readyId=-1, nC = 0;
  Heap *wHeap = NULL, *restHeap = NULL;
  wHeap = initHeap(wHeap, loadComp, freeLoad);
  restHeap = initHeap(restHeap, loadComp, freeLoad);
  unsigned int minThreshold = maxHandle > n ? n : maxHandle;
  pthread_t thList[minThreshold];
  pthread_attr_t attr;
  pthread_attr_init(&attr);
#ifdef __linux__
  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
#endif

  for (readyId=0; readyId < minThreshold; ++readyId) {
    unsigned int *iNew = (unsigned int *)malloc(sizeof(unsigned int));
    *iNew = readyId;
    Load *l = createLoad(iNew);
    l->thId = readyId;
    addLoad(wHeap, l);
    pthread_create(thList + readyId, &attr, func, l);
  }

  int i, minFreeLoadCount = minThreshold >> 1;
  if (readyId < n) {
    heapifyFromHead(wHeap);
    i = readyId;
    int chillThId = -1;
    Load *wHead = NULL;
    while (i < n) {
      printf("\033[32mwHeap: "); printHeap(wHeap, printLoad);
      printf("\n\033[33mrHeap: "); printHeap(restHeap, printLoad);
      printf("\ni:%d n:%d chillThId: %d\033[00m\n", i, n, chillThId);

      if ((wHead = peek(wHeap)) != NULL) {
        printf("wHead: %d\n", wHead->id);

        void *data = NULL;
        int join = pthread_join(thList[wHead->thId], &data);
        printf("newJoin: %d\n", join);
        if (! join) {
          printf("joined: %d\n", wHead->thId);
          if (data != NULL) {
            printf("\033[36m\nRetr %s :%d\033[00m\n", (char *)data, wHead->thId); 
            free(data);
          }
          chillThId = wHead->thId;
          printf("chillThId: %d\n", chillThId);
        #ifdef DEBUG
          printf("wHead->thId: %d\n", wHead->thId);
        #endif
          heapExtract(wHeap, (const void **)&wHead); 
          wHead->id = getAvailableId(restHeap);
          addLoad(restHeap, wHead); 
          printf("rHeap"); printHeap(restHeap, printLoad);
          wHead = NULL;
        }
      }

      if (getSize(wHeap) < minFreeLoadCount && peek(restHeap) != NULL) {
      #ifdef DEBUG
        printf("Peeked: %p\n", peek(restHeap));
        printf("\nrestHeap\n");
      #endif
        heapExtract(restHeap, (const void **)&wHead);
        if (wHead == NULL) continue;
      #ifdef DEBUG
        printf("wHead->thId:: %p\n", wHead);
      #endif
        wHead->thId = chillThId;
        *((int *)wHead->data) = i;

        addLoad(wHeap, wHead);
        int createStatus =\
          pthread_create(thList + wHead->thId, &attr, func, wHead);
        printf("createdStatus: %d i: %d\n", createStatus, i);
        if (! createStatus) {
          ++i;
        }
      }
    }
  }

  while (! isEmpty(wHeap)) {
    Load *tmpHead = NULL;
    if (! heapExtract(wHeap, (const void **)&tmpHead) && tmpHead != NULL) {
      void *data = NULL;
      if (! pthread_join(thList[tmpHead->thId], &data)) {
        if (data != NULL) {
          printf("i: %d Joined msg: %s\n", i, (char *)data);
          free(data);
        }
      }
    }
    freeLoad(tmpHead);
  }

  destroyHeap(wHeap);
  destroyHeap(restHeap);
}