CSize CDynamicHelp::CalcLayout(DWORD mode, int length) { CSize result_size(50, 50); if (mode & (LM_HORZDOCK | LM_VERTDOCK)) { CRect rect; CWnd* main_wnd= AfxGetMainWnd(); if (CMDIFrameWnd* frame_wnd= dynamic_cast<CMDIFrameWnd*>(main_wnd)) ::GetClientRect(frame_wnd->wndMDI_client_, rect); else main_wnd->GetClientRect(rect); result_size = rect.Size(); result_size += CSize(10, 10); if (mode & 0x8000) MRU_width_ = length; result_size.cx = MRU_width_; } if (mode & LM_MRUWIDTH) SizeToolBar(MRU_width_); else if (mode & LM_HORZDOCK) return CSize(result_size.cx, min_h); else if (mode & LM_VERTDOCK) return CSize(MRU_width_, result_size.cy); else if (length != -1) SizeToolBar(length, !!(mode & LM_LENGTHY)); else if (style_ & CBRS_FLOATING) SizeToolBar(MRU_width_); else SizeToolBar(mode & LM_HORZ ? 32767 : 0); result_size = default_size_; if (mode & LM_COMMIT) MRU_width_ = result_size.cx; return result_size; }
size_t redis_transaction::get_size() const { return result_size(); }
virtual bool run() { const std::vector<sd::core::ViewNode *> &parents = this->getPreviousViewNodes(); sd::core::ImageView_<T> *image = static_cast<sd::core::ImageView_<T>*>(parents[0]); if (parents.size() != 1) { std::cout << "\tExpecting 1 parent exactly, found " << parents.size() << ". Abort!\n"; return false; } sd::frontend::Parameter pchannel; this->getParams("channel", pchannel); std::string wanted_channel = pchannel.getString(); std::cout << "SELECTED channel: " << wanted_channel << std::endl; sd::frontend::Parameter pNbTiles; this->getParams("nbTiles", pNbTiles); int nbTiles = pNbTiles.getInteger(); /* RGBA: R is 0, G is 1...*/ int channel_id = 0; if(wanted_channel == "Red") channel_id = 0; else if(wanted_channel == "Green") channel_id = 1; else if(wanted_channel == "Blue") channel_id = 2; else if(wanted_channel == "Alpha") channel_id = 3; else std::cout << "Error on channel, default: red" << std::endl; std::vector<float> histogram_data_1(256, 0); std::vector<float> histogram_data(nbTiles, 0); int loop_count = 0; int value = 0; for(auto source_it = image->begin(); source_it != image->end(); ++source_it){ value = (float)source_it(channel_id); histogram_data_1[value]++; loop_count++; } int coef = 256/nbTiles; for(int i=0; i<nbTiles; i++){ for(int j=0; j<coef; j++){ histogram_data[i] += histogram_data_1[(i+1)*coef+j]; } } float maxHeight = 0; for(int i=0; i<=nbTiles; i++){ if(maxHeight < histogram_data[i]){ maxHeight = histogram_data[i]; } } if(maxHeight != 0){ for(int i=0; i<=nbTiles; i++){ histogram_data[i] = (histogram_data[i]*256)/maxHeight; } } int sizeX = nbTiles; int sizeY = nbTiles; sd::Size result_size(sizeX, sizeY); sd::core::ImageViewInfo info(sd::GRAYLEVEL, sd::Z_AXIS, result_size); this->init(info); T* resultData = this->getData(); std::fill(resultData, resultData+result_size.dataSize(), 255); this->setMinMax(0, 255); auto itR = this->begin(); for(int i = 0; i < nbTiles; i++){ for(int j = 0; j < nbTiles; j++, itR++){ for(int k = 0; k < 4; k++){ if((i) < (int)(nbTiles-histogram_data[j])) itR(k) = 255; else itR(k) = 0; } } } return true; }
inline size_t serial_reduce_by_key(InputKeyIterator keys_first, InputKeyIterator keys_last, InputValueIterator values_first, OutputKeyIterator keys_result, OutputValueIterator values_result, BinaryFunction function, BinaryPredicate predicate, command_queue &queue) { typedef typename std::iterator_traits<InputValueIterator>::value_type value_type; typedef typename std::iterator_traits<InputKeyIterator>::value_type key_type; typedef typename ::boost::compute::result_of<BinaryFunction(value_type, value_type)>::type result_type; const context &context = queue.get_context(); size_t count = detail::iterator_range_size(keys_first, keys_last); if(count < 1){ return count; } meta_kernel k("serial_reduce_by_key"); size_t count_arg = k.add_arg<uint_>("count"); size_t result_size_arg = k.add_arg<uint_ *>(memory_object::global_memory, "result_size"); k << k.decl<result_type>("result") << " = " << values_first[0] << ";\n" << k.decl<key_type>("previous_key") << " = " << keys_first[0] << ";\n" << k.decl<result_type>("value") << ";\n" << k.decl<key_type>("key") << ";\n" << k.decl<uint_>("size") << " = 1;\n" << keys_result[0] << " = previous_key;\n" << values_result[0] << " = result;\n" << "for(ulong i = 1; i < count; i++) {\n" << " value = " << values_first[k.var<uint_>("i")] << ";\n" << " key = " << keys_first[k.var<uint_>("i")] << ";\n" << " if (" << predicate(k.var<key_type>("previous_key"), k.var<key_type>("key")) << ") {\n" << " result = " << function(k.var<result_type>("result"), k.var<result_type>("value")) << ";\n" << " }\n " << " else { \n" << keys_result[k.var<uint_>("size - 1")] << " = previous_key;\n" << values_result[k.var<uint_>("size - 1")] << " = result;\n" << " result = value;\n" << " size++;\n" << " } \n" << " previous_key = key;\n" << "}\n" << keys_result[k.var<uint_>("size - 1")] << " = previous_key;\n" << values_result[k.var<uint_>("size - 1")] << " = result;\n" << "*result_size = size;"; kernel kernel = k.compile(context); scalar<uint_> result_size(context); kernel.set_arg(result_size_arg, result_size.get_buffer()); kernel.set_arg(count_arg, static_cast<uint_>(count)); queue.enqueue_task(kernel); return static_cast<size_t>(result_size.read(queue)); }