void InflationTermStructure::checkRange(Time t,
                                        bool extrapolate) const {
    QL_REQUIRE(t >= timeFromReference(baseDate()),
               "time (" << t << ") is before base date");
    QL_REQUIRE(extrapolate || allowsExtrapolation() || t <= maxTime(),
               "time (" << t << ") is past max curve time ("
               << maxTime() << ")");
}
Beispiel #2
0
 void TermStructure::checkRange(Time t,
                                bool extrapolate) const {
     QL_REQUIRE(t >= 0.0,
                "negative time (" << t << ") given");
     QL_REQUIRE(extrapolate || allowsExtrapolation()
                || t <= maxTime() || close_enough(t, maxTime()),
                "time (" << t << ") is past max curve time ("
                         << maxTime() << ")");
 }
 void YoYOptionletVolatilitySurface::checkRange(Time t, Rate strike,
                                         bool extrapolate) const {
     QL_REQUIRE(t >= timeFromReference(baseDate()),
                "time (" << t << ") is before base date");
     QL_REQUIRE(extrapolate || allowsExtrapolation() || t <= maxTime(),
                "time (" << t << ") is past max curve time ("
                << maxTime() << ")");
     QL_REQUIRE(extrapolate || allowsExtrapolation() ||
                (strike >= minStrike() && strike <= maxStrike()),
                "strike (" << strike << ") is outside the curve domain ["
                << minStrike() << "," << maxStrike()<< "] at time = " << t);
 }
fileIsSameDialog::fileIsSameDialog(QWidget *parent,QFileInfo fileInfo,QString firstRenamingRule,QString otherRenamingRule) :
	QDialog(parent),
	ui(new Ui::fileIsSameDialog)
{
	ui->setupUi(this);
	action=FileExists_Cancel;
	oldName=fileInfo.fileName();
	destinationInfo=fileInfo;
	ui->lineEditNewName->setText(oldName);
	ui->lineEditNewName->setPlaceholderText(oldName);
	ui->label_content_size->setText(QString::number(fileInfo.size()));
	ui->label_content_modified->setText(fileInfo.lastModified().toString());
	ui->label_content_file_name->setText(fileInfo.fileName());
	updateRenameButton();
	QDateTime maxTime(QDate(ULTRACOPIER_PLUGIN_MINIMALYEAR,1,1));
	if(maxTime<fileInfo.lastModified())
	{
		ui->label_modified->setVisible(true);
		ui->label_content_modified->setVisible(true);
		ui->label_content_modified->setText(fileInfo.lastModified().toString());
	}
	else
	{
		ui->label_modified->setVisible(false);
		ui->label_content_modified->setVisible(false);
	}
	this->firstRenamingRule=firstRenamingRule;
	this->otherRenamingRule=otherRenamingRule;
}
void QueueResourcesDialog::verify()
{
   QString time(m_dialog.walltime->text());
   bool ok(false);
   int n(time.toInt(&ok));
   if (ok) time += ":00:00";
   m_dialog.walltime->setText(time);

   if (m_timeValidator.validate(time, n) != QValidator::Acceptable) {
      QMsgBox::warning(this, "IQmol", "Wall time must be in the format h:mm:ss");
      return;
   }

   QueueResources* currentQueue((*m_queueResourcesList)[m_dialog.queue->currentIndex()]);
   QStringList requestedTime(time.split(":", QString::SkipEmptyParts));

   time = currentQueue->m_maxWallTime;
   QStringList maxTime(time.split(":", QString::SkipEmptyParts));

   if (requestedTime.size() < 3 || maxTime.size() < 3) {
      QMsgBox::warning(this, "IQmol", "Validated wall time not in the format h:mm:ss");
      return;
   }

   int t1, t2;
   t1  = requestedTime[0].toInt(&ok) * 60 * 60;
   t1 += requestedTime[1].toInt(&ok) * 60;
   t1 += requestedTime[2].toInt(&ok);
   t2  = maxTime[0].toInt(&ok) * 60 * 60;
   t2 += maxTime[1].toInt(&ok) * 60;
   t2 += maxTime[2].toInt(&ok);

   if (t1 > t2) {
      QMsgBox::warning(this, "IQmol", "Wall time exceeds queue maximum of " + time);
      return;
   }else if (m_dialog.memory->value() > currentQueue->m_maxMemory) {
      QMsgBox::warning(this, "IQmol", "Memory exceeds queue limit of " 
         + QString::number(currentQueue->m_maxMemory));
      return;
   }else if (m_dialog.scratch->value() > currentQueue->m_maxScratch) {
      QMsgBox::warning(this, "IQmol", "Scratch exceeds queue limit of " 
         + QString::number(currentQueue->m_maxScratch));
      return;
   }else if (m_dialog.ncpus->value() > currentQueue->m_maxCpus) {
      QMsgBox::warning(this, "IQmol", "Number of CPUs exceeds queue limit of " 
         + QString::number(currentQueue->m_maxCpus));
      return;
   }

   saveAsDefaults();
   accept();
}
T Spline<T>::sample(float time, bool loop) const
{
	if (loop)
	{
		time = fmod(time, maxTime());
	}
	findKey(time);
	float factor = (time - m_times[m_lastKey]) / (m_times[m_lastKey + 1] - m_times[m_lastKey]);
	return sampleCubicBezier(m_keys[m_lastKey],
							 m_knots[m_lastKey * 2],
							 m_knots[m_lastKey * 2 + 1],
							 m_keys[m_lastKey + 1],
							 factor);
}
QVariant Cache::load(QString name, QString *error)
{
	error->clear();
	
	// If the name is in the cache,
	if (recent().contains(name)) {
		QVariantMap result;
		recent().removeOne(name);
		recent().prepend(name);
		
		// If the data is not loaded,
		if (!data().contains(name)) {
			// Load the data
			QByteArray array = read_file(directory() + '/' + name.replace('/', '-'), error);
			if (!error->isEmpty()) return QVariant();
			
			bool ok;
			QJson::Parser parser;
			result = parser.parse(array, &ok).toMap();
			if (!ok) {
				*error = INVALID_JSON + parser.errorString();
				return QVariant();
			}
			
			this->data()[name] = result;
 		} else {
			result = this->data()[name].toMap();
		}
 		
 		//qDebug() << "Saved:" << result["time"].toDateTime();
		//qDebug() << "Now:" << QDateTime::currentDateTime();
		
		//qDebug() << "Data exists in cache:" << name;
 		
		// If the data is current,
		if (maxTime() == 0 || result["time"].toDateTime().msecsTo(QDateTime::currentDateTime()) < maxTime()) {
			// Return the data
			return result["data"];
		} else { // Otherwise,	
			// Return no data, with error "Outdated data"
			*error = OUTDATED_DATA;
			return result["data"];
		}
	} else { // Otherwise,
		//qDebug() << "Data not in cache:" << name;
		// Return no data, with error "No data in cache"
		*error = NO_DATA;
		return QVariant();
	}
}
FileIsSameDialog::FileIsSameDialog(QWidget *parent,QFileInfo fileInfo,QString firstRenamingRule,QString otherRenamingRule) :
    QDialog(parent),
    ui(new Ui::fileIsSameDialog)
{
    Qt::WindowFlags flags = windowFlags();
    #ifdef Q_OS_LINUX
    flags=flags & ~Qt::X11BypassWindowManagerHint;
    #endif
    flags=flags | Qt::WindowStaysOnTopHint;
    setWindowFlags(flags);

    ui->setupUi(this);
    action=FileExists_Cancel;
    oldName=TransferThread::resolvedName(fileInfo);
    destinationInfo=fileInfo;
    ui->lineEditNewName->setText(oldName);
    ui->lineEditNewName->setPlaceholderText(oldName);
    ui->label_content_size->setText(QString::number(fileInfo.size()));
    ui->label_content_modified->setText(fileInfo.lastModified().toString());
    ui->label_content_file_name->setText(TransferThread::resolvedName(fileInfo));
    QString folder=fileInfo.absolutePath();
    if(folder.size()>80)
        folder=folder.mid(0,38)+"..."+folder.mid(folder.size()-38);
    ui->label_content_folder->setText(folder);
    updateRenameButton();
    QDateTime maxTime(QDate(ULTRACOPIER_PLUGIN_MINIMALYEAR,1,1));
    if(maxTime<fileInfo.lastModified())
    {
        ui->label_modified->setVisible(true);
        ui->label_content_modified->setVisible(true);
        ui->label_content_modified->setText(fileInfo.lastModified().toString());
    }
    else
    {
        ui->label_modified->setVisible(false);
        ui->label_content_modified->setVisible(false);
    }
    if(!fileInfo.exists())
    {
        ui->label_content_size->setVisible(false);
        ui->label_size->setVisible(false);
        ui->label_modified->setVisible(false);
        ui->label_content_modified->setVisible(false);
    }
    this->firstRenamingRule=firstRenamingRule;
    this->otherRenamingRule=otherRenamingRule;
    on_SuggestNewName_clicked();
}
Beispiel #9
0
void
UiSettings::loadSettings()
{
    QSettings s( "CS224", "snow" );

    windowPosition() = s.value( "windowPosition", QPoint(0,0) ).toPoint();
    windowSize() = s.value( "windowSize", QSize(1000,800) ).toSize();

    fillNumParticles() = s.value( "fillNumParticles", 512*128 ).toInt();
    fillResolution() = s.value( "fillResolution", 0.05f ).toFloat();
    fillDensity() = s.value( "fillDensity", 150.f ).toFloat();

    exportDensity() = s.value("exportDensity", false).toBool();
    exportVelocity() = s.value("exportVelocity", false).toBool();

    exportFPS() = s.value("exportFPS", 24).toInt();
    maxTime() = s.value("maxTime", 3).toFloat();

    gridPosition() = vec3( s.value("gridPositionX", 0.f).toFloat(),
                           s.value("gridPositionY", 0.f).toFloat(),
                           s.value("gridPositionZ", 0.f).toFloat() );


    gridDimensions() = glm::ivec3( s.value("gridDimensionX", 128).toInt(),
                                   s.value("gridDimensionY", 128).toInt(),
                                   s.value("gridDimensionZ", 128).toInt() );

    gridResolution() = s.value( "gridResolution", 0.05f ).toFloat();

    timeStep() = s.value( "timeStep", 1e-5 ).toFloat();
    implicit() = s.value( "implicit", true ).toBool();
    materialPreset() = s.value( "materialPreset", MAT_DEFAULT).toInt();

    showContainers() = s.value( "showContainers", true ).toBool();
    showContainersMode() = s.value( "showContainersMode", WIREFRAME ).toInt();
    showColliders() = s.value( "showColliders", true ).toBool();
    showCollidersMode() = s.value( "showCollidersMode", SOLID ).toInt();
    showGrid() = s.value( "showGrid", false ).toBool();
    showGridMode() = s.value( "showGridMode", MIN_FACE_CELLS ).toInt();
    showGridData() = s.value( "showGridData", false ).toBool();
    showGridDataMode() = s.value( "showGridDataMode", NODE_DENSITY ).toInt();
    showParticles() = s.value( "showParticles", true ).toBool();
    showParticlesMode() = s.value( "showParticlesMode", PARTICLE_MASS ).toInt();

    selectionColor() = glm::vec4( 0.302f, 0.773f, 0.839f, 1.f );
}
DiscountFactor ClonedYieldTermStructure::discountImpl(Time t) const {
    QL_REQUIRE(valid_, "termstructure not valid, evaluation date ("
                           << Settings::instance().evaluationDate()
                           << ") is before the evaluation date when the "
                              "termstructure was frozen ("
                           << originalEvalDate_);
    Time tMax = maxTime();
    Time tEff = t + offset_;
    if (tEff < tMax) {
        // also ok for offset_ = 0
        return interpolate(tEff) /
               interpolate(offset_);
    }

    // flat fwd extrapolation
    DiscountFactor dMax = std::exp(logDiscounts_.back());
    return dMax * std::exp(-instFwdMax_ * (tEff - tMax));
}
Beispiel #11
0
void
UiSettings::saveSettings()
{
    QSettings s( "CS224", "snow" );

    s.setValue( "windowPosition", windowPosition() );
    s.setValue( "windowSize", windowSize() );

    s.setValue( "fillNumParticles", fillNumParticles() );
    s.setValue( "fillResolution", fillResolution() );
    s.setValue( "fillDensity", fillDensity() );

    s.setValue("exportDensity", exportDensity());
    s.setValue("exportVelocity",exportVelocity());
    s.setValue( "exportFPS", exportFPS());
    s.setValue( "maxTime", maxTime());

    s.setValue( "gridPositionX", gridPosition().x );
    s.setValue( "gridPositionY", gridPosition().y );
    s.setValue( "gridPositionZ", gridPosition().z );

    s.setValue( "gridDimensionX", gridDimensions().x );
    s.setValue( "gridDimensionY", gridDimensions().y );
    s.setValue( "gridDimensionZ", gridDimensions().z );

    s.setValue( "gridResolution", gridResolution() );

    s.setValue( "timeStep", timeStep() );
    s.setValue( "implicit", implicit() );
    s.setValue("materialPreset", materialPreset());

    s.setValue( "showContainers", showContainers() );
    s.setValue( "showContainersMode", showContainersMode() );
    s.setValue( "showColliders", showColliders() );
    s.setValue( "showCollidersMode", showCollidersMode() );
    s.setValue( "showGrid", showGrid() );
    s.setValue( "showGridMode", showGridMode() );
    s.setValue( "showGridData", showGridData() );
    s.setValue( "showGridDataMode", showGridDataMode() );
    s.setValue( "showParticles", showParticles() );
    s.setValue( "showParticlesMode", showParticlesMode() );
}
Beispiel #12
0
fileErrorDialog::fileErrorDialog(QWidget *parent,QFileInfo fileInfo,QString errorString,bool havePutAtTheEndButton) :
	QDialog(parent),
	ui(new Ui::fileErrorDialog)
{
	ui->setupUi(this);
	action=FileError_Cancel;
	ui->label_error->setText(errorString);
	ui->label_content_file_name->setText(fileInfo.fileName());
	if(fileInfo.exists())
	{
		ui->label_content_size->setText(QString::number(fileInfo.size()));
		QDateTime maxTime(QDate(ULTRACOPIER_PLUGIN_MINIMALYEAR,1,1));
		if(maxTime<fileInfo.lastModified())
		{
			ui->label_modified->setVisible(true);
			ui->label_content_modified->setVisible(true);
			ui->label_content_modified->setText(fileInfo.lastModified().toString());
		}
		else
		{
			ui->label_modified->setVisible(false);
			ui->label_content_modified->setVisible(false);
		}
		if(fileInfo.isDir())
		{
			this->setWindowTitle(tr("Error on folder"));
			ui->label_size->hide();
			ui->label_content_size->hide();
			ui->label_file_name->setText(tr("Folder name"));
		}
	}
	else
	{
		ui->label_size->hide();
		ui->label_content_size->hide();
		ui->label_modified->hide();
		ui->label_content_modified->hide();
	}
	if(!havePutAtTheEndButton)
		ui->PutToBottom->hide();
}
Beispiel #13
0
void CalendarWidget::draw()
{
    ofFill();
    ofSetColor(0, 200);

    ofDrawRectangle(_window);

    std::string formatStringHourMin = "%h:%M %A";
    std::string formatStringHour = "%h:%M";
    std::string formatStringHourMinSec = "%h:%M:%S %A";

    Poco::LocalDateTime minTime(_windowInterval.getStart());
    Poco::LocalDateTime maxTime(_windowInterval.getEnd());

    Poco::LocalDateTime startQuarter = Utils::ceiling(minTime, Poco::Timespan::MINUTES * 5);

    ofPushMatrix();
    ofTranslate(_window.getPosition());

    std::vector<Poco::Timestamp> hours = Utils::getInstances(startQuarter.utc().timestamp(),
                                                             maxTime.utc().timestamp(),
                                                             Period(Period::MINUTE, 5));

    std::vector<Poco::Timestamp>::const_iterator hourIter = hours.begin();

    while (hourIter != hours.end())
    {
        Poco::DateTime time = Poco::DateTime(*hourIter);

        int y = _window.getHeight() * _windowInterval.map(time.timestamp());

        int minute = time.minute();

        float alpha = ofMap(std::abs(_windowInterval.map(time.timestamp()) - 0.5), 0, .2, .25, 1, true);

        if (0 == minute)
        {
            ofSetColor(255, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }
        else if (0 == minute % 15)
        {
            ofSetColor(255, 255, 0, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }
        else
        {
            ofSetColor(127, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }

        std::string label = Utils::format(Poco::LocalDateTime(time), formatStringHourMinSec);

        int width = _font.stringWidth(label);
        int height = _font.stringHeight(label);

        if (y - height - 4 > 0)
        {
            _font.drawString(label, _window.getWidth() - width - 4, y - 4);
        }

        ++hourIter;
    }

    int y = _window.getHeight() * _windowInterval.map(_now);

    ofSetColor(255);
    ofDrawLine(0, y, _window.getWidth(), y);

    std::string label = Utils::format(Poco::LocalDateTime(_now), formatStringHourMinSec);

    int width = _font.stringWidth(label);

    _font.drawString(label, _window.getWidth() - width - 4, y - 4);

    std::sort(_currentEvents.begin(), _currentEvents.end());


    ICalendar::EventInstances::const_iterator iter = _currentEvents.begin();

    int x = 0;

    while (iter != _currentEvents.end())
    {
        const ICalendarEvent& event = (*iter).getEvent();
        const Interval& interval = (*iter).getInterval();

        if (_windowInterval.intersects(interval))
        {
            int y0 = _window.getHeight() * _windowInterval.map(interval.getStart());
            int y1 = _window.getHeight() * _windowInterval.map(interval.getEnd());

            ofFill();
            ofSetColor(255, 50);

            if (interval.contains(_now))
            {
                ofSetColor(255, 255, 0, 50);
            }
            else
            {
                ofSetColor(255, 50);
            }


            ofDrawRectRounded(x, y0, 80, y1 - y0, 5);

            ofNoFill();
            ofSetColor(127);
            ofDrawRectRounded(x, y0, 80, y1 - y0, 5);

            ofSetColor(255);
            ofDrawRectRounded(x-1, y0-1, 80+2, y1 - y0+2, 5);


            std::string startLabel = Utils::format(Poco::LocalDateTime(interval.getStart()), formatStringHour);
            std::string endLabel = Utils::format(Poco::LocalDateTime(interval.getEnd()), formatStringHour);

            ofFill();
            ofSetColor(255);
            _font.drawString(event.getSummary(), x + 5, y0 + 10);
            _font.drawString(startLabel,         x + 5, y0 + 20);
            _font.drawString(endLabel,           x + 5, y0 + 30);
            
            x+= 84;
            
            if (x > _window.getWidth() - 160) x = 0;
            
        }
        
        ++iter;
    }
    
    ofPopMatrix();
}
Beispiel #14
0
 TimeBase TimeBase::MaxTime()
 {
   return maxTime();
 }
FileErrorDialog::FileErrorDialog(QWidget *parent, QFileInfo fileInfo, std::string errorString, const ErrorType &errorType) :
    QDialog(parent),
    ui(new Ui::fileErrorDialog)
{
    Qt::WindowFlags flags = windowFlags();
    #ifdef Q_OS_LINUX
    flags=flags & ~Qt::X11BypassWindowManagerHint;
    #endif
    flags=flags | Qt::WindowStaysOnTopHint;
    setWindowFlags(flags);

    ui->setupUi(this);
    action=FileError_Cancel;
    ui->label_error->setText(QString::fromStdString(errorString));
    if(fileInfo.exists())
    {
        ui->label_content_file_name->setText(QString::fromStdString(TransferThread::resolvedName(fileInfo)));
        if(ui->label_content_file_name->text().isEmpty())
        {
            ui->label_content_file_name->setText(fileInfo.absoluteFilePath());
            ui->label_folder->setVisible(false);
            ui->label_content_folder->setVisible(false);
        }
        else
        {
            QString folder=fileInfo.absolutePath();
            if(folder.size()>80)
                folder=folder.mid(0,38)+"..."+folder.mid(folder.size()-38);
            ui->label_content_folder->setText(fileInfo.absolutePath());
        }
        ui->label_content_size->setText(QString::number(fileInfo.size()));
        QDateTime maxTime(QDate(ULTRACOPIER_PLUGIN_MINIMALYEAR,1,1));
        if(maxTime<fileInfo.lastModified())
        {
            ui->label_modified->setVisible(true);
            ui->label_content_modified->setVisible(true);
            ui->label_content_modified->setText(fileInfo.lastModified().toString());
        }
        else
        {
            ui->label_modified->setVisible(false);
            ui->label_content_modified->setVisible(false);
        }
        if(fileInfo.isDir())
        {
            this->setWindowTitle(tr("Error on folder"));
            ui->label_size->hide();
            ui->label_content_size->hide();
            ui->label_file_name->setText(tr("Folder name"));
        }
        ui->label_file_destination->setVisible(fileInfo.isSymLink());
        ui->label_content_file_destination->setVisible(fileInfo.isSymLink());
        if(fileInfo.isSymLink())
            ui->label_content_file_destination->setText(fileInfo.symLinkTarget());
    }
    else
    {
        ui->label_content_file_name->setText(QString::fromStdString(TransferThread::resolvedName(fileInfo)));
        if(ui->label_content_file_name->text().isEmpty())
        {
            ui->label_content_file_name->setText(fileInfo.absoluteFilePath());
            ui->label_folder->setVisible(false);
            ui->label_content_folder->setVisible(false);
        }
        else
            ui->label_content_folder->setText(fileInfo.absolutePath());

        ui->label_file_destination->hide();
        ui->label_content_file_destination->hide();
        ui->label_size->hide();
        ui->label_content_size->hide();
        ui->label_modified->hide();
        ui->label_content_modified->hide();
    }
    if(errorType==ErrorType_Folder || errorType==ErrorType_FolderWithRety)
        ui->PutToBottom->hide();
    if(errorType==ErrorType_Folder)
        ui->Retry->hide();

    ui->Rights->hide();
    #ifdef ULTRACOPIER_PLUGIN_RIGHTS
        if(isInAdmin)
            ui->Rights->hide();
        #ifdef Q_OS_WIN32
        if(errorType!=ErrorType_Rights)
            ui->Rights->hide();
        #else
        ui->Rights->hide();
        #endif
    #else
        ui->Rights->hide();
    #endif
}