MusicAudioRecorderCore::MusicAudioRecorderCore(QObject *parent) : QObject(parent) { m_mpAudioInputFile = nullptr; m_mpAudioOutputFile = nullptr; m_mpOutputFile = new QFile(this); m_mpOutputFile->setFileName( RECORD_FILE ); m_mFormatFile.setSampleSize(16); m_mFormatFile.setSampleType(QAudioFormat::SignedInt); m_mFormatFile.setByteOrder(QAudioFormat::LittleEndian); m_mFormatFile.setCodec("audio/pcm"); QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice()); if(!info.isFormatSupported(m_mFormatFile)) { M_LOGGER_WARN("input default mFormatFile not supported try to use nearest"); m_mFormatFile = info.nearestFormat(m_mFormatFile); } QAudioDeviceInfo info1(QAudioDeviceInfo::defaultOutputDevice()); if(!info1.isFormatSupported(m_mFormatFile)) { M_LOGGER_WARN("output default mFormatFile not supported - trying to use nearest"); M_LOGGER_WARN("output no support input mFormatFile."); } if(m_mFormatFile.sampleSize() != 16) { M_LOGGER_INFO(QString("audio device doesn't support 16 bit support %d bit samples, example cannot run %1") .arg(m_mFormatFile.sampleSize())); } }
/** @SYMTestCaseID GRAPHICS-RESOURCE-0201 @SYMTestCaseDesc Test Graphics Resource with low memory conditions. @SYMPREQ PREQ2637 @SYMFssID RSgImage RSgDrawable RSgDriver @SYMTestPriority High @SYMTestType UT @SYMTestPurpose To ensure the correct errors or KErrNoMemory are returned by graphics resource apis under low memory conditions. @SYMTestActions Force allocations to fail on the RSgDrivers heap, try running each of the conformance tests and stress tests to ensure no RSgDriver allocated memory or heap memory is leaked. It also creates an image in this process which is used in another process for OOM testing. @SYMTestExpectedResults Return codes of the functions tested should be either the expected value or KErrNoMemory This is handled by CTSgTestStepBase::CheckErrorL. No ALLOC or SGALLOC panics should occur. */ void CTGraphicsResourceInternal::TestOOML() { // drawable OOM test TSgResIntTestInfo testInfo = { ESgResIntDrawableOOM }; TInt result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo); TEST(result & EFirstTestPassed); // image OOM test testInfo.iTestCase = ESgResIntImageOOM; RSgDriver sgDriver; TInt err = sgDriver.Open(); TESTEL(err == KErrNone, err); CleanupClosePushL(sgDriver); RSgImage image1; TSgImageInfo info1(TSize(8, 8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); err = image1.Create(info1); TESTEL(err == KErrNone, err); CleanupClosePushL(image1); testInfo.iDrawableId = image1.Id(); result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo); TEST(result & EFirstTestPassed); CleanupStack::PopAndDestroy(2, &sgDriver); }
static bool WriteImage( FileFormatInstance* instance, const I& image ) { if ( !image.IsShared() || !image.IsCompletelySelected() ) { I tmp( (void*)0, 0, 0 ); tmp.Assign( image ); return WriteImage( instance, tmp ); } image.PushSelections(); image.ResetSelections(); ImageInfo info1( image ); image.PopSelections(); bool ok = (*API->FileFormat->WriteImage)( instance->handle, image.Allocator().Handle() ) != api_false; image.PushSelections(); image.ResetSelections(); ImageInfo info2( image ); image.PopSelections(); if ( info1 != info2 ) APIHackingAttempt( "WriteImage" ); return ok; }
bool ProcessInstance::CanExecuteOn( const ImageVariant& image, String& whyNot ) const { if ( !image.IsSharedImage() || !image.IsCompletelySelected() ) { ImageVariant tmp; tmp.CreateSharedImageAs( image ).AssignImage( image ); return CanExecuteOn( tmp, whyNot ); } image.PushSelections(); image.ResetSelections(); ImageInfo info1( *image ); image.PopSelections(); whyNot.Clear(); whyNot.Reserve( WHYNOT_MAXLENGTH ); bool ok = (*API->Process->ValidateImageExecution)( handle, image.SharedImageHandle(), whyNot.c_str(), WHYNOT_MAXLENGTH ) != api_false; image.PushSelections(); image.ResetSelections(); ImageInfo info2( *image ); image.PopSelections(); if ( info1 != info2 ) APIHackingAttempt( "ValidateImageExecution" ); return ok; }
void VideoPlayer::ChangePlaylist() { QFileInfo info1("C:\\Users\\MichaU\\Desktop\\ResonanceP2.mp4"); QMediaPlaylist *lista1 = new QMediaPlaylist; lista1->addMedia(QUrl::fromLocalFile(info1.absoluteFilePath())); lista1->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); mediaPlayer.setPlaylist(lista1); mediaPlayer.play(); }
int FileListItem::compare( QListViewItem * i, int col, bool ascending ) const { QFileInfo info1( key( col, ascending ) ); //this QFileInfo info2( i->key( col, ascending ) ); //that int fileComp = info1.fileName().compare( info2.fileName() ); if ( fileComp != 0 ) return fileComp; else return info1.extension().compare( info2.extension() ); }
int main() { QFileInfo info1("../qcombobox_example.cpp"); qDebug() << "absoluteFilePath(): " << info1.absoluteFilePath(); qDebug() << "baseName(): " << info1.baseName(); qDebug() << "fileName(): " << info1.fileName(); qDebug() << "dir(): " << info1.dir(); qDebug() << "size(): " << info1.size(); qDebug() << "suffix(): " << info1.suffix(); }
void TestPageTextInfo::testPageNumber() { KWPageManager manager; QCOMPARE(manager.pageCount(), 0); KWPage page1 = manager.appendPage(); KWPage page2 = manager.appendPage(); KWPage page3 = manager.appendPage(); KWPage page4 = manager.appendPage(); KWPage page5 = manager.appendPage(); KWPageStyle style2("foo"); manager.addPageStyle(style2); KWPage page40 = manager.appendPage(style2); QCOMPARE(page40.pageNumber(), 6); page40.setPageNumber(40); QCOMPARE(page5.pageNumber(), 5); QCOMPARE(page40.pageNumber(), 40); KWPage page41 = manager.appendPage(); QCOMPARE(page41.pageNumber(), 41); KWPageTextInfo info1(page1); QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 0), 1); QCOMPARE(info1.pageNumber(KoTextPage::PreviousPage, 0), -1); QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 0), 2); QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 4), 5); QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 5), -1); QCOMPARE(info1.pageNumber(KoTextPage::CurrentPage, 40), 41); QCOMPARE(info1.pageNumber(KoTextPage::PreviousPage, 1), -1); QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 3), 5); QCOMPARE(info1.pageNumber(KoTextPage::NextPage, 4), -1); KWPageTextInfo info2(page2); QCOMPARE(info2.pageNumber(KoTextPage::CurrentPage, 0), 2); QCOMPARE(info2.pageNumber(KoTextPage::PreviousPage, 0), 1); QCOMPARE(info2.pageNumber(KoTextPage::NextPage, 0), 3); KWPageTextInfo info3(page5); QCOMPARE(info3.pageNumber(KoTextPage::CurrentPage, 0), 5); QCOMPARE(info3.pageNumber(KoTextPage::PreviousPage, 0), 4); QCOMPARE(info3.pageNumber(KoTextPage::NextPage, 0), 40); KWPageTextInfo info40(page40); QCOMPARE(info40.pageNumber(KoTextPage::CurrentPage, 0), 40); QCOMPARE(info40.pageNumber(KoTextPage::PreviousPage, 0), 5); QCOMPARE(info40.pageNumber(KoTextPage::NextPage, 0), 41); KWPageTextInfo info41(page41); QCOMPARE(info41.pageNumber(KoTextPage::CurrentPage, 0), 41); QCOMPARE(info41.pageNumber(KoTextPage::PreviousPage, 0), 40); QCOMPARE(info41.pageNumber(KoTextPage::NextPage, 0), -1); }
QString MainWindow::extraThemes() { QDir dir(QString(m_confDir).append("/theme")); if (!dir.exists()) return toJSArray(); QStringList dirList = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs); QStringList themeList; Q_FOREACH(const QString& themedir, dirList) { QFileInfo info1(dir.absoluteFilePath(QString(themedir).append("/info.json"))); QFileInfo info2(dir.absoluteFilePath(QString(themedir).append("/style.css"))); if (info1.exists() && info1.isFile() && info2.exists() && info2.isFile()) themeList << QUrl::fromLocalFile(dir.absoluteFilePath(themedir)).toString(); }
void CommandLineParserTest::testPlugInsWithParameters() { static const char *lines[] = { "", "TestPlugIn1.dll=login = lain", "Clocker.dll", NULL }; parse( lines ); CPPUNIT_ASSERT_EQUAL( 2, _parser->getPlugInCount() ); CommandLinePlugInInfo info1( _parser->getPlugInAt( 0 ) ); CPPUNIT_ASSERT_EQUAL( std::string("TestPlugIn1.dll"), info1.m_fileName ); CPPUNIT_ASSERT_EQUAL( std::string("login = lain"), info1.m_parameters.getCommandLine() ); CommandLinePlugInInfo info2( _parser->getPlugInAt( 1 ) ); CPPUNIT_ASSERT_EQUAL( std::string("Clocker.dll"), info2.m_fileName ); CPPUNIT_ASSERT( info2.m_parameters.getCommandLine().empty() ); }
int main(int argc, char **argv) { QCoreApplication app(argc, argv); QFile::remove("cache.cdb"); if (! QFile::copy("cache1.cdb", "cache.cdb")) { qDebug() << "Can't copy cache1.cdb!"; fail(); } sleep(1); if (! ContextRegistryInfo::instance()->listKeys().contains("Battery.OnBattery")) { qDebug() << "Battery.OnBattery not found in cache1.cdb!"; fail(); } ContextPropertyInfo info1("Battery.OnBattery"); if (info1.provided() != true) { qDebug() << "Battery.OnBattery should be provided!"; fail(); } QFile::remove("cache.cdb"); if (! QFile::copy("cache2.cdb", "cache.cdb")) { qDebug() << "Can't copy cache2.cdb!"; fail(); } sleep(1); app.processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 1000); ContextPropertyInfo info2("Battery.OnBattery"); if (info2.provided() == true) { qDebug() << "Battery.OnBattery should not be provided!"; fail(); } QFile::remove("cache.cdb"); return 0; }
void HTMLMenuItemElement::WalkRadioGroup(Visitor* aVisitor) { nsIContent* parent = GetParent(); if (!parent) { aVisitor->Visit(this); return; } nsAttrInfo info1(GetAttrInfo(kNameSpaceID_None, nsGkAtoms::radiogroup)); bool info1Empty = !info1.mValue || info1.mValue->IsEmptyString(); for (nsIContent* cur = parent->GetFirstChild(); cur; cur = cur->GetNextSibling()) { HTMLMenuItemElement* menuitem = HTMLMenuItemElement::FromContent(cur); if (!menuitem || menuitem->GetType() != CMD_TYPE_RADIO) { continue; } nsAttrInfo info2(menuitem->GetAttrInfo(kNameSpaceID_None, nsGkAtoms::radiogroup)); bool info2Empty = !info2.mValue || info2.mValue->IsEmptyString(); if (info1Empty != info2Empty || (info1.mValue && info2.mValue && !info1.mValue->Equals(*info2.mValue))) { continue; } if (!aVisitor->Visit(menuitem)) { break; } } }
void Dialog::MakeGiftResource(void) { Cursor & cursor = Cursor::Get(); Display & display = Display::Get(); LocalEvent & le = LocalEvent::Get(); const Settings & conf = Settings::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); const u16 window_w = 320; const u16 window_h = 224; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(); const Rect & box = frameborder.GetArea(); const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0); background.Blit(Rect(0, 0, window_w, window_h), box); Kingdom & myKingdom = world.GetKingdom(conf.CurrentColor()); Funds funds1(myKingdom.GetFunds()); Funds funds2; Text text; text.Set("Select Recipients"); text.Blit(box.x + (box.w - text.w()) / 2, box.y + 5); SelectRecipientsColors selector(Point(box.x + 65, box.y + 28)); selector.Redraw(); text.Set("Your Funds"); text.Blit(box.x + (box.w - text.w()) / 2, box.y + 55); ResourceBar info1(funds1, box.x + 25, box.y + 80); info1.Redraw(); text.Set("Planned Gift"); text.Blit(box.x + (box.w - text.w()) / 2, box.y + 125); ResourceBar info2(funds2, box.x + 25, box.y + 150); info2.Redraw(); ButtonGroups btnGroups(box, Dialog::OK|Dialog::CANCEL); btnGroups.DisableButton1(true); btnGroups.Draw(); cursor.Show(); display.Flip(); u8 count = Color::Count(selector.recipients); // message loop u16 result = Dialog::ZERO; while(result == Dialog::ZERO && le.HandleEvents()) { if(selector.QueueEventProcessing()) { u8 new_count = Color::Count(selector.recipients); cursor.Hide(); btnGroups.DisableButton1(0 == new_count || 0 == funds2.GetValidItems()); if(count != new_count) { funds1 = myKingdom.GetFunds(); funds2.Reset(); info1.Redraw(); info2.Redraw(); count = new_count; } btnGroups.Draw(); selector.Redraw(); cursor.Show(); display.Flip(); } else if(info2.QueueEventProcessing(funds1, count)) { cursor.Hide(); btnGroups.DisableButton1(0 == Color::Count(selector.recipients) || 0 == funds2.GetValidItems()); info1.Redraw(); info2.Redraw(); btnGroups.Draw(); cursor.Show(); display.Flip(); } result = btnGroups.QueueEventProcessing(); } if(Dialog::OK == result) { EventDate event; event.resource = funds2; event.computer = true; event.first = world.CountDay() + 1; event.subsequent = 0; event.colors = selector.recipients; event.message = "Gift from %{name}"; const Player* player = Settings::Get().GetPlayers().GetCurrent(); if(player) String::Replace(event.message, "%{name}", player->name); world.AddEventDate(event); if(1 < count) funds2 *= count; myKingdom.OddFundsResource(funds2); } }
MusicAudioRecorderWidget::MusicAudioRecorderWidget(QWidget *parent) : MusicAbstractMoveDialog(parent), ui(new Ui::MusicAudioRecorderWidget), m_mBuffer(BufferSize, 0) { ui->setupUi(this); ui->topTitleCloseButton->setIcon(QIcon(":/share/searchclosed")); ui->topTitleCloseButton->setStyleSheet(MusicUIObject::MToolButtonStyle03); ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor)); ui->topTitleCloseButton->setToolTip(tr("Close")); connect(ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close())); ui->startButton->setStyleSheet(MusicUIObject::MPushButtonStyle05); ui->startButton->setCursor(QCursor(Qt::PointingHandCursor)); ui->startButton->setToolTip(tr("startAudio")); ui->stopButton->setStyleSheet(MusicUIObject::MPushButtonStyle05); ui->stopButton->setCursor(QCursor(Qt::PointingHandCursor)); ui->stopButton->setToolTip(tr("stopAudio")); ui->playButton->setStyleSheet(MusicUIObject::MPushButtonStyle05); ui->playButton->setCursor(QCursor(Qt::PointingHandCursor)); ui->playButton->setToolTip(tr("playAudio")); ui->saveButton->setStyleSheet(MusicUIObject::MPushButtonStyle05); ui->saveButton->setCursor(QCursor(Qt::PointingHandCursor)); ui->saveButton->setToolTip(tr("saveButton")); connect(ui->startButton, SIGNAL(clicked()), SLOT(onRecordStart())); connect(ui->stopButton, SIGNAL(clicked()), SLOT(onRecordStop())); connect(ui->playButton, SIGNAL(clicked()), SLOT(onRecordPlay())); connect(ui->saveButton, SIGNAL(clicked()), SLOT(onRecordSave())); ui->checkBox->setStyleSheet(MusicUIObject::MCheckBoxStyle01); ui->checkBox_2->setStyleSheet(MusicUIObject::MCheckBoxStyle01); ui->checkBox_3->setStyleSheet(MusicUIObject::MCheckBoxStyle01); ui->checkBox_4->setStyleSheet(MusicUIObject::MCheckBoxStyle01); ui->checkBox_5->setStyleSheet(MusicUIObject::MCheckBoxStyle01); ui->checkBox->setCursor(QCursor(Qt::PointingHandCursor)); ui->checkBox_2->setCursor(QCursor(Qt::PointingHandCursor)); ui->checkBox_3->setCursor(QCursor(Qt::PointingHandCursor)); ui->checkBox_4->setCursor(QCursor(Qt::PointingHandCursor)); ui->checkBox_5->setCursor(QCursor(Qt::PointingHandCursor)); connect(&m_timer, SIGNAL(timeout()), SLOT(onTimerout())); ui->stopButton->setEnabled(false); ui->playButton->setEnabled(false); ui->saveButton->setEnabled(false); m_movie = nullptr; m_time = 0; m_miMaxValue = 0; ui->horizontalSlider->setValue(100); m_miVolume = 100; m_mpOutputFile = nullptr; m_mpAudioInputFile = nullptr; m_mpAudioOutputFile = nullptr; m_mpAudioInputSound = nullptr; m_mpAudioOutputSound = nullptr; m_mpInputDevSound = nullptr; m_mpInputDevSound = nullptr; m_mpOutputFile = new QFile(this); m_mpOutputFile->setFileName("record.raw"); m_mFormatFile.setSampleSize(16); m_mFormatFile.setSampleType(QAudioFormat::SignedInt); m_mFormatFile.setByteOrder(QAudioFormat::LittleEndian); m_mFormatFile.setCodec("audio/pcm"); QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice()); if(!info.isFormatSupported(m_mFormatFile)) { M_LOGGERS("input default mFormatFile not supported try to use nearest"); m_mFormatFile = info.nearestFormat(m_mFormatFile); } QAudioDeviceInfo info1(QAudioDeviceInfo::defaultOutputDevice()); if(!info1.isFormatSupported(m_mFormatFile)) { M_LOGGERS("output default mFormatFile not supported - trying to use nearest"); // mFormatFile = info.nearestFormat(mFormatSound); M_LOGGERS("output no support input mFormatFile."); return; } if(m_mFormatFile.sampleSize() != 16) { M_LOGGER << "audio device doesn't support 16 bit support %d bit samples, example cannot run" << m_mFormatFile.sampleSize() << LOG_END; m_mpAudioInputFile = 0; return; } m_mpAudioInputFile = nullptr; m_mpAudioOutputFile = nullptr; initMonitor(); }
pilo::i32_t functional_test_insert_erase(void* param) { M_UNUSED(param); fixed_array<testing_pod_info, 800> array; if (array.capacity() != 800) { return -1; } for (int i = 0; i < 700; i++) { testing_pod_info info(i, ""); array.push_back(info); if (array.full()) { break; } } testing_pod_info info1(700, ""); array.insert(700, info1); if (array.size() != 701) { return -200; } for (int i = 0; i < (int) array.size(); i++) { if (array.get(i).m_id != i) { return -10000 - i; } } testing_pod_info info2(-456, ""); array.insert(125, info2); for (int i = 0; i < (int) array.size(); i++) { if (i == 125) { if (array.at(i).m_id != -456) { return -456; } } else if (i < 125) { if (array.at(i).m_id != i) { return -2000 - i; } } else if (i > 125) { if (array.at(i).m_id != i - 1) { return -2000 - i; } } } return 0; }
void Polar::setPolarName(QString fname) { isCsv=true; loaded=false; clearPolar(); if(this->mainWindow->getSelectedBoat() && this->mainWindow->getSelectedBoat()->get_boatType()==BOAT_REAL) coeffPolar=Settings::getSetting("polarEfficiency",100).toInt()/100.0; else coeffPolar=1.0; //qWarning() << "Opening polar" << fname<<"with coeff"<<coeffPolar; name=fname; QString nameF = appFolder.value("polar")+fname+".csv"; QFile file(nameF); if (fname.endsWith(".csv",Qt::CaseInsensitive) || fname.endsWith(".pol",Qt::CaseInsensitive)) { nameF=appFolder.value("polar")+fname; file.setFileName(nameF); if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Impossible d'ouvrir le fichier %1")).arg(name)); return; } isCsv=fname.endsWith("csv",Qt::CaseInsensitive); } else { if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { isCsv=false; nameF = appFolder.value("polar")+fname+".pol"; file.setFileName(nameF); if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Impossible d'ouvrir le fichier %1 (ni en .csv ni en .pol)")).arg(name)); return; } } } QTextStream stream(&file); QString line; QStringList list; /* read first line to see line length */ line=stream.readLine(); line.remove("\""); if(line.isNull()) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Fichier %1 vide")).arg(fname)); file.close(); return; } if(isCsv) list = line.split(';'); else list = line.split('\t'); if(list[0].toUpper() != "TWA\\TWS" && list[0].toUpper() != "TWA/TWS" && list[0].toUpper() != "TWA") { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Fichier %1 invalide (doit commencer par TWA\\TWS et non '%2')")) .arg(fname) .arg(list[0])); file.close(); return; } int i; for(i=1;i<list.count();++i) { if(!tws.isEmpty() && list[i].toDouble()<=tws.last()) break; tws.append(list[i].toDouble()); } bool missingTws0=false; if(tws.first()!=0.0) { missingTws0=true; } bool firstTWA=true; while(true) { line=stream.readLine(); if(line.isNull()) break; line.remove("\""); if (isCsv) list = line.split(";"); else list = line.split("\t"); if(firstTWA) { firstTWA=false; if(list.first().toDouble()!=0.0) { for(int t=0;t<tws.count();++t) { polar_data.append(0); } if(missingTws0) polar_data.append(0); twa.append(0.0); } } twa.append(list[0].toDouble()); if(missingTws0) polar_data.append(0); for(i=1;i<list.count();++i) { if(i>tws.count()) break; polar_data.append(list[i].toDouble()*this->coeffPolar); } while(i<=tws.count()) polar_data.append(0); } if(missingTws0) tws.prepend(0.0); #if 0 qWarning()<<"polar data for"<<nameF; QString debug="xxx.x "; foreach(double dd,tws) debug+=QString().sprintf("%04.1f ",dd); qWarning()<<debug; QListIterator<double> i1(polar_data); QListIterator<double> i2(twa); while(i2.hasNext()) { debug=QString().sprintf("%05.1f ",i2.next()); for(int nn=0;nn<tws.count();++nn) debug+=QString().sprintf("%04.1f ",i1.next()); qWarning()<<debug; } #endif mid_twa=qRound(twa.count()/2.0); mid_tws=qRound(tws.count()/2.0); /* polaire chargee */ /* pre-calculate B-VMG for every tws at 0.1 precision with a twa step of 1 and then .1 */ double ws=0.0; double wa=0.0; double bvmg,bvmg_d,bvmg_u,wa_u,wa_d,wa_limit; maxSpeed=0.0; do { wa_u=0.0; wa_d=180.0; bvmg_u=bvmg_d=0; double speed; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_u<bvmg) //bvmg is positive here { bvmg_u=bvmg; wa_u=wa; } if(bvmg_d>bvmg) //bvmg is negative here { bvmg_d=bvmg; wa_d=wa; } wa=qRound(wa+1); } while(wa<181.00); wa=wa_u-1; wa_limit=wa_u+1; if(wa<0) wa=0.0; if(wa_limit<1) wa_limit=1.0; if(wa_limit>180) wa_limit=180.0; bvmg_u=0.0; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_u<bvmg) { bvmg_u=bvmg; wa_u=wa; } wa=wa+0.1; } while(wa<(wa_limit+0.1000)); wa=wa_d-1; wa_limit=wa_d+1; if(wa<0) wa=0.0; if(wa_limit<1) wa_limit=1.0; if(wa_limit>180) wa_limit=180.0; bvmg_d=0.0; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_d>bvmg) { bvmg_d=bvmg; wa_d=wa; } wa=wa+0.1; }while(wa<wa_limit+0.1); best_vmg_up.append(wa_u); best_vmg_down.append(wa_d); wa=0.0; ws=ws+.1; }while(ws<60.1); loaded=true; QFileInfo fi(file.fileName()); QString nameFVmg = appFolder.value("polar")+fi.baseName()+".vmg"; fileVMG.setFileName(nameFVmg); if (fileVMG.open(QIODevice::ReadOnly | QIODevice::Text )) { if(fileVMG.size()<4329500 || fileVMG.size()>4329700) fileVMG.remove(); else { QFileInfo info1(fileVMG); QFileInfo info2(file); if(this->mainWindow->isStartingUp && info1.lastModified()<info2.lastModified()) fileVMG.remove(); else { file.close(); return; } } } file.close(); //precalculate regular VMGs //qWarning() << "Start computing vmg"; fileVMG.open(QIODevice::WriteOnly | QIODevice::Text ); double vmg=0; QTextStream sVmg(&fileVMG); QString ssVmg; QProgressDialog * progress; progress=new QProgressDialog((QWidget*)mainWindow); progress->setWindowModality(Qt::ApplicationModal); progress->setLabelText(tr("Pre-calcul des valeurs de VMG pour ")+fname); progress->setMaximum(600); progress->setMinimum(0); progress->setCancelButton(NULL); progress->setMaximumHeight(100); progress->show(); for (int tws=0;tws<601;tws++) { progress->setValue(tws); for (int twa=0;twa<1801;twa++) { bvmgWind((double) twa/10.0,(double) tws/10.0,&vmg); ssVmg.sprintf("%.4d",qRound(A360(vmg)*10.0)); sVmg<<ssVmg; } } fileVMG.close(); if(!fileVMG.open(QIODevice::ReadOnly | QIODevice::Text )) qWarning()<<"fileVMG could not be re-opened!"; progress->close(); delete progress; }
/* ----------------------------------------------------------------------- */ void SIMPLE_Agents::addRobotPhysics( const vector <double> &_pos, const vector <double> &_rot ){ mass = 0.150; btQuaternion rotation; rotation.setEulerZYX( 0.0, _rot[1], 0.0); btVector3 position = btVector3(_pos[0],robot_height * 0.65,_pos[2]); btMotionState* motion = new btDefaultMotionState(btTransform(rotation, position)); btCylinderShape* cylinder1=new btCylinderShape(btVector3(robot_radius,robot_height*0.5,robot_radius)); cylinder1->setMargin(robot_radius*0.5); btVector3 inertia(0.0,0.0,0.0); cylinder1->calculateLocalInertia(mass,inertia); btRigidBody::btRigidBodyConstructionInfo info(mass,motion,cylinder1,inertia); //info.m_restitution = 0.0f; info.m_friction = 0.5f; //info.m_rollingFriction = 0.1; body=new btRigidBody(info); body->setLinearFactor(btVector3(1,1,1)); body->setAngularFactor(btVector3(0,1,0)); body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK ); world->addRigidBody(body); btCylinderShape* wheel1 = new btCylinderShape(btVector3(wheel_radius,wheel_width,wheel_radius)); double mass1 = 0.15; btVector3 inertia1(0.0,0.0,0.0); wheel1->calculateLocalInertia(mass1,inertia1); btTransform t1; t1.setIdentity(); t1.setOrigin(btVector3(_pos[0], wheel_radius + pos[1], half_wheel_distance + pos[2])); btQuaternion rotation1; rotation1.setEulerZYX( 0.0, _rot[1], 1.57072428); t1.setRotation(rotation1); btMotionState* motion1=new btDefaultMotionState(t1); btRigidBody::btRigidBodyConstructionInfo info1(mass1,motion1,wheel1,inertia1); //info1.m_restitution = 0.0f; info1.m_friction = 0.45f; //info1.m_rollingFriction = 10.0; right_wheel=new btRigidBody(info1); world->addRigidBody(right_wheel); right_wheel->setLinearFactor(btVector3(1,1,1)); right_wheel->setAngularFactor(btVector3(1,1,1)); btVector3 axisA(0.f, 0.f, 1.0f); btVector3 axisB(0.f, 1.f, 0.f); btVector3 pivotA(0.f, -robot_height* 0.22, half_wheel_distance); btVector3 pivotB(0.0f, 0.0f, 0.0f); right_hinge = new btHingeConstraint(*body, *right_wheel, pivotA, pivotB, axisA, axisB); btJointFeedback* feedback1 = new btJointFeedback; feedback1->m_appliedForceBodyA = btVector3(0, 0, 0); feedback1->m_appliedForceBodyB = btVector3(0, 0, 0); feedback1->m_appliedTorqueBodyA = btVector3(0, 0, 0); feedback1->m_appliedTorqueBodyB = btVector3(0, 0, 0); right_hinge->setJointFeedback(feedback1); right_hinge->enableFeedback(true); right_hinge->setLimit(1,-1,1.0,0.3,1); right_hinge->enableAngularMotor(false, 0,0); //right_hinge->setOverrideNumSolverIterations(1000); world->addConstraint(right_hinge, true); btCylinderShape* wheel2 = new btCylinderShape(btVector3(wheel_radius,wheel_width,wheel_radius)); double mass2 = 0.15; btVector3 inertia2(0.0,0.0,0.0); wheel2->calculateLocalInertia(mass2,inertia2); btTransform t2; t2.setIdentity(); t2.setOrigin(btVector3(pos[0], wheel_radius + pos[1], half_wheel_distance + pos[2])); btQuaternion rotation2; rotation2.setEulerZYX( 0.0, _rot[1], 1.57072428); t2.setRotation(rotation2); btMotionState* motion2=new btDefaultMotionState(t2); //wheel2->setMargin(0.0); btRigidBody::btRigidBodyConstructionInfo info2(mass2,motion2,wheel2,inertia2); //info2.m_restitution = 0.0f; info2.m_friction = 0.45f; // info2.m_rollingFriction = 10.0; left_wheel=new btRigidBody(info2); right_wheel->setLinearFactor(btVector3(1,1,1)); right_wheel->setAngularFactor(btVector3(1,1,1)); world->addRigidBody(left_wheel); btVector3 axisA1(0.0f, 0.0f, 1.0f); btVector3 axisB1(0.0f, 1.0f, 0.0f); btVector3 pivotA1(0.f, -robot_height* 0.22,-half_wheel_distance); btVector3 pivotB1(0.0f, 0.0f, 0.0f); left_hinge = new btHingeConstraint(*body, *left_wheel, pivotA1, pivotB1, axisA1, axisB1); left_hinge->enableFeedback(true); btJointFeedback* feedback = new btJointFeedback; feedback->m_appliedForceBodyA = btVector3(0, 0, 0); feedback->m_appliedForceBodyB = btVector3(0, 0, 0); feedback->m_appliedTorqueBodyA = btVector3(0, 0, 0); feedback->m_appliedTorqueBodyB = btVector3(0, 0, 0); left_hinge->setJointFeedback(feedback); left_hinge->setLimit(1,-1,1.0,0.3,1); left_hinge->enableAngularMotor(false, 0,0); //left_hinge->setOverrideNumSolverIterations(1000); world->addConstraint(left_hinge, true); }
LoopTreeNode* DependenceHoisting:: Transform ( LoopTreeDepComp &comp, const CompSlice *slice, LoopTreeNode *h1) { bool alreadySliced = true; for (CompSlice::ConstLoopIterator iter = slice->GetConstLoopIterator(); iter.Current() != 0; iter.Advance()) { if (iter.Current() != h1) { alreadySliced = false; break; } } if (alreadySliced) return h1; SymbolicVar ivar = SliceLoopIvar( LoopTransformInterface::getAstInterface(), slice); SymbolicVal step = SliceLoopStep( slice).step; SymbolicBound bound = SliceLoopRange( slice, h1); LoopTreeNode *h2 = (step > 0)? comp.GetLoopTreeCreate()->CreateLoopNode(ivar,bound.lb,bound.ub,step) : comp.GetLoopTreeCreate()->CreateLoopNode(ivar,bound.ub,bound.lb,step); LoopTreeTransform().InsertLoop(h2, h1, -1); CompSlice::ConstStmtIterator stmtIter=slice->GetConstStmtIterator(); for (LoopTreeNode *stmt; (stmt = stmtIter.Current()); stmtIter++) { CompSlice::SliceStmtInfo info = stmtIter.CurrentInfo(); LoopTreeMergeStmtLoop()( h2, info.loop, stmt, info.align); } CompSlice::UpdateLoopIterator loopIter= slice->GetUpdateLoopIterator(); LoopTreeNode* loop; while ((loop = loopIter.Current())) { loopIter++; DepCompDistributeLoop()(comp,loop); } for (loopIter.Reset(); (loop = loopIter.Current()); loopIter++) { if (loopIter.CurrentInfo().stmtcount < CountEnclosedStmts(loop)){ CompSlice::SliceLoopInfo info = loopIter.CurrentInfo(); LoopTreeTraverseSelectStmt inStmts(loop); for (LoopTreeNode *s; (s = inStmts.Current()); ) { inStmts.Advance(); CompSlice::SliceStmtInfo info1(slice->QuerySliceStmtInfo(s)); if (info1.loop != loop) { DepRel r ( DEPDIR_LE, info1.align - info.minalign); DepRel r1 = comp.GetDomain(s).Entry(info1.loop->LoopLevel(), loop->LoopLevel()); DepRel r2 = r & r1; if (r2 != r1 && !r2.IsTop()) LoopTreeSplitStmt()( s, info1.loop, loop, r); } } DepCompDistributeLoop()(comp, loop); loop = loopIter.Current(); while (loopIter.CurrentInfo().stmtcount < CountEnclosedStmts(loop)) { while (loop->ChildCount() == 1) { LoopTreeNode* child = loop->FirstChild(); LoopTreeSwapNodePos()( loop, child); if (child->IncreaseLoopLevel()) break; } DepCompDistributeLoop()( comp, loop ); } } } OptimizeLoopTree(h2); return h2; }
void tst_QFileInfo::canonicalFilePath() { const QString fileName("tmp.canon"); QFile tempFile(fileName); QVERIFY(tempFile.open(QFile::WriteOnly)); QFileInfo fi(tempFile.fileName()); QCOMPARE(fi.canonicalFilePath(), QDir::currentPath() + "/" + fileName); tempFile.remove(); // This used to crash on Mac, verify that it doesn't anymore. QFileInfo info("/tmp/../../../../../../../../../../../../../../../../../"); info.canonicalFilePath(); #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) // This used to crash on Mac QFileInfo dontCrash(QLatin1String("/")); QCOMPARE(dontCrash.canonicalFilePath(), QLatin1String("/")); #endif #ifndef Q_OS_WIN // test symlinks QFile::remove("link.lnk"); { QFile file(SRCDIR "tst_qfileinfo.cpp"); if (file.link("link.lnk")) { QFileInfo info1(file); QFileInfo info2("link.lnk"); QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); } } # if !defined(Q_OS_SYMBIAN) // Symbian doesn't support links to directories { const QString link(QDir::tempPath() + QDir::separator() + "tst_qfileinfo"); QFile::remove(link); QFile file(QDir::currentPath()); if (file.link(link)) { QFile tempfile("tempfile.txt"); tempfile.open(QIODevice::ReadWrite); tempfile.write("This file is generated by the QFileInfo autotest."); QVERIFY(tempfile.flush()); tempfile.close(); QFileInfo info1("tempfile.txt"); QFileInfo info2(link + QDir::separator() + "tempfile.txt"); QVERIFY(info1.exists()); QVERIFY(info2.exists()); QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); QFileInfo info3(link + QDir::separator() + "link.lnk"); QFileInfo info4(SRCDIR "tst_qfileinfo.cpp"); QVERIFY(!info3.canonicalFilePath().isEmpty()); QCOMPARE(info4.canonicalFilePath(), info3.canonicalFilePath()); tempfile.remove(); } } { QString link(QDir::tempPath() + QDir::separator() + "tst_qfileinfo" + QDir::separator() + "link_to_tst_qfileinfo"); QFile::remove(link); QFile file(QDir::tempPath() + QDir::separator() + "tst_qfileinfo" + QDir::separator() + "tst_qfileinfo.cpp"); if (file.link(link)) { QFileInfo info1("tst_qfileinfo.cpp"); QFileInfo info2(link); QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); } } # endif #endif }