/** @brief populateTasks * * @TODO: document this function */ void TaskArea::populateTasks() { lastMouse = NULL; for (itemList_t::iterator i = itemList.begin(); i != itemList.end(); ++i) { delete (*i); } itemList.clear(); itemMapping.clear(); for (int i = 0; i < GetTaskListSize(); ++i) { if (GetTask(i)) { Task *newTask = new Task(GetTask(i), vertical); addItem(newTask); } } if (vertical && stretchTaskarea) addItem(new clsFlexiSpacer()); calculateSizes(true); if (!stretchTaskarea) SendMessage(barWnd, BOXBAR_UPDATESIZE, 0, 0); else InvalidateRect(barWnd, &itemArea, TRUE); }
/* TODO: Should probably check for likelihood also */ cl_bool separationCheckDevCapabilities(const DevInfo* di, const AstronomyParameters* ap, const IntegralArea* ias) { cl_uint i; SeparationSizes sizes; #if DOUBLEPREC if (!mwSupportsDoubles(di)) { warn("Device doesn't support double precision\n"); return MW_CL_ERROR; } #endif /* DOUBLEPREC */ for (i = 0; i < ap->number_integrals; ++i) { calculateSizes(&sizes, ap, &ias[i]); if (!separationCheckDevMemory(di, &sizes)) { warn("Capability check failed for cut %u\n", i); return CL_FALSE; } } return CL_TRUE; }
Object::Object() { try { position = { { 0., 0., 0. }, 0., 0., -1, 0, 0, false }; scale = .1f; ModelLoader modelLoader; model = modelLoader.ReadModel("resources\\objects\\Captain America.obj", "resources\\objects\\Captain America.mtl"); if (!model) { throw "Can't load player's geometry"; } else { boundingBox.isShowing = false; calculateSizes(); glGenBuffers(1, &tid); glBindBuffer(GL_ARRAY_BUFFER, tid); glBufferData(GL_ARRAY_BUFFER, model->UV_vertices.size()*sizeof(float), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, model->UV_vertices.size()*sizeof(float), &model->UV_vertices[0]); glBindBuffer(GL_ARRAY_BUFFER, 0); glGenBuffers(1, &nid); glBindBuffer(GL_ARRAY_BUFFER, nid); glBufferData(GL_ARRAY_BUFFER, model->normals.size()*sizeof(float), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, model->normals.size()*sizeof(float), &model->normals[0]); glBindBuffer(GL_ARRAY_BUFFER, 0); glGenBuffers(1, &vid); glBindBuffer(GL_ARRAY_BUFFER, vid); glBufferData(GL_ARRAY_BUFFER, model->vertices.size()*sizeof(float), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, model->vertices.size()*sizeof(float), &model->vertices[0]); glBindBuffer(GL_ARRAY_BUFFER, 0); glGenBuffers(1, &bbvid); glBindBuffer(GL_ARRAY_BUFFER, bbvid); glBufferData(GL_ARRAY_BUFFER, 72 * sizeof(float), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, 72 * sizeof(float), &boundingBox.coords[0]); glBindBuffer(GL_ARRAY_BUFFER, 0); } } catch (const char* error) { model = NULL; std::cout << error << std::endl; } }
static cl_bool separationCheckDevMemory(const DevInfo* di, const AstronomyParameters* ap, const IntegralArea* ias) { cl_int i; SeparationSizes sizes; for (i = 0; i < ap->number_integrals; ++i) { calculateSizes(&sizes, ap, &ias[i]); if (!separationCheckCutMemory(di, &sizes)) { mw_printf("Capability check failed for cut %u\n", i); return CL_FALSE; } } return CL_TRUE; }
/** * Initializes all storages, gathers the camera matrix and calculates the texture dimensions * @param width_in The width of each frame image * @param height_in The height of each frame image * @param x_in The number of voxels in x direction * @param y_in The number of voxels in y direction * @param z_in The number of voxels in z direction */ Reconstruction::Reconstruction(int width_in, int height_in, int x_in, int y_in, int z_in) : x(x_in), y(y_in), z(z_in), imgWidth(width_in), imgHeight(height_in) { // Allocate the boolean storage for the voxels voxels = new bool[x * y * z]; memset(voxels, (unsigned char)255, x*y*z*sizeof(bool)); // Calculate how to distribute the texels on the texture calculateSizes(); // Allocate the image to store the voxels on voxe = cvCreateImage(cvSize(width, height) , IPL_DEPTH_8U, 4); memset(voxe->imageData, (uchar) 255, width*height*4*sizeof(uchar)); // Get the camera matrix for correct reconstruction getCameraMatrix(); LOG("Initialized the reconstruction"); }
cl_int integrateCL(const AstronomyParameters* ap, const IntegralArea* ia, const StreamConstants* sc, const StreamGauss sg, EvaluationState* es, const CLRequest* clr, CLInfo* ci) { cl_int err; RunSizes runSizes; SeparationSizes sizes; SeparationCLMem cm = EMPTY_SEPARATION_CL_MEM; /* Need to test sizes for each integral, since the area size can change */ calculateSizes(&sizes, ap, ia); if (findRunSizes(&runSizes, ci, &ci->di, ap, ia, clr)) { mw_printf("Failed to find good run sizes\n"); return MW_CL_ERROR; } err = createSeparationBuffers(ci, &cm, ap, ia, sc, sg, &sizes); if (err != CL_SUCCESS) { mwPerrorCL(err, "Failed to create CL buffers"); return err; } err = separationSetKernelArgs(&cm, &runSizes); if (err != CL_SUCCESS) { mwPerrorCL(err, "Failed to set integral kernel arguments"); return err; } err = runIntegral(ci, &cm, &runSizes, es, clr, ap, ia); releaseSeparationBuffers(&cm); separationIntegralGetSums(es); return err; }
void Downloader::updateProgress (qint64 received, qint64 total) { if (total > 0) { m_ui->progressBar->setMinimum (0); m_ui->progressBar->setMaximum (100); m_ui->progressBar->setValue ((received * 100) / total); calculateSizes (received, total); calculateTimeRemaining (received, total); } else { m_ui->progressBar->setMinimum (0); m_ui->progressBar->setMaximum (0); m_ui->progressBar->setValue (-1); m_ui->downloadLabel->setText (tr ("Downloading Updates") + "..."); m_ui->timeLabel->setText (QString ("%1: %2") .arg (tr ("Time Remaining")) .arg (tr ("Unknown"))); } }
W32Widget::Size W32Table::minimumSize() const { std::vector<short> widths, heights; calculateSizes(widths, heights); Size size( leftMargin() + rightMargin() + myHorizontalSpacing * (widths.size() - 1), topMargin() + bottomMargin() ); for (std::vector<short>::const_iterator it = widths.begin(); it != widths.end(); ++it) { size.Width += *it; } int hCount = 0; for (std::vector<short>::const_iterator it = heights.begin(); it != heights.end(); ++it) { if (*it > 0) { size.Height += *it; ++hCount; } } if (hCount > 1) { size.Height += myVerticalSpacing * (hCount - 1); } return size; }
void W32Table::setPosition(int x, int y, Size size) { std::vector<short> widths, heights, lefts, rights; calculateSizes(widths, heights); if ((widths.size() == 0) || (heights.size() == 0)) { return; } Size minSize( leftMargin() + rightMargin() + myHorizontalSpacing * (widths.size() - 1), topMargin() + bottomMargin() ); for (std::vector<short>::const_iterator it = widths.begin(); it != widths.end(); ++it) { minSize.Width += *it; } int hCount = 0; for (std::vector<short>::const_iterator it = heights.begin(); it != heights.end(); ++it) { if (*it > 0) { minSize.Height += *it; ++hCount; } } if (hCount == 0) { return; } minSize.Height += myVerticalSpacing * (hCount - 1); { short delta = size.Width - minSize.Width; int len = widths.size(); lefts.reserve(len); rights.reserve(len); short currentX = x + leftMargin(); for (int i = 0; i < len; ++i) { short d = delta / (len - i); widths[i] += d; delta -= d; lefts.push_back(currentX); currentX += widths[i]; rights.push_back(currentX); currentX += myHorizontalSpacing; } } { short delta = size.Height - minSize.Height; int len = hCount; for (std::vector<short>::iterator it = heights.begin(); len > 0; ++it) { if (*it > 0) { short d = delta / len; *it += d; delta -= d; --len; } } } int ey = y + topMargin(); for (std::vector<RowList>::const_iterator it = myRows.begin(); it != myRows.end(); ++it) { short h = heights[it - myRows.begin()]; if (h > 0) { for (RowList::const_iterator jt = it->begin(); jt != it->end(); ++jt) { if (jt->Widget->isVisible()) { jt->Widget->setPosition(lefts[jt->XFrom], ey, Size(rights[jt->XTo] - lefts[jt->XFrom], h)); } } ey += h + myVerticalSpacing; } } }
/** @brief wndProc * * @TODO: document this function */ LRESULT TaskArea::wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_TIMER: if (wParam == m_dragTimer) { if (m_dragTask) { SendMessage(hBlackboxWnd, BB_BRINGTOFRONT, 0, (LPARAM)m_dragTask->GetTaskWnd()); m_dragTask = NULL; } KillTimer(barWnd, m_dragTimer); } break; case BB_RECONFIGURE: readSettings(); populateTasks(); break; case BB_BROADCAST: { LPCSTR msg_string = (LPCSTR)lParam; LPCSTR element = NULL; msg_string += 1; if (!strnicmp(msg_string, m_pluginPrefix, strlen(m_pluginPrefix))) { msg_string += strlen(m_pluginPrefix) + 1; if (!strnicmp(msg_string, m_itemPrefix, strlen(m_itemPrefix))) { msg_string += strlen(m_itemPrefix) + 1; if ((element = "Stretch") && !strnicmp(msg_string, element, strlen(element))) { //msg_string += strlen(element); //m_iconSize = atoi(msg_string); //s_settingsManager.WriteSetting(m_pluginPrefix, "Tasks", element); //populateTasks(); //PostMessage(barWnd, BOXBAR_UPDATESIZE, 1, 0); } } else if (!strnicmp(msg_string, m_basePrefix.c_str(), m_basePrefix.size())) { if (itemList.size()) { itemList.front()->wndProc(hWnd, msg, wParam, lParam); } PostMessage(barWnd, BOXBAR_UPDATESIZE, 1, 0); configMenu(NULL, true); return 0; } } } break; case BB_TASKSUPDATE: switch (lParam) { case TASKITEM_FLASHED: case TASKITEM_ACTIVATED: Collection::wndProc(hWnd, msg, wParam, lParam); RedrawWindow(barWnd, NULL, NULL, RDW_INVALIDATE | RDW_INTERNALPAINT); return 0; case TASKITEM_ADDED: if (std::find_if(itemList.begin(), itemList.end(), bind2nd(TaskIsHWnd(), reinterpret_cast<HWND>(wParam))) == itemList.end()) { Task *newTask = new Task(reinterpret_cast<HWND>(wParam), vertical); itemList_t::iterator insertLoc = itemList.end(); if (vertical && stretchTaskarea) { insertLoc--; } itemList.insert(insertLoc, newTask); if (stretchTaskarea) { calculateSizes(true); RedrawWindow(barWnd, NULL, NULL, RDW_INVALIDATE | RDW_INTERNALPAINT); } else { PostMessage(barWnd, BOXBAR_UPDATESIZE, 1, 0); } } break; case TASKITEM_REMOVED: { itemList.remove_if(bind2nd(TaskIsHWnd(), reinterpret_cast<HWND>(wParam))); if (stretchTaskarea) { calculateSizes(true); RedrawWindow(barWnd, NULL, NULL, RDW_INVALIDATE | RDW_INTERNALPAINT); } else { PostMessage(barWnd, BOXBAR_UPDATESIZE, 1, 0); } break; } //populateTasks(); } break; } return Collection::wndProc(hWnd, msg, wParam, lParam); }
void ImportImageDlg::renderPixmap() { QPixmap alpha; alpha.loadFromData(alphaData, 143); ui.ImagePreview->setCursor(Qt::WaitCursor); calculateSizes(); m_convertedImage.modifyImage(); m_pixmap = QPixmap(m_convertedImage.columns(), m_convertedImage.rows()); m_pixmap.fill(); m_convertedImage.quantizeColorSpace(Magick::RGBColorspace); m_convertedImage.quantizeColors(ui.UseMaximumColors->isChecked() ? std::min(ui.MaximumColors->value(), SymbolManager::library(Configuration::palette_DefaultSymbolLibrary())->indexes().count()) : SymbolManager::library(Configuration::palette_DefaultSymbolLibrary())->indexes().count()); m_convertedImage.quantize(); m_convertedImage.map(m_colorMap); m_convertedImage.modifyImage(); QPainter painter; painter.begin(&m_pixmap); painter.drawTiledPixmap(m_pixmap.rect(), alpha); int width = m_convertedImage.columns(); int height = m_convertedImage.rows(); int pixelCount = width * height; QProgressDialog progress(i18n("Rendering preview"), i18n("Cancel"), 0, pixelCount, this); progress.setWindowModality(Qt::WindowModal); Magick::Pixels cache(m_convertedImage); const Magick::PixelPacket *pixels = cache.getConst(0, 0, width, height); for (int dy = 0 ; dy < height ; dy++) { QApplication::processEvents(); progress.setValue(dy * width); if (progress.wasCanceled()) { break; } for (int dx = 0 ; dx < width ; dx++) { Magick::PixelPacket packet = *pixels++; if (!(packet.opacity)) { if (!(m_ignoreColor && packet == m_ignoreColorValue)) { #if MAGICKCORE_QUANTUM_DEPTH == 8 QColor color(packet.red, packet.green, packet.blue); #else QColor color(packet.red / 256, packet.green / 256, packet.blue / 256); #endif painter.setPen(QPen(color)); painter.drawPoint(dx, dy); } } } } painter.end(); ui.ImagePreview->setPixmap(m_pixmap); ui.ImagePreview->setCursor(Qt::ArrowCursor); }