Save::Save(QWidget *parent) : QDialog(parent) { img = 0; setModal(false); setWindowFlags(Qt::Window); QHBoxLayout *layout = new QHBoxLayout(this); QVBoxLayout *sLayout = new QVBoxLayout; layout->addLayout(sLayout); QGroupBox *gbBlock = new QGroupBox(tr("Block size")); sLayout->addWidget(gbBlock); QHBoxLayout *gbBlockLayout = new QHBoxLayout(gbBlock); gbBlockLayout->addWidget(spBlockSize[0] = new QSpinBox); gbBlockLayout->addWidget(new QLabel(tr("x"))); gbBlockLayout->addWidget(spBlockSize[1] = new QSpinBox); for (int i = 0; i != 2; i++) { spBlockSize[i]->setMinimum(1); spBlockSize[i]->setMaximum(2048); spBlockSize[i]->setValue(DEFSZ); } QGroupBox *gbCount = new QGroupBox(tr("Block count")); sLayout->addWidget(gbCount); QHBoxLayout *gbCountLayout = new QHBoxLayout(gbCount); gbCountLayout->addWidget(spBlockCount[0] = new QSpinBox); gbCountLayout->addWidget(new QLabel(tr("x"))); gbCountLayout->addWidget(spBlockCount[1] = new QSpinBox); for (int i = 0; i != 2; i++) { spBlockCount[i]->setMinimum(1); spBlockCount[i]->setMaximum(1000); spBlockCount[i]->setValue(DEFCNT); } sLayout->addWidget(lFinalRes = new QLabel); QPushButton *pbRender = new QPushButton(tr("Render")); sLayout->addWidget(pbRender); QPushButton *pbSave = new QPushButton(tr("Save image")); sLayout->addWidget(pbSave); layout->addWidget(lwProgess = new QListWidget); QScrollArea *saOutput = new QScrollArea; saOutput->setBackgroundRole(QPalette::Dark); saOutput->setWidget(lOutput = new QLabel); layout->addWidget(saOutput, 4); for (int i = 0; i != 2; i++) { connect(spBlockSize[i], SIGNAL(valueChanged(int)), this, SLOT(updateRes())); connect(spBlockCount[i], SIGNAL(valueChanged(int)), this, SLOT(updateRes())); } connect(pbRender, SIGNAL(clicked(bool)), this, SLOT(render())); connect(pbSave, SIGNAL(clicked(bool)), this, SLOT(save())); updateRes(); }
void KRenderSys::_fillRenderList(KEntityManager *Eman, std::vector<std::pair<KEntity *, KRenderable *>> &Output) { Output.resize(0); // culling is disabled ED_STATIC auto render = Eman->getComponentStorage<KRenderCom>(CTypes::RenderInstance); // inite objects list for (auto rit = render->begin(); rit != render->end(); ++rit) { auto ent = Eman->getEntity(rit->getOwnerHandle()); // catch renderable components if (ent->isActive()) { auto com = ent->getComponent(rit->getRenderable()); com->updateRes(); auto renderable = dynamic_cast<KRenderable *>(com); if (renderable->isVisible() && renderable->getIndexSize() > 0) { Output.push_back({ ent ,renderable }); } } } }
int wmain(int argc, wchar_t** argv) { if (argc != 3) { printf("Usage: redit <exe file> <icon file>\n"); return 1; } mozilla::ScopedClose file; if (0 != _wsopen_s(&file.rwget(), argv[2], _O_BINARY | _O_RDONLY, _SH_DENYWR, _S_IREAD) || (-1 == file)) { fprintf(stderr, "Unable to open icon file.\n"); return 1; } // Load all the data from the icon file long filesize = _filelength(file); nsAutoArrayPtr<BYTE> data(new BYTE[filesize]); if(!data) { fprintf(stderr, "Failed to allocate memory for icon file.\n"); return 1; } _read(file, data, filesize); IconHeader* header = reinterpret_cast<IconHeader*>(data.get()); // Open the target library for updating ScopedResourceUpdate updateRes(BeginUpdateResourceW(argv[1], FALSE)); if (NULL == updateRes) { fprintf(stderr, "Unable to open library for modification.\n"); return 1; } // Allocate the group resource entry long groupSize = sizeof(IconHeader) + header->ImageCount * sizeof(IconResEntry); nsAutoArrayPtr<BYTE> group(new BYTE[groupSize]); if(!group) { fprintf(stderr, "Failed to allocate memory for new images.\n"); return 1; } memcpy(group, data, sizeof(IconHeader)); IconDirEntry* sourceIcon = reinterpret_cast<IconDirEntry*>(data + sizeof(IconHeader)); IconResEntry* targetIcon = reinterpret_cast<IconResEntry*>(group + sizeof(IconHeader)); for (int id = 1; id <= header->ImageCount; id++) { // Add the individual icon if (!UpdateResourceW(updateRes, RT_ICON, MAKEINTRESOURCE(id), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), data + sourceIcon->ImageOffset, sourceIcon->ImageSize)) { fprintf(stderr, "Unable to update resource (RT_ICON).\n"); return 1; } // Copy the data for this icon // (note that the structs have different sizes) memcpy(targetIcon, sourceIcon, sizeof(IconResEntry)); targetIcon->ResourceID = id; sourceIcon++; targetIcon++; } if (!UpdateResourceW(updateRes, RT_GROUP_ICON, L"MAINICON", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), group, groupSize)) { fprintf(stderr, "Unable to update resource (RT_GROUP_ICON).\n"); return 1; } // Save the modifications if(!EndUpdateResourceW(updateRes.forget(), FALSE)) { fprintf(stderr, "Unable to write changes to library.\n"); return 1; } return 0; }
int main(int argc, char *argv[]) { /* Command line arguments * -s simulator * -n no of simulations */ void (*forwardSimulate)(st_part_at* prop_part, double tstep); forwardSimulate = getForwardSimulator(argc, argv); int n = getIters(argc, argv, 0, 1); char *output_file = getOutputFile(argc, argv); char *dir = getDir(argc, argv); char *path = createPath(dir, output_file); printf("Writing to %s\n", path); FILE *out = fopen(path, "w"); int i, k; r = gsl_rng_alloc(gsl_rng_mt19937); /* For timings */ struct timeb t_start, t_end; double t_diff; /* Values for scaling parameter*/ int N_C = 41; double sim_time;/*Simulation time in secs, for a single sim*/ double sc; /*The following three vectors were generated in R and copied in */ double sc_vec[41] = {1,1.3,1.6,2,2.5,3.2,4,5,6.3,7.9,10, 12.6,15.8,20,25.1,31.6,39.8,50.1, 63.1,79.4,100, 125.9,158.5,199.5,251.2,316.2,398.1,501.2,631,794.3, 1000,1258.9,1584.9,1995.3,2511.9,3162.3,3981.1,5011.9,6309.6,7943.3, 10000}; double X1[41] = {1,1,1,2,2,3,4,5,6,7,9,11,12,14,16,17,19,20, 21,21,22,23,23,23,24,24,24, 24,24,24,24,24,24,24,24,24,24,24,24,24,24}; double X2[41] = {20,20,20,20,20,20,20,20,20,20,21,21,22, 24,26,28,32,36,43,50,60,73,89,110,135,168,209,260,325,407, 510,639,802,1007,1265,1591,2000,2515,3164,3981,5010}; /* Initialise LNA */ pSIv = SetUpSIRI(); pODEIv = pODEInfoAlloc(pgetvoidRI(pSIv)); /* Initialise parameters * Other paramters and IC are changed in the * loop */ st_part_at *part; part = timingsInitPrior(0, 0); VSET(part->params, 0, 2.0); VSET(part->params, 2, 1.0/50.0); VSET(part->params, 3, 1.0); for(k=0; k<N_C; k++) { sc = sc_vec[k]; VSET(part->params, 1,sc); VSET(part->params, 4, 1.0/(50*sc)); ftime(&t_start); for(i=0; i<n; i++){ VSET(part->sps, 0, X1[k]); VSET(part->sps, 1, X2[k]); //VSET(part->sps, 0, 0); VSET(part->sps, 1, 0); updateRes(part->res); forwardSimulate(part, 100); } ftime(&t_end); t_diff = toMilliseconds(t_start, t_end); sim_time = (t_diff/1000.0)/n; printf("%f, %f\n", sc, sim_time); fprintf(out, "%f, %f\n", sc, sim_time); } ODEInfoDeAlloc(pODEIv); DestroySIRI(pSIv); gsl_rng_free(r); return(GSL_SUCCESS); }