示例#1
0
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value)
{
    ASSERT(type <= LengthTypePC);

    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    m_valueInSpecifiedUnits = value;
}
示例#2
0
void SVGLength::setValueAsString(const String& string, ExceptionCode& ec)
{
    if (string.isEmpty())
        return;

    float convertedNumber = 0;
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
    const UChar* ptr = upconvertedCharacters;
    const UChar* end = ptr + string.length();

    if (!parseNumber(ptr, end, convertedNumber, false)) {
        ec = SYNTAX_ERR;
        return;
    }

    SVGLengthType type = stringToLengthType(ptr, end);
    ASSERT(ptr <= end);
    if (type == LengthTypeUnknown) {
        ec = SYNTAX_ERR;
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
}
示例#3
0
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return;

    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    m_valueInSpecifiedUnits = value;
}
示例#4
0
void SVGLength::convertToSpecifiedUnits(unsigned short type)
{
    ASSERT(type <= LengthTypePC);

    float valueInUserUnits = value();
    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    setValue(valueInUserUnits);
}
示例#5
0
void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return;

    float valueInUserUnits = value(context);
    m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type);
    setValue(valueInUserUnits);
}
示例#6
0
ExceptionOr<void> SVGLengthValue::newValueSpecifiedUnits(unsigned short type, float value)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return Exception { NOT_SUPPORTED_ERR };

    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    m_valueInSpecifiedUnits = value;
    return { };
}
示例#7
0
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionCode& ec)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        ec = NOT_SUPPORTED_ERR;
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    m_valueInSpecifiedUnits = value;
}
示例#8
0
void SVGLength::setValue(float value, const SVGLengthContext& context, ExceptionState& exceptionState)
{
    // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
    if (extractType(m_unit) == LengthTypePercentage)
        value = value / 100;

    float convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit), exceptionState);
    if (!exceptionState.hadException())
        m_valueInSpecifiedUnits = convertedValue;
}
示例#9
0
void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionState& exceptionState)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
    m_valueInSpecifiedUnits = value;
}
示例#10
0
ExceptionOr<void> SVGLengthValue::setValue(float value, const SVGLengthContext& context)
{
    // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
    if (extractType(m_unit) == LengthTypePercentage)
        value = value / 100;

    auto convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit));
    if (convertedValue.hasException())
        return convertedValue.releaseException();
    m_valueInSpecifiedUnits = convertedValue.releaseReturnValue();
    return { };
}
示例#11
0
void SVGLength::setValueAsString(const String& s)
{
    if (s.isEmpty())
        return;

    double convertedNumber = 0;
    const UChar* ptr = s.characters();
    const UChar* end = ptr + s.length();
    parseNumber(ptr, end, convertedNumber, false);

    m_unit = storeUnit(extractMode(m_unit), stringToLengthType(s));
    m_valueInSpecifiedUnits = narrowPrecisionToFloat(convertedNumber);
}
示例#12
0
ExceptionOr<void> SVGLengthValue::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context)
{
    if (type == LengthTypeUnknown || type > LengthTypePC)
        return Exception { NOT_SUPPORTED_ERR };

    auto valueInUserUnits = valueForBindings(context);
    if (valueInUserUnits.hasException())
        return valueInUserUnits.releaseException();

    auto originalUnitAndType = m_unit;
    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    auto result = setValue(valueInUserUnits.releaseReturnValue(), context);
    if (result.hasException()) {
        m_unit = originalUnitAndType;
        return result.releaseException();
    }

    return { };
}
示例#13
0
bool SVGLength::setValueAsString(const String& s)
{
    if (s.isEmpty())
        return false;

    float convertedNumber = 0.0f;
    const UChar* ptr = s.characters();
    const UChar* end = ptr + s.length();

    if (!parseNumber(ptr, end, convertedNumber, false))
        return false;

    SVGLengthType type = stringToLengthType(ptr, end);
    if (type == LengthTypeUnknown)
        return false;

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
    return true;
}
示例#14
0
void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context, ExceptionState& exceptionState)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
        return;
    }

    float valueInUserUnits = value(context, exceptionState);
    if (exceptionState.hadException())
        return;

    unsigned int originalUnitAndType = m_unit;
    m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
    setValue(valueInUserUnits, context, exceptionState);
    if (!exceptionState.hadException())
        return;

    // Eventually restore old unit and type
    m_unit = originalUnitAndType;
}
示例#15
0
void SVGLength::setValueAsString(const String& string, ExceptionState& exceptionState)
{
    if (string.isEmpty())
        return;

    float convertedNumber = 0;
    SVGLengthType type = LengthTypeUnknown;

    bool success = string.is8Bit() ?
        parseValueInternal<LChar>(string, convertedNumber, type) :
        parseValueInternal<UChar>(string, convertedNumber, type);

    if (!success) {
        exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
}
示例#16
0
void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context, ExceptionCode& ec)
{
    if (type == LengthTypeUnknown || type > LengthTypePC) {
        ec = NOT_SUPPORTED_ERR;
        return;
    }

    float valueInUserUnits = value(context, ec);
    if (ec)
        return;

    unsigned int originalUnitAndType = m_unit;    
    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
    setValue(valueInUserUnits, context, ec);
    if (!ec)
        return;

    // Eventually restore old unit and type
    m_unit = originalUnitAndType;
}
示例#17
0
ExceptionOr<void> SVGLengthValue::setValueAsString(const String& string)
{
    if (string.isEmpty())
        return { };

    float convertedNumber = 0;
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
    const UChar* ptr = upconvertedCharacters;
    const UChar* end = ptr + string.length();

    if (!parseNumber(ptr, end, convertedNumber, false))
        return Exception { SYNTAX_ERR };

    auto type = parseLengthType(ptr, end);
    if (type == LengthTypeUnknown)
        return Exception { SYNTAX_ERR };

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
    return { };
}
示例#18
0
float SVGLength::convertValueFromPercentageToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const
{
    float width = 0;
    float height = 0;
    if (!determineViewport(context, width, height)) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    switch (extractMode(m_unit)) {
    case LengthModeWidth:
        return value * width;
    case LengthModeHeight:
        return value * height;
    case LengthModeOther:
        return value * sqrtf((width * width + height * height) / 2);
    };

    ASSERT_NOT_REACHED();
    return 0;
}
GridDisplay::GridDisplay(int winSize, Tracklist *tracklist, Grid* grid_, QWidget *parent)
: MyDisplay(tracklist, parent), _winSize(winSize)
{
	this->grid_ = grid_;
	_cellSize = grid_->getCellSize(_winSize);
	setMinimumSize(winSize, winSize);
	setMouseTracking(true);
	setAcceptDrops(true);
	squareHasInitialized.resize(grid_->getHeight() * grid_->getWidth());
	for(int i = 0; i < grid_->getHeight() * grid_->getWidth(); i++)
		squareHasInitialized[i] = false;
	oldXPos = -1;
	oldYPos = -1;
	oldX1Pos = -1;
	oldY1Pos = -1;
	fullScreenMouseOn = false;
	initDone = false;
	fullScreenTimer = new QTimer(this);
	fullScreenTimer->setInterval(150);
	colourMapMode_ = false;


	connect(this, SIGNAL(clearMode()), grid_, SLOT(clearMode()));
	connect(this, SIGNAL(extractMode()), grid_, SLOT(setExtractMode()));
	connect(this, SIGNAL(trainMode()), grid_, SLOT(setTrainMode()));
	connect(this, SIGNAL(predictMode()), grid_, SLOT(setPredictMode()));
	connect(this, SIGNAL(initMode()), grid_, SLOT(setInitMode()));
	connect(this, SIGNAL(savePredictionGridSignal(QString)), grid_, SLOT(savePredictionGrid(QString)));
	connect(this, SIGNAL(openPredictionGridSignal(QString)), grid_, SLOT(openPredictionGrid(QString)));
	connect(grid_, SIGNAL(repaintSignal()), this, SLOT(repaintSlot()));
	connect(this, SIGNAL(cancelButtonPressed()), grid_, SLOT(cancelPressed()));
	connect(this, SIGNAL(hashLoadPressed()), grid_, SLOT(openHash()));
	connect(fullScreenTimer, SIGNAL(timeout()), this, SLOT(fullScreenMouseMove()));
	connect(grid_, SIGNAL(errorBox(QString)), this, SLOT(showErrorMessage(QString)));
	connect(this, SIGNAL(resetGridAction()), grid_, SLOT(resetGridSlot()));
}
示例#20
0
ExceptionOr<float> SVGLengthValue::valueForBindings(const SVGLengthContext& context) const
{
    return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit));
}
示例#21
0
float SVGLength::value(const SVGLengthContext& context, ExceptionState& exceptionState) const
{
    return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit), exceptionState);
}
示例#22
0
SVGLengthMode SVGLength::unitMode() const
{
    return extractMode(m_unit);
}
void GridDisplay::extract()
{
	cout << "extract" <<endl;
	emit extractMode();
	grid_->buttonPressed.wakeAll();
}
示例#24
0
float SVGLength::value() const
{
    SVGLengthType type = extractType(m_unit);
    if (type == LengthTypeUnknown)
        return 0.0f;

    switch (type) {
    case LengthTypeNumber:
        return m_valueInSpecifiedUnits;
    case LengthTypePercentage:
        return SVGLength::PercentageOfViewport(m_valueInSpecifiedUnits / 100.0f, m_context, extractMode(m_unit));
    case LengthTypeEMS:
    case LengthTypeEXS:
    {
        RenderStyle* style = 0;
        if (m_context && m_context->renderer())
            style = m_context->renderer()->style();
        if (style) {
            float useSize = style->fontSize();
            ASSERT(useSize > 0);
            if (type == LengthTypeEMS)
                return m_valueInSpecifiedUnits * useSize;
            else {
                float xHeight = style->font().xHeight();
                // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
                // if this causes problems in real world cases maybe it would be best to remove this
                return m_valueInSpecifiedUnits * ceilf(xHeight);
            }
        }
        return 0.0f;
    }
    case LengthTypePX:
        return m_valueInSpecifiedUnits;
    case LengthTypeCM:
        return m_valueInSpecifiedUnits / 2.54f * cssPixelsPerInch;
    case LengthTypeMM:
        return m_valueInSpecifiedUnits / 25.4f * cssPixelsPerInch;
    case LengthTypeIN:
        return m_valueInSpecifiedUnits * cssPixelsPerInch;
    case LengthTypePT:
        return m_valueInSpecifiedUnits / 72.0f * cssPixelsPerInch;
    case LengthTypePC:
        return m_valueInSpecifiedUnits / 6.0f * cssPixelsPerInch;
    default:
        break;
    }

    ASSERT_NOT_REACHED();
    return 0.0f;
}