/** * Cut the low resolution image * and save it in 'tabelasBaixa' folder. */ void VectorROIsCreator::cutAndSaveLowImage(ROI* r) { IplImage* lowResolutionImage; try { lowResolutionImage = cvLoadImage(r->getOriginalLowResolutionImagePath().c_str()); } catch(exception e) { cerr << "Image can't load. Try again, renaming the image path." << endl; } vector<CvPoint> vecOfPoints; vecOfPoints.push_back(r->getLeftUpper()); vecOfPoints.push_back(r->getRightBottom()); PointsAdapter adapter(HIGH_2_LOW, this->metaInfo); vecOfPoints = adapter.adaptPoints(vecOfPoints); CvPoint leftUpperAdapted = vecOfPoints.at(0); CvPoint rightBottomAdapted = vecOfPoints.at(1); ImageCutter cutter(lowResolutionImage, leftUpperAdapted, rightBottomAdapted); cutter.cut(); ImageSaver saver(lowResolutionImage, r->getLowResolutionImageCutPath()); saver.save(); cvReleaseImage(&lowResolutionImage); }
TEST_F(TestJsonCppAdapter, BasicArrayIteration) { const unsigned int numElements = 10; // Create a rapidjson document that consists of an array of numbers Json::Value document(Json::arrayValue); for (unsigned int i = 0; i < numElements; i++) { document.append(Json::Value(i)); } // Ensure that wrapping the document preserves the array and does not allow // it to be cast to other types valijson::adapters::JsonCppAdapter adapter(document); ASSERT_NO_THROW( adapter.getArray() ); ASSERT_ANY_THROW( adapter.getBool() ); ASSERT_ANY_THROW( adapter.getDouble() ); ASSERT_ANY_THROW( adapter.getObject() ); ASSERT_ANY_THROW( adapter.getString() ); // Ensure that the array contains the expected number of elements EXPECT_EQ( numElements, adapter.getArray().size() ); // Ensure that the elements are returned in the order they were inserted unsigned int expectedValue = 0; BOOST_FOREACH( const valijson::adapters::JsonCppAdapter value, adapter.getArray() ) { ASSERT_TRUE( value.isNumber() ); EXPECT_EQ( double(expectedValue), value.getNumber() ); expectedValue++; } // Ensure that the correct number of elements were iterated over EXPECT_EQ(numElements, expectedValue); }
ColorSetChooser::ColorSetChooser(QWidget* parent): QWidget(parent) { KoResourceServer<KoColorSet> * rserver = KoResourceServerProvider::instance()->paletteServer(false); QSharedPointer<KoAbstractResourceServerAdapter> adapter(new KoResourceServerAdapter<KoColorSet>(rserver)); m_itemChooser = new KoResourceItemChooser(adapter, this); m_itemChooser->setItemDelegate(new ColorSetDelegate(this)); m_itemChooser->setFixedSize(250, 250); m_itemChooser->setRowHeight(30); m_itemChooser->setColumnCount(1); connect(m_itemChooser, SIGNAL(resourceSelected(KoResource*)), this, SLOT(resourceSelected(KoResource*))); QPushButton* saveButton = new QPushButton(i18n("Save")); connect(saveButton, SIGNAL(clicked(bool)), this, SLOT(slotSave())); m_nameEdit = new QLineEdit(this); m_nameEdit->setPlaceholderText(i18n("Insert name")); m_nameEdit->setClearButtonEnabled(true); m_columnEdit = new QSpinBox(this); m_columnEdit->setRange(1, 30); m_columnEdit->setValue(10); QGridLayout* layout = new QGridLayout(this); layout->addWidget(m_itemChooser, 0, 0, 1, 3); layout->addWidget(new QLabel(i18n("Name:"), this), 1, 0, 1, 1); layout->addWidget(m_nameEdit, 1, 1, 1, 2); layout->addWidget(new QLabel(i18n("Columns:"), this), 2, 0, 1, 1); layout->addWidget(m_columnEdit, 2, 1, 1, 1); layout->addWidget(saveButton, 2, 2, 1, 1); layout->setColumnStretch(1, 1); }
void WindowAdapterTest::testWindowAdapter() { debug(LOG_DEBUG, DEBUG_LOG, 0, "window adapter test"); // create an image Image<unsigned char> image(16, 16); for (unsigned int x = 0; x < 16; x++) { for (unsigned int y = 0; y < 16; y++) { image.pixel(x, y) = x * y; } } // create the subframe ImageRectangle frame(ImagePoint(4, 4), ImageSize(8, 8)); debug(LOG_DEBUG, DEBUG_LOG, 0, "frame: %s", frame.toString().c_str()); // create an adapter for a subframe WindowAdapter<unsigned char> adapter(image, frame); // access the subframe ImageSize size = adapter.getSize(); debug(LOG_DEBUG, DEBUG_LOG, 0, "adapter size: %s", size.toString().c_str()); for (int x = 0; x < size.width(); x++) { for (int y = 0; y < size.height(); y++) { unsigned char value = adapter.pixel(x, y); unsigned char v = (frame.origin().x() + x) * (frame.origin().y() + y); if (v != value) { debug(LOG_DEBUG, DEBUG_LOG, 0, "expected %d != %d found", (int)v, (int)value); } CPPUNIT_ASSERT(value == v); } } debug(LOG_DEBUG, DEBUG_LOG, 0, "window adapter test complete"); }
void CrashReport::connectMgr(JNIEnv* pEnv, jobject mgr) { if (m_jMgr == NULL) { /* Connect to java GTTerminal class */ CNativeAdapter adapter(pEnv); m_jMgr = adapter.newGlobalRef(mgr); } }
QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices() { QList<QBluetoothHostInfo> localDevices; OrgBluezManagerInterface manager(QLatin1String("org.bluez"), QLatin1String("/"), QDBusConnection::systemBus()); QDBusPendingReply<QList<QDBusObjectPath> > reply = manager.ListAdapters(); reply.waitForFinished(); if (reply.isError()) return localDevices; foreach (const QDBusObjectPath &path, reply.value()) { QBluetoothHostInfo hostinfo; OrgBluezAdapterInterface adapter(QLatin1String("org.bluez"), path.path(), QDBusConnection::systemBus()); QDBusPendingReply<QVariantMap> reply = adapter.GetProperties(); reply.waitForFinished(); if (reply.isError()) continue; hostinfo.setAddress(QBluetoothAddress(reply.value().value(QLatin1String("Address")).toString())); hostinfo.setName(reply.value().value(QLatin1String("Name")).toString()); localDevices.append(hostinfo); } return localDevices; }
LayoutUnit FloatingObjects::logicalLeftOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight) { ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft> adapter(m_layoutObject, logicalTop, logicalTop + logicalHeight, fixedOffset); placedFloatsTree().allOverlapsWithAdapter(adapter); return adapter.offset(); }
LayoutUnit FloatingObjects::logicalRightOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight) { ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight> adapter(m_layoutObject, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), fixedOffset); placedFloatsTree().allOverlapsWithAdapter(adapter); return std::min(fixedOffset, adapter.offset()); }
LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelowForBlock( LayoutUnit logicalHeight) { FindNextFloatLogicalBottomAdapter adapter(*m_layoutObject, logicalHeight); placedFloatsTree().allOverlapsWithAdapter(adapter); return adapter.nextLogicalBottom(); }
OptionletStripper2::ObjectiveFunction::ObjectiveFunction( const boost::shared_ptr<OptionletStripper1>& optionletStripper1, const boost::shared_ptr<CapFloor>& cap, Real targetValue) : cap_(cap), targetValue_(targetValue) { boost::shared_ptr<OptionletVolatilityStructure> adapter(new StrippedOptionletAdapter(optionletStripper1)); // set an implausible value, so that calculation is forced // at first operator()(Volatility x) call spreadQuote_ = boost::shared_ptr<SimpleQuote>(new SimpleQuote(-1.0)); boost::shared_ptr<OptionletVolatilityStructure> spreadedAdapter(new SpreadedOptionletVolatility(Handle<OptionletVolatilityStructure>( adapter), Handle<Quote>(spreadQuote_))); boost::shared_ptr<BlackCapFloorEngine> engine(new BlackCapFloorEngine( optionletStripper1->iborIndex()->forwardingTermStructure(), Handle<OptionletVolatilityStructure>(spreadedAdapter))); cap_->setPricingEngine(engine); }
LayoutUnit FloatingObjects::logicalRightOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight, ShapeOutsideFloatOffsetMode offsetMode, LayoutUnit *heightRemaining) { #if !ENABLE(CSS_SHAPES) UNUSED_PARAM(offsetMode); #endif LayoutUnit offset = fixedOffset; ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), offset); placedFloatsTree().allOverlapsWithAdapter(adapter); if (heightRemaining) *heightRemaining = adapter.getHeightRemaining(); #if ENABLE(CSS_SHAPES) const FloatingObject* outermostFloat = adapter.outermostFloat(); if (offsetMode == ShapeOutsideFloatShapeOffset && outermostFloat) { if (ShapeOutsideInfo* shapeOutside = outermostFloat->renderer().shapeOutsideInfo()) { shapeOutside->updateDeltasForContainingBlockLine(m_renderer, outermostFloat, logicalTop, logicalHeight); offset += shapeOutside->leftMarginBoxDelta(); } } #endif return min(fixedOffset, offset); }
inline StructureAdapterPtr createStructureAdapter(const ObjCryst::Molecule& molecule) { StructureAdapterPtr adapter(new ObjCrystMoleculeAdapter(molecule)); return adapter; }
LayoutMultiColumnSet* LayoutMultiColumnFlowThread::columnSetAtBlockOffset(LayoutUnit offset) const { if (LayoutMultiColumnSet* columnSet = m_lastSetWorkedOn) { // Layout in progress. We are calculating the set heights as we speak, so the column set range // information is not up-to-date. while (columnSet->logicalTopInFlowThread() > offset) { // Sometimes we have to use a previous set. This happens when we're working with a block // that contains a spanner (so that there's a column set both before and after the // spanner, and both sets contain said block). LayoutMultiColumnSet* previousSet = columnSet->previousSiblingMultiColumnSet(); if (!previousSet) break; columnSet = previousSet; } return columnSet; } ASSERT(!m_columnSetsInvalidated); if (m_multiColumnSetList.isEmpty()) return nullptr; if (offset <= 0) return m_multiColumnSetList.first(); MultiColumnSetSearchAdapter adapter(offset); m_multiColumnSetIntervalTree.allOverlapsWithAdapter<MultiColumnSetSearchAdapter>(adapter); // If no set was found, the offset is in the flow thread overflow. if (!adapter.result() && !m_multiColumnSetList.isEmpty()) return m_multiColumnSetList.last(); return adapter.result(); }
inline StructureAdapterPtr createStructureAdapter(const ObjCryst::Crystal& cryst) { StructureAdapterPtr adapter(new ObjCrystStructureAdapter(cryst)); return adapter; }
Chat::Chat(QWidget *parent) : QDialog(parent), currentAdapterIndex(0), ui(new Ui_Chat) { ui->setupUi(this); connect(ui->quitButton, SIGNAL(clicked()), this, SLOT(accept())); connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectClicked())); connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendClicked())); localAdapters = QBluetoothLocalDevice::allDevices(); if (localAdapters.count() < 2) { ui->localAdapterBox->setVisible(false); } else { //we ignore more than two adapters ui->localAdapterBox->setVisible(true); ui->firstAdapter->setText(tr("Default (%1)", "%1 = Bluetooth address"). arg(localAdapters.at(0).address().toString())); ui->secondAdapter->setText(localAdapters.at(1).address().toString()); ui->firstAdapter->setChecked(true); connect(ui->firstAdapter, SIGNAL(clicked()), this, SLOT(newAdapterSelected())); connect(ui->secondAdapter, SIGNAL(clicked()), this, SLOT(newAdapterSelected())); QBluetoothLocalDevice adapter(localAdapters.at(0).address()); adapter.setHostMode(QBluetoothLocalDevice::HostDiscoverable); } server = new ChatServer(this); connect(server, SIGNAL(clientConnected(QString)), this, SLOT(clientConnected(QString))); connect(server, SIGNAL(clientDisconnected(QString)), this, SLOT(clientDisconnected(QString))); connect(server, SIGNAL(messageReceived(QString,QString)), this, SLOT(showMessage(QString,QString))); connect(this, SIGNAL(sendMessage(QString)), server, SLOT(sendMessage(QString))); server->startServer(); localName = QBluetoothLocalDevice().name(); }
TEST(BlockCipherAdapterTest, WrongInputLength) { AES aes(Decode(AESCTRTestVectors[0].key)) ; BlockCipherAdapter adapter(&aes, Decode(AESCTRTestVectors[0].iv), BlockCipherAdapter::Mode::CTR) ; ASSERT_THROW(adapter.Encode(Decode("")), std::string) ; ASSERT_THROW(adapter.Encode(Decode("01234567890123456789")), std::string) ; ASSERT_THROW(adapter.Encode(Decode("0123456789012345678901234567890123456789012345678901234567890123456789")), std::string) ; }
value_string::operator string() const { this->validateInstantiated(); cStringWrapper adapter(this->cValueP); return string(adapter.str, adapter.length); }
void GameLogic::debugDraw(DebugGraphics *graphics) { PhysicsDebugGraphicsAdapter adapter(graphics); adapter.SetFlags(b2Draw::e_shapeBit); world_->SetDebugDraw(&adapter); world_->DrawDebugData(); world_->SetDebugDraw(0); }
LayoutUnit FloatingObjects::logicalRightOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight) { ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset); if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree()) placedFloatsTree->allOverlapsWithAdapter(adapter); return std::min(fixedOffset, adapter.offset()); }
LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight) { FindNextFloatLogicalBottomAdapter adapter(m_renderer, logicalHeight); if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree()) placedFloatsTree->allOverlapsWithAdapter(adapter); return adapter.nextLogicalBottom(); }
int main(int argc, char *argv[]) { Adaptee adaptee; Adapter adapter(&adaptee); adapter.hello(); adapter.world(); return 0; }
value_string::operator string() const { env_wrap env; cStringWrapper adapter(this->cValueP); return string(adapter.str, adapter.length); }
PassRefPtr<ScriptHeapSnapshot> ScriptProfiler::takeHeapSnapshot(const String& title, HeapSnapshotProgress* control) { v8::HandleScope hs; ASSERT(control); ActivityControlAdapter adapter(control); const v8::HeapSnapshot* snapshot = v8::HeapProfiler::TakeSnapshot(v8String(title), v8::HeapSnapshot::kFull, &adapter); return snapshot ? ScriptHeapSnapshot::create(snapshot) : 0; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); BubbleManager manager; NotificationsDBusAdaptor adapter(&manager); manager.registerAsService(); return app.exec(); }
inline NativeFunction *addOverload(TFunction functionPointer, TSignature signature) { NativeFunctionConcrete<TFunction, TSignature> *funcDecl = new NativeFunctionConcrete<TFunction, TSignature>(this->m_isolationScope, functionPointer, signature); boost::shared_ptr< NativeFunctionConcrete<TFunction, TSignature> > adapter(funcDecl); this->m_overloads->push_back(adapter); return this; }
void Waypoints::WaypointNameTree::VisitNormalisedPrefix(const TCHAR *prefix, WaypointVisitor &visitor) const { TCHAR normalized[_tcslen(prefix) + 1]; NormalizeSearchString(normalized, prefix); VisitorAdapter adapter(visitor); visit_prefix(normalized, adapter); }
const string component::generate(const string::size_type maxLineLength, const string::size_type curLinePos) const { std::ostringstream oss; utility::outputStreamAdapter adapter(oss); generate(adapter, maxLineLength, curLinePos, NULL); return (oss.str()); }
LayoutUnit FloatingObjects::logicalRightOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining) { ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight> adapter(m_layoutObject, logicalTop, logicalTop, fixedOffset); placedFloatsTree().allOverlapsWithAdapter(adapter); if (heightRemaining) *heightRemaining = adapter.heightRemaining(); return std::min(fixedOffset, adapter.offset()); }
TEST_P(BlockCipherAdapter_AESCTR, AESCTR) { int cases = std::min(GetParam().plain.size(), GetParam().cipher.size()) ; ASSERT_GT(cases, 0) << "No plain/cipher to test" ; AES aes(Decode(GetParam().key)) ; BlockCipherAdapter adapter(&aes, Decode(GetParam().iv), BlockCipherAdapter::Mode::CTR) ; for(int i=0;i<cases;i++) ASSERT_EQ(Decode(GetParam().cipher[i]), adapter.Encode(Decode(GetParam().plain[i]))) ; }
LayoutUnit FloatingObjects::logicalLeftOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining) { int logicalTopAsInt = roundToInt(logicalTop); ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft> adapter(m_layoutObject, logicalTopAsInt, logicalTopAsInt, fixedOffset); placedFloatsTree().allOverlapsWithAdapter(adapter); if (heightRemaining) *heightRemaining = adapter.heightRemaining(); return adapter.offset(); }