forked from qt-creator/qt-creator
ModelEditor: Apply naming convention to variables
This change applies the naming convention to function parameters and local variables. Change-Id: Ifa495c70520923f14ba6791513d3691bfa7694f6 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -66,9 +66,9 @@ ConfigController::~ConfigController()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigController::setStereotypeController(StereotypeController *stereotype_controller)
|
void ConfigController::setStereotypeController(StereotypeController *stereotypeController)
|
||||||
{
|
{
|
||||||
d->m_stereotypeController = stereotype_controller;
|
d->m_stereotypeController = stereotypeController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigController::readStereotypeDefinitions(const QString &path)
|
void ConfigController::readStereotypeDefinitions(const QString &path)
|
||||||
@@ -79,8 +79,8 @@ void ConfigController::readStereotypeDefinitions(const QString &path)
|
|||||||
|
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
dir.setNameFilters(QStringList() << QStringLiteral("*.def"));
|
dir.setNameFilters(QStringList() << QStringLiteral("*.def"));
|
||||||
foreach (const QString &file_name, dir.entryList(QDir::Files)) {
|
foreach (const QString &fileName, dir.entryList(QDir::Files)) {
|
||||||
QFile file(QFileInfo(dir, file_name).absoluteFilePath());
|
QFile file(QFileInfo(dir, fileName).absoluteFilePath());
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
QString text = QString::fromUtf8(file.readAll());
|
QString text = QString::fromUtf8(file.readAll());
|
||||||
file.close();
|
file.close();
|
||||||
@@ -99,9 +99,9 @@ void ConfigController::readStereotypeDefinitions(const QString &path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigController::onStereotypeIconParsed(const StereotypeIcon &stereotype_icon)
|
void ConfigController::onStereotypeIconParsed(const StereotypeIcon &stereotypeIcon)
|
||||||
{
|
{
|
||||||
d->m_stereotypeController->addStereotypeIcon(stereotype_icon);
|
d->m_stereotypeController->addStereotypeIcon(stereotypeIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigController::onToolbarParsed(const Toolbar &toolbar)
|
void ConfigController::onToolbarParsed(const Toolbar &toolbar)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setStereotypeController(StereotypeController *stereotype_controller);
|
void setStereotypeController(StereotypeController *stereotypeController);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onStereotypeIconParsed(const StereotypeIcon &stereotype_icon);
|
void onStereotypeIconParsed(const StereotypeIcon &stereotypeIcon);
|
||||||
|
|
||||||
void onToolbarParsed(const Toolbar &toolbar);
|
void onToolbarParsed(const Toolbar &toolbar);
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ SourcePos::SourcePos()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SourcePos::SourcePos(int source_id, int line_number, int column_number)
|
SourcePos::SourcePos(int sourceId, int lineNumber, int columnNumber)
|
||||||
: m_sourceId(source_id),
|
: m_sourceId(sourceId),
|
||||||
m_lineNumber(line_number),
|
m_lineNumber(lineNumber),
|
||||||
m_columnNumber(column_number)
|
m_columnNumber(columnNumber)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
SourcePos();
|
SourcePos();
|
||||||
|
|
||||||
SourcePos(int source_id, int line_number, int column_number = -1);
|
SourcePos(int sourceId, int lineNumber, int columnNumber = -1);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ QHash<T, U> operator<<(QHash<T, U> hash, QPair<T, U> pair) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StereotypeDefinitionParserError::StereotypeDefinitionParserError(const QString &error_msg, const SourcePos &source_pos)
|
StereotypeDefinitionParserError::StereotypeDefinitionParserError(const QString &errorMsg, const SourcePos &sourcePos)
|
||||||
: Exception(error_msg),
|
: Exception(errorMsg),
|
||||||
m_sourcePos(source_pos)
|
m_sourcePos(sourcePos)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -145,8 +145,8 @@ StereotypeDefinitionParser::~StereotypeDefinitionParser()
|
|||||||
|
|
||||||
void StereotypeDefinitionParser::parse(ITextSource *source)
|
void StereotypeDefinitionParser::parse(ITextSource *source)
|
||||||
{
|
{
|
||||||
TextScanner text_scanner;
|
TextScanner textScanner;
|
||||||
text_scanner.setKeywords(
|
textScanner.setKeywords(
|
||||||
QList<QPair<QString, int> >()
|
QList<QPair<QString, int> >()
|
||||||
<< qMakePair(QString(QStringLiteral("icon")), KEYWORD_ICON)
|
<< qMakePair(QString(QStringLiteral("icon")), KEYWORD_ICON)
|
||||||
<< qMakePair(QString(QStringLiteral("title")), KEYWORD_TITLE)
|
<< qMakePair(QString(QStringLiteral("title")), KEYWORD_TITLE)
|
||||||
@@ -178,7 +178,7 @@ void StereotypeDefinitionParser::parse(ITextSource *source)
|
|||||||
<< qMakePair(QString(QStringLiteral("tool")), KEYWORD_TOOL)
|
<< qMakePair(QString(QStringLiteral("tool")), KEYWORD_TOOL)
|
||||||
<< qMakePair(QString(QStringLiteral("separator")), KEYWORD_SEPARATOR)
|
<< qMakePair(QString(QStringLiteral("separator")), KEYWORD_SEPARATOR)
|
||||||
);
|
);
|
||||||
text_scanner.setOperators(
|
textScanner.setOperators(
|
||||||
QList<QPair<QString, int> >()
|
QList<QPair<QString, int> >()
|
||||||
<< qMakePair(QString(QStringLiteral(";")), OPERATOR_SEMICOLON)
|
<< qMakePair(QString(QStringLiteral(";")), OPERATOR_SEMICOLON)
|
||||||
<< qMakePair(QString(QStringLiteral(":")), OPERATOR_COLON)
|
<< qMakePair(QString(QStringLiteral(":")), OPERATOR_COLON)
|
||||||
@@ -186,9 +186,9 @@ void StereotypeDefinitionParser::parse(ITextSource *source)
|
|||||||
<< qMakePair(QString(QStringLiteral(".")), OPERATOR_PERIOD)
|
<< qMakePair(QString(QStringLiteral(".")), OPERATOR_PERIOD)
|
||||||
<< qMakePair(QString(QStringLiteral("-")), OPERATOR_MINUS)
|
<< qMakePair(QString(QStringLiteral("-")), OPERATOR_MINUS)
|
||||||
);
|
);
|
||||||
text_scanner.setSource(source);
|
textScanner.setSource(source);
|
||||||
|
|
||||||
d->m_scanner = &text_scanner;
|
d->m_scanner = &textScanner;
|
||||||
try {
|
try {
|
||||||
parseFile();
|
parseFile();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@@ -227,22 +227,22 @@ void StereotypeDefinitionParser::parseIcon()
|
|||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.getSourcePos());
|
||||||
}
|
}
|
||||||
QString id = token.getText();
|
QString id = token.getText();
|
||||||
StereotypeIcon stereotype_icon;
|
StereotypeIcon stereotypeIcon;
|
||||||
stereotype_icon.setId(id);
|
stereotypeIcon.setId(id);
|
||||||
parseIconProperties(&stereotype_icon);
|
parseIconProperties(&stereotypeIcon);
|
||||||
token = readNextToken();
|
token = readNextToken();
|
||||||
if (token.getType() != Token::TOKEN_KEYWORD || token.getSubtype() != KEYWORD_BEGIN) {
|
if (token.getType() != Token::TOKEN_KEYWORD || token.getSubtype() != KEYWORD_BEGIN) {
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'begin'."), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'begin'."), token.getSourcePos());
|
||||||
}
|
}
|
||||||
parseIconCommands(&stereotype_icon);
|
parseIconCommands(&stereotypeIcon);
|
||||||
token = readNextToken();
|
token = readNextToken();
|
||||||
if (token.getType() != Token::TOKEN_KEYWORD || token.getSubtype() != KEYWORD_END) {
|
if (token.getType() != Token::TOKEN_KEYWORD || token.getSubtype() != KEYWORD_END) {
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'end'."), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'end'."), token.getSourcePos());
|
||||||
}
|
}
|
||||||
emit iconParsed(stereotype_icon);
|
emit iconParsed(stereotypeIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDefinitionParser::parseIconProperties(StereotypeIcon *stereotype_icon)
|
void StereotypeDefinitionParser::parseIconProperties(StereotypeIcon *stereotypeIcon)
|
||||||
{
|
{
|
||||||
Token token;
|
Token token;
|
||||||
bool loop = true;
|
bool loop = true;
|
||||||
@@ -255,24 +255,24 @@ void StereotypeDefinitionParser::parseIconProperties(StereotypeIcon *stereotype_
|
|||||||
} else {
|
} else {
|
||||||
switch (token.getSubtype()) {
|
switch (token.getSubtype()) {
|
||||||
case KEYWORD_TITLE:
|
case KEYWORD_TITLE:
|
||||||
stereotype_icon->setTitle(parseStringProperty());
|
stereotypeIcon->setTitle(parseStringProperty());
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_ELEMENTS:
|
case KEYWORD_ELEMENTS:
|
||||||
{
|
{
|
||||||
QList<QString> identifiers = parseIdentifierListProperty();
|
QList<QString> identifiers = parseIdentifierListProperty();
|
||||||
foreach (const QString &identifier, identifiers) {
|
foreach (const QString &identifier, identifiers) {
|
||||||
static QHash<QString, StereotypeIcon::Element> element_names = QHash<QString, StereotypeIcon::Element>()
|
static QHash<QString, StereotypeIcon::Element> elementNames = QHash<QString, StereotypeIcon::Element>()
|
||||||
<< qMakePair(QString(QStringLiteral("package")), StereotypeIcon::ELEMENT_PACKAGE)
|
<< qMakePair(QString(QStringLiteral("package")), StereotypeIcon::ELEMENT_PACKAGE)
|
||||||
<< qMakePair(QString(QStringLiteral("component")), StereotypeIcon::ELEMENT_COMPONENT)
|
<< qMakePair(QString(QStringLiteral("component")), StereotypeIcon::ELEMENT_COMPONENT)
|
||||||
<< qMakePair(QString(QStringLiteral("class")), StereotypeIcon::ELEMENT_CLASS)
|
<< qMakePair(QString(QStringLiteral("class")), StereotypeIcon::ELEMENT_CLASS)
|
||||||
<< qMakePair(QString(QStringLiteral("diagram")), StereotypeIcon::ELEMENT_DIAGRAM)
|
<< qMakePair(QString(QStringLiteral("diagram")), StereotypeIcon::ELEMENT_DIAGRAM)
|
||||||
<< qMakePair(QString(QStringLiteral("item")), StereotypeIcon::ELEMENT_ITEM);
|
<< qMakePair(QString(QStringLiteral("item")), StereotypeIcon::ELEMENT_ITEM);
|
||||||
QString element_name = identifier.toLower();
|
QString elementName = identifier.toLower();
|
||||||
if (!element_names.contains(element_name)) {
|
if (!elementNames.contains(elementName)) {
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(identifier), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(identifier), token.getSourcePos());
|
||||||
}
|
}
|
||||||
elements.insert(element_names.value(element_name));
|
elements.insert(elementNames.value(elementName));
|
||||||
}
|
}
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
@@ -282,75 +282,75 @@ void StereotypeDefinitionParser::parseIconProperties(StereotypeIcon *stereotype_
|
|||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_WIDTH:
|
case KEYWORD_WIDTH:
|
||||||
stereotype_icon->setWidth(parseFloatProperty());
|
stereotypeIcon->setWidth(parseFloatProperty());
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_HEIGHT:
|
case KEYWORD_HEIGHT:
|
||||||
stereotype_icon->setHeight(parseFloatProperty());
|
stereotypeIcon->setHeight(parseFloatProperty());
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_MINWIDTH:
|
case KEYWORD_MINWIDTH:
|
||||||
stereotype_icon->setMinWidth(parseFloatProperty());
|
stereotypeIcon->setMinWidth(parseFloatProperty());
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_MINHEIGHT:
|
case KEYWORD_MINHEIGHT:
|
||||||
stereotype_icon->setMinHeight(parseFloatProperty());
|
stereotypeIcon->setMinHeight(parseFloatProperty());
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_LOCK_SIZE:
|
case KEYWORD_LOCK_SIZE:
|
||||||
{
|
{
|
||||||
QString lock_value = parseIdentifierProperty();
|
QString lockValue = parseIdentifierProperty();
|
||||||
QString lock_name = lock_value.toLower();
|
QString lockName = lockValue.toLower();
|
||||||
static QHash<QString, StereotypeIcon::SizeLock> lock_names = QHash<QString, StereotypeIcon::SizeLock>()
|
static QHash<QString, StereotypeIcon::SizeLock> lockNames = QHash<QString, StereotypeIcon::SizeLock>()
|
||||||
<< qMakePair(QString(QStringLiteral("none")), StereotypeIcon::LOCK_NONE)
|
<< qMakePair(QString(QStringLiteral("none")), StereotypeIcon::LOCK_NONE)
|
||||||
<< qMakePair(QString(QStringLiteral("width")), StereotypeIcon::LOCK_WIDTH)
|
<< qMakePair(QString(QStringLiteral("width")), StereotypeIcon::LOCK_WIDTH)
|
||||||
<< qMakePair(QString(QStringLiteral("height")), StereotypeIcon::LOCK_HEIGHT)
|
<< qMakePair(QString(QStringLiteral("height")), StereotypeIcon::LOCK_HEIGHT)
|
||||||
<< qMakePair(QString(QStringLiteral("size")), StereotypeIcon::LOCK_SIZE)
|
<< qMakePair(QString(QStringLiteral("size")), StereotypeIcon::LOCK_SIZE)
|
||||||
<< qMakePair(QString(QStringLiteral("ratio")), StereotypeIcon::LOCK_RATIO);
|
<< qMakePair(QString(QStringLiteral("ratio")), StereotypeIcon::LOCK_RATIO);
|
||||||
if (lock_names.contains(lock_name)) {
|
if (lockNames.contains(lockName)) {
|
||||||
StereotypeIcon::SizeLock size_lock = lock_names.value(lock_name);
|
StereotypeIcon::SizeLock sizeLock = lockNames.value(lockName);
|
||||||
stereotype_icon->setSizeLock(size_lock);
|
stereotypeIcon->setSizeLock(sizeLock);
|
||||||
} else {
|
} else {
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for size lock.")).arg(lock_value), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for size lock.")).arg(lockValue), token.getSourcePos());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEYWORD_DISPLAY:
|
case KEYWORD_DISPLAY:
|
||||||
{
|
{
|
||||||
QString display_value = parseIdentifierProperty();
|
QString displayValue = parseIdentifierProperty();
|
||||||
QString display_name = display_value.toLower();
|
QString displayName = displayValue.toLower();
|
||||||
static QHash<QString, StereotypeIcon::Display> display_names = QHash<QString, StereotypeIcon::Display>()
|
static QHash<QString, StereotypeIcon::Display> displayNames = QHash<QString, StereotypeIcon::Display>()
|
||||||
<< qMakePair(QString(QStringLiteral("none")), StereotypeIcon::DISPLAY_NONE)
|
<< qMakePair(QString(QStringLiteral("none")), StereotypeIcon::DISPLAY_NONE)
|
||||||
<< qMakePair(QString(QStringLiteral("label")), StereotypeIcon::DISPLAY_LABEL)
|
<< qMakePair(QString(QStringLiteral("label")), StereotypeIcon::DISPLAY_LABEL)
|
||||||
<< qMakePair(QString(QStringLiteral("decoration")), StereotypeIcon::DISPLAY_DECORATION)
|
<< qMakePair(QString(QStringLiteral("decoration")), StereotypeIcon::DISPLAY_DECORATION)
|
||||||
<< qMakePair(QString(QStringLiteral("icon")), StereotypeIcon::DISPLAY_ICON)
|
<< qMakePair(QString(QStringLiteral("icon")), StereotypeIcon::DISPLAY_ICON)
|
||||||
<< qMakePair(QString(QStringLiteral("smart")), StereotypeIcon::DISPLAY_SMART);
|
<< qMakePair(QString(QStringLiteral("smart")), StereotypeIcon::DISPLAY_SMART);
|
||||||
if (display_names.contains(display_name)) {
|
if (displayNames.contains(displayName)) {
|
||||||
StereotypeIcon::Display display = display_names.value(display_name);
|
StereotypeIcon::Display display = displayNames.value(displayName);
|
||||||
stereotype_icon->setDisplay(display);
|
stereotypeIcon->setDisplay(display);
|
||||||
} else {
|
} else {
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for stereotype display.")).arg(display_value), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for stereotype display.")).arg(displayValue), token.getSourcePos());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEYWORD_TEXTALIGN:
|
case KEYWORD_TEXTALIGN:
|
||||||
{
|
{
|
||||||
QString align_value = parseIdentifierProperty();
|
QString alignValue = parseIdentifierProperty();
|
||||||
QString align_name = align_value.toLower();
|
QString alignName = alignValue.toLower();
|
||||||
static QHash<QString, StereotypeIcon::TextAlignment> align_names = QHash<QString, StereotypeIcon::TextAlignment>()
|
static QHash<QString, StereotypeIcon::TextAlignment> alignNames = QHash<QString, StereotypeIcon::TextAlignment>()
|
||||||
<< qMakePair(QString(QStringLiteral("below")), StereotypeIcon::TEXTALIGN_BELOW)
|
<< qMakePair(QString(QStringLiteral("below")), StereotypeIcon::TEXTALIGN_BELOW)
|
||||||
<< qMakePair(QString(QStringLiteral("center")), StereotypeIcon::TEXTALIGN_CENTER)
|
<< qMakePair(QString(QStringLiteral("center")), StereotypeIcon::TEXTALIGN_CENTER)
|
||||||
<< qMakePair(QString(QStringLiteral("none")), StereotypeIcon::TEXTALIGN_NONE);
|
<< qMakePair(QString(QStringLiteral("none")), StereotypeIcon::TEXTALIGN_NONE);
|
||||||
if (align_names.contains(align_name)) {
|
if (alignNames.contains(alignName)) {
|
||||||
StereotypeIcon::TextAlignment text_alignment = align_names.value(align_name);
|
StereotypeIcon::TextAlignment textAlignment = alignNames.value(alignName);
|
||||||
stereotype_icon->setTextAlignment(text_alignment);
|
stereotypeIcon->setTextAlignment(textAlignment);
|
||||||
} else {
|
} else {
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for text alignment.")).arg(align_value), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for text alignment.")).arg(alignValue), token.getSourcePos());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEYWORD_BASECOLOR:
|
case KEYWORD_BASECOLOR:
|
||||||
stereotype_icon->setBaseColor(parseColorProperty());
|
stereotypeIcon->setBaseColor(parseColorProperty());
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -359,8 +359,8 @@ void StereotypeDefinitionParser::parseIconProperties(StereotypeIcon *stereotype_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stereotype_icon->setElements(elements);
|
stereotypeIcon->setElements(elements);
|
||||||
stereotype_icon->setStereotypes(stereotypes);
|
stereotypeIcon->setStereotypes(stereotypes);
|
||||||
d->m_scanner->unread(token);
|
d->m_scanner->unread(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,11 +464,11 @@ QColor StereotypeDefinitionParser::parseColorProperty()
|
|||||||
return parseColorExpression();
|
return parseColorExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDefinitionParser::parseIconCommands(StereotypeIcon *stereotype_icon)
|
void StereotypeDefinitionParser::parseIconCommands(StereotypeIcon *stereotypeIcon)
|
||||||
{
|
{
|
||||||
Token token;
|
Token token;
|
||||||
bool loop = true;
|
bool loop = true;
|
||||||
IconShape icon_shape;
|
IconShape iconShape;
|
||||||
QList<ShapeValueF> parameters;
|
QList<ShapeValueF> parameters;
|
||||||
|
|
||||||
typedef QList<IconCommandParameter> Parameters;
|
typedef QList<IconCommandParameter> Parameters;
|
||||||
@@ -484,67 +484,67 @@ void StereotypeDefinitionParser::parseIconCommands(StereotypeIcon *stereotype_ic
|
|||||||
switch (token.getSubtype()) {
|
switch (token.getSubtype()) {
|
||||||
case KEYWORD_CIRCLE:
|
case KEYWORD_CIRCLE:
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED);
|
||||||
icon_shape.addCircle(ShapePointF(parameters.at(0), parameters.at(1)), parameters.at(2));
|
iconShape.addCircle(ShapePointF(parameters.at(0), parameters.at(1)), parameters.at(2));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_ELLIPSE:
|
case KEYWORD_ELLIPSE:
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
|
||||||
icon_shape.addEllipse(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)));
|
iconShape.addEllipse(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_LINE:
|
case KEYWORD_LINE:
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
|
||||||
icon_shape.addLine(ShapePointF(parameters.at(0), parameters.at(1)), ShapePointF(parameters.at(2), parameters.at(3)));
|
iconShape.addLine(ShapePointF(parameters.at(0), parameters.at(1)), ShapePointF(parameters.at(2), parameters.at(3)));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_RECT:
|
case KEYWORD_RECT:
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
|
||||||
icon_shape.addRect(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)));
|
iconShape.addRect(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_ROUNDEDRECT:
|
case KEYWORD_ROUNDEDRECT:
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << FIX);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << FIX);
|
||||||
icon_shape.addRoundedRect(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), parameters.at(4));
|
iconShape.addRoundedRect(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), parameters.at(4));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_ARC:
|
case KEYWORD_ARC:
|
||||||
{
|
{
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
|
||||||
qreal start_angle = expectAbsoluteValue(parameters.at(4), d->m_scanner->getSourcePos());
|
qreal startAngle = expectAbsoluteValue(parameters.at(4), d->m_scanner->getSourcePos());
|
||||||
qreal span_angle = expectAbsoluteValue(parameters.at(5), d->m_scanner->getSourcePos());
|
qreal spanAngle = expectAbsoluteValue(parameters.at(5), d->m_scanner->getSourcePos());
|
||||||
icon_shape.addArc(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), start_angle, span_angle);
|
iconShape.addArc(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, spanAngle);
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEYWORD_MOVETO:
|
case KEYWORD_MOVETO:
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED);
|
||||||
icon_shape.moveTo(ShapePointF(parameters.at(0), parameters.at(1)));
|
iconShape.moveTo(ShapePointF(parameters.at(0), parameters.at(1)));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_LINETO:
|
case KEYWORD_LINETO:
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED);
|
||||||
icon_shape.lineTo(ShapePointF(parameters.at(0), parameters.at(1)));
|
iconShape.lineTo(ShapePointF(parameters.at(0), parameters.at(1)));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
case KEYWORD_ARCMOVETO:
|
case KEYWORD_ARCMOVETO:
|
||||||
{
|
{
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE);
|
||||||
qreal angle = expectAbsoluteValue(parameters.at(4), d->m_scanner->getSourcePos());
|
qreal angle = expectAbsoluteValue(parameters.at(4), d->m_scanner->getSourcePos());
|
||||||
icon_shape.arcMoveTo(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), angle);
|
iconShape.arcMoveTo(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), angle);
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEYWORD_ARCTO:
|
case KEYWORD_ARCTO:
|
||||||
{
|
{
|
||||||
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
|
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
|
||||||
qreal start_angle = expectAbsoluteValue(parameters.at(4), d->m_scanner->getSourcePos());
|
qreal startAngle = expectAbsoluteValue(parameters.at(4), d->m_scanner->getSourcePos());
|
||||||
qreal sweep_length = expectAbsoluteValue(parameters.at(5), d->m_scanner->getSourcePos());
|
qreal sweepLength = expectAbsoluteValue(parameters.at(5), d->m_scanner->getSourcePos());
|
||||||
icon_shape.arcTo(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), start_angle, sweep_length);
|
iconShape.arcTo(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, sweepLength);
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEYWORD_CLOSE:
|
case KEYWORD_CLOSE:
|
||||||
icon_shape.closePath();
|
iconShape.closePath();
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -553,7 +553,7 @@ void StereotypeDefinitionParser::parseIconCommands(StereotypeIcon *stereotype_ic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stereotype_icon->setIconShape(icon_shape);
|
stereotypeIcon->setIconShape(iconShape);
|
||||||
d->m_scanner->unread(token);
|
d->m_scanner->unread(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,25 +594,25 @@ void StereotypeDefinitionParser::parseToolbarCommands(Toolbar *toolbar)
|
|||||||
switch (token.getSubtype()) {
|
switch (token.getSubtype()) {
|
||||||
case KEYWORD_TOOL:
|
case KEYWORD_TOOL:
|
||||||
{
|
{
|
||||||
QString tool_name = parseStringExpression();
|
QString toolName = parseStringExpression();
|
||||||
expectComma();
|
expectComma();
|
||||||
QString element = parseIdentifierExpression();
|
QString element = parseIdentifierExpression();
|
||||||
static QSet<QString> element_names = QSet<QString>()
|
static QSet<QString> elementNames = QSet<QString>()
|
||||||
<< QStringLiteral("package")
|
<< QStringLiteral("package")
|
||||||
<< QStringLiteral("component")
|
<< QStringLiteral("component")
|
||||||
<< QStringLiteral("class")
|
<< QStringLiteral("class")
|
||||||
<< QStringLiteral("item")
|
<< QStringLiteral("item")
|
||||||
<< QStringLiteral("annotation")
|
<< QStringLiteral("annotation")
|
||||||
<< QStringLiteral("boundary");
|
<< QStringLiteral("boundary");
|
||||||
QString element_name = element.toLower();
|
QString elementName = element.toLower();
|
||||||
if (!element_names.contains(element_name)) {
|
if (!elementNames.contains(elementName)) {
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(element), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(element), token.getSourcePos());
|
||||||
}
|
}
|
||||||
QString stereotype;
|
QString stereotype;
|
||||||
if (nextIsComma()) {
|
if (nextIsComma()) {
|
||||||
stereotype = parseStringExpression();
|
stereotype = parseStringExpression();
|
||||||
}
|
}
|
||||||
tools.append(Toolbar::Tool(tool_name, element, stereotype));
|
tools.append(Toolbar::Tool(toolName, element, stereotype));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -727,10 +727,10 @@ Token StereotypeDefinitionParser::readNextToken()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal StereotypeDefinitionParser::expectAbsoluteValue(const ShapeValueF &value, const SourcePos &source_pos)
|
qreal StereotypeDefinitionParser::expectAbsoluteValue(const ShapeValueF &value, const SourcePos &sourcePos)
|
||||||
{
|
{
|
||||||
if (value.getUnit() != ShapeValueF::UNIT_ABSOLUTE || value.getOrigin() != ShapeValueF::ORIGIN_SMART) {
|
if (value.getUnit() != ShapeValueF::UNIT_ABSOLUTE || value.getOrigin() != ShapeValueF::ORIGIN_SMART) {
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected absolute value"), source_pos);
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected absolute value"), sourcePos);
|
||||||
}
|
}
|
||||||
return value.getValue();
|
return value.getValue();
|
||||||
}
|
}
|
||||||
@@ -753,11 +753,11 @@ bool StereotypeDefinitionParser::nextIsComma()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDefinitionParser::expectOperator(int op, const QString &op_name)
|
void StereotypeDefinitionParser::expectOperator(int op, const QString &opName)
|
||||||
{
|
{
|
||||||
Token token = d->m_scanner->read();
|
Token token = d->m_scanner->read();
|
||||||
if (token.getType() != Token::TOKEN_OPERATOR || token.getSubtype() != op) {
|
if (token.getType() != Token::TOKEN_OPERATOR || token.getSubtype() != op) {
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Expected '%1'.")).arg(op_name), token.getSourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Expected '%1'.")).arg(opName), token.getSourcePos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class QMT_EXPORT StereotypeDefinitionParserError :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StereotypeDefinitionParserError(const QString &error_msg, const SourcePos &source_pos);
|
StereotypeDefinitionParserError(const QString &errorMsg, const SourcePos &sourcePos);
|
||||||
|
|
||||||
~StereotypeDefinitionParserError();
|
~StereotypeDefinitionParserError();
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void iconParsed(const StereotypeIcon &stereotype_icon);
|
void iconParsed(const StereotypeIcon &stereotypeIcon);
|
||||||
|
|
||||||
void toolbarParsed(const Toolbar &toolbar);
|
void toolbarParsed(const Toolbar &toolbar);
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ private:
|
|||||||
|
|
||||||
void parseIcon();
|
void parseIcon();
|
||||||
|
|
||||||
void parseIconProperties(StereotypeIcon *stereotype_icon);
|
void parseIconProperties(StereotypeIcon *stereotypeIcon);
|
||||||
|
|
||||||
void parseToolbar();
|
void parseToolbar();
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ private:
|
|||||||
|
|
||||||
QColor parseColorProperty();
|
QColor parseColorProperty();
|
||||||
|
|
||||||
void parseIconCommands(StereotypeIcon *stereotype_icon);
|
void parseIconCommands(StereotypeIcon *stereotypeIcon);
|
||||||
|
|
||||||
QList<ShapeValueF> parseIconCommandParameters(const QList<IconCommandParameter> ¶meters);
|
QList<ShapeValueF> parseIconCommandParameters(const QList<IconCommandParameter> ¶meters);
|
||||||
|
|
||||||
@@ -133,13 +133,13 @@ private:
|
|||||||
|
|
||||||
Token readNextToken();
|
Token readNextToken();
|
||||||
|
|
||||||
qreal expectAbsoluteValue(const ShapeValueF &value, const SourcePos &source_pos);
|
qreal expectAbsoluteValue(const ShapeValueF &value, const SourcePos &sourcePos);
|
||||||
|
|
||||||
void expectSemicolonOrEndOfLine();
|
void expectSemicolonOrEndOfLine();
|
||||||
|
|
||||||
bool nextIsComma();
|
bool nextIsComma();
|
||||||
|
|
||||||
void expectOperator(int op, const QString &op_name);
|
void expectOperator(int op, const QString &opName);
|
||||||
|
|
||||||
void expectComma();
|
void expectComma();
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ void StringTextSource::setText(const QString &text)
|
|||||||
m_columnNumber = 1;
|
m_columnNumber = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringTextSource::setSourceId(int source_id)
|
void StringTextSource::setSourceId(int sourceId)
|
||||||
{
|
{
|
||||||
m_sourceId = source_id;
|
m_sourceId = sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceChar StringTextSource::readNextChar()
|
SourceChar StringTextSource::readNextChar()
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
int getSourceId() const { return m_sourceId; }
|
int getSourceId() const { return m_sourceId; }
|
||||||
|
|
||||||
void setSourceId(int source_id);
|
void setSourceId(int sourceId);
|
||||||
|
|
||||||
// ITextSource interface
|
// ITextSource interface
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ typedef QPair<QString, int> DefTuple;
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
TextScannerError::TextScannerError(const QString &error_msg, const SourcePos &source_pos)
|
TextScannerError::TextScannerError(const QString &errorMsg, const SourcePos &sourcePos)
|
||||||
: Exception(error_msg),
|
: Exception(errorMsg),
|
||||||
m_sourcePos(source_pos)
|
m_sourcePos(sourcePos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,9 +110,9 @@ void TextScanner::setOperators(const QList<QPair<QString, int> > &operators)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextScanner::setSource(ITextSource *text_source)
|
void TextScanner::setSource(ITextSource *textSource)
|
||||||
{
|
{
|
||||||
d->m_source = text_source;
|
d->m_source = textSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourcePos TextScanner::getSourcePos() const
|
SourcePos TextScanner::getSourcePos() const
|
||||||
@@ -126,23 +126,23 @@ Token TextScanner::read()
|
|||||||
return d->m_unreadTokens.pop();
|
return d->m_unreadTokens.pop();
|
||||||
}
|
}
|
||||||
skipWhitespaces();
|
skipWhitespaces();
|
||||||
SourceChar source_char = readChar();
|
SourceChar sourceChar = readChar();
|
||||||
if (source_char.ch == QLatin1Char('\'') || source_char.ch == QLatin1Char('\"')) {
|
if (sourceChar.ch == QLatin1Char('\'') || sourceChar.ch == QLatin1Char('\"')) {
|
||||||
return scanString(source_char);
|
return scanString(sourceChar);
|
||||||
} else if (source_char.ch.isDigit()) {
|
} else if (sourceChar.ch.isDigit()) {
|
||||||
return scanNumber(source_char);
|
return scanNumber(sourceChar);
|
||||||
} else if (source_char.ch.isLetter() || source_char.ch == QLatin1Char('_')) {
|
} else if (sourceChar.ch.isLetter() || sourceChar.ch == QLatin1Char('_')) {
|
||||||
return scanIdentifier(source_char);
|
return scanIdentifier(sourceChar);
|
||||||
} else if (source_char.ch == QLatin1Char('#')) {
|
} else if (sourceChar.ch == QLatin1Char('#')) {
|
||||||
return scanColorIdentifier(source_char);
|
return scanColorIdentifier(sourceChar);
|
||||||
} else if (source_char.ch == QChar::LineFeed || source_char.ch == QChar::CarriageReturn) {
|
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn) {
|
||||||
return Token(Token::TOKEN_ENDOFLINE, QString(), source_char.pos);
|
return Token(Token::TOKEN_ENDOFLINE, QString(), sourceChar.pos);
|
||||||
} else if (source_char.ch.isNull()) {
|
} else if (sourceChar.ch.isNull()) {
|
||||||
return Token(Token::TOKEN_ENDOFINPUT, QString(), source_char.pos);
|
return Token(Token::TOKEN_ENDOFINPUT, QString(), sourceChar.pos);
|
||||||
} else if (d->m_operatorFirstCharsSet.contains(source_char.ch)) {
|
} else if (d->m_operatorFirstCharsSet.contains(sourceChar.ch)) {
|
||||||
return scanOperator(source_char);
|
return scanOperator(sourceChar);
|
||||||
} else {
|
} else {
|
||||||
throw TextScannerError(QStringLiteral("Unexpected character."), source_char.pos);
|
throw TextScannerError(QStringLiteral("Unexpected character."), sourceChar.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,158 +163,158 @@ SourceChar TextScanner::readChar()
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextScanner::unreadChar(const SourceChar &source_char)
|
void TextScanner::unreadChar(const SourceChar &sourceChar)
|
||||||
{
|
{
|
||||||
d->m_unreadSourceChars.push(source_char);
|
d->m_unreadSourceChars.push(sourceChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextScanner::skipWhitespaces()
|
void TextScanner::skipWhitespaces()
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
SourceChar source_char = readChar();
|
SourceChar sourceChar = readChar();
|
||||||
if (source_char.ch == QLatin1Char('/')) {
|
if (sourceChar.ch == QLatin1Char('/')) {
|
||||||
SourceChar second_source_char = readChar();
|
SourceChar secondSourceChar = readChar();
|
||||||
if (second_source_char.ch == QLatin1Char('/')) {
|
if (secondSourceChar.ch == QLatin1Char('/')) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
SourceChar comment_char = readChar();
|
SourceChar commentChar = readChar();
|
||||||
if (comment_char.ch.isNull() || comment_char.ch == QChar::LineFeed || comment_char.ch == QChar::CarriageReturn) {
|
if (commentChar.ch.isNull() || commentChar.ch == QChar::LineFeed || commentChar.ch == QChar::CarriageReturn) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unreadChar(second_source_char);
|
unreadChar(secondSourceChar);
|
||||||
unreadChar(source_char);
|
unreadChar(sourceChar);
|
||||||
}
|
}
|
||||||
} else if (source_char.ch == QChar::LineFeed || source_char.ch == QChar::CarriageReturn || !source_char.ch.isSpace()) {
|
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn || !sourceChar.ch.isSpace()) {
|
||||||
unreadChar(source_char);
|
unreadChar(sourceChar);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Token TextScanner::scanString(const SourceChar &delimiter_char)
|
Token TextScanner::scanString(const SourceChar &delimiterChar)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
SourceChar source_char = readChar();
|
SourceChar sourceChar = readChar();
|
||||||
if (source_char.ch == delimiter_char.ch) {
|
if (sourceChar.ch == delimiterChar.ch) {
|
||||||
return Token(Token::TOKEN_STRING, text, delimiter_char.pos);
|
return Token(Token::TOKEN_STRING, text, delimiterChar.pos);
|
||||||
} else if (source_char.ch == QLatin1Char('\\')) {
|
} else if (sourceChar.ch == QLatin1Char('\\')) {
|
||||||
source_char = readChar();
|
sourceChar = readChar();
|
||||||
if (source_char.ch == QLatin1Char('n')) {
|
if (sourceChar.ch == QLatin1Char('n')) {
|
||||||
text += QLatin1Char('\n');
|
text += QLatin1Char('\n');
|
||||||
} else if (source_char.ch == QLatin1Char('\\')) {
|
} else if (sourceChar.ch == QLatin1Char('\\')) {
|
||||||
text += QLatin1Char('\\');
|
text += QLatin1Char('\\');
|
||||||
} else if (source_char.ch == QLatin1Char('t')) {
|
} else if (sourceChar.ch == QLatin1Char('t')) {
|
||||||
text += QLatin1Char('\t');
|
text += QLatin1Char('\t');
|
||||||
} else if (source_char.ch == QLatin1Char('\"')) {
|
} else if (sourceChar.ch == QLatin1Char('\"')) {
|
||||||
text += QLatin1Char('\"');
|
text += QLatin1Char('\"');
|
||||||
} else if (source_char.ch == QLatin1Char('\'')) {
|
} else if (sourceChar.ch == QLatin1Char('\'')) {
|
||||||
text += QLatin1Char('\'');
|
text += QLatin1Char('\'');
|
||||||
} else {
|
} else {
|
||||||
throw TextScannerError(QStringLiteral("Unexpected character after '\\' in string constant."), source_char.pos);
|
throw TextScannerError(QStringLiteral("Unexpected character after '\\' in string constant."), sourceChar.pos);
|
||||||
}
|
}
|
||||||
} else if (source_char.ch == QChar::LineFeed || source_char.ch == QChar::CarriageReturn) {
|
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn) {
|
||||||
throw TextScannerError(QStringLiteral("Unexpected end of line in string constant."), source_char.pos);
|
throw TextScannerError(QStringLiteral("Unexpected end of line in string constant."), sourceChar.pos);
|
||||||
} else {
|
} else {
|
||||||
text += source_char.ch;
|
text += sourceChar.ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Token TextScanner::scanNumber(const SourceChar &first_digit)
|
Token TextScanner::scanNumber(const SourceChar &firstDigit)
|
||||||
{
|
{
|
||||||
QString text = first_digit.ch;
|
QString text = firstDigit.ch;
|
||||||
SourceChar source_char;
|
SourceChar sourceChar;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
source_char = readChar();
|
sourceChar = readChar();
|
||||||
if (!source_char.ch.isDigit()) {
|
if (!sourceChar.ch.isDigit()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
text += source_char.ch;
|
text += sourceChar.ch;
|
||||||
}
|
}
|
||||||
if (source_char.ch == QLatin1Char('.')) {
|
if (sourceChar.ch == QLatin1Char('.')) {
|
||||||
text += source_char.ch;
|
text += sourceChar.ch;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
source_char = readChar();
|
sourceChar = readChar();
|
||||||
if (!source_char.ch.isDigit()) {
|
if (!sourceChar.ch.isDigit()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
text += source_char.ch;
|
text += sourceChar.ch;
|
||||||
}
|
}
|
||||||
unreadChar(source_char);
|
unreadChar(sourceChar);
|
||||||
return Token(Token::TOKEN_FLOAT, text, first_digit.pos);
|
return Token(Token::TOKEN_FLOAT, text, firstDigit.pos);
|
||||||
} else {
|
} else {
|
||||||
unreadChar(source_char);
|
unreadChar(sourceChar);
|
||||||
return Token(Token::TOKEN_INTEGER, text, first_digit.pos);
|
return Token(Token::TOKEN_INTEGER, text, firstDigit.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Token TextScanner::scanIdentifier(const SourceChar &first_char)
|
Token TextScanner::scanIdentifier(const SourceChar &firstChar)
|
||||||
{
|
{
|
||||||
QString text = first_char.ch;
|
QString text = firstChar.ch;
|
||||||
SourceChar source_char;
|
SourceChar sourceChar;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
source_char = readChar();
|
sourceChar = readChar();
|
||||||
if (!source_char.ch.isLetterOrNumber() && source_char.ch != QLatin1Char('_')) {
|
if (!sourceChar.ch.isLetterOrNumber() && sourceChar.ch != QLatin1Char('_')) {
|
||||||
unreadChar(source_char);
|
unreadChar(sourceChar);
|
||||||
QString keyword = text.toLower();
|
QString keyword = text.toLower();
|
||||||
if (d->m_keywordToSubtypeMap.contains(keyword)) {
|
if (d->m_keywordToSubtypeMap.contains(keyword)) {
|
||||||
return Token(Token::TOKEN_KEYWORD, d->m_keywordToSubtypeMap.value(keyword), text, first_char.pos);
|
return Token(Token::TOKEN_KEYWORD, d->m_keywordToSubtypeMap.value(keyword), text, firstChar.pos);
|
||||||
}
|
}
|
||||||
return Token(Token::TOKEN_IDENTIFIER, text, first_char.pos);
|
return Token(Token::TOKEN_IDENTIFIER, text, firstChar.pos);
|
||||||
}
|
}
|
||||||
text += source_char.ch;
|
text += sourceChar.ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Token TextScanner::scanColorIdentifier(const SourceChar &first_char)
|
Token TextScanner::scanColorIdentifier(const SourceChar &firstChar)
|
||||||
{
|
{
|
||||||
QString text = first_char.ch;
|
QString text = firstChar.ch;
|
||||||
SourceChar source_char;
|
SourceChar sourceChar;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
source_char = readChar();
|
sourceChar = readChar();
|
||||||
QChar ch = source_char.ch.toLower();
|
QChar ch = sourceChar.ch.toLower();
|
||||||
if (!(ch.isDigit() || (ch >= QLatin1Char('a') && ch <= QLatin1Char('f')))) {
|
if (!(ch.isDigit() || (ch >= QLatin1Char('a') && ch <= QLatin1Char('f')))) {
|
||||||
unreadChar(source_char);
|
unreadChar(sourceChar);
|
||||||
return Token(Token::TOKEN_COLOR, text, first_char.pos);
|
return Token(Token::TOKEN_COLOR, text, firstChar.pos);
|
||||||
}
|
}
|
||||||
text += source_char.ch;
|
text += sourceChar.ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Token TextScanner::scanOperator(const SourceChar &first_char)
|
Token TextScanner::scanOperator(const SourceChar &firstChar)
|
||||||
{
|
{
|
||||||
QString text = first_char.ch;
|
QString text = firstChar.ch;
|
||||||
SourceChar source_char;
|
SourceChar sourceChar;
|
||||||
QStack<SourceChar> extra_chars;
|
QStack<SourceChar> extraChars;
|
||||||
bool have_operator = false;
|
bool haveOperator = false;
|
||||||
int operator_length = 0;
|
int operatorLength = 0;
|
||||||
int subtype = 0;
|
int subtype = 0;
|
||||||
QString op;
|
QString op;
|
||||||
extra_chars.push(first_char);
|
extraChars.push(firstChar);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (d->m_operatorToSubtypeMap.contains(text)) {
|
if (d->m_operatorToSubtypeMap.contains(text)) {
|
||||||
have_operator = true;
|
haveOperator = true;
|
||||||
operator_length = text.length();
|
operatorLength = text.length();
|
||||||
subtype = d->m_operatorToSubtypeMap.value(text);
|
subtype = d->m_operatorToSubtypeMap.value(text);
|
||||||
op = text;
|
op = text;
|
||||||
}
|
}
|
||||||
source_char = readChar();
|
sourceChar = readChar();
|
||||||
if (text.length() >= d->m_maxOperatorLength || !d->m_operatorCharsSet.contains(source_char.ch)) {
|
if (text.length() >= d->m_maxOperatorLength || !d->m_operatorCharsSet.contains(sourceChar.ch)) {
|
||||||
unreadChar(source_char);
|
unreadChar(sourceChar);
|
||||||
int i = text.length();
|
int i = text.length();
|
||||||
while (i > operator_length) {
|
while (i > operatorLength) {
|
||||||
--i;
|
--i;
|
||||||
unreadChar(extra_chars.pop());
|
unreadChar(extraChars.pop());
|
||||||
}
|
}
|
||||||
QMT_CHECK(have_operator);
|
QMT_CHECK(haveOperator);
|
||||||
Q_UNUSED(have_operator); // avoid warning in release mode
|
Q_UNUSED(haveOperator); // avoid warning in release mode
|
||||||
return Token(Token::TOKEN_OPERATOR, subtype, op, first_char.pos);
|
return Token(Token::TOKEN_OPERATOR, subtype, op, firstChar.pos);
|
||||||
}
|
}
|
||||||
text += source_char.ch;
|
text += sourceChar.ch;
|
||||||
extra_chars.push(source_char);
|
extraChars.push(sourceChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class QMT_EXPORT TextScannerError :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TextScannerError(const QString &error_msg, const SourcePos &source_pos);
|
TextScannerError(const QString &errorMsg, const SourcePos &sourcePos);
|
||||||
|
|
||||||
~TextScannerError();
|
~TextScannerError();
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
|
|
||||||
void setOperators(const QList<QPair<QString, int> > &operators);
|
void setOperators(const QList<QPair<QString, int> > &operators);
|
||||||
|
|
||||||
void setSource(ITextSource *text_source);
|
void setSource(ITextSource *textSource);
|
||||||
|
|
||||||
SourcePos getSourcePos() const;
|
SourcePos getSourcePos() const;
|
||||||
|
|
||||||
@@ -94,19 +94,19 @@ private:
|
|||||||
|
|
||||||
SourceChar readChar();
|
SourceChar readChar();
|
||||||
|
|
||||||
void unreadChar(const SourceChar &source_char);
|
void unreadChar(const SourceChar &sourceChar);
|
||||||
|
|
||||||
void skipWhitespaces();
|
void skipWhitespaces();
|
||||||
|
|
||||||
Token scanString(const SourceChar &delimiter_char);
|
Token scanString(const SourceChar &delimiterChar);
|
||||||
|
|
||||||
Token scanNumber(const SourceChar &first_digit);
|
Token scanNumber(const SourceChar &firstDigit);
|
||||||
|
|
||||||
Token scanIdentifier(const SourceChar &first_char);
|
Token scanIdentifier(const SourceChar &firstChar);
|
||||||
|
|
||||||
Token scanColorIdentifier(const SourceChar &first_char);
|
Token scanColorIdentifier(const SourceChar &firstChar);
|
||||||
|
|
||||||
Token scanOperator(const SourceChar &first_char);
|
Token scanOperator(const SourceChar &firstChar);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ namespace qmt {
|
|||||||
|
|
||||||
struct SourceChar {
|
struct SourceChar {
|
||||||
SourceChar() { }
|
SourceChar() { }
|
||||||
SourceChar(QChar chr, const SourcePos &source_pos)
|
SourceChar(QChar chr, const SourcePos &sourcePos)
|
||||||
: ch(chr),
|
: ch(chr),
|
||||||
pos(source_pos)
|
pos(sourcePos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
src/libs/3rdparty/modeling/qmt/config/token.cpp
vendored
12
src/libs/3rdparty/modeling/qmt/config/token.cpp
vendored
@@ -38,19 +38,19 @@ Token::Token()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Token(Type type, const QString &text, const SourcePos &source_pos)
|
Token::Token(Type type, const QString &text, const SourcePos &sourcePos)
|
||||||
: m_type(type),
|
: m_type(type),
|
||||||
m_subtype(0),
|
m_subtype(0),
|
||||||
m_text(text),
|
m_text(text),
|
||||||
m_sourcePos(source_pos)
|
m_sourcePos(sourcePos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Token(Token::Type type, int subtype, const QString &text, const SourcePos &source_pos)
|
Token::Token(Token::Type type, int subtype, const QString &text, const SourcePos &sourcePos)
|
||||||
: m_type(type),
|
: m_type(type),
|
||||||
m_subtype(subtype),
|
m_subtype(subtype),
|
||||||
m_text(text),
|
m_text(text),
|
||||||
m_sourcePos(source_pos)
|
m_sourcePos(sourcePos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ void Token::setText(const QString &text)
|
|||||||
m_text = text;
|
m_text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setSourcePos(const SourcePos &source_pos)
|
void Token::setSourcePos(const SourcePos &sourcePos)
|
||||||
{
|
{
|
||||||
m_sourcePos = source_pos;
|
m_sourcePos = sourcePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace qmt
|
} // namespace qmt
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Token();
|
Token();
|
||||||
Token(Type type, const QString &text, const SourcePos &source_pos);
|
Token(Type type, const QString &text, const SourcePos &sourcePos);
|
||||||
Token(Type type, int subtype, const QString &text, const SourcePos &source_pos);
|
Token(Type type, int subtype, const QString &text, const SourcePos &sourcePos);
|
||||||
~Token();
|
~Token();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
|
|
||||||
SourcePos getSourcePos() const { return m_sourcePos; }
|
SourcePos getSourcePos() const { return m_sourcePos; }
|
||||||
|
|
||||||
void setSourcePos(const SourcePos &source_pos);
|
void setSourcePos(const SourcePos &sourcePos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_type;
|
Type m_type;
|
||||||
|
|||||||
@@ -45,117 +45,117 @@ NameController::~NameController()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NameController::convertFileNameToElementName(const QString &file_name)
|
QString NameController::convertFileNameToElementName(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFileInfo file_info(file_name);
|
QFileInfo fileInfo(fileName);
|
||||||
QString base_name = file_info.baseName().trimmed();
|
QString baseName = fileInfo.baseName().trimmed();
|
||||||
QString element_name;
|
QString elementName;
|
||||||
bool make_uppercase = true;
|
bool makeUppercase = true;
|
||||||
bool insert_space = false;
|
bool insertSpace = false;
|
||||||
for (int i = 0; i < base_name.size(); ++i) {
|
for (int i = 0; i < baseName.size(); ++i) {
|
||||||
if (base_name.at(i) == QLatin1Char('_')) {
|
if (baseName.at(i) == QLatin1Char('_')) {
|
||||||
make_uppercase = true;
|
makeUppercase = true;
|
||||||
insert_space = true;
|
insertSpace = true;
|
||||||
} else if (base_name.at(i) == QLatin1Char(' ') || base_name.at(i) == QLatin1Char('-')) {
|
} else if (baseName.at(i) == QLatin1Char(' ') || baseName.at(i) == QLatin1Char('-')) {
|
||||||
make_uppercase = true;
|
makeUppercase = true;
|
||||||
insert_space = false;
|
insertSpace = false;
|
||||||
element_name += base_name.at(i);
|
elementName += baseName.at(i);
|
||||||
} else if (make_uppercase) {
|
} else if (makeUppercase) {
|
||||||
if (insert_space) {
|
if (insertSpace) {
|
||||||
element_name += QLatin1Char(' ');
|
elementName += QLatin1Char(' ');
|
||||||
insert_space = false;
|
insertSpace = false;
|
||||||
}
|
}
|
||||||
element_name += base_name.at(i).toUpper();
|
elementName += baseName.at(i).toUpper();
|
||||||
make_uppercase = false;
|
makeUppercase = false;
|
||||||
} else {
|
} else {
|
||||||
if (insert_space) {
|
if (insertSpace) {
|
||||||
element_name += QLatin1Char(' ');
|
elementName += QLatin1Char(' ');
|
||||||
insert_space = false;
|
insertSpace = false;
|
||||||
}
|
}
|
||||||
element_name += base_name.at(i);
|
elementName += baseName.at(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return element_name;
|
return elementName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NameController::convertElementNameToBaseFileName(const QString &element_name)
|
QString NameController::convertElementNameToBaseFileName(const QString &elementName)
|
||||||
{
|
{
|
||||||
QString base_file_name;
|
QString baseFileName;
|
||||||
bool insert_underscore = false;
|
bool insertUnderscore = false;
|
||||||
for (int i = 0; i < element_name.size(); ++i) {
|
for (int i = 0; i < elementName.size(); ++i) {
|
||||||
if (element_name.at(i) == QLatin1Char(' ')) {
|
if (elementName.at(i) == QLatin1Char(' ')) {
|
||||||
insert_underscore = true;
|
insertUnderscore = true;
|
||||||
} else {
|
} else {
|
||||||
if (insert_underscore) {
|
if (insertUnderscore) {
|
||||||
base_file_name += QLatin1Char('_');
|
baseFileName += QLatin1Char('_');
|
||||||
insert_underscore = false;
|
insertUnderscore = false;
|
||||||
}
|
}
|
||||||
base_file_name += element_name.at(i).toLower();
|
baseFileName += elementName.at(i).toLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return base_file_name;
|
return baseFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NameController::calcRelativePath(const QString &absolute_file_name, const QString &anchor_path)
|
QString NameController::calcRelativePath(const QString &absoluteFileName, const QString &anchorPath)
|
||||||
{
|
{
|
||||||
int second_last_slash_index = -1;
|
int secondLastSlashIndex = -1;
|
||||||
int slash_index = -1;
|
int slashIndex = -1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < absolute_file_name.size() && i < anchor_path.size() && absolute_file_name.at(i) == anchor_path.at(i)) {
|
while (i < absoluteFileName.size() && i < anchorPath.size() && absoluteFileName.at(i) == anchorPath.at(i)) {
|
||||||
if (absolute_file_name.at(i) == QLatin1Char('/')) {
|
if (absoluteFileName.at(i) == QLatin1Char('/')) {
|
||||||
second_last_slash_index = slash_index;
|
secondLastSlashIndex = slashIndex;
|
||||||
slash_index = i;
|
slashIndex = i;
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString relative_path;
|
QString relativePath;
|
||||||
|
|
||||||
if (slash_index < 0) {
|
if (slashIndex < 0) {
|
||||||
relative_path = absolute_file_name;
|
relativePath = absoluteFileName;
|
||||||
} else if (i >= absolute_file_name.size()) {
|
} else if (i >= absoluteFileName.size()) {
|
||||||
// absolute_file_name is a substring of anchor path.
|
// absoluteFileName is a substring of anchor path.
|
||||||
if (slash_index == i - 1) {
|
if (slashIndex == i - 1) {
|
||||||
if (second_last_slash_index < 0) {
|
if (secondLastSlashIndex < 0) {
|
||||||
relative_path = absolute_file_name;
|
relativePath = absoluteFileName;
|
||||||
} else {
|
} else {
|
||||||
relative_path = absolute_file_name.mid(second_last_slash_index + 1);
|
relativePath = absoluteFileName.mid(secondLastSlashIndex + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
relative_path = absolute_file_name.mid(slash_index + 1);
|
relativePath = absoluteFileName.mid(slashIndex + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
relative_path = absolute_file_name.mid(slash_index + 1);
|
relativePath = absoluteFileName.mid(slashIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return relative_path;
|
return relativePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NameController::calcElementNameSearchId(const QString &element_name)
|
QString NameController::calcElementNameSearchId(const QString &elementName)
|
||||||
{
|
{
|
||||||
QString search_id;
|
QString searchId;
|
||||||
foreach (const QChar &c, element_name) {
|
foreach (const QChar &c, elementName) {
|
||||||
if (c.isLetterOrNumber()) {
|
if (c.isLetterOrNumber()) {
|
||||||
search_id += c.toLower();
|
searchId += c.toLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return search_id;
|
return searchId;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> NameController::buildElementsPath(const QString &file_path, bool ignore_last_file_path_part)
|
QList<QString> NameController::buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart)
|
||||||
{
|
{
|
||||||
QList<QString> relative_elements;
|
QList<QString> relativeElements;
|
||||||
|
|
||||||
QStringList splitted = file_path.split(QStringLiteral("/"));
|
QStringList splitted = filePath.split(QStringLiteral("/"));
|
||||||
QStringList::const_iterator splitted_end = splitted.end();
|
QStringList::const_iterator splittedEnd = splitted.end();
|
||||||
if (ignore_last_file_path_part || splitted.last().isEmpty()) {
|
if (ignoreLastFilePathPart || splitted.last().isEmpty()) {
|
||||||
splitted_end = --splitted_end;
|
splittedEnd = --splittedEnd;
|
||||||
}
|
}
|
||||||
for (QStringList::const_iterator it = splitted.cbegin(); it != splitted_end; ++it) {
|
for (QStringList::const_iterator it = splitted.cbegin(); it != splittedEnd; ++it) {
|
||||||
QString package_name = qmt::NameController::convertFileNameToElementName(*it);
|
QString packageName = qmt::NameController::convertFileNameToElementName(*it);
|
||||||
relative_elements.append(package_name);
|
relativeElements.append(packageName);
|
||||||
}
|
}
|
||||||
return relative_elements;
|
return relativeElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static QString convertFileNameToElementName(const QString &file_name);
|
static QString convertFileNameToElementName(const QString &fileName);
|
||||||
|
|
||||||
static QString convertElementNameToBaseFileName(const QString &element_name);
|
static QString convertElementNameToBaseFileName(const QString &elementName);
|
||||||
|
|
||||||
static QString calcRelativePath(const QString &absolute_file_name, const QString &anchor_path);
|
static QString calcRelativePath(const QString &absoluteFileName, const QString &anchorPath);
|
||||||
|
|
||||||
static QString calcElementNameSearchId(const QString &element_name);
|
static QString calcElementNameSearchId(const QString &elementName);
|
||||||
|
|
||||||
static QList<QString> buildElementsPath(const QString &file_path, bool ignore_last_file_path_part);
|
static QList<QString> buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ void Selection::append(const Index &index)
|
|||||||
m_indices.append(index);
|
m_indices.append(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::append(const Uid &element_key, const Uid &owner_key)
|
void Selection::append(const Uid &elementKey, const Uid &ownerKey)
|
||||||
{
|
{
|
||||||
append(Index(element_key, owner_key));
|
append(Index(elementKey, ownerKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ public:
|
|||||||
class Index {
|
class Index {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Index(const Uid &element_key, const Uid &owner_key)
|
Index(const Uid &elementKey, const Uid &ownerKey)
|
||||||
: m_elementKey(element_key),
|
: m_elementKey(elementKey),
|
||||||
m_ownerKey(owner_key)
|
m_ownerKey(ownerKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
|
|
||||||
void append(const Index &index);
|
void append(const Index &index);
|
||||||
|
|
||||||
void append(const Uid &element_key, const Uid &owner_key);
|
void append(const Uid &elementKey, const Uid &ownerKey);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -50,21 +50,21 @@ int UndoCommand::id() const
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndoCommand::setDoNotMerge(bool do_not_merge)
|
void UndoCommand::setDoNotMerge(bool doNotMerge)
|
||||||
{
|
{
|
||||||
m_doNotMerge = do_not_merge;
|
m_doNotMerge = doNotMerge;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UndoCommand::mergeWith(const QUndoCommand *other)
|
bool UndoCommand::mergeWith(const QUndoCommand *other)
|
||||||
{
|
{
|
||||||
const UndoCommand *other_command = dynamic_cast<const UndoCommand *>(other);
|
const UndoCommand *otherCommand = dynamic_cast<const UndoCommand *>(other);
|
||||||
if (!other_command) {
|
if (!otherCommand) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (other_command->m_doNotMerge) {
|
if (otherCommand->m_doNotMerge) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mergeWith(other_command);
|
return mergeWith(otherCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UndoCommand::mergeWith(const UndoCommand *other)
|
bool UndoCommand::mergeWith(const UndoCommand *other)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
|
|
||||||
void setDoNotMerge(bool do_not_merge);
|
void setDoNotMerge(bool doNotMerge);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -84,14 +84,14 @@ void DAnnotation::setRect(const QRectF &rect)
|
|||||||
m_rect = rect;
|
m_rect = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DAnnotation::setVisualRole(DAnnotation::VisualRole visual_role)
|
void DAnnotation::setVisualRole(DAnnotation::VisualRole visualRole)
|
||||||
{
|
{
|
||||||
m_visualRole = visual_role;
|
m_visualRole = visualRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DAnnotation::setAutoSize(bool auto_sized)
|
void DAnnotation::setAutoSize(bool autoSized)
|
||||||
{
|
{
|
||||||
m_autoSized = auto_sized;
|
m_autoSized = autoSized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DAnnotation::accept(DVisitor *visitor)
|
void DAnnotation::accept(DVisitor *visitor)
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ public:
|
|||||||
|
|
||||||
VisualRole getVisualRole() const { return m_visualRole; }
|
VisualRole getVisualRole() const { return m_visualRole; }
|
||||||
|
|
||||||
void setVisualRole(VisualRole visual_role);
|
void setVisualRole(VisualRole visualRole);
|
||||||
|
|
||||||
bool hasAutoSize() const { return m_autoSized; }
|
bool hasAutoSize() const { return m_autoSized; }
|
||||||
|
|
||||||
void setAutoSize(bool auto_sized);
|
void setAutoSize(bool autoSized);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -93,14 +93,14 @@ DAssociation::~DAssociation()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DAssociation::setA(const DAssociationEnd &end_a)
|
void DAssociation::setA(const DAssociationEnd &endA)
|
||||||
{
|
{
|
||||||
m_endA = end_a;
|
m_endA = endA;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DAssociation::setB(const DAssociationEnd &end_b)
|
void DAssociation::setB(const DAssociationEnd &endB)
|
||||||
{
|
{
|
||||||
m_endB = end_b;
|
m_endB = endB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DAssociation::setAssociationClassUid(const Uid &uid)
|
void DAssociation::setAssociationClassUid(const Uid &uid)
|
||||||
|
|||||||
@@ -92,11 +92,11 @@ public:
|
|||||||
|
|
||||||
DAssociationEnd getA() const { return m_endA; }
|
DAssociationEnd getA() const { return m_endA; }
|
||||||
|
|
||||||
void setA(const DAssociationEnd &end_a);
|
void setA(const DAssociationEnd &endA);
|
||||||
|
|
||||||
DAssociationEnd getB() const { return m_endB; }
|
DAssociationEnd getB() const { return m_endB; }
|
||||||
|
|
||||||
void setB(const DAssociationEnd &end_b);
|
void setB(const DAssociationEnd &endB);
|
||||||
|
|
||||||
Uid getAssoicationClassUid() const { return m_associationClassUid; }
|
Uid getAssoicationClassUid() const { return m_associationClassUid; }
|
||||||
|
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ DClass::DClass()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DClass::setNamespace(const QString &name_space)
|
void DClass::setNamespace(const QString &nameSpace)
|
||||||
{
|
{
|
||||||
m_namespace = name_space;
|
m_namespace = nameSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DClass::setTemplateParameters(const QList<QString> &template_parameters)
|
void DClass::setTemplateParameters(const QList<QString> &templateParameters)
|
||||||
{
|
{
|
||||||
m_templateParameters = template_parameters;
|
m_templateParameters = templateParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DClass::setMembers(const QList<MClassMember> &members)
|
void DClass::setMembers(const QList<MClassMember> &members)
|
||||||
@@ -57,19 +57,19 @@ void DClass::setMembers(const QList<MClassMember> &members)
|
|||||||
m_members = members;
|
m_members = members;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DClass::setVisibleMembers(const QSet<Uid> &visible_members)
|
void DClass::setVisibleMembers(const QSet<Uid> &visibleMembers)
|
||||||
{
|
{
|
||||||
m_visibleMembers = visible_members;
|
m_visibleMembers = visibleMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DClass::setTemplateDisplay(DClass::TemplateDisplay template_display)
|
void DClass::setTemplateDisplay(DClass::TemplateDisplay templateDisplay)
|
||||||
{
|
{
|
||||||
m_templateDisplay = template_display;
|
m_templateDisplay = templateDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DClass::setShowAllMembers(bool show_all_members)
|
void DClass::setShowAllMembers(bool showAllMembers)
|
||||||
{
|
{
|
||||||
m_showAllMembers = show_all_members;
|
m_showAllMembers = showAllMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DClass::accept(DVisitor *visitor)
|
void DClass::accept(DVisitor *visitor)
|
||||||
|
|||||||
10
src/libs/3rdparty/modeling/qmt/diagram/dclass.h
vendored
10
src/libs/3rdparty/modeling/qmt/diagram/dclass.h
vendored
@@ -57,11 +57,11 @@ public:
|
|||||||
|
|
||||||
QString getNamespace() const { return m_namespace; }
|
QString getNamespace() const { return m_namespace; }
|
||||||
|
|
||||||
void setNamespace(const QString &name_space);
|
void setNamespace(const QString &nameSpace);
|
||||||
|
|
||||||
QList<QString> getTemplateParameters() const { return m_templateParameters; }
|
QList<QString> getTemplateParameters() const { return m_templateParameters; }
|
||||||
|
|
||||||
void setTemplateParameters(const QList<QString> &template_parameters);
|
void setTemplateParameters(const QList<QString> &templateParameters);
|
||||||
|
|
||||||
QList<MClassMember> getMembers() const { return m_members; }
|
QList<MClassMember> getMembers() const { return m_members; }
|
||||||
|
|
||||||
@@ -69,15 +69,15 @@ public:
|
|||||||
|
|
||||||
QSet<Uid> getVisibleMembers() const { return m_visibleMembers; }
|
QSet<Uid> getVisibleMembers() const { return m_visibleMembers; }
|
||||||
|
|
||||||
void setVisibleMembers(const QSet<Uid> &visible_members);
|
void setVisibleMembers(const QSet<Uid> &visibleMembers);
|
||||||
|
|
||||||
TemplateDisplay getTemplateDisplay() const { return m_templateDisplay; }
|
TemplateDisplay getTemplateDisplay() const { return m_templateDisplay; }
|
||||||
|
|
||||||
void setTemplateDisplay(TemplateDisplay template_display);
|
void setTemplateDisplay(TemplateDisplay templateDisplay);
|
||||||
|
|
||||||
bool getShowAllMembers() const { return m_showAllMembers; }
|
bool getShowAllMembers() const { return m_showAllMembers; }
|
||||||
|
|
||||||
void setShowAllMembers(bool show_all_members);
|
void setShowAllMembers(bool showAllMembers);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ DComponent::DComponent()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DComponent::setPlainShape(bool plane_shape)
|
void DComponent::setPlainShape(bool planeShape)
|
||||||
{
|
{
|
||||||
m_plainShape = plane_shape;
|
m_plainShape = planeShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DComponent::accept(DVisitor *visitor)
|
void DComponent::accept(DVisitor *visitor)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
bool getPlainShape() const { return m_plainShape; }
|
bool getPlainShape() const { return m_plainShape; }
|
||||||
|
|
||||||
void setPlainShape(bool plane_shape);
|
void setPlainShape(bool planeShape);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ void DItem::setShape(const QString &shape)
|
|||||||
m_shape = shape;
|
m_shape = shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DItem::setShapeEditable(bool shape_editable)
|
void DItem::setShapeEditable(bool shapeEditable)
|
||||||
{
|
{
|
||||||
m_shapeEditable = shape_editable;
|
m_shapeEditable = shapeEditable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DItem::accept(DVisitor *visitor)
|
void DItem::accept(DVisitor *visitor)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
bool isShapeEditable() const { return m_shapeEditable; }
|
bool isShapeEditable() const { return m_shapeEditable; }
|
||||||
|
|
||||||
void setShapeEditable(bool shape_editable);
|
void setShapeEditable(bool shapeEditable);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -123,29 +123,29 @@ void DObject::setDepth(int depth)
|
|||||||
m_depth = depth;
|
m_depth = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DObject::setVisualPrimaryRole(DObject::VisualPrimaryRole visual_primary_role)
|
void DObject::setVisualPrimaryRole(DObject::VisualPrimaryRole visualPrimaryRole)
|
||||||
{
|
{
|
||||||
m_visualPrimaryRole = visual_primary_role;
|
m_visualPrimaryRole = visualPrimaryRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DObject::setVisualSecondaryRole(DObject::VisualSecondaryRole visual_secondary_role)
|
void DObject::setVisualSecondaryRole(DObject::VisualSecondaryRole visualSecondaryRole)
|
||||||
{
|
{
|
||||||
m_visualSecondaryRole = visual_secondary_role;
|
m_visualSecondaryRole = visualSecondaryRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DObject::setStereotypeDisplay(DObject::StereotypeDisplay stereotype_display)
|
void DObject::setStereotypeDisplay(DObject::StereotypeDisplay stereotypeDisplay)
|
||||||
{
|
{
|
||||||
m_stereotypeDisplay = stereotype_display;
|
m_stereotypeDisplay = stereotypeDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DObject::setAutoSize(bool auto_sized)
|
void DObject::setAutoSize(bool autoSized)
|
||||||
{
|
{
|
||||||
m_autoSized = auto_sized;
|
m_autoSized = autoSized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DObject::setVisualEmphasized(bool visual_emphasized)
|
void DObject::setVisualEmphasized(bool visualEmphasized)
|
||||||
{
|
{
|
||||||
m_visualEmphasized = visual_emphasized;
|
m_visualEmphasized = visualEmphasized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DObject::accept(DVisitor *visitor)
|
void DObject::accept(DVisitor *visitor)
|
||||||
|
|||||||
10
src/libs/3rdparty/modeling/qmt/diagram/dobject.h
vendored
10
src/libs/3rdparty/modeling/qmt/diagram/dobject.h
vendored
@@ -122,23 +122,23 @@ public:
|
|||||||
|
|
||||||
VisualPrimaryRole getVisualPrimaryRole() const { return m_visualPrimaryRole; }
|
VisualPrimaryRole getVisualPrimaryRole() const { return m_visualPrimaryRole; }
|
||||||
|
|
||||||
void setVisualPrimaryRole(VisualPrimaryRole visual_primary_role);
|
void setVisualPrimaryRole(VisualPrimaryRole visualPrimaryRole);
|
||||||
|
|
||||||
VisualSecondaryRole getVisualSecondaryRole() const { return m_visualSecondaryRole; }
|
VisualSecondaryRole getVisualSecondaryRole() const { return m_visualSecondaryRole; }
|
||||||
|
|
||||||
void setVisualSecondaryRole(VisualSecondaryRole visual_secondary_role);
|
void setVisualSecondaryRole(VisualSecondaryRole visualSecondaryRole);
|
||||||
|
|
||||||
StereotypeDisplay getStereotypeDisplay() const { return m_stereotypeDisplay; }
|
StereotypeDisplay getStereotypeDisplay() const { return m_stereotypeDisplay; }
|
||||||
|
|
||||||
void setStereotypeDisplay(StereotypeDisplay stereotype_display);
|
void setStereotypeDisplay(StereotypeDisplay stereotypeDisplay);
|
||||||
|
|
||||||
bool hasAutoSize() const { return m_autoSized; }
|
bool hasAutoSize() const { return m_autoSized; }
|
||||||
|
|
||||||
void setAutoSize(bool auto_sized);
|
void setAutoSize(bool autoSized);
|
||||||
|
|
||||||
bool isVisualEmphasized() const { return m_visualEmphasized; }
|
bool isVisualEmphasized() const { return m_visualEmphasized; }
|
||||||
|
|
||||||
void setVisualEmphasized(bool visual_emphasized);
|
void setVisualEmphasized(bool visualEmphasized);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ void DRelation::setName(const QString &name)
|
|||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRelation::setIntermediatePoints(const QList<DRelation::IntermediatePoint> &intermediate_points)
|
void DRelation::setIntermediatePoints(const QList<DRelation::IntermediatePoint> &intermediatePoints)
|
||||||
{
|
{
|
||||||
m_intermediatePoints = intermediate_points;
|
m_intermediatePoints = intermediatePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
QList<IntermediatePoint> getIntermediatePoints() const { return m_intermediatePoints; }
|
QList<IntermediatePoint> getIntermediatePoints() const { return m_intermediatePoints; }
|
||||||
|
|
||||||
void setIntermediatePoints(const QList<IntermediatePoint> &intermediate_points);
|
void setIntermediatePoints(const QList<IntermediatePoint> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -71,41 +71,41 @@ void DFactory::visitMElement(const MElement *element)
|
|||||||
|
|
||||||
void DFactory::visitMObject(const MObject *object)
|
void DFactory::visitMObject(const MObject *object)
|
||||||
{
|
{
|
||||||
DObject *diagram_object = dynamic_cast<DObject *>(m_product);
|
DObject *diagramObject = dynamic_cast<DObject *>(m_product);
|
||||||
QMT_CHECK(diagram_object);
|
QMT_CHECK(diagramObject);
|
||||||
diagram_object->setModelUid(object->getUid());
|
diagramObject->setModelUid(object->getUid());
|
||||||
visitMElement(object);
|
visitMElement(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMPackage(const MPackage *package)
|
void DFactory::visitMPackage(const MPackage *package)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DPackage *diagram_package = new DPackage();
|
DPackage *diagramPackage = new DPackage();
|
||||||
m_product = diagram_package;
|
m_product = diagramPackage;
|
||||||
visitMObject(package);
|
visitMObject(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMClass(const MClass *klass)
|
void DFactory::visitMClass(const MClass *klass)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DClass *diagram_klass = new DClass();
|
DClass *diagramKlass = new DClass();
|
||||||
m_product = diagram_klass;
|
m_product = diagramKlass;
|
||||||
visitMObject(klass);
|
visitMObject(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMComponent(const MComponent *component)
|
void DFactory::visitMComponent(const MComponent *component)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DComponent *diagram_component = new DComponent();
|
DComponent *diagramComponent = new DComponent();
|
||||||
m_product = diagram_component;
|
m_product = diagramComponent;
|
||||||
visitMObject(component);
|
visitMObject(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMDiagram(const MDiagram *diagram)
|
void DFactory::visitMDiagram(const MDiagram *diagram)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DDiagram *diagram_diagram = new DDiagram();
|
DDiagram *diagramDiagram = new DDiagram();
|
||||||
m_product = diagram_diagram;
|
m_product = diagramDiagram;
|
||||||
visitMObject(diagram);
|
visitMObject(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,40 +118,40 @@ void DFactory::visitMCanvasDiagram(const MCanvasDiagram *diagram)
|
|||||||
void DFactory::visitMItem(const MItem *item)
|
void DFactory::visitMItem(const MItem *item)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DItem *diagram_item = new DItem();
|
DItem *diagramItem = new DItem();
|
||||||
m_product = diagram_item;
|
m_product = diagramItem;
|
||||||
visitMObject(item);
|
visitMObject(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMRelation(const MRelation *relation)
|
void DFactory::visitMRelation(const MRelation *relation)
|
||||||
{
|
{
|
||||||
DRelation *diagram_relation = dynamic_cast<DRelation *>(m_product);
|
DRelation *diagramRelation = dynamic_cast<DRelation *>(m_product);
|
||||||
QMT_CHECK(diagram_relation);
|
QMT_CHECK(diagramRelation);
|
||||||
diagram_relation->setModelUid(relation->getUid());
|
diagramRelation->setModelUid(relation->getUid());
|
||||||
visitMElement(relation);
|
visitMElement(relation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMDependency(const MDependency *dependency)
|
void DFactory::visitMDependency(const MDependency *dependency)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DDependency *diagram_dependency = new DDependency();
|
DDependency *diagramDependency = new DDependency();
|
||||||
m_product = diagram_dependency;
|
m_product = diagramDependency;
|
||||||
visitMRelation(dependency);
|
visitMRelation(dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMInheritance(const MInheritance *inheritance)
|
void DFactory::visitMInheritance(const MInheritance *inheritance)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DInheritance *diagram_inheritance = new DInheritance();
|
DInheritance *diagramInheritance = new DInheritance();
|
||||||
m_product = diagram_inheritance;
|
m_product = diagramInheritance;
|
||||||
visitMRelation(inheritance);
|
visitMRelation(inheritance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFactory::visitMAssociation(const MAssociation *association)
|
void DFactory::visitMAssociation(const MAssociation *association)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!m_product);
|
QMT_CHECK(!m_product);
|
||||||
DAssociation *diagram_association = new DAssociation();
|
DAssociation *diagramAssociation = new DAssociation();
|
||||||
m_product = diagram_association;
|
m_product = diagramAssociation;
|
||||||
visitMRelation(association);
|
visitMRelation(association);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ class DiagramController::DiagramUndoCommand :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DiagramUndoCommand(DiagramController *diagram_controller, const Uid &diagram_key, const QString &text)
|
DiagramUndoCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &text)
|
||||||
: UndoCommand(text),
|
: UndoCommand(text),
|
||||||
m_diagramController(diagram_controller),
|
m_diagramController(diagramController),
|
||||||
m_diagramKey(diagram_key)
|
m_diagramKey(diagramKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,10 +107,10 @@ class DiagramController::UpdateElementCommand :
|
|||||||
public DiagramUndoCommand
|
public DiagramUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UpdateElementCommand(DiagramController *diagram_controller, const Uid &diagram_key, DElement *element,
|
UpdateElementCommand(DiagramController *diagramController, const Uid &diagramKey, DElement *element,
|
||||||
DiagramController::UpdateAction update_action)
|
DiagramController::UpdateAction updateAction)
|
||||||
: DiagramUndoCommand(diagram_controller, diagram_key, tr("Change")),
|
: DiagramUndoCommand(diagramController, diagramKey, tr("Change")),
|
||||||
m_updateAction(update_action)
|
m_updateAction(updateAction)
|
||||||
{
|
{
|
||||||
DCloneVisitor visitor;
|
DCloneVisitor visitor;
|
||||||
element->accept(&visitor);
|
element->accept(&visitor);
|
||||||
@@ -124,22 +124,22 @@ public:
|
|||||||
|
|
||||||
bool mergeWith(const UndoCommand *other)
|
bool mergeWith(const UndoCommand *other)
|
||||||
{
|
{
|
||||||
const UpdateElementCommand *other_update_command = dynamic_cast<const UpdateElementCommand *>(other);
|
const UpdateElementCommand *otherUpdateCommand = dynamic_cast<const UpdateElementCommand *>(other);
|
||||||
if (!other_update_command) {
|
if (!otherUpdateCommand) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getDiagramKey() != other_update_command->getDiagramKey()) {
|
if (getDiagramKey() != otherUpdateCommand->getDiagramKey()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_updateAction == DiagramController::UPDATE_MAJOR || other_update_command->m_updateAction == DiagramController::UPDATE_MAJOR
|
if (m_updateAction == DiagramController::UPDATE_MAJOR || otherUpdateCommand->m_updateAction == DiagramController::UPDATE_MAJOR
|
||||||
|| m_updateAction != other_update_command->m_updateAction) {
|
|| m_updateAction != otherUpdateCommand->m_updateAction) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// join other elements into this command
|
// join other elements into this command
|
||||||
foreach (const DElement *other_element, other_update_command->m_clonedElements.values()) {
|
foreach (const DElement *otherElement, otherUpdateCommand->m_clonedElements.values()) {
|
||||||
if (!m_clonedElements.contains(other_element->getUid())) {
|
if (!m_clonedElements.contains(otherElement->getUid())) {
|
||||||
DCloneVisitor visitor;
|
DCloneVisitor visitor;
|
||||||
other_element->accept(&visitor);
|
otherElement->accept(&visitor);
|
||||||
m_clonedElements.insert(visitor.getCloned()->getUid(), visitor.getCloned());
|
m_clonedElements.insert(visitor.getCloned()->getUid(), visitor.getCloned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,27 +164,27 @@ public:
|
|||||||
private:
|
private:
|
||||||
void swap()
|
void swap()
|
||||||
{
|
{
|
||||||
DiagramController *diagram_controller = getDiagramController();
|
DiagramController *diagramController = getDiagramController();
|
||||||
MDiagram *diagram = getDiagram();
|
MDiagram *diagram = getDiagram();
|
||||||
foreach (DElement *cloned_element, m_clonedElements) {
|
foreach (DElement *clonedElement, m_clonedElements) {
|
||||||
DElement *active_element = diagram_controller->findElement(cloned_element->getUid(), diagram);
|
DElement *activeElement = diagramController->findElement(clonedElement->getUid(), diagram);
|
||||||
QMT_CHECK(active_element);
|
QMT_CHECK(activeElement);
|
||||||
int row = diagram->getDiagramElements().indexOf(active_element);
|
int row = diagram->getDiagramElements().indexOf(activeElement);
|
||||||
emit diagram_controller->beginUpdateElement(row, diagram);
|
emit diagramController->beginUpdateElement(row, diagram);
|
||||||
// clone active element
|
// clone active element
|
||||||
DCloneVisitor clone_visitor;
|
DCloneVisitor cloneVisitor;
|
||||||
active_element->accept(&clone_visitor);
|
activeElement->accept(&cloneVisitor);
|
||||||
DElement *new_element = clone_visitor.getCloned();
|
DElement *newElement = cloneVisitor.getCloned();
|
||||||
// reset active element to cloned element
|
// reset active element to cloned element
|
||||||
DFlatAssignmentVisitor visitor(active_element);
|
DFlatAssignmentVisitor visitor(activeElement);
|
||||||
cloned_element->accept(&visitor);
|
clonedElement->accept(&visitor);
|
||||||
// replace stored element with new cloned active element
|
// replace stored element with new cloned active element
|
||||||
QMT_CHECK(cloned_element->getUid() == new_element->getUid());
|
QMT_CHECK(clonedElement->getUid() == newElement->getUid());
|
||||||
m_clonedElements.insert(new_element->getUid(), new_element);
|
m_clonedElements.insert(newElement->getUid(), newElement);
|
||||||
delete cloned_element;
|
delete clonedElement;
|
||||||
emit diagram_controller->endUpdateElement(row, diagram);
|
emit diagramController->endUpdateElement(row, diagram);
|
||||||
}
|
}
|
||||||
diagram_controller->diagramModified(diagram);
|
diagramController->diagramModified(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -199,8 +199,8 @@ class DiagramController::AbstractAddRemCommand :
|
|||||||
public DiagramUndoCommand
|
public DiagramUndoCommand
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
AbstractAddRemCommand(DiagramController *diagram_controller, const Uid &diagram_key, const QString &command_label)
|
AbstractAddRemCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
||||||
: DiagramUndoCommand(diagram_controller, diagram_key, command_label)
|
: DiagramUndoCommand(diagramController, diagramKey, commandLabel)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,46 +213,46 @@ protected:
|
|||||||
|
|
||||||
void remove()
|
void remove()
|
||||||
{
|
{
|
||||||
DiagramController *diagram_controller = getDiagramController();
|
DiagramController *diagramController = getDiagramController();
|
||||||
MDiagram *diagram = getDiagram();
|
MDiagram *diagram = getDiagram();
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
for (int i = 0; i < m_clonedElements.count(); ++i) {
|
for (int i = 0; i < m_clonedElements.count(); ++i) {
|
||||||
Clone &clone = m_clonedElements[i];
|
Clone &clone = m_clonedElements[i];
|
||||||
QMT_CHECK(!clone.m_clonedElement);
|
QMT_CHECK(!clone.m_clonedElement);
|
||||||
DElement *active_element = diagram_controller->findElement(clone.m_elementKey, diagram);
|
DElement *activeElement = diagramController->findElement(clone.m_elementKey, diagram);
|
||||||
QMT_CHECK(active_element);
|
QMT_CHECK(activeElement);
|
||||||
clone.m_indexOfElement = diagram->getDiagramElements().indexOf(active_element);
|
clone.m_indexOfElement = diagram->getDiagramElements().indexOf(activeElement);
|
||||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||||
emit diagram_controller->beginRemoveElement(clone.m_indexOfElement, diagram);
|
emit diagramController->beginRemoveElement(clone.m_indexOfElement, diagram);
|
||||||
DCloneDeepVisitor clone_visitor;
|
DCloneDeepVisitor cloneVisitor;
|
||||||
active_element->accept(&clone_visitor);
|
activeElement->accept(&cloneVisitor);
|
||||||
clone.m_clonedElement = clone_visitor.getCloned();
|
clone.m_clonedElement = cloneVisitor.getCloned();
|
||||||
diagram->removeDiagramElement(active_element);
|
diagram->removeDiagramElement(activeElement);
|
||||||
emit diagram_controller->endRemoveElement(clone.m_indexOfElement, diagram);
|
emit diagramController->endRemoveElement(clone.m_indexOfElement, diagram);
|
||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
if (removed) {
|
if (removed) {
|
||||||
diagram_controller->diagramModified(diagram);
|
diagramController->diagramModified(diagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert()
|
void insert()
|
||||||
{
|
{
|
||||||
DiagramController *diagram_controller = getDiagramController();
|
DiagramController *diagramController = getDiagramController();
|
||||||
MDiagram *diagram = getDiagram();
|
MDiagram *diagram = getDiagram();
|
||||||
bool inserted = false;
|
bool inserted = false;
|
||||||
for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
|
for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
|
||||||
Clone &clone = m_clonedElements[i];
|
Clone &clone = m_clonedElements[i];
|
||||||
QMT_CHECK(clone.m_clonedElement);
|
QMT_CHECK(clone.m_clonedElement);
|
||||||
QMT_CHECK(clone.m_clonedElement->getUid() == clone.m_elementKey);
|
QMT_CHECK(clone.m_clonedElement->getUid() == clone.m_elementKey);
|
||||||
emit diagram_controller->beginInsertElement(clone.m_indexOfElement, diagram);
|
emit diagramController->beginInsertElement(clone.m_indexOfElement, diagram);
|
||||||
diagram->insertDiagramElement(clone.m_indexOfElement, clone.m_clonedElement);
|
diagram->insertDiagramElement(clone.m_indexOfElement, clone.m_clonedElement);
|
||||||
clone.m_clonedElement = 0;
|
clone.m_clonedElement = 0;
|
||||||
emit diagram_controller->endInsertElement(clone.m_indexOfElement, diagram);
|
emit diagramController->endInsertElement(clone.m_indexOfElement, diagram);
|
||||||
inserted = true;
|
inserted = true;
|
||||||
}
|
}
|
||||||
if (inserted) {
|
if (inserted) {
|
||||||
diagram_controller->diagramModified(diagram);
|
diagramController->diagramModified(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -266,16 +266,16 @@ class DiagramController::AddElementsCommand :
|
|||||||
public AbstractAddRemCommand
|
public AbstractAddRemCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AddElementsCommand(DiagramController *diagram_controller, const Uid &diagram_key, const QString &command_label)
|
AddElementsCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
||||||
: AbstractAddRemCommand(diagram_controller, diagram_key, command_label)
|
: AbstractAddRemCommand(diagramController, diagramKey, commandLabel)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const Uid &element_key)
|
void add(const Uid &elementKey)
|
||||||
{
|
{
|
||||||
Clone clone;
|
Clone clone;
|
||||||
|
|
||||||
clone.m_elementKey = element_key;
|
clone.m_elementKey = elementKey;
|
||||||
m_clonedElements.append(clone);
|
m_clonedElements.append(clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,8 +299,8 @@ class DiagramController::RemoveElementsCommand :
|
|||||||
public AbstractAddRemCommand
|
public AbstractAddRemCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RemoveElementsCommand(DiagramController *diagram_controller, const Uid &diagram_key, const QString &command_label)
|
RemoveElementsCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
||||||
: AbstractAddRemCommand(diagram_controller, diagram_key, command_label)
|
: AbstractAddRemCommand(diagramController, diagramKey, commandLabel)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,8 +340,8 @@ class DiagramController::FindDiagramsVisitor :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FindDiagramsVisitor(QList<MDiagram *> *all_diagrams)
|
FindDiagramsVisitor(QList<MDiagram *> *allDiagrams)
|
||||||
: m_allDiagrams(all_diagrams)
|
: m_allDiagrams(allDiagrams)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,43 +368,43 @@ DiagramController::~DiagramController()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::setModelController(ModelController *model_controller)
|
void DiagramController::setModelController(ModelController *modelController)
|
||||||
{
|
{
|
||||||
if (m_modelController) {
|
if (m_modelController) {
|
||||||
disconnect(m_modelController, 0, this, 0);
|
disconnect(m_modelController, 0, this, 0);
|
||||||
m_modelController = 0;
|
m_modelController = 0;
|
||||||
}
|
}
|
||||||
if (model_controller) {
|
if (modelController) {
|
||||||
m_modelController = model_controller;
|
m_modelController = modelController;
|
||||||
connect(model_controller, SIGNAL(beginResetModel()), this, SLOT(onBeginResetModel()));
|
connect(modelController, SIGNAL(beginResetModel()), this, SLOT(onBeginResetModel()));
|
||||||
connect(model_controller, SIGNAL(endResetModel()), this, SLOT(onEndResetModel()));
|
connect(modelController, SIGNAL(endResetModel()), this, SLOT(onEndResetModel()));
|
||||||
|
|
||||||
connect(model_controller, SIGNAL(beginUpdateObject(int,const MObject*)), this, SLOT(onBeginUpdateObject(int,const MObject*)));
|
connect(modelController, SIGNAL(beginUpdateObject(int,const MObject*)), this, SLOT(onBeginUpdateObject(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(endUpdateObject(int,const MObject*)), this, SLOT(onEndUpdateObject(int,const MObject*)));
|
connect(modelController, SIGNAL(endUpdateObject(int,const MObject*)), this, SLOT(onEndUpdateObject(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(beginInsertObject(int,const MObject*)), this, SLOT(onBeginInsertObject(int,const MObject*)));
|
connect(modelController, SIGNAL(beginInsertObject(int,const MObject*)), this, SLOT(onBeginInsertObject(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(endInsertObject(int,const MObject*)), this, SLOT(onEndInsertObject(int,const MObject*)));
|
connect(modelController, SIGNAL(endInsertObject(int,const MObject*)), this, SLOT(onEndInsertObject(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(beginRemoveObject(int,const MObject*)), this, SLOT(onBeginRemoveObject(int,const MObject*)));
|
connect(modelController, SIGNAL(beginRemoveObject(int,const MObject*)), this, SLOT(onBeginRemoveObject(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(endRemoveObject(int,const MObject*)), this, SLOT(onEndRemoveObject(int,const MObject*)));
|
connect(modelController, SIGNAL(endRemoveObject(int,const MObject*)), this, SLOT(onEndRemoveObject(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(beginMoveObject(int,const MObject*)), this, SLOT(onBeginMoveObject(int,const MObject*)));
|
connect(modelController, SIGNAL(beginMoveObject(int,const MObject*)), this, SLOT(onBeginMoveObject(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(endMoveObject(int,const MObject*)), this, SLOT(onEndMoveObject(int,const MObject*)));
|
connect(modelController, SIGNAL(endMoveObject(int,const MObject*)), this, SLOT(onEndMoveObject(int,const MObject*)));
|
||||||
|
|
||||||
connect(model_controller, SIGNAL(beginUpdateRelation(int,const MObject*)), this, SLOT(onBeginUpdateRelation(int,const MObject*)));
|
connect(modelController, SIGNAL(beginUpdateRelation(int,const MObject*)), this, SLOT(onBeginUpdateRelation(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(endUpdateRelation(int,const MObject*)), this, SLOT(onEndUpdateRelation(int,const MObject*)));
|
connect(modelController, SIGNAL(endUpdateRelation(int,const MObject*)), this, SLOT(onEndUpdateRelation(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(beginRemoveRelation(int,const MObject*)), this, SLOT(onBeginRemoveRelation(int,const MObject*)));
|
connect(modelController, SIGNAL(beginRemoveRelation(int,const MObject*)), this, SLOT(onBeginRemoveRelation(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(endRemoveRelation(int,const MObject*)), this, SLOT(onEndRemoveRelation(int,const MObject*)));
|
connect(modelController, SIGNAL(endRemoveRelation(int,const MObject*)), this, SLOT(onEndRemoveRelation(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(beginMoveRelation(int,const MObject*)), this, SLOT(onBeginMoveRelation(int,const MObject*)));
|
connect(modelController, SIGNAL(beginMoveRelation(int,const MObject*)), this, SLOT(onBeginMoveRelation(int,const MObject*)));
|
||||||
connect(model_controller, SIGNAL(endMoveRelation(int,const MObject*)), this, SLOT(onEndMoveRelation(int,const MObject*)));
|
connect(modelController, SIGNAL(endMoveRelation(int,const MObject*)), this, SLOT(onEndMoveRelation(int,const MObject*)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::setUndoController(UndoController *undo_controller)
|
void DiagramController::setUndoController(UndoController *undoController)
|
||||||
{
|
{
|
||||||
m_undoController = undo_controller;
|
m_undoController = undoController;
|
||||||
}
|
}
|
||||||
|
|
||||||
MDiagram *DiagramController::findDiagram(const Uid &diagram_key) const
|
MDiagram *DiagramController::findDiagram(const Uid &diagramKey) const
|
||||||
{
|
{
|
||||||
return dynamic_cast<MDiagram *>(m_modelController->findObject(diagram_key));
|
return dynamic_cast<MDiagram *>(m_modelController->findObject(diagramKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::addElement(DElement *element, MDiagram *diagram)
|
void DiagramController::addElement(DElement *element, MDiagram *diagram)
|
||||||
@@ -413,9 +413,9 @@ void DiagramController::addElement(DElement *element, MDiagram *diagram)
|
|||||||
emit beginInsertElement(row, diagram);
|
emit beginInsertElement(row, diagram);
|
||||||
updateElementFromModel(element, diagram, false);
|
updateElementFromModel(element, diagram, false);
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
AddElementsCommand *undo_command = new AddElementsCommand(this, diagram->getUid(), tr("Add Object"));
|
AddElementsCommand *undoCommand = new AddElementsCommand(this, diagram->getUid(), tr("Add Object"));
|
||||||
m_undoController->push(undo_command);
|
m_undoController->push(undoCommand);
|
||||||
undo_command->add(element->getUid());
|
undoCommand->add(element->getUid());
|
||||||
}
|
}
|
||||||
diagram->addDiagramElement(element);
|
diagram->addDiagramElement(element);
|
||||||
emit endInsertElement(row, diagram);
|
emit endInsertElement(row, diagram);
|
||||||
@@ -428,9 +428,9 @@ void DiagramController::removeElement(DElement *element, MDiagram *diagram)
|
|||||||
int row = diagram->getDiagramElements().indexOf(element);
|
int row = diagram->getDiagramElements().indexOf(element);
|
||||||
emit beginRemoveElement(row, diagram);
|
emit beginRemoveElement(row, diagram);
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
RemoveElementsCommand *undo_command = new RemoveElementsCommand(this, diagram->getUid(), tr("Remove Object"));
|
RemoveElementsCommand *undoCommand = new RemoveElementsCommand(this, diagram->getUid(), tr("Remove Object"));
|
||||||
m_undoController->push(undo_command);
|
m_undoController->push(undoCommand);
|
||||||
undo_command->add(element);
|
undoCommand->add(element);
|
||||||
}
|
}
|
||||||
diagram->removeDiagramElement(element);
|
diagram->removeDiagramElement(element);
|
||||||
emit endRemoveElement(row, diagram);
|
emit endRemoveElement(row, diagram);
|
||||||
@@ -444,29 +444,29 @@ DElement *DiagramController::findElement(const Uid &key, const MDiagram *diagram
|
|||||||
return diagram->findDiagramElement(key);
|
return diagram->findDiagramElement(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramController::hasDelegate(const MElement *model_element, const MDiagram *diagram) const
|
bool DiagramController::hasDelegate(const MElement *modelElement, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
// PERFORM smarter implementation after map is introduced
|
// PERFORM smarter implementation after map is introduced
|
||||||
return findDelegate(model_element, diagram) != 0;
|
return findDelegate(modelElement, diagram) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DElement *DiagramController::findDelegate(const MElement *model_element, const MDiagram *diagram) const
|
DElement *DiagramController::findDelegate(const MElement *modelElement, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(diagram);
|
Q_UNUSED(diagram);
|
||||||
// PERFORM use map to increase performance
|
// PERFORM use map to increase performance
|
||||||
foreach (DElement *diagram_element, diagram->getDiagramElements()) {
|
foreach (DElement *diagramElement, diagram->getDiagramElements()) {
|
||||||
if (diagram_element->getModelUid().isValid() && diagram_element->getModelUid() == model_element->getUid()) {
|
if (diagramElement->getModelUid().isValid() && diagramElement->getModelUid() == modelElement->getUid()) {
|
||||||
return diagram_element;
|
return diagramElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction update_action)
|
void DiagramController::startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction updateAction)
|
||||||
{
|
{
|
||||||
emit beginUpdateElement(diagram->getDiagramElements().indexOf(element), diagram);
|
emit beginUpdateElement(diagram->getDiagramElements().indexOf(element), diagram);
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
m_undoController->push(new UpdateElementCommand(this, diagram->getUid(), element, update_action));
|
m_undoController->push(new UpdateElementCommand(this, diagram->getUid(), element, updateAction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,49 +486,49 @@ void DiagramController::breakUndoChain()
|
|||||||
m_undoController->doNotMerge();
|
m_undoController->doNotMerge();
|
||||||
}
|
}
|
||||||
|
|
||||||
DContainer DiagramController::cutElements(const DSelection &diagram_selection, MDiagram *diagram)
|
DContainer DiagramController::cutElements(const DSelection &diagramSelection, MDiagram *diagram)
|
||||||
{
|
{
|
||||||
DContainer copied_elements = copyElements(diagram_selection, diagram);
|
DContainer copiedElements = copyElements(diagramSelection, diagram);
|
||||||
deleteElements(diagram_selection, diagram, tr("Cut"));
|
deleteElements(diagramSelection, diagram, tr("Cut"));
|
||||||
return copied_elements;
|
return copiedElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
DContainer DiagramController::copyElements(const DSelection &diagram_selection, const MDiagram *diagram)
|
DContainer DiagramController::copyElements(const DSelection &diagramSelection, const MDiagram *diagram)
|
||||||
{
|
{
|
||||||
QMT_CHECK(diagram);
|
QMT_CHECK(diagram);
|
||||||
|
|
||||||
DReferences simplified_selection = simplify(diagram_selection, diagram);
|
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
|
||||||
DContainer copied_elements;
|
DContainer copiedElements;
|
||||||
foreach (const DElement *element, simplified_selection.getElements()) {
|
foreach (const DElement *element, simplifiedSelection.getElements()) {
|
||||||
DCloneDeepVisitor visitor;
|
DCloneDeepVisitor visitor;
|
||||||
element->accept(&visitor);
|
element->accept(&visitor);
|
||||||
DElement *cloned_element = visitor.getCloned();
|
DElement *clonedElement = visitor.getCloned();
|
||||||
copied_elements.submit(cloned_element);
|
copiedElements.submit(clonedElement);
|
||||||
}
|
}
|
||||||
return copied_elements;
|
return copiedElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::pasteElements(const DContainer &diagram_container, MDiagram *diagram)
|
void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagram *diagram)
|
||||||
{
|
{
|
||||||
QMT_CHECK(diagram);
|
QMT_CHECK(diagram);
|
||||||
|
|
||||||
// clone all elements and renew their keys
|
// clone all elements and renew their keys
|
||||||
QHash<Uid, Uid> renewed_keys;
|
QHash<Uid, Uid> renewedKeys;
|
||||||
QList<DElement *> cloned_elements;
|
QList<DElement *> clonedElements;
|
||||||
foreach (const DElement *element, diagram_container.getElements()) {
|
foreach (const DElement *element, diagramContainer.getElements()) {
|
||||||
if (!isDelegatedElementOnDiagram(element, diagram)) {
|
if (!isDelegatedElementOnDiagram(element, diagram)) {
|
||||||
DCloneDeepVisitor visitor;
|
DCloneDeepVisitor visitor;
|
||||||
element->accept(&visitor);
|
element->accept(&visitor);
|
||||||
DElement *cloned_element = visitor.getCloned();
|
DElement *clonedElement = visitor.getCloned();
|
||||||
renewElementKey(cloned_element, &renewed_keys);
|
renewElementKey(clonedElement, &renewedKeys);
|
||||||
cloned_elements.append(cloned_element);
|
clonedElements.append(clonedElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fix all keys referencing between pasting elements
|
// fix all keys referencing between pasting elements
|
||||||
foreach(DElement *cloned_element, cloned_elements) {
|
foreach(DElement *clonedElement, clonedElements) {
|
||||||
DRelation *relation = dynamic_cast<DRelation *>(cloned_element);
|
DRelation *relation = dynamic_cast<DRelation *>(clonedElement);
|
||||||
if (relation) {
|
if (relation) {
|
||||||
updateRelationKeys(relation, renewed_keys);
|
updateRelationKeys(relation, renewedKeys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
@@ -536,31 +536,31 @@ void DiagramController::pasteElements(const DContainer &diagram_container, MDiag
|
|||||||
}
|
}
|
||||||
// insert all elements
|
// insert all elements
|
||||||
bool added = false;
|
bool added = false;
|
||||||
foreach (DElement *cloned_element, cloned_elements) {
|
foreach (DElement *clonedElement, clonedElements) {
|
||||||
if (!dynamic_cast<DRelation *>(cloned_element)) {
|
if (!dynamic_cast<DRelation *>(clonedElement)) {
|
||||||
int row = diagram->getDiagramElements().size();
|
int row = diagram->getDiagramElements().size();
|
||||||
emit beginInsertElement(row, diagram);
|
emit beginInsertElement(row, diagram);
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
AddElementsCommand *undo_command = new AddElementsCommand(this, diagram->getUid(), tr("Paste"));
|
AddElementsCommand *undoCommand = new AddElementsCommand(this, diagram->getUid(), tr("Paste"));
|
||||||
m_undoController->push(undo_command);
|
m_undoController->push(undoCommand);
|
||||||
undo_command->add(cloned_element->getUid());
|
undoCommand->add(clonedElement->getUid());
|
||||||
}
|
}
|
||||||
diagram->addDiagramElement(cloned_element);
|
diagram->addDiagramElement(clonedElement);
|
||||||
emit endInsertElement(row, diagram);
|
emit endInsertElement(row, diagram);
|
||||||
added = true;
|
added = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (DElement *cloned_element, cloned_elements) {
|
foreach (DElement *clonedElement, clonedElements) {
|
||||||
DRelation *cloned_relation = dynamic_cast<DRelation *>(cloned_element);
|
DRelation *clonedRelation = dynamic_cast<DRelation *>(clonedElement);
|
||||||
if (cloned_relation && areRelationEndsOnDiagram(cloned_relation, diagram)) {
|
if (clonedRelation && areRelationEndsOnDiagram(clonedRelation, diagram)) {
|
||||||
int row = diagram->getDiagramElements().size();
|
int row = diagram->getDiagramElements().size();
|
||||||
emit beginInsertElement(row, diagram);
|
emit beginInsertElement(row, diagram);
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
AddElementsCommand *undo_command = new AddElementsCommand(this, diagram->getUid(), tr("Paste"));
|
AddElementsCommand *undoCommand = new AddElementsCommand(this, diagram->getUid(), tr("Paste"));
|
||||||
m_undoController->push(undo_command);
|
m_undoController->push(undoCommand);
|
||||||
undo_command->add(cloned_element->getUid());
|
undoCommand->add(clonedElement->getUid());
|
||||||
}
|
}
|
||||||
diagram->addDiagramElement(cloned_element);
|
diagram->addDiagramElement(clonedElement);
|
||||||
emit endInsertElement(row, diagram);
|
emit endInsertElement(row, diagram);
|
||||||
added = true;
|
added = true;
|
||||||
}
|
}
|
||||||
@@ -573,9 +573,9 @@ void DiagramController::pasteElements(const DContainer &diagram_container, MDiag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::deleteElements(const DSelection &diagram_selection, MDiagram *diagram)
|
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram)
|
||||||
{
|
{
|
||||||
deleteElements(diagram_selection, diagram, tr("Delete"));
|
deleteElements(diagramSelection, diagram, tr("Delete"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::onBeginResetModel()
|
void DiagramController::onBeginResetModel()
|
||||||
@@ -591,8 +591,8 @@ void DiagramController::onEndResetModel()
|
|||||||
// remove all elements which are not longer part of the model
|
// remove all elements which are not longer part of the model
|
||||||
foreach (DElement *element, diagram->getDiagramElements()) {
|
foreach (DElement *element, diagram->getDiagramElements()) {
|
||||||
if (element->getModelUid().isValid()) {
|
if (element->getModelUid().isValid()) {
|
||||||
MElement *model_element = m_modelController->findElement(element->getModelUid());
|
MElement *modelElement = m_modelController->findElement(element->getModelUid());
|
||||||
if (!model_element) {
|
if (!modelElement) {
|
||||||
removeElement(element, diagram);
|
removeElement(element, diagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -615,21 +615,21 @@ void DiagramController::onBeginUpdateObject(int row, const MObject *parent)
|
|||||||
|
|
||||||
void DiagramController::onEndUpdateObject(int row, const MObject *parent)
|
void DiagramController::onEndUpdateObject(int row, const MObject *parent)
|
||||||
{
|
{
|
||||||
MObject *model_object = m_modelController->getObject(row, parent);
|
MObject *modelObject = m_modelController->getObject(row, parent);
|
||||||
QMT_CHECK(model_object);
|
QMT_CHECK(modelObject);
|
||||||
MPackage *model_package = dynamic_cast<MPackage *>(model_object);
|
MPackage *modelPackage = dynamic_cast<MPackage *>(modelObject);
|
||||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||||
DObject *object = findDelegate<DObject>(model_object, diagram);
|
DObject *object = findDelegate<DObject>(modelObject, diagram);
|
||||||
if (object) {
|
if (object) {
|
||||||
updateElementFromModel(object, diagram, true);
|
updateElementFromModel(object, diagram, true);
|
||||||
}
|
}
|
||||||
if (model_package) {
|
if (modelPackage) {
|
||||||
// update each element that has the updated object as its owner (for context changes)
|
// update each element that has the updated object as its owner (for context changes)
|
||||||
foreach (DElement *diagram_element, diagram->getDiagramElements()) {
|
foreach (DElement *diagramElement, diagram->getDiagramElements()) {
|
||||||
if (diagram_element->getModelUid().isValid()) {
|
if (diagramElement->getModelUid().isValid()) {
|
||||||
MObject *mobject = m_modelController->findObject(diagram_element->getModelUid());
|
MObject *mobject = m_modelController->findObject(diagramElement->getModelUid());
|
||||||
if (mobject && mobject->getOwner() == model_package) {
|
if (mobject && mobject->getOwner() == modelPackage) {
|
||||||
updateElementFromModel(diagram_element, diagram, true);
|
updateElementFromModel(diagramElement, diagram, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -647,10 +647,10 @@ void DiagramController::onEndInsertObject(int row, const MObject *owner)
|
|||||||
{
|
{
|
||||||
QMT_CHECK(owner);
|
QMT_CHECK(owner);
|
||||||
|
|
||||||
MObject *model_object = m_modelController->getObject(row, owner);
|
MObject *modelObject = m_modelController->getObject(row, owner);
|
||||||
if (MDiagram *model_diagram = dynamic_cast<MDiagram *>(model_object)) {
|
if (MDiagram *modelDiagram = dynamic_cast<MDiagram *>(modelObject)) {
|
||||||
QMT_CHECK(!m_allDiagrams.contains(model_diagram));
|
QMT_CHECK(!m_allDiagrams.contains(modelDiagram));
|
||||||
m_allDiagrams.append(model_diagram);
|
m_allDiagrams.append(modelDiagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,8 +658,8 @@ void DiagramController::onBeginRemoveObject(int row, const MObject *parent)
|
|||||||
{
|
{
|
||||||
QMT_CHECK(parent);
|
QMT_CHECK(parent);
|
||||||
|
|
||||||
MObject *model_object = m_modelController->getObject(row, parent);
|
MObject *modelObject = m_modelController->getObject(row, parent);
|
||||||
removeObjects(model_object);
|
removeObjects(modelObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::onEndRemoveObject(int row, const MObject *parent)
|
void DiagramController::onEndRemoveObject(int row, const MObject *parent)
|
||||||
@@ -668,10 +668,10 @@ void DiagramController::onEndRemoveObject(int row, const MObject *parent)
|
|||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::onBeginMoveObject(int former_row, const MObject *former_owner)
|
void DiagramController::onBeginMoveObject(int formerRow, const MObject *formerOwner)
|
||||||
{
|
{
|
||||||
Q_UNUSED(former_row);
|
Q_UNUSED(formerRow);
|
||||||
Q_UNUSED(former_owner);
|
Q_UNUSED(formerOwner);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,15 +680,15 @@ void DiagramController::onEndMoveObject(int row, const MObject *owner)
|
|||||||
onEndUpdateObject(row, owner);
|
onEndUpdateObject(row, owner);
|
||||||
|
|
||||||
// if diagram was moved update all elements because of changed context
|
// if diagram was moved update all elements because of changed context
|
||||||
MObject *model_object = m_modelController->getObject(row, owner);
|
MObject *modelObject = m_modelController->getObject(row, owner);
|
||||||
QMT_CHECK(model_object);
|
QMT_CHECK(modelObject);
|
||||||
MDiagram *model_diagram = dynamic_cast<MDiagram *>(model_object);
|
MDiagram *modelDiagram = dynamic_cast<MDiagram *>(modelObject);
|
||||||
if (model_diagram) {
|
if (modelDiagram) {
|
||||||
emit beginResetDiagram(model_diagram);
|
emit beginResetDiagram(modelDiagram);
|
||||||
foreach (DElement *diagram_element, model_diagram->getDiagramElements()) {
|
foreach (DElement *diagramElement, modelDiagram->getDiagramElements()) {
|
||||||
updateElementFromModel(diagram_element, model_diagram, false);
|
updateElementFromModel(diagramElement, modelDiagram, false);
|
||||||
}
|
}
|
||||||
emit endResetDiagram(model_diagram);
|
emit endResetDiagram(modelDiagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,9 +702,9 @@ void DiagramController::onBeginUpdateRelation(int row, const MObject *owner)
|
|||||||
|
|
||||||
void DiagramController::onEndUpdateRelation(int row, const MObject *owner)
|
void DiagramController::onEndUpdateRelation(int row, const MObject *owner)
|
||||||
{
|
{
|
||||||
MRelation *model_relation = owner->getRelations().at(row);
|
MRelation *modelRelation = owner->getRelations().at(row);
|
||||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||||
DRelation *relation = findDelegate<DRelation>(model_relation, diagram);
|
DRelation *relation = findDelegate<DRelation>(modelRelation, diagram);
|
||||||
if (relation) {
|
if (relation) {
|
||||||
updateElementFromModel(relation, diagram, true);
|
updateElementFromModel(relation, diagram, true);
|
||||||
}
|
}
|
||||||
@@ -715,8 +715,8 @@ void DiagramController::onBeginRemoveRelation(int row, const MObject *owner)
|
|||||||
{
|
{
|
||||||
QMT_CHECK(owner);
|
QMT_CHECK(owner);
|
||||||
|
|
||||||
MRelation *model_relation = owner->getRelations().at(row);
|
MRelation *modelRelation = owner->getRelations().at(row);
|
||||||
removeRelations(model_relation);
|
removeRelations(modelRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::onEndRemoveRelation(int row, const MObject *owner)
|
void DiagramController::onEndRemoveRelation(int row, const MObject *owner)
|
||||||
@@ -725,10 +725,10 @@ void DiagramController::onEndRemoveRelation(int row, const MObject *owner)
|
|||||||
Q_UNUSED(owner);
|
Q_UNUSED(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::onBeginMoveRelation(int former_row, const MObject *former_owner)
|
void DiagramController::onBeginMoveRelation(int formerRow, const MObject *formerOwner)
|
||||||
{
|
{
|
||||||
Q_UNUSED(former_row);
|
Q_UNUSED(formerRow);
|
||||||
Q_UNUSED(former_owner);
|
Q_UNUSED(formerOwner);
|
||||||
|
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
@@ -738,28 +738,28 @@ void DiagramController::onEndMoveRelation(int row, const MObject *owner)
|
|||||||
onEndUpdateRelation(row, owner);
|
onEndUpdateRelation(row, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::deleteElements(const DSelection &diagram_selection, MDiagram *diagram, const QString &command_label)
|
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram, const QString &commandLabel)
|
||||||
{
|
{
|
||||||
QMT_CHECK(diagram);
|
QMT_CHECK(diagram);
|
||||||
|
|
||||||
DReferences simplified_selection = simplify(diagram_selection, diagram);
|
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
|
||||||
if (simplified_selection.getElements().isEmpty()) {
|
if (simplifiedSelection.getElements().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
m_undoController->beginMergeSequence(command_label);
|
m_undoController->beginMergeSequence(commandLabel);
|
||||||
}
|
}
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
foreach (DElement *element, simplified_selection.getElements()) {
|
foreach (DElement *element, simplifiedSelection.getElements()) {
|
||||||
// element may have been deleted indirectly by predecessor element in loop
|
// element may have been deleted indirectly by predecessor element in loop
|
||||||
if ((element = findElement(element->getUid(), diagram))) {
|
if ((element = findElement(element->getUid(), diagram))) {
|
||||||
removeRelations(element, diagram);
|
removeRelations(element, diagram);
|
||||||
int row = diagram->getDiagramElements().indexOf(element);
|
int row = diagram->getDiagramElements().indexOf(element);
|
||||||
emit beginRemoveElement(diagram->getDiagramElements().indexOf(element), diagram);
|
emit beginRemoveElement(diagram->getDiagramElements().indexOf(element), diagram);
|
||||||
if (m_undoController) {
|
if (m_undoController) {
|
||||||
RemoveElementsCommand *cut_command = new RemoveElementsCommand(this, diagram->getUid(), command_label);
|
RemoveElementsCommand *cutCommand = new RemoveElementsCommand(this, diagram->getUid(), commandLabel);
|
||||||
m_undoController->push(cut_command);
|
m_undoController->push(cutCommand);
|
||||||
cut_command->add(element);
|
cutCommand->add(element);
|
||||||
}
|
}
|
||||||
diagram->removeDiagramElement(element);
|
diagram->removeDiagramElement(element);
|
||||||
emit endRemoveElement(row, diagram);
|
emit endRemoveElement(row, diagram);
|
||||||
@@ -785,26 +785,26 @@ DElement *DiagramController::findElementOnAnyDiagram(const Uid &uid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::removeObjects(MObject *model_object)
|
void DiagramController::removeObjects(MObject *modelObject)
|
||||||
{
|
{
|
||||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||||
DElement *diagram_element = findDelegate(model_object, diagram);
|
DElement *diagramElement = findDelegate(modelObject, diagram);
|
||||||
if (diagram_element) {
|
if (diagramElement) {
|
||||||
removeElement(diagram_element, diagram);
|
removeElement(diagramElement, diagram);
|
||||||
}
|
}
|
||||||
foreach (const Handle<MRelation> &relation, model_object->getRelations()) {
|
foreach (const Handle<MRelation> &relation, modelObject->getRelations()) {
|
||||||
DElement *diagram_element = findDelegate(relation.getTarget(), diagram);
|
DElement *diagramElement = findDelegate(relation.getTarget(), diagram);
|
||||||
if (diagram_element) {
|
if (diagramElement) {
|
||||||
removeElement(diagram_element, diagram);
|
removeElement(diagramElement, diagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (const Handle<MObject> &object, model_object->getChildren()) {
|
foreach (const Handle<MObject> &object, modelObject->getChildren()) {
|
||||||
if (object.hasTarget()) {
|
if (object.hasTarget()) {
|
||||||
removeObjects(object.getTarget());
|
removeObjects(object.getTarget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MDiagram *diagram = dynamic_cast<MDiagram *>(model_object)) {
|
if (MDiagram *diagram = dynamic_cast<MDiagram *>(modelObject)) {
|
||||||
emit diagramAboutToBeRemoved(diagram);
|
emit diagramAboutToBeRemoved(diagram);
|
||||||
QMT_CHECK(m_allDiagrams.contains(diagram));
|
QMT_CHECK(m_allDiagrams.contains(diagram));
|
||||||
m_allDiagrams.removeOne(diagram);
|
m_allDiagrams.removeOne(diagram);
|
||||||
@@ -817,59 +817,59 @@ void DiagramController::removeObjects(MObject *model_object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::removeRelations(MRelation *model_relation)
|
void DiagramController::removeRelations(MRelation *modelRelation)
|
||||||
{
|
{
|
||||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||||
DElement *diagram_element = findDelegate(model_relation, diagram);
|
DElement *diagramElement = findDelegate(modelRelation, diagram);
|
||||||
if (diagram_element) {
|
if (diagramElement) {
|
||||||
removeElement(diagram_element, diagram);
|
removeElement(diagramElement, diagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
|
void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
|
||||||
{
|
{
|
||||||
DObject *diagram_object = dynamic_cast<DObject *>(element);
|
DObject *diagramObject = dynamic_cast<DObject *>(element);
|
||||||
if (diagram_object) {
|
if (diagramObject) {
|
||||||
foreach (DElement *diagram_element, diagram->getDiagramElements()) {
|
foreach (DElement *diagramElement, diagram->getDiagramElements()) {
|
||||||
if (DRelation *diagram_relation = dynamic_cast<DRelation *>(diagram_element)) {
|
if (DRelation *diagramRelation = dynamic_cast<DRelation *>(diagramElement)) {
|
||||||
if (diagram_relation->getEndA() == diagram_object->getUid() || diagram_relation->getEndB() == diagram_object->getUid()) {
|
if (diagramRelation->getEndA() == diagramObject->getUid() || diagramRelation->getEndB() == diagramObject->getUid()) {
|
||||||
removeElement(diagram_relation, diagram);
|
removeElement(diagramRelation, diagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::renewElementKey(DElement *element, QHash<Uid, Uid> *renewed_keys)
|
void DiagramController::renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys)
|
||||||
{
|
{
|
||||||
QMT_CHECK(renewed_keys);
|
QMT_CHECK(renewedKeys);
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
DElement *existing_element_on_diagram = findElementOnAnyDiagram(element->getUid());
|
DElement *existingElementOnDiagram = findElementOnAnyDiagram(element->getUid());
|
||||||
if (existing_element_on_diagram) {
|
if (existingElementOnDiagram) {
|
||||||
QMT_CHECK(existing_element_on_diagram != element);
|
QMT_CHECK(existingElementOnDiagram != element);
|
||||||
Uid old_key = element->getUid();
|
Uid oldKey = element->getUid();
|
||||||
element->renewUid();
|
element->renewUid();
|
||||||
Uid new_key = element->getUid();
|
Uid newKey = element->getUid();
|
||||||
renewed_keys->insert(old_key, new_key);
|
renewedKeys->insert(oldKey, newKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewed_keys)
|
void DiagramController::updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewedKeys)
|
||||||
{
|
{
|
||||||
Uid new_end_a_key = renewed_keys.value(relation->getEndA(), Uid::getInvalidUid());
|
Uid newEndAKey = renewedKeys.value(relation->getEndA(), Uid::getInvalidUid());
|
||||||
if (new_end_a_key.isValid()) {
|
if (newEndAKey.isValid()) {
|
||||||
relation->setEndA(new_end_a_key);
|
relation->setEndA(newEndAKey);
|
||||||
}
|
}
|
||||||
Uid new_end_b_key = renewed_keys.value(relation->getEndB(), Uid::getInvalidUid());
|
Uid newEndBKey = renewedKeys.value(relation->getEndB(), Uid::getInvalidUid());
|
||||||
if (new_end_b_key.isValid()) {
|
if (newEndBKey.isValid()) {
|
||||||
relation->setEndB(new_end_b_key);
|
relation->setEndB(newEndBKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::updateElementFromModel(DElement *element, const MDiagram *diagram, bool emit_update_signal)
|
void DiagramController::updateElementFromModel(DElement *element, const MDiagram *diagram, bool emitUpdateSignal)
|
||||||
{
|
{
|
||||||
if (!element->getModelUid().isValid()) {
|
if (!element->getModelUid().isValid()) {
|
||||||
return;
|
return;
|
||||||
@@ -880,7 +880,7 @@ void DiagramController::updateElementFromModel(DElement *element, const MDiagram
|
|||||||
MElement *melement = m_modelController->findElement(element->getModelUid());
|
MElement *melement = m_modelController->findElement(element->getModelUid());
|
||||||
QMT_CHECK(melement);
|
QMT_CHECK(melement);
|
||||||
|
|
||||||
if (emit_update_signal) {
|
if (emitUpdateSignal) {
|
||||||
visitor.setCheckNeedsUpdate(true);
|
visitor.setCheckNeedsUpdate(true);
|
||||||
melement->accept(&visitor);
|
melement->accept(&visitor);
|
||||||
if (visitor.updateNeeded()) {
|
if (visitor.updateNeeded()) {
|
||||||
@@ -902,10 +902,10 @@ void DiagramController::diagramModified(MDiagram *diagram)
|
|||||||
emit modified(diagram);
|
emit modified(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
DReferences DiagramController::simplify(const DSelection &diagram_selection, const MDiagram *diagram)
|
DReferences DiagramController::simplify(const DSelection &diagramSelection, const MDiagram *diagram)
|
||||||
{
|
{
|
||||||
DReferences references;
|
DReferences references;
|
||||||
foreach (const DSelection::Index &index, diagram_selection.getIndices()) {
|
foreach (const DSelection::Index &index, diagramSelection.getIndices()) {
|
||||||
DElement *element = findElement(index.getElementKey(), diagram);
|
DElement *element = findElement(index.getElementKey(), diagram);
|
||||||
if (element) {
|
if (element) {
|
||||||
references.append(element);
|
references.append(element);
|
||||||
@@ -924,11 +924,11 @@ MElement *DiagramController::getDelegatedElement(const DElement *element) const
|
|||||||
|
|
||||||
bool DiagramController::isDelegatedElementOnDiagram(const DElement *element, const MDiagram *diagram) const
|
bool DiagramController::isDelegatedElementOnDiagram(const DElement *element, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
MElement *model_element = getDelegatedElement(element);
|
MElement *modelElement = getDelegatedElement(element);
|
||||||
if (!model_element) {
|
if (!modelElement) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return hasDelegate(model_element, diagram);
|
return hasDelegate(modelElement, diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramController::areRelationEndsOnDiagram(const DRelation *relation, const MDiagram *diagram) const
|
bool DiagramController::areRelationEndsOnDiagram(const DRelation *relation, const MDiagram *diagram) const
|
||||||
|
|||||||
@@ -116,15 +116,15 @@ public:
|
|||||||
|
|
||||||
ModelController *getModelController() const { return m_modelController; }
|
ModelController *getModelController() const { return m_modelController; }
|
||||||
|
|
||||||
void setModelController(ModelController *model_controller);
|
void setModelController(ModelController *modelController);
|
||||||
|
|
||||||
UndoController *getUndoController() const { return m_undoController; }
|
UndoController *getUndoController() const { return m_undoController; }
|
||||||
|
|
||||||
void setUndoController(UndoController *undo_controller);
|
void setUndoController(UndoController *undoController);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MDiagram *findDiagram(const Uid &diagram_key) const;
|
MDiagram *findDiagram(const Uid &diagramKey) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -137,17 +137,17 @@ public:
|
|||||||
template<class T>
|
template<class T>
|
||||||
T *findElement(const Uid &key, const MDiagram *diagram) const { return dynamic_cast<T *>(findElement(key, diagram)); }
|
T *findElement(const Uid &key, const MDiagram *diagram) const { return dynamic_cast<T *>(findElement(key, diagram)); }
|
||||||
|
|
||||||
bool hasDelegate(const MElement *model_element, const MDiagram *diagram) const;
|
bool hasDelegate(const MElement *modelElement, const MDiagram *diagram) const;
|
||||||
|
|
||||||
DElement *findDelegate(const MElement *model_element, const MDiagram *diagram) const;
|
DElement *findDelegate(const MElement *modelElement, const MDiagram *diagram) const;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T *findDelegate(const MElement *model_element, const MDiagram *diagram) const
|
T *findDelegate(const MElement *modelElement, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
return dynamic_cast<T *>(findDelegate(model_element, diagram));
|
return dynamic_cast<T *>(findDelegate(modelElement, diagram));
|
||||||
}
|
}
|
||||||
|
|
||||||
void startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction update_action);
|
void startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction updateAction);
|
||||||
|
|
||||||
void finishUpdateElement(DElement *element, MDiagram *diagram, bool cancelled);
|
void finishUpdateElement(DElement *element, MDiagram *diagram, bool cancelled);
|
||||||
|
|
||||||
@@ -155,13 +155,13 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DContainer cutElements(const DSelection &diagram_selection, MDiagram *diagram);
|
DContainer cutElements(const DSelection &diagramSelection, MDiagram *diagram);
|
||||||
|
|
||||||
DContainer copyElements(const DSelection &diagram_selection, const MDiagram *diagram);
|
DContainer copyElements(const DSelection &diagramSelection, const MDiagram *diagram);
|
||||||
|
|
||||||
void pasteElements(const DContainer &diagram_container, MDiagram *diagram);
|
void pasteElements(const DContainer &diagramContainer, MDiagram *diagram);
|
||||||
|
|
||||||
void deleteElements(const DSelection &diagram_selection, MDiagram *diagram);
|
void deleteElements(const DSelection &diagramSelection, MDiagram *diagram);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ private slots:
|
|||||||
|
|
||||||
void onEndRemoveObject(int row, const MObject *parent);
|
void onEndRemoveObject(int row, const MObject *parent);
|
||||||
|
|
||||||
void onBeginMoveObject(int former_row, const MObject *former_owner);
|
void onBeginMoveObject(int formerRow, const MObject *formerOwner);
|
||||||
|
|
||||||
void onEndMoveObject(int row, const MObject *owner);
|
void onEndMoveObject(int row, const MObject *owner);
|
||||||
|
|
||||||
@@ -193,31 +193,31 @@ private slots:
|
|||||||
|
|
||||||
void onEndRemoveRelation(int row, const MObject *owner);
|
void onEndRemoveRelation(int row, const MObject *owner);
|
||||||
|
|
||||||
void onBeginMoveRelation(int former_row, const MObject *former_owner);
|
void onBeginMoveRelation(int formerRow, const MObject *formerOwner);
|
||||||
|
|
||||||
void onEndMoveRelation(int row, const MObject *owner);
|
void onEndMoveRelation(int row, const MObject *owner);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void deleteElements(const DSelection &diagram_selection, MDiagram *diagram, const QString &command_label);
|
void deleteElements(const DSelection &diagramSelection, MDiagram *diagram, const QString &commandLabel);
|
||||||
|
|
||||||
DElement *findElementOnAnyDiagram(const Uid &uid);
|
DElement *findElementOnAnyDiagram(const Uid &uid);
|
||||||
|
|
||||||
void removeObjects(MObject *model_object);
|
void removeObjects(MObject *modelObject);
|
||||||
|
|
||||||
void removeRelations(MRelation *model_relation);
|
void removeRelations(MRelation *modelRelation);
|
||||||
|
|
||||||
void removeRelations(DElement *element, MDiagram *diagram);
|
void removeRelations(DElement *element, MDiagram *diagram);
|
||||||
|
|
||||||
void renewElementKey(DElement *element, QHash<Uid, Uid> *renewed_keys);
|
void renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys);
|
||||||
|
|
||||||
void updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewed_keys);
|
void updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewedKeys);
|
||||||
|
|
||||||
void updateElementFromModel(DElement *element, const MDiagram *diagram, bool emit_update_signal);
|
void updateElementFromModel(DElement *element, const MDiagram *diagram, bool emitUpdateSignal);
|
||||||
|
|
||||||
void diagramModified(MDiagram *diagram);
|
void diagramModified(MDiagram *diagram);
|
||||||
|
|
||||||
DReferences simplify(const DSelection &diagram_selection, const MDiagram *diagram);
|
DReferences simplify(const DSelection &diagramSelection, const MDiagram *diagram);
|
||||||
|
|
||||||
MElement *getDelegatedElement(const DElement *element) const;
|
MElement *getDelegatedElement(const DElement *element) const;
|
||||||
|
|
||||||
|
|||||||
@@ -54,18 +54,18 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DUpdateVisitor::DUpdateVisitor(DElement *target, const MDiagram *diagram, bool check_needs_update)
|
DUpdateVisitor::DUpdateVisitor(DElement *target, const MDiagram *diagram, bool checkNeedsUpdate)
|
||||||
: m_target(target),
|
: m_target(target),
|
||||||
m_diagram(diagram),
|
m_diagram(diagram),
|
||||||
m_checkNeedsUpdate(check_needs_update),
|
m_checkNeedsUpdate(checkNeedsUpdate),
|
||||||
m_updateNeeded(!check_needs_update)
|
m_updateNeeded(!checkNeedsUpdate)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DUpdateVisitor::setCheckNeedsUpdate(bool check_needs_update)
|
void DUpdateVisitor::setCheckNeedsUpdate(bool checkNeedsUpdate)
|
||||||
{
|
{
|
||||||
m_checkNeedsUpdate = check_needs_update;
|
m_checkNeedsUpdate = checkNeedsUpdate;
|
||||||
m_updateNeeded = !check_needs_update;
|
m_updateNeeded = !checkNeedsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DUpdateVisitor::visitMElement(const MElement *element)
|
void DUpdateVisitor::visitMElement(const MElement *element)
|
||||||
@@ -82,11 +82,11 @@ void DUpdateVisitor::visitMObject(const MObject *object)
|
|||||||
if (isUpdating(object->getStereotypes() != dobject->getStereotypes())) {
|
if (isUpdating(object->getStereotypes() != dobject->getStereotypes())) {
|
||||||
dobject->setStereotypes(object->getStereotypes());
|
dobject->setStereotypes(object->getStereotypes());
|
||||||
}
|
}
|
||||||
const MObject *object_owner = object->getOwner();
|
const MObject *objectOwner = object->getOwner();
|
||||||
const MObject *diagram_owner = m_diagram->getOwner();
|
const MObject *diagramOwner = m_diagram->getOwner();
|
||||||
if (object_owner && diagram_owner && object_owner->getUid() != diagram_owner->getUid()) {
|
if (objectOwner && diagramOwner && objectOwner->getUid() != diagramOwner->getUid()) {
|
||||||
if (isUpdating(object_owner->getName() != dobject->getContext())) {
|
if (isUpdating(objectOwner->getName() != dobject->getContext())) {
|
||||||
dobject->setContext(object_owner->getName());
|
dobject->setContext(objectOwner->getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isUpdating(!dobject->getContext().isEmpty())) {
|
if (isUpdating(!dobject->getContext().isEmpty())) {
|
||||||
@@ -191,34 +191,34 @@ void DUpdateVisitor::visitMAssociation(const MAssociation *association)
|
|||||||
{
|
{
|
||||||
DAssociation *dassociation = dynamic_cast<DAssociation *>(m_target);
|
DAssociation *dassociation = dynamic_cast<DAssociation *>(m_target);
|
||||||
QMT_CHECK(dassociation);
|
QMT_CHECK(dassociation);
|
||||||
DAssociationEnd end_a;
|
DAssociationEnd endA;
|
||||||
end_a.setName(association->getA().getName());
|
endA.setName(association->getA().getName());
|
||||||
end_a.setCardinatlity(association->getA().getCardinality());
|
endA.setCardinatlity(association->getA().getCardinality());
|
||||||
end_a.setNavigable(association->getA().isNavigable());
|
endA.setNavigable(association->getA().isNavigable());
|
||||||
end_a.setKind(association->getA().getKind());
|
endA.setKind(association->getA().getKind());
|
||||||
if (isUpdating(end_a != dassociation->getA())) {
|
if (isUpdating(endA != dassociation->getA())) {
|
||||||
dassociation->setA(end_a);
|
dassociation->setA(endA);
|
||||||
}
|
}
|
||||||
DAssociationEnd end_b;
|
DAssociationEnd endB;
|
||||||
end_b.setName(association->getB().getName());
|
endB.setName(association->getB().getName());
|
||||||
end_b.setCardinatlity(association->getB().getCardinality());
|
endB.setCardinatlity(association->getB().getCardinality());
|
||||||
end_b.setNavigable(association->getB().isNavigable());
|
endB.setNavigable(association->getB().isNavigable());
|
||||||
end_b.setKind(association->getB().getKind());
|
endB.setKind(association->getB().getKind());
|
||||||
if (isUpdating(end_b != dassociation->getB())) {
|
if (isUpdating(endB != dassociation->getB())) {
|
||||||
dassociation->setB(end_b);
|
dassociation->setB(endB);
|
||||||
}
|
}
|
||||||
visitMRelation(association);
|
visitMRelation(association);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DUpdateVisitor::isUpdating(bool value_changed)
|
bool DUpdateVisitor::isUpdating(bool valueChanged)
|
||||||
{
|
{
|
||||||
if (m_checkNeedsUpdate) {
|
if (m_checkNeedsUpdate) {
|
||||||
if (value_changed) {
|
if (valueChanged) {
|
||||||
m_updateNeeded = true;
|
m_updateNeeded = true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return value_changed;
|
return valueChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ class QMT_EXPORT DUpdateVisitor :
|
|||||||
public MConstVisitor
|
public MConstVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DUpdateVisitor(DElement *target, const MDiagram *diagram, bool check_needs_update = false);
|
DUpdateVisitor(DElement *target, const MDiagram *diagram, bool checkNeedsUpdate = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool updateNeeded() const { return m_updateNeeded; }
|
bool updateNeeded() const { return m_updateNeeded; }
|
||||||
|
|
||||||
void setCheckNeedsUpdate(bool check_needs_update);
|
void setCheckNeedsUpdate(bool checkNeedsUpdate);
|
||||||
|
|
||||||
void visitMElement(const MElement *element);
|
void visitMElement(const MElement *element);
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool isUpdating(bool value_changed);
|
bool isUpdating(bool valueChanged);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void align(AlignType align_type, const QString &identifier) = 0;
|
virtual void align(AlignType alignType, const QString &identifier) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
virtual ~IIntersectionable() { }
|
virtual ~IIntersectionable() { }
|
||||||
|
|
||||||
virtual bool intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line = 0) const = 0;
|
virtual bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine = 0) const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Latch(LatchType latch_type, qreal pos, qreal other_pos1, qreal other_pos2, const QString &identifier)
|
Latch(LatchType latchType, qreal pos, qreal otherPos1, qreal otherPos2, const QString &identifier)
|
||||||
: m_latchType(latch_type),
|
: m_latchType(latchType),
|
||||||
m_pos(pos),
|
m_pos(pos),
|
||||||
m_otherPos1(other_pos1),
|
m_otherPos1(otherPos1),
|
||||||
m_otherPos2(other_pos2),
|
m_otherPos2(otherPos2),
|
||||||
m_identifier(identifier)
|
m_identifier(identifier)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -85,9 +85,9 @@ public:
|
|||||||
|
|
||||||
virtual ~ILatchable() { }
|
virtual ~ILatchable() { }
|
||||||
|
|
||||||
virtual QList<Latch> getHorizontalLatches(Action action, bool grabbed_item) const = 0;
|
virtual QList<Latch> getHorizontalLatches(Action action, bool grabbedItem) const = 0;
|
||||||
|
|
||||||
virtual QList<Latch> getVerticalLatches(Action action, bool grabbed_item) const = 0;
|
virtual QList<Latch> getVerticalLatches(Action action, bool grabbedItem) const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
virtual void moveDelta(const QPointF &delta) = 0;
|
virtual void moveDelta(const QPointF &delta) = 0;
|
||||||
|
|
||||||
virtual void alignItemPositionToRaster(double raster_width, double raster_height) = 0;
|
virtual void alignItemPositionToRaster(double rasterWidth, double rasterHeight) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
virtual QPointF getRelationStartPos() const = 0;
|
virtual QPointF getRelationStartPos() const = 0;
|
||||||
|
|
||||||
virtual void relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points) = 0;
|
virtual void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ public:
|
|||||||
|
|
||||||
virtual QSizeF getMinimumSize() const = 0;
|
virtual QSizeF getMinimumSize() const = 0;
|
||||||
|
|
||||||
virtual void setPosAndRect(const QPointF &original_pos, const QRectF &original_rect, const QPointF &top_left_delta, const QPointF &bottom_right_delta) = 0;
|
virtual void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta) = 0;
|
||||||
|
|
||||||
virtual void alignItemSizeToRaster(Side adjust_horizontal_side, Side adjust_vertical_side, double raster_width, double raster_height) = 0;
|
virtual void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ public:
|
|||||||
|
|
||||||
virtual bool isSecondarySelected() const = 0;
|
virtual bool isSecondarySelected() const = 0;
|
||||||
|
|
||||||
virtual void setSecondarySelected(bool secondary_selected) = 0;
|
virtual void setSecondarySelected(bool secondarySelected) = 0;
|
||||||
|
|
||||||
virtual bool isFocusSelected() const = 0;
|
virtual bool isFocusSelected() const = 0;
|
||||||
|
|
||||||
virtual void setFocusSelected(bool focus_selected) = 0;
|
virtual void setFocusSelected(bool focusSelected) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,13 +47,13 @@ public:
|
|||||||
|
|
||||||
virtual QPointF getHandlePos(int index) = 0;
|
virtual QPointF getHandlePos(int index) = 0;
|
||||||
|
|
||||||
virtual void insertHandle(int before_index, const QPointF &pos) = 0;
|
virtual void insertHandle(int beforeIndex, const QPointF &pos) = 0;
|
||||||
|
|
||||||
virtual void deleteHandle(int index) = 0;
|
virtual void deleteHandle(int index) = 0;
|
||||||
|
|
||||||
virtual void setHandlePos(int index, const QPointF &pos) = 0;
|
virtual void setHandlePos(int index, const QPointF &pos) = 0;
|
||||||
|
|
||||||
virtual void alignHandleToRaster(int index, double raster_width, double raster_height) = 0;
|
virtual void alignHandleToRaster(int index, double rasterWidth, double rasterHeight) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,9 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DiagramGraphicsScene::DiagramGraphicsScene(DiagramSceneModel *diagram_scene_model, QObject *parent)
|
DiagramGraphicsScene::DiagramGraphicsScene(DiagramSceneModel *diagramSceneModel, QObject *parent)
|
||||||
: QGraphicsScene(parent),
|
: QGraphicsScene(parent),
|
||||||
m_diagramSceneModel(diagram_scene_model)
|
m_diagramSceneModel(diagramSceneModel)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class QMT_EXPORT DiagramGraphicsScene :
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DiagramGraphicsScene(DiagramSceneModel *diagram_scene_model, QObject *parent = 0);
|
DiagramGraphicsScene(DiagramSceneModel *diagramSceneModel, QObject *parent = 0);
|
||||||
|
|
||||||
~DiagramGraphicsScene();
|
~DiagramGraphicsScene();
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ DiagramSceneModel::DiagramSceneModel(QObject *parent)
|
|||||||
m_focusItem(0)
|
m_focusItem(0)
|
||||||
{
|
{
|
||||||
m_latchController->setDiagramSceneModel(this);
|
m_latchController->setDiagramSceneModel(this);
|
||||||
connect(m_graphicsScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
connect(m_graphicsScene, SIGNAL(selectionHasChanged()), this, SLOT(onSelectionChanged()));
|
||||||
|
|
||||||
// add one item at origin to force scene rect to include origin always
|
// add one item at origin to force scene rect to include origin always
|
||||||
m_graphicsScene->addItem(m_originItem);
|
m_graphicsScene->addItem(m_originItem);
|
||||||
@@ -137,17 +137,17 @@ DiagramSceneModel::~DiagramSceneModel()
|
|||||||
m_graphicsScene->deleteLater();
|
m_graphicsScene->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::setDiagramController(DiagramController *diagram_controller)
|
void DiagramSceneModel::setDiagramController(DiagramController *diagramController)
|
||||||
{
|
{
|
||||||
if (m_diagramController == diagram_controller) {
|
if (m_diagramController == diagramController) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_diagramController) {
|
if (m_diagramController) {
|
||||||
disconnect(m_diagramController, 0, this, 0);
|
disconnect(m_diagramController, 0, this, 0);
|
||||||
m_diagramController = 0;
|
m_diagramController = 0;
|
||||||
}
|
}
|
||||||
m_diagramController = diagram_controller;
|
m_diagramController = diagramController;
|
||||||
if (diagram_controller) {
|
if (diagramController) {
|
||||||
connect(m_diagramController, SIGNAL(beginResetAllDiagrams()), this, SLOT(onBeginResetAllDiagrams()));
|
connect(m_diagramController, SIGNAL(beginResetAllDiagrams()), this, SLOT(onBeginResetAllDiagrams()));
|
||||||
connect(m_diagramController, SIGNAL(endResetAllDiagrams()), this, SLOT(onEndResetAllDiagrams()));
|
connect(m_diagramController, SIGNAL(endResetAllDiagrams()), this, SLOT(onEndResetAllDiagrams()));
|
||||||
connect(m_diagramController, SIGNAL(beginResetDiagram(const MDiagram*)), this, SLOT(onBeginResetDiagram(const MDiagram*)));
|
connect(m_diagramController, SIGNAL(beginResetDiagram(const MDiagram*)), this, SLOT(onBeginResetDiagram(const MDiagram*)));
|
||||||
@@ -161,19 +161,19 @@ void DiagramSceneModel::setDiagramController(DiagramController *diagram_controll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::setDiagramSceneController(DiagramSceneController *diagram_scene_controller)
|
void DiagramSceneModel::setDiagramSceneController(DiagramSceneController *diagramSceneController)
|
||||||
{
|
{
|
||||||
m_diagramSceneController = diagram_scene_controller;
|
m_diagramSceneController = diagramSceneController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::setStyleController(StyleController *style_controller)
|
void DiagramSceneModel::setStyleController(StyleController *styleController)
|
||||||
{
|
{
|
||||||
m_styleController = style_controller;
|
m_styleController = styleController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::setStereotypeController(StereotypeController *stereotype_controller)
|
void DiagramSceneModel::setStereotypeController(StereotypeController *stereotypeController)
|
||||||
{
|
{
|
||||||
m_stereotypeController = stereotype_controller;
|
m_stereotypeController = stereotypeController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::setDiagram(MDiagram *diagram)
|
void DiagramSceneModel::setDiagram(MDiagram *diagram)
|
||||||
@@ -222,10 +222,10 @@ DSelection DiagramSceneModel::getSelectedElements() const
|
|||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
DElement *DiagramSceneModel::findTopmostElement(const QPointF &scene_pos) const
|
DElement *DiagramSceneModel::findTopmostElement(const QPointF &scenePos) const
|
||||||
{
|
{
|
||||||
// fetch affected items from scene in correct drawing order to find topmost element
|
// fetch affected items from scene in correct drawing order to find topmost element
|
||||||
QList<QGraphicsItem *> items = m_graphicsScene->items(scene_pos);
|
QList<QGraphicsItem *> items = m_graphicsScene->items(scenePos);
|
||||||
foreach (QGraphicsItem *item, items) {
|
foreach (QGraphicsItem *item, items) {
|
||||||
if (m_graphicsItems.contains(item)) {
|
if (m_graphicsItems.contains(item)) {
|
||||||
return m_itemToElementMap.value(item);
|
return m_itemToElementMap.value(item);
|
||||||
@@ -269,14 +269,14 @@ void DiagramSceneModel::selectAllElements()
|
|||||||
|
|
||||||
void DiagramSceneModel::selectElement(DElement *element)
|
void DiagramSceneModel::selectElement(DElement *element)
|
||||||
{
|
{
|
||||||
QGraphicsItem *select_item = m_elementToItemMap.value(element);
|
QGraphicsItem *selectItem = m_elementToItemMap.value(element);
|
||||||
foreach (QGraphicsItem *item, m_selectedItems) {
|
foreach (QGraphicsItem *item, m_selectedItems) {
|
||||||
if (item != select_item) {
|
if (item != selectItem) {
|
||||||
item->setSelected(false);
|
item->setSelected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (select_item) {
|
if (selectItem) {
|
||||||
select_item->setSelected(true);
|
selectItem->setSelected(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,26 +290,26 @@ void DiagramSceneModel::editElement(DElement *element)
|
|||||||
|
|
||||||
void DiagramSceneModel::copyToClipboard()
|
void DiagramSceneModel::copyToClipboard()
|
||||||
{
|
{
|
||||||
QMimeData *mime_data = new QMimeData();
|
QMimeData *mimeData = new QMimeData();
|
||||||
|
|
||||||
// Selections would also render to the clipboard
|
// Selections would also render to the clipboard
|
||||||
m_graphicsScene->clearSelection();
|
m_graphicsScene->clearSelection();
|
||||||
removeExtraSceneItems();
|
removeExtraSceneItems();
|
||||||
|
|
||||||
QRectF scene_bounding_rect = m_graphicsScene->itemsBoundingRect();
|
QRectF sceneBoundingRect = m_graphicsScene->itemsBoundingRect();
|
||||||
|
|
||||||
{
|
{
|
||||||
// Create the image with the size of the shrunk scene
|
// Create the image with the size of the shrunk scene
|
||||||
const int scale_factor = 4;
|
const int scaleFactor = 4;
|
||||||
const int border = 4;
|
const int border = 4;
|
||||||
const int base_dpi = 75;
|
const int baseDpi = 75;
|
||||||
const int dots_per_meter = 10000 * base_dpi / 254;
|
const int dotsPerMeter = 10000 * baseDpi / 254;
|
||||||
QSize image_size = scene_bounding_rect.size().toSize();
|
QSize imageSize = sceneBoundingRect.size().toSize();
|
||||||
image_size += QSize(2 * border, 2 * border);
|
imageSize += QSize(2 * border, 2 * border);
|
||||||
image_size *= scale_factor;
|
imageSize *= scaleFactor;
|
||||||
QImage image(image_size, QImage::Format_ARGB32);
|
QImage image(imageSize, QImage::Format_ARGB32);
|
||||||
image.setDotsPerMeterX(dots_per_meter * scale_factor);
|
image.setDotsPerMeterX(dotsPerMeter * scaleFactor);
|
||||||
image.setDotsPerMeterY(dots_per_meter * scale_factor);
|
image.setDotsPerMeterY(dotsPerMeter * scaleFactor);
|
||||||
image.fill(Qt::white);
|
image.fill(Qt::white);
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
painter.begin(&image);
|
painter.begin(&image);
|
||||||
@@ -317,57 +317,57 @@ void DiagramSceneModel::copyToClipboard()
|
|||||||
m_graphicsScene->render(&painter,
|
m_graphicsScene->render(&painter,
|
||||||
QRectF(border, border,
|
QRectF(border, border,
|
||||||
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
|
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
|
||||||
scene_bounding_rect);
|
sceneBoundingRect);
|
||||||
painter.end();
|
painter.end();
|
||||||
mime_data->setImageData(image);
|
mimeData->setImageData(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_PDF_CLIPBOARD
|
#ifdef USE_PDF_CLIPBOARD
|
||||||
{
|
{
|
||||||
const double scale_factor = 1.0;
|
const double scaleFactor = 1.0;
|
||||||
const double border = 5;
|
const double border = 5;
|
||||||
const double base_dpi = 100;
|
const double baseDpi = 100;
|
||||||
const double dots_per_mm = 25.4 / base_dpi;
|
const double dotsPerMm = 25.4 / baseDpi;
|
||||||
|
|
||||||
QBuffer pdf_buffer;
|
QBuffer pdfBuffer;
|
||||||
pdf_buffer.open(QIODevice::WriteOnly);
|
pdfBuffer.open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
QPdfWriter pdf_writer(&pdf_buffer);
|
QPdfWriter pdfWriter(&pdfBuffer);
|
||||||
QSizeF page_size = scene_bounding_rect.size();
|
QSizeF pageSize = sceneBoundingRect.size();
|
||||||
page_size += QSizeF(2.0 * border, 2.0 * border);
|
pageSize += QSizeF(2.0 * border, 2.0 * border);
|
||||||
page_size *= scale_factor;
|
pageSize *= scaleFactor;
|
||||||
pdf_writer.setPageSize(QPdfWriter::Custom);
|
pdfWriter.setPageSize(QPdfWriter::Custom);
|
||||||
pdf_writer.setPageSizeMM(page_size * dots_per_mm);
|
pdfWriter.setPageSizeMM(pageSize * dotsPerMm);
|
||||||
|
|
||||||
QPainter pdf_painter;
|
QPainter pdfPainter;
|
||||||
pdf_painter.begin(&pdf_writer);
|
pdfPainter.begin(&pdfWriter);
|
||||||
m_graphicsScene->render(&pdf_painter,
|
m_graphicsScene->render(&pdfPainter,
|
||||||
QRectF(border, border,
|
QRectF(border, border,
|
||||||
pdf_painter.device()->width() - 2 * border, pdf_painter.device()->height() - 2 * border),
|
pdfPainter.device()->width() - 2 * border, pdfPainter.device()->height() - 2 * border),
|
||||||
scene_bounding_rect);
|
sceneBoundingRect);
|
||||||
pdf_painter.end();
|
pdfPainter.end();
|
||||||
pdf_buffer.close();
|
pdfBuffer.close();
|
||||||
mime_data->setData(QStringLiteral("application/pdf"), pdf_buffer.buffer());
|
mimeData->setData(QStringLiteral("application/pdf"), pdfBuffer.buffer());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SVG_CLIPBOARD
|
#ifdef USE_SVG_CLIPBOARD
|
||||||
{
|
{
|
||||||
QBuffer svg_buffer;
|
QBuffer svgBuffer;
|
||||||
QSvgGenerator svg_generator;
|
QSvgGenerator svgGenerator;
|
||||||
svg_generator.setOutputDevice(&svg_buffer);
|
svgGenerator.setOutputDevice(&svgBuffer);
|
||||||
QSize svg_scene_size = scene_bounding_rect.size().toSize();
|
QSize svgSceneSize = sceneBoundingRect.size().toSize();
|
||||||
svg_generator.setSize(svg_scene_size);
|
svgGenerator.setSize(svgSceneSize);
|
||||||
svg_generator.setViewBox(QRect(QPoint(0,0), svg_scene_size));
|
svgGenerator.setViewBox(QRect(QPoint(0,0), svgSceneSize));
|
||||||
QPainter svg_painter;
|
QPainter svgPainter;
|
||||||
svg_painter.begin(&svg_generator);
|
svgPainter.begin(&svgGenerator);
|
||||||
svg_painter.setRenderHint(QPainter::Antialiasing);
|
svgPainter.setRenderHint(QPainter::Antialiasing);
|
||||||
m_graphicsScene->render(&svg_painter,
|
m_graphicsScene->render(&svgPainter,
|
||||||
QRectF(border, border,
|
QRectF(border, border,
|
||||||
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
|
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
|
||||||
scene_bounding_rect);
|
sceneBoundingRect);
|
||||||
svg_painter.end();
|
svgPainter.end();
|
||||||
mime_data->setData(QStringLiteral("image/svg+xml"), svg_buffer.buffer());
|
mimeData->setData(QStringLiteral("image/svg+xml"), svgBuffer.buffer());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -375,30 +375,30 @@ void DiagramSceneModel::copyToClipboard()
|
|||||||
// TODO implement emf clipboard
|
// TODO implement emf clipboard
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QApplication::clipboard()->setMimeData(mime_data, QClipboard::Clipboard);
|
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
|
||||||
|
|
||||||
addExtraSceneItems();
|
addExtraSceneItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramSceneModel::exportPng(const QString &file_name)
|
bool DiagramSceneModel::exportPng(const QString &fileName)
|
||||||
{
|
{
|
||||||
removeExtraSceneItems();
|
removeExtraSceneItems();
|
||||||
|
|
||||||
QRectF scene_bounding_rect = m_graphicsScene->itemsBoundingRect();
|
QRectF sceneBoundingRect = m_graphicsScene->itemsBoundingRect();
|
||||||
|
|
||||||
// Create the image with the size of the shrunk scene
|
// Create the image with the size of the shrunk scene
|
||||||
const int scale_factor = 1;
|
const int scaleFactor = 1;
|
||||||
const int border = 5;
|
const int border = 5;
|
||||||
const int base_dpi = 75;
|
const int baseDpi = 75;
|
||||||
const int dots_per_meter = 10000 * base_dpi / 254;
|
const int dotsPerMeter = 10000 * baseDpi / 254;
|
||||||
|
|
||||||
QSize image_size = scene_bounding_rect.size().toSize();
|
QSize imageSize = sceneBoundingRect.size().toSize();
|
||||||
image_size += QSize(2 * border, 2 * border);
|
imageSize += QSize(2 * border, 2 * border);
|
||||||
image_size *= scale_factor;
|
imageSize *= scaleFactor;
|
||||||
|
|
||||||
QImage image(image_size, QImage::Format_ARGB32);
|
QImage image(imageSize, QImage::Format_ARGB32);
|
||||||
image.setDotsPerMeterX(dots_per_meter * scale_factor);
|
image.setDotsPerMeterX(dotsPerMeter * scaleFactor);
|
||||||
image.setDotsPerMeterY(dots_per_meter * scale_factor);
|
image.setDotsPerMeterY(dotsPerMeter * scaleFactor);
|
||||||
image.fill(Qt::white);
|
image.fill(Qt::white);
|
||||||
|
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
@@ -407,53 +407,53 @@ bool DiagramSceneModel::exportPng(const QString &file_name)
|
|||||||
m_graphicsScene->render(&painter,
|
m_graphicsScene->render(&painter,
|
||||||
QRectF(border, border,
|
QRectF(border, border,
|
||||||
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
|
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
|
||||||
scene_bounding_rect);
|
sceneBoundingRect);
|
||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
bool success = image.save(file_name);
|
bool success = image.save(fileName);
|
||||||
|
|
||||||
addExtraSceneItems();
|
addExtraSceneItems();
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::exportPdf(const QString &file_name)
|
void DiagramSceneModel::exportPdf(const QString &fileName)
|
||||||
{
|
{
|
||||||
removeExtraSceneItems();
|
removeExtraSceneItems();
|
||||||
|
|
||||||
QRectF scene_bounding_rect = m_graphicsScene->itemsBoundingRect();
|
QRectF sceneBoundingRect = m_graphicsScene->itemsBoundingRect();
|
||||||
|
|
||||||
const double scale_factor = 1.0;
|
const double scaleFactor = 1.0;
|
||||||
const double border = 5;
|
const double border = 5;
|
||||||
const double base_dpi = 100;
|
const double baseDpi = 100;
|
||||||
const double dots_per_mm = 25.4 / base_dpi;
|
const double dotsPerMm = 25.4 / baseDpi;
|
||||||
|
|
||||||
QSizeF page_size = scene_bounding_rect.size();
|
QSizeF pageSize = sceneBoundingRect.size();
|
||||||
page_size += QSizeF(2.0 * border, 2.0 * border);
|
pageSize += QSizeF(2.0 * border, 2.0 * border);
|
||||||
page_size *= scale_factor;
|
pageSize *= scaleFactor;
|
||||||
|
|
||||||
QPdfWriter pdf_writer(file_name);
|
QPdfWriter pdfWriter(fileName);
|
||||||
pdf_writer.setPageSize(QPdfWriter::Custom);
|
pdfWriter.setPageSize(QPdfWriter::Custom);
|
||||||
pdf_writer.setPageSizeMM(page_size * dots_per_mm);
|
pdfWriter.setPageSizeMM(pageSize * dotsPerMm);
|
||||||
|
|
||||||
QPainter pdf_painter;
|
QPainter pdfPainter;
|
||||||
pdf_painter.begin(&pdf_writer);
|
pdfPainter.begin(&pdfWriter);
|
||||||
m_graphicsScene->render(&pdf_painter,
|
m_graphicsScene->render(&pdfPainter,
|
||||||
QRectF(border, border,
|
QRectF(border, border,
|
||||||
pdf_painter.device()->width() - 2 * border, pdf_painter.device()->height() - 2 * border),
|
pdfPainter.device()->width() - 2 * border, pdfPainter.device()->height() - 2 * border),
|
||||||
scene_bounding_rect);
|
sceneBoundingRect);
|
||||||
pdf_painter.end();
|
pdfPainter.end();
|
||||||
|
|
||||||
addExtraSceneItems();
|
addExtraSceneItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::selectItem(QGraphicsItem *item, bool multi_select)
|
void DiagramSceneModel::selectItem(QGraphicsItem *item, bool multiSelect)
|
||||||
{
|
{
|
||||||
if (!multi_select) {
|
if (!multiSelect) {
|
||||||
if (!item->isSelected()) {
|
if (!item->isSelected()) {
|
||||||
foreach (QGraphicsItem *selected_item, m_selectedItems) {
|
foreach (QGraphicsItem *selectedItem, m_selectedItems) {
|
||||||
if (selected_item != item) {
|
if (selectedItem != item) {
|
||||||
selected_item->setSelected(false);
|
selectedItem->setSelected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item->setSelected(true);
|
item->setSelected(true);
|
||||||
@@ -463,9 +463,9 @@ void DiagramSceneModel::selectItem(QGraphicsItem *item, bool multi_select)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::moveSelectedItems(QGraphicsItem *grabbed_item, const QPointF &delta)
|
void DiagramSceneModel::moveSelectedItems(QGraphicsItem *grabbedItem, const QPointF &delta)
|
||||||
{
|
{
|
||||||
Q_UNUSED(grabbed_item);
|
Q_UNUSED(grabbedItem);
|
||||||
|
|
||||||
if (delta != QPointF(0.0, 0.0)) {
|
if (delta != QPointF(0.0, 0.0)) {
|
||||||
foreach (QGraphicsItem *item, m_selectedItems) {
|
foreach (QGraphicsItem *item, m_selectedItems) {
|
||||||
@@ -503,50 +503,50 @@ void DiagramSceneModel::onDoubleClickedItem(QGraphicsItem *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGraphicsItem *item, CollidingMode colliding_mode) const
|
QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGraphicsItem *item, CollidingMode collidingMode) const
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> colliding_items;
|
QList<QGraphicsItem *> collidingItems;
|
||||||
|
|
||||||
const IResizable *resizable = dynamic_cast<const IResizable *>(item);
|
const IResizable *resizable = dynamic_cast<const IResizable *>(item);
|
||||||
if (!resizable) {
|
if (!resizable) {
|
||||||
return colliding_items;
|
return collidingItems;
|
||||||
}
|
}
|
||||||
QRectF rect = resizable->getRect();
|
QRectF rect = resizable->getRect();
|
||||||
rect.translate(resizable->getPos());
|
rect.translate(resizable->getPos());
|
||||||
|
|
||||||
switch (colliding_mode) {
|
switch (collidingMode) {
|
||||||
case COLLIDING_INNER_ITEMS:
|
case COLLIDING_INNER_ITEMS:
|
||||||
foreach (QGraphicsItem *candidate, m_graphicsItems) {
|
foreach (QGraphicsItem *candidate, m_graphicsItems) {
|
||||||
if (const IResizable *candidate_resizable = dynamic_cast<const IResizable *>(candidate)) {
|
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
|
||||||
QRectF candidate_rect = candidate_resizable->getRect();
|
QRectF candidateRect = candidateResizable->getRect();
|
||||||
candidate_rect.translate(candidate_resizable->getPos());
|
candidateRect.translate(candidateResizable->getPos());
|
||||||
if (candidate_rect.left() >= rect.left() && candidate_rect.right() <= rect.right()
|
if (candidateRect.left() >= rect.left() && candidateRect.right() <= rect.right()
|
||||||
&& candidate_rect.top() >= rect.top() && candidate_rect.bottom() <= rect.bottom()) {
|
&& candidateRect.top() >= rect.top() && candidateRect.bottom() <= rect.bottom()) {
|
||||||
colliding_items.append(candidate);
|
collidingItems.append(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLLIDING_ITEMS:
|
case COLLIDING_ITEMS:
|
||||||
foreach (QGraphicsItem *candidate, m_graphicsItems) {
|
foreach (QGraphicsItem *candidate, m_graphicsItems) {
|
||||||
if (const IResizable *candidate_resizable = dynamic_cast<const IResizable *>(candidate)) {
|
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
|
||||||
QRectF candidate_rect = candidate_resizable->getRect();
|
QRectF candidateRect = candidateResizable->getRect();
|
||||||
candidate_rect.translate(candidate_resizable->getPos());
|
candidateRect.translate(candidateResizable->getPos());
|
||||||
if (candidate_rect.left() <= rect.right() && candidate_rect.right() >= rect.left()
|
if (candidateRect.left() <= rect.right() && candidateRect.right() >= rect.left()
|
||||||
&& candidate_rect.top() <= rect.bottom() && candidate_rect.bottom() >= rect.top()) {
|
&& candidateRect.top() <= rect.bottom() && candidateRect.bottom() >= rect.top()) {
|
||||||
colliding_items.append(candidate);
|
collidingItems.append(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLLIDING_OUTER_ITEMS:
|
case COLLIDING_OUTER_ITEMS:
|
||||||
foreach (QGraphicsItem *candidate, m_graphicsItems) {
|
foreach (QGraphicsItem *candidate, m_graphicsItems) {
|
||||||
if (const IResizable *candidate_resizable = dynamic_cast<const IResizable *>(candidate)) {
|
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
|
||||||
QRectF candidate_rect = candidate_resizable->getRect();
|
QRectF candidateRect = candidateResizable->getRect();
|
||||||
candidate_rect.translate(candidate_resizable->getPos());
|
candidateRect.translate(candidateResizable->getPos());
|
||||||
if (candidate_rect.left() <= rect.left() && candidate_rect.right() >= rect.right()
|
if (candidateRect.left() <= rect.left() && candidateRect.right() >= rect.right()
|
||||||
&& candidate_rect.top() <= rect.top() && candidate_rect.bottom() >= rect.bottom()) {
|
&& candidateRect.top() <= rect.top() && candidateRect.bottom() >= rect.bottom()) {
|
||||||
colliding_items.append(candidate);
|
collidingItems.append(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -554,7 +554,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
|
|||||||
default:
|
default:
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
}
|
}
|
||||||
return colliding_items;
|
return collidingItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::sceneActivated()
|
void DiagramSceneModel::sceneActivated()
|
||||||
@@ -605,31 +605,31 @@ void DiagramSceneModel::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
void DiagramSceneModel::mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *event)
|
void DiagramSceneModel::mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->modifiers() & Qt::AltModifier) {
|
if (event->modifiers() & Qt::AltModifier) {
|
||||||
ModelController *model_controller = getDiagramController()->getModelController();
|
ModelController *modelController = getDiagramController()->getModelController();
|
||||||
MPackage *new_owner = 0;
|
MPackage *newOwner = 0;
|
||||||
QSet<QGraphicsItem *> selected_item_set = m_graphicsScene->selectedItems().toSet();
|
QSet<QGraphicsItem *> selectedItemSet = m_graphicsScene->selectedItems().toSet();
|
||||||
QList<QGraphicsItem *> items_under_mouse = m_graphicsScene->items(event->scenePos());
|
QList<QGraphicsItem *> itemsUnderMouse = m_graphicsScene->items(event->scenePos());
|
||||||
foreach (QGraphicsItem *item, items_under_mouse) {
|
foreach (QGraphicsItem *item, itemsUnderMouse) {
|
||||||
if (!selected_item_set.contains(item)) {
|
if (!selectedItemSet.contains(item)) {
|
||||||
// the item may be any graphics item not matching to a DElement
|
// the item may be any graphics item not matching to a DElement
|
||||||
DElement *element = m_itemToElementMap.value(item);
|
DElement *element = m_itemToElementMap.value(item);
|
||||||
if (element && element->getModelUid().isValid()) {
|
if (element && element->getModelUid().isValid()) {
|
||||||
new_owner = model_controller->findElement<MPackage>(element->getModelUid());
|
newOwner = modelController->findElement<MPackage>(element->getModelUid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (new_owner) {
|
if (newOwner) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (new_owner) {
|
if (newOwner) {
|
||||||
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
|
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
|
||||||
DElement *element = m_itemToElementMap.value(item);
|
DElement *element = m_itemToElementMap.value(item);
|
||||||
QMT_CHECK(element);
|
QMT_CHECK(element);
|
||||||
if (element->getModelUid().isValid()) {
|
if (element->getModelUid().isValid()) {
|
||||||
MObject *model_object = model_controller->findObject(element->getModelUid());
|
MObject *modelObject = modelController->findObject(element->getModelUid());
|
||||||
if (model_object) {
|
if (modelObject) {
|
||||||
if (new_owner != model_object->getOwner()) {
|
if (newOwner != modelObject->getOwner()) {
|
||||||
model_controller->moveObject(new_owner, model_object);
|
modelController->moveObject(newOwner, modelObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -743,38 +743,38 @@ void DiagramSceneModel::onEndRemoveElement(int row, const MDiagram *diagram)
|
|||||||
|
|
||||||
void DiagramSceneModel::onSelectionChanged()
|
void DiagramSceneModel::onSelectionChanged()
|
||||||
{
|
{
|
||||||
bool selection_changed = false;
|
bool selectionChanged = false;
|
||||||
|
|
||||||
// collect and update all primary selected items (selected by user)
|
// collect and update all primary selected items (selected by user)
|
||||||
QSet<QGraphicsItem *> new_selected_items = QSet<QGraphicsItem *>::fromList(m_graphicsScene->selectedItems());
|
QSet<QGraphicsItem *> newSelectedItems = QSet<QGraphicsItem *>::fromList(m_graphicsScene->selectedItems());
|
||||||
updateFocusItem(new_selected_items);
|
updateFocusItem(newSelectedItems);
|
||||||
foreach (QGraphicsItem *item, m_selectedItems) {
|
foreach (QGraphicsItem *item, m_selectedItems) {
|
||||||
if (!new_selected_items.contains(item)) {
|
if (!newSelectedItems.contains(item)) {
|
||||||
DElement *element = m_itemToElementMap.value(item);
|
DElement *element = m_itemToElementMap.value(item);
|
||||||
updateGraphicsItem(item, element);
|
updateGraphicsItem(item, element);
|
||||||
selection_changed = true;
|
selectionChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (QGraphicsItem *item, new_selected_items) {
|
foreach (QGraphicsItem *item, newSelectedItems) {
|
||||||
if (!m_selectedItems.contains(item)) {
|
if (!m_selectedItems.contains(item)) {
|
||||||
DElement *element = m_itemToElementMap.value(item);
|
DElement *element = m_itemToElementMap.value(item);
|
||||||
updateGraphicsItem(item, element);
|
updateGraphicsItem(item, element);
|
||||||
selection_changed = true;
|
selectionChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_selectedItems = new_selected_items;
|
m_selectedItems = newSelectedItems;
|
||||||
|
|
||||||
// collect and update all secondary selected items
|
// collect and update all secondary selected items
|
||||||
QSet<QGraphicsItem *> new_secondary_selected_items;
|
QSet<QGraphicsItem *> newSecondarySelectedItems;
|
||||||
|
|
||||||
// select all contained objects secondarily
|
// select all contained objects secondarily
|
||||||
foreach (QGraphicsItem *selected_item, m_selectedItems) {
|
foreach (QGraphicsItem *selectedItem, m_selectedItems) {
|
||||||
foreach (QGraphicsItem *item, collectCollidingObjectItems(selected_item, COLLIDING_INNER_ITEMS)) {
|
foreach (QGraphicsItem *item, collectCollidingObjectItems(selectedItem, COLLIDING_INNER_ITEMS)) {
|
||||||
if (!item->isSelected() && dynamic_cast<ISelectable *>(item) != 0
|
if (!item->isSelected() && dynamic_cast<ISelectable *>(item) != 0
|
||||||
&& item->collidesWithItem(selected_item, Qt::ContainsItemBoundingRect)
|
&& item->collidesWithItem(selectedItem, Qt::ContainsItemBoundingRect)
|
||||||
&& isInFrontOf(item, selected_item)) {
|
&& isInFrontOf(item, selectedItem)) {
|
||||||
QMT_CHECK(!m_selectedItems.contains(item));
|
QMT_CHECK(!m_selectedItems.contains(item));
|
||||||
new_secondary_selected_items.insert(item);
|
newSecondarySelectedItems.insert(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -783,48 +783,48 @@ void DiagramSceneModel::onSelectionChanged()
|
|||||||
foreach (DElement *element, m_diagram->getDiagramElements()) {
|
foreach (DElement *element, m_diagram->getDiagramElements()) {
|
||||||
DRelation *relation = dynamic_cast<DRelation *>(element);
|
DRelation *relation = dynamic_cast<DRelation *>(element);
|
||||||
if (relation) {
|
if (relation) {
|
||||||
QGraphicsItem *relation_item = m_elementToItemMap.value(relation);
|
QGraphicsItem *relationItem = m_elementToItemMap.value(relation);
|
||||||
QMT_CHECK(relation_item);
|
QMT_CHECK(relationItem);
|
||||||
DObject *end_a_object = m_diagramController->findElement<DObject>(relation->getEndA(), m_diagram);
|
DObject *endAObject = m_diagramController->findElement<DObject>(relation->getEndA(), m_diagram);
|
||||||
QMT_CHECK(end_a_object);
|
QMT_CHECK(endAObject);
|
||||||
QGraphicsItem *end_a_item = m_elementToItemMap.value(end_a_object);
|
QGraphicsItem *endAItem = m_elementToItemMap.value(endAObject);
|
||||||
QMT_CHECK(end_a_item);
|
QMT_CHECK(endAItem);
|
||||||
DObject *end_b_object = m_diagramController->findElement<DObject>(relation->getEndB(), m_diagram);
|
DObject *endBObject = m_diagramController->findElement<DObject>(relation->getEndB(), m_diagram);
|
||||||
QMT_CHECK(end_b_object);
|
QMT_CHECK(endBObject);
|
||||||
QGraphicsItem *end_b_item = m_elementToItemMap.value(end_b_object);
|
QGraphicsItem *endBItem = m_elementToItemMap.value(endBObject);
|
||||||
QMT_CHECK(end_b_item);
|
QMT_CHECK(endBItem);
|
||||||
if (!relation_item->isSelected()
|
if (!relationItem->isSelected()
|
||||||
&& (m_selectedItems.contains(end_a_item) || new_secondary_selected_items.contains(end_a_item))
|
&& (m_selectedItems.contains(endAItem) || newSecondarySelectedItems.contains(endAItem))
|
||||||
&& (m_selectedItems.contains(end_b_item) || new_secondary_selected_items.contains(end_b_item))) {
|
&& (m_selectedItems.contains(endBItem) || newSecondarySelectedItems.contains(endBItem))) {
|
||||||
QMT_CHECK(!m_selectedItems.contains(relation_item));
|
QMT_CHECK(!m_selectedItems.contains(relationItem));
|
||||||
new_secondary_selected_items.insert(relation_item);
|
newSecondarySelectedItems.insert(relationItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
|
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
|
||||||
if (!new_secondary_selected_items.contains(item)) {
|
if (!newSecondarySelectedItems.contains(item)) {
|
||||||
ISelectable *selectable = dynamic_cast<ISelectable *>(item);
|
ISelectable *selectable = dynamic_cast<ISelectable *>(item);
|
||||||
QMT_CHECK(selectable);
|
QMT_CHECK(selectable);
|
||||||
selectable->setSecondarySelected(false);
|
selectable->setSecondarySelected(false);
|
||||||
selection_changed = true;
|
selectionChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (QGraphicsItem *item, new_secondary_selected_items) {
|
foreach (QGraphicsItem *item, newSecondarySelectedItems) {
|
||||||
if (!m_secondarySelectedItems.contains(item)) {
|
if (!m_secondarySelectedItems.contains(item)) {
|
||||||
ISelectable *selectable = dynamic_cast<ISelectable *>(item);
|
ISelectable *selectable = dynamic_cast<ISelectable *>(item);
|
||||||
QMT_CHECK(selectable);
|
QMT_CHECK(selectable);
|
||||||
selectable->setSecondarySelected(true);
|
selectable->setSecondarySelected(true);
|
||||||
selection_changed = true;
|
selectionChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_secondarySelectedItems = new_secondary_selected_items;
|
m_secondarySelectedItems = newSecondarySelectedItems;
|
||||||
|
|
||||||
QMT_CHECK((m_selectedItems & m_secondarySelectedItems).isEmpty());
|
QMT_CHECK((m_selectedItems & m_secondarySelectedItems).isEmpty());
|
||||||
|
|
||||||
if (selection_changed) {
|
if (selectionChanged) {
|
||||||
m_diagramController->breakUndoChain();
|
m_diagramController->breakUndoChain();
|
||||||
emit selectionChanged(m_diagram);
|
emit selectionHasChanged(m_diagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,23 +892,23 @@ void DiagramSceneModel::deleteGraphicsItem(QGraphicsItem *item, DElement *elemen
|
|||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::updateFocusItem(const QSet<QGraphicsItem *> &selected_items)
|
void DiagramSceneModel::updateFocusItem(const QSet<QGraphicsItem *> &selectedItems)
|
||||||
{
|
{
|
||||||
QGraphicsItem *mouse_grabber_item = m_graphicsScene->mouseGrabberItem();
|
QGraphicsItem *mouseGrabberItem = m_graphicsScene->mouseGrabberItem();
|
||||||
QGraphicsItem *focus_item = 0;
|
QGraphicsItem *focusItem = 0;
|
||||||
ISelectable *selectable = 0;
|
ISelectable *selectable = 0;
|
||||||
|
|
||||||
if (mouse_grabber_item && selected_items.contains(mouse_grabber_item)) {
|
if (mouseGrabberItem && selectedItems.contains(mouseGrabberItem)) {
|
||||||
selectable = dynamic_cast<ISelectable *>(mouse_grabber_item);
|
selectable = dynamic_cast<ISelectable *>(mouseGrabberItem);
|
||||||
if (selectable) {
|
if (selectable) {
|
||||||
focus_item = mouse_grabber_item;
|
focusItem = mouseGrabberItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (focus_item && focus_item != m_focusItem) {
|
if (focusItem && focusItem != m_focusItem) {
|
||||||
unsetFocusItem();
|
unsetFocusItem();
|
||||||
selectable->setFocusSelected(true);
|
selectable->setFocusSelected(true);
|
||||||
m_focusItem = focus_item;
|
m_focusItem = focusItem;
|
||||||
} else if (m_focusItem && !selected_items.contains(m_focusItem)) {
|
} else if (m_focusItem && !selectedItems.contains(m_focusItem)) {
|
||||||
unsetFocusItem();
|
unsetFocusItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -916,8 +916,8 @@ void DiagramSceneModel::updateFocusItem(const QSet<QGraphicsItem *> &selected_it
|
|||||||
void DiagramSceneModel::unsetFocusItem()
|
void DiagramSceneModel::unsetFocusItem()
|
||||||
{
|
{
|
||||||
if (m_focusItem) {
|
if (m_focusItem) {
|
||||||
if (ISelectable *old_selectable = dynamic_cast<ISelectable *>(m_focusItem)) {
|
if (ISelectable *oldSelectable = dynamic_cast<ISelectable *>(m_focusItem)) {
|
||||||
old_selectable->setFocusSelected(false);
|
oldSelectable->setFocusSelected(false);
|
||||||
} else {
|
} else {
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
}
|
}
|
||||||
@@ -925,17 +925,17 @@ void DiagramSceneModel::unsetFocusItem()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *front_item, const QGraphicsItem *back_item)
|
bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem)
|
||||||
{
|
{
|
||||||
QMT_CHECK(front_item);
|
QMT_CHECK(frontItem);
|
||||||
QMT_CHECK(back_item);
|
QMT_CHECK(backItem);
|
||||||
|
|
||||||
// shortcut for usual case of root items
|
// shortcut for usual case of root items
|
||||||
if (front_item->parentItem() == 0 && back_item->parentItem() == 0) {
|
if (frontItem->parentItem() == 0 && backItem->parentItem() == 0) {
|
||||||
foreach (const QGraphicsItem *item, m_graphicsScene->items()) {
|
foreach (const QGraphicsItem *item, m_graphicsScene->items()) {
|
||||||
if (item == front_item) {
|
if (item == frontItem) {
|
||||||
return true;
|
return true;
|
||||||
} else if (item == back_item) {
|
} else if (item == backItem) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -944,56 +944,56 @@ bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *front_item, const QGrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
// collect all anchestors of front item
|
// collect all anchestors of front item
|
||||||
QList<const QGraphicsItem *> front_stack;
|
QList<const QGraphicsItem *> frontStack;
|
||||||
const QGraphicsItem *iterator = front_item;
|
const QGraphicsItem *iterator = frontItem;
|
||||||
while (iterator != 0) {
|
while (iterator != 0) {
|
||||||
front_stack.append(iterator);
|
frontStack.append(iterator);
|
||||||
iterator = iterator->parentItem();
|
iterator = iterator->parentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect all anchestors of back item
|
// collect all anchestors of back item
|
||||||
QList<const QGraphicsItem *> back_stack;
|
QList<const QGraphicsItem *> backStack;
|
||||||
iterator = back_item;
|
iterator = backItem;
|
||||||
while (iterator != 0) {
|
while (iterator != 0) {
|
||||||
back_stack.append(iterator);
|
backStack.append(iterator);
|
||||||
iterator = iterator->parentItem();
|
iterator = iterator->parentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
// search lowest common anchestor
|
// search lowest common anchestor
|
||||||
int front_index = front_stack.size() - 1;
|
int frontIndex = frontStack.size() - 1;
|
||||||
int back_index = back_stack.size() - 1;
|
int backIndex = backStack.size() - 1;
|
||||||
while (front_index >= 0 && back_index >= 0 && front_stack.at(front_index) == back_stack.at(back_index)) {
|
while (frontIndex >= 0 && backIndex >= 0 && frontStack.at(frontIndex) == backStack.at(backIndex)) {
|
||||||
--front_index;
|
--frontIndex;
|
||||||
--back_index;
|
--backIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (front_index < 0 && back_index < 0) {
|
if (frontIndex < 0 && backIndex < 0) {
|
||||||
QMT_CHECK(front_item == back_item);
|
QMT_CHECK(frontItem == backItem);
|
||||||
return false;
|
return false;
|
||||||
} else if (front_index < 0) {
|
} else if (frontIndex < 0) {
|
||||||
// front item is higher in hierarchy and thus behind back item
|
// front item is higher in hierarchy and thus behind back item
|
||||||
return false;
|
return false;
|
||||||
} else if (back_index < 0) {
|
} else if (backIndex < 0) {
|
||||||
// back item is higher in hierarchy and thus in behind front item
|
// back item is higher in hierarchy and thus in behind front item
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
front_item = front_stack.at(front_index);
|
frontItem = frontStack.at(frontIndex);
|
||||||
back_item = back_stack.at(back_index);
|
backItem = backStack.at(backIndex);
|
||||||
QMT_CHECK(front_item != back_item);
|
QMT_CHECK(frontItem != backItem);
|
||||||
|
|
||||||
if (front_item->zValue() != back_item->zValue()) {
|
if (frontItem->zValue() != backItem->zValue()) {
|
||||||
return front_item->zValue() > back_item->zValue();
|
return frontItem->zValue() > backItem->zValue();
|
||||||
} else {
|
} else {
|
||||||
QList<QGraphicsItem *> children;
|
QList<QGraphicsItem *> children;
|
||||||
if (front_index + 1 < front_stack.size()) {
|
if (frontIndex + 1 < frontStack.size()) {
|
||||||
children = front_stack.at(front_index + 1)->childItems();
|
children = frontStack.at(frontIndex + 1)->childItems();
|
||||||
} else {
|
} else {
|
||||||
children = m_graphicsScene->items(Qt::AscendingOrder);
|
children = m_graphicsScene->items(Qt::AscendingOrder);
|
||||||
}
|
}
|
||||||
foreach (const QGraphicsItem *item, children) {
|
foreach (const QGraphicsItem *item, children) {
|
||||||
if (item == front_item) {
|
if (item == frontItem) {
|
||||||
return false;
|
return false;
|
||||||
} else if (item == back_item) {
|
} else if (item == backItem) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,25 +92,25 @@ signals:
|
|||||||
|
|
||||||
void diagramSceneActivated(const MDiagram *diagram);
|
void diagramSceneActivated(const MDiagram *diagram);
|
||||||
|
|
||||||
void selectionChanged(const MDiagram *diagram);
|
void selectionHasChanged(const MDiagram *diagram);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DiagramController *getDiagramController() const { return m_diagramController; }
|
DiagramController *getDiagramController() const { return m_diagramController; }
|
||||||
|
|
||||||
void setDiagramController(DiagramController *diagram_controller);
|
void setDiagramController(DiagramController *diagramController);
|
||||||
|
|
||||||
DiagramSceneController *getDiagramSceneController() const { return m_diagramSceneController; }
|
DiagramSceneController *getDiagramSceneController() const { return m_diagramSceneController; }
|
||||||
|
|
||||||
void setDiagramSceneController(DiagramSceneController *diagram_scene_controller);
|
void setDiagramSceneController(DiagramSceneController *diagramSceneController);
|
||||||
|
|
||||||
StyleController *getStyleController() const { return m_styleController; }
|
StyleController *getStyleController() const { return m_styleController; }
|
||||||
|
|
||||||
void setStyleController(StyleController *style_controller);
|
void setStyleController(StyleController *styleController);
|
||||||
|
|
||||||
StereotypeController *getStereotypeController() const { return m_stereotypeController; }
|
StereotypeController *getStereotypeController() const { return m_stereotypeController; }
|
||||||
|
|
||||||
void setStereotypeController(StereotypeController *stereotype_controller);
|
void setStereotypeController(StereotypeController *stereotypeController);
|
||||||
|
|
||||||
MDiagram *getDiagram() const { return m_diagram; }
|
MDiagram *getDiagram() const { return m_diagram; }
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
DSelection getSelectedElements() const;
|
DSelection getSelectedElements() const;
|
||||||
|
|
||||||
DElement *findTopmostElement(const QPointF &scene_pos) const;
|
DElement *findTopmostElement(const QPointF &scenePos) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -156,21 +156,21 @@ public:
|
|||||||
|
|
||||||
void copyToClipboard();
|
void copyToClipboard();
|
||||||
|
|
||||||
bool exportPng(const QString &file_name);
|
bool exportPng(const QString &fileName);
|
||||||
|
|
||||||
void exportPdf(const QString &file_name);
|
void exportPdf(const QString &fileName);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void selectItem(QGraphicsItem *item, bool multi_select);
|
void selectItem(QGraphicsItem *item, bool multiSelect);
|
||||||
|
|
||||||
void moveSelectedItems(QGraphicsItem *grabbed_item, const QPointF &delta);
|
void moveSelectedItems(QGraphicsItem *grabbedItem, const QPointF &delta);
|
||||||
|
|
||||||
void alignSelectedItemsPositionOnRaster();
|
void alignSelectedItemsPositionOnRaster();
|
||||||
|
|
||||||
void onDoubleClickedItem(QGraphicsItem *item);
|
void onDoubleClickedItem(QGraphicsItem *item);
|
||||||
|
|
||||||
QList<QGraphicsItem *> collectCollidingObjectItems(const QGraphicsItem *item, CollidingMode colliding_mode) const;
|
QList<QGraphicsItem *> collectCollidingObjectItems(const QGraphicsItem *item, CollidingMode collidingMode) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -228,11 +228,11 @@ private:
|
|||||||
|
|
||||||
void deleteGraphicsItem(QGraphicsItem *item, DElement *element);
|
void deleteGraphicsItem(QGraphicsItem *item, DElement *element);
|
||||||
|
|
||||||
void updateFocusItem(const QSet<QGraphicsItem *> &selected_items);
|
void updateFocusItem(const QSet<QGraphicsItem *> &selectedItems);
|
||||||
|
|
||||||
void unsetFocusItem();
|
void unsetFocusItem();
|
||||||
|
|
||||||
bool isInFrontOf(const QGraphicsItem *front_item, const QGraphicsItem *back_item);
|
bool isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,8 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DiagramSceneModel::CreationVisitor::CreationVisitor(DiagramSceneModel *diagram_scene_model)
|
DiagramSceneModel::CreationVisitor::CreationVisitor(DiagramSceneModel *diagramSceneModel)
|
||||||
: m_diagramSceneModel(diagram_scene_model),
|
: m_diagramSceneModel(diagramSceneModel),
|
||||||
m_graphicsItem(0)
|
m_graphicsItem(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -142,10 +142,10 @@ void DiagramSceneModel::CreationVisitor::visitDBoundary(DBoundary *boundary)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DiagramSceneModel::UpdateVisitor::UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagram_scene_model, DElement *related_element)
|
DiagramSceneModel::UpdateVisitor::UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagramSceneModel, DElement *relatedElement)
|
||||||
: m_graphicsItem(item),
|
: m_graphicsItem(item),
|
||||||
m_diagramSceneModel(diagram_scene_model),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
m_relatedElement(related_element)
|
m_relatedElement(relatedElement)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,10 +175,10 @@ void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package)
|
|||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
if (m_relatedElement == 0) {
|
if (m_relatedElement == 0) {
|
||||||
PackageItem *package_item = qgraphicsitem_cast<PackageItem *>(m_graphicsItem);
|
PackageItem *packageItem = qgraphicsitem_cast<PackageItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(package_item);
|
QMT_CHECK(packageItem);
|
||||||
QMT_CHECK(package_item->getObject() == package);
|
QMT_CHECK(packageItem->getObject() == package);
|
||||||
package_item->update();
|
packageItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDObject(package);
|
visitDObject(package);
|
||||||
@@ -189,10 +189,10 @@ void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass)
|
|||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
if (m_relatedElement == 0) {
|
if (m_relatedElement == 0) {
|
||||||
ClassItem *class_item = qgraphicsitem_cast<ClassItem *>(m_graphicsItem);
|
ClassItem *classItem = qgraphicsitem_cast<ClassItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(class_item);
|
QMT_CHECK(classItem);
|
||||||
QMT_CHECK(class_item->getObject() == klass);
|
QMT_CHECK(classItem->getObject() == klass);
|
||||||
class_item->update();
|
classItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDObject(klass);
|
visitDObject(klass);
|
||||||
@@ -203,10 +203,10 @@ void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component)
|
|||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
if (m_relatedElement == 0) {
|
if (m_relatedElement == 0) {
|
||||||
ComponentItem *component_item = qgraphicsitem_cast<ComponentItem *>(m_graphicsItem);
|
ComponentItem *componentItem = qgraphicsitem_cast<ComponentItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(component_item);
|
QMT_CHECK(componentItem);
|
||||||
QMT_CHECK(component_item->getObject() == component);
|
QMT_CHECK(componentItem->getObject() == component);
|
||||||
component_item->update();
|
componentItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDObject(component);
|
visitDObject(component);
|
||||||
@@ -217,10 +217,10 @@ void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram)
|
|||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
if (m_relatedElement == 0) {
|
if (m_relatedElement == 0) {
|
||||||
DiagramItem *document_item = qgraphicsitem_cast<DiagramItem *>(m_graphicsItem);
|
DiagramItem *documentItem = qgraphicsitem_cast<DiagramItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(document_item);
|
QMT_CHECK(documentItem);
|
||||||
QMT_CHECK(document_item->getObject() == diagram);
|
QMT_CHECK(documentItem->getObject() == diagram);
|
||||||
document_item->update();
|
documentItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDObject(diagram);
|
visitDObject(diagram);
|
||||||
@@ -231,10 +231,10 @@ void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item)
|
|||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
if (m_relatedElement == 0) {
|
if (m_relatedElement == 0) {
|
||||||
ItemItem *item_item = qgraphicsitem_cast<ItemItem *>(m_graphicsItem);
|
ItemItem *itemItem = qgraphicsitem_cast<ItemItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(item_item);
|
QMT_CHECK(itemItem);
|
||||||
QMT_CHECK(item_item->getObject() == item);
|
QMT_CHECK(itemItem->getObject() == item);
|
||||||
item_item->update();
|
itemItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
visitDObject(item);
|
visitDObject(item);
|
||||||
@@ -245,10 +245,10 @@ void DiagramSceneModel::UpdateVisitor::visitDRelation(DRelation *relation)
|
|||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
if (m_relatedElement == 0 || m_relatedElement->getUid() == relation->getEndA() || m_relatedElement->getUid() == relation->getEndB()) {
|
if (m_relatedElement == 0 || m_relatedElement->getUid() == relation->getEndA() || m_relatedElement->getUid() == relation->getEndB()) {
|
||||||
RelationItem *relation_item = qgraphicsitem_cast<RelationItem *>(m_graphicsItem);
|
RelationItem *relationItem = qgraphicsitem_cast<RelationItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(relation_item);
|
QMT_CHECK(relationItem);
|
||||||
QMT_CHECK(relation_item->getRelation() == relation);
|
QMT_CHECK(relationItem->getRelation() == relation);
|
||||||
relation_item->update();
|
relationItem->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,10 +272,10 @@ void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation)
|
|||||||
Q_UNUSED(annotation); // avoid warning in release mode
|
Q_UNUSED(annotation); // avoid warning in release mode
|
||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
AnnotationItem *annotation_item = qgraphicsitem_cast<AnnotationItem *>(m_graphicsItem);
|
AnnotationItem *annotationItem = qgraphicsitem_cast<AnnotationItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(annotation_item);
|
QMT_CHECK(annotationItem);
|
||||||
QMT_CHECK(annotation_item->getAnnotation() == annotation);
|
QMT_CHECK(annotationItem->getAnnotation() == annotation);
|
||||||
annotation_item->update();
|
annotationItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary)
|
void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary)
|
||||||
@@ -283,10 +283,10 @@ void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary)
|
|||||||
Q_UNUSED(boundary); // avoid warning in release mode
|
Q_UNUSED(boundary); // avoid warning in release mode
|
||||||
QMT_CHECK(m_graphicsItem);
|
QMT_CHECK(m_graphicsItem);
|
||||||
|
|
||||||
BoundaryItem *boundary_item = qgraphicsitem_cast<BoundaryItem *>(m_graphicsItem);
|
BoundaryItem *boundaryItem = qgraphicsitem_cast<BoundaryItem *>(m_graphicsItem);
|
||||||
QMT_CHECK(boundary_item);
|
QMT_CHECK(boundaryItem);
|
||||||
QMT_CHECK(boundary_item->getBoundary() == boundary);
|
QMT_CHECK(boundaryItem->getBoundary() == boundary);
|
||||||
boundary_item->update();
|
boundaryItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class QMT_EXPORT DiagramSceneModel::CreationVisitor :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CreationVisitor(DiagramSceneModel *diagram_scene_model);
|
CreationVisitor(DiagramSceneModel *diagramSceneModel);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ class DiagramSceneModel::UpdateVisitor :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagram_scene_model, DElement *related_element = 0);
|
UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagramSceneModel, DElement *relatedElement = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
AnnotationItem::AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
AnnotationItem::AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_annotation(annotation),
|
m_annotation(annotation),
|
||||||
m_diagramSceneModel(diagram_scene_model),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
m_secondarySelected(false),
|
m_secondarySelected(false),
|
||||||
m_focusSelected(false),
|
m_focusSelected(false),
|
||||||
m_selectionMarker(0),
|
m_selectionMarker(0),
|
||||||
@@ -162,28 +162,28 @@ QSizeF AnnotationItem::getMinimumSize() const
|
|||||||
return calcMinimumGeometry();
|
return calcMinimumGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::setPosAndRect(const QPointF &original_pos, const QRectF &original_rect, const QPointF &top_left_delta, const QPointF &bottom_right_delta)
|
void AnnotationItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta)
|
||||||
{
|
{
|
||||||
QPointF new_pos = original_pos;
|
QPointF newPos = originalPos;
|
||||||
QRectF new_rect = original_rect;
|
QRectF newRect = originalRect;
|
||||||
GeometryUtilities::adjustPosAndRect(&new_pos, &new_rect, top_left_delta, bottom_right_delta, QPointF(0.0, 0.0));
|
GeometryUtilities::adjustPosAndRect(&newPos, &newRect, topLeftDelta, bottomRightDelta, QPointF(0.0, 0.0));
|
||||||
if (new_pos != m_annotation->getPos() || new_rect != m_annotation->getRect()) {
|
if (newPos != m_annotation->getPos() || newRect != m_annotation->getRect()) {
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
||||||
m_annotation->setPos(new_pos);
|
m_annotation->setPos(newPos);
|
||||||
if (new_rect.size() != m_annotation->getRect().size()) {
|
if (newRect.size() != m_annotation->getRect().size()) {
|
||||||
m_annotation->setAutoSize(false);
|
m_annotation->setAutoSize(false);
|
||||||
}
|
}
|
||||||
m_annotation->setRect(new_rect);
|
m_annotation->setRect(newRect);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::alignItemSizeToRaster(Side adjust_horizontal_side, Side adjust_vertical_side, double raster_width, double raster_height)
|
void AnnotationItem::alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
Q_UNUSED(adjust_horizontal_side);
|
Q_UNUSED(adjustHorizontalSide);
|
||||||
Q_UNUSED(adjust_vertical_side);
|
Q_UNUSED(adjustVerticalSide);
|
||||||
Q_UNUSED(raster_width);
|
Q_UNUSED(rasterWidth);
|
||||||
Q_UNUSED(raster_height);
|
Q_UNUSED(rasterHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::moveDelta(const QPointF &delta)
|
void AnnotationItem::moveDelta(const QPointF &delta)
|
||||||
@@ -193,17 +193,17 @@ void AnnotationItem::moveDelta(const QPointF &delta)
|
|||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::alignItemPositionToRaster(double raster_width, double raster_height)
|
void AnnotationItem::alignItemPositionToRaster(double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
QPointF pos = m_annotation->getPos();
|
QPointF pos = m_annotation->getPos();
|
||||||
QRectF rect = m_annotation->getRect();
|
QRectF rect = m_annotation->getRect();
|
||||||
QPointF top_left = pos + rect.topLeft();
|
QPointF topLeft = pos + rect.topLeft();
|
||||||
|
|
||||||
double left_delta = qRound(top_left.x() / raster_width) * raster_width - top_left.x();
|
double leftDelta = qRound(topLeft.x() / rasterWidth) * rasterWidth - topLeft.x();
|
||||||
double top_delta = qRound(top_left.y() / raster_height) * raster_height - top_left.y();
|
double topDelta = qRound(topLeft.y() / rasterHeight) * rasterHeight - topLeft.y();
|
||||||
QPointF top_left_delta(left_delta, top_delta);
|
QPointF topLeftDelta(leftDelta, topDelta);
|
||||||
|
|
||||||
setPosAndRect(pos, rect, top_left_delta, top_left_delta);
|
setPosAndRect(pos, rect, topLeftDelta, topLeftDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnnotationItem::isSecondarySelected() const
|
bool AnnotationItem::isSecondarySelected() const
|
||||||
@@ -211,10 +211,10 @@ bool AnnotationItem::isSecondarySelected() const
|
|||||||
return m_secondarySelected;
|
return m_secondarySelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::setSecondarySelected(bool secondary_selected)
|
void AnnotationItem::setSecondarySelected(bool secondarySelected)
|
||||||
{
|
{
|
||||||
if (m_secondarySelected != secondary_selected) {
|
if (m_secondarySelected != secondarySelected) {
|
||||||
m_secondarySelected = secondary_selected;
|
m_secondarySelected = secondarySelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,10 +224,10 @@ bool AnnotationItem::isFocusSelected() const
|
|||||||
return m_focusSelected;
|
return m_focusSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::setFocusSelected(bool focus_selected)
|
void AnnotationItem::setFocusSelected(bool focusSelected)
|
||||||
{
|
{
|
||||||
if (m_focusSelected != focus_selected) {
|
if (m_focusSelected != focusSelected) {
|
||||||
m_focusSelected = focus_selected;
|
m_focusSelected = focusSelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,10 +289,10 @@ void AnnotationItem::updateSelectionMarker()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::updateSelectionMarkerGeometry(const QRectF &annotation_rect)
|
void AnnotationItem::updateSelectionMarkerGeometry(const QRectF &annotationRect)
|
||||||
{
|
{
|
||||||
if (m_selectionMarker) {
|
if (m_selectionMarker) {
|
||||||
m_selectionMarker->setRect(annotation_rect);
|
m_selectionMarker->setRect(annotationRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,10 +318,10 @@ void AnnotationItem::onContentsChanged()
|
|||||||
m_onChanged = true;
|
m_onChanged = true;
|
||||||
|
|
||||||
if (!m_onUpdate) {
|
if (!m_onUpdate) {
|
||||||
QString plain_text = m_textItem->toPlainText();
|
QString plainText = m_textItem->toPlainText();
|
||||||
if (m_annotation->getText() != plain_text) {
|
if (m_annotation->getText() != plainText) {
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
||||||
m_annotation->setText(plain_text);
|
m_annotation->setText(plainText);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -337,8 +337,8 @@ QSizeF AnnotationItem::calcMinimumGeometry() const
|
|||||||
if (getAnnotation()->hasAutoSize()) {
|
if (getAnnotation()->hasAutoSize()) {
|
||||||
if (m_textItem) {
|
if (m_textItem) {
|
||||||
m_textItem->setTextWidth(-1);
|
m_textItem->setTextWidth(-1);
|
||||||
QSizeF text_size = m_textItem->document()->size();
|
QSizeF textSize = m_textItem->document()->size();
|
||||||
width = text_size.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
width = textSize.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
@@ -355,9 +355,9 @@ void AnnotationItem::updateGeometry()
|
|||||||
if (getAnnotation()->hasAutoSize()) {
|
if (getAnnotation()->hasAutoSize()) {
|
||||||
if (m_textItem) {
|
if (m_textItem) {
|
||||||
m_textItem->setTextWidth(-1);
|
m_textItem->setTextWidth(-1);
|
||||||
QSizeF text_size = m_textItem->document()->size();
|
QSizeF textSize = m_textItem->document()->size();
|
||||||
width = text_size.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
width = textSize.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
||||||
height = text_size.height() + 2 * CONTENTS_BORDER_VERTICAL;
|
height = textSize.height() + 2 * CONTENTS_BORDER_VERTICAL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QRectF rect = getAnnotation()->getRect();
|
QRectF rect = getAnnotation()->getRect();
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class AnnotationItem :
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~AnnotationItem();
|
~AnnotationItem();
|
||||||
|
|
||||||
@@ -86,25 +86,25 @@ public:
|
|||||||
|
|
||||||
QSizeF getMinimumSize() const;
|
QSizeF getMinimumSize() const;
|
||||||
|
|
||||||
void setPosAndRect(const QPointF &original_pos, const QRectF &original_rect, const QPointF &top_left_delta, const QPointF &bottom_right_delta);
|
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
||||||
|
|
||||||
void alignItemSizeToRaster(Side adjust_horizontal_side, Side adjust_vertical_side, double raster_width, double raster_height);
|
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double raster_width, double raster_height);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondary_selected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focus_selected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ protected:
|
|||||||
|
|
||||||
void updateSelectionMarker();
|
void updateSelectionMarker();
|
||||||
|
|
||||||
void updateSelectionMarkerGeometry(const QRectF &annotation_rect);
|
void updateSelectionMarkerGeometry(const QRectF &annotationRect);
|
||||||
|
|
||||||
const Style *getAdaptedStyle();
|
const Style *getAdaptedStyle();
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,8 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
AssociationItem::AssociationItem(DAssociation *association, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
AssociationItem::AssociationItem(DAssociation *association, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: RelationItem(association, diagram_scene_model, parent),
|
: RelationItem(association, diagramSceneModel, parent),
|
||||||
m_association(association),
|
m_association(association),
|
||||||
m_endAName(0),
|
m_endAName(0),
|
||||||
m_endACardinality(0),
|
m_endACardinality(0),
|
||||||
@@ -72,107 +72,107 @@ void AssociationItem::update(const Style *style)
|
|||||||
updateEndLabels(m_association->getB(), m_association->getA(), &m_endBName, &m_endBCardinality, style);
|
updateEndLabels(m_association->getB(), m_association->getA(), &m_endBName, &m_endBCardinality, style);
|
||||||
|
|
||||||
QMT_CHECK(m_arrow);
|
QMT_CHECK(m_arrow);
|
||||||
QGraphicsItem *end_a_item = m_diagramSceneModel->getGraphicsItem(m_association->getEndA());
|
QGraphicsItem *endAItem = m_diagramSceneModel->getGraphicsItem(m_association->getEndA());
|
||||||
QMT_CHECK(end_a_item);
|
QMT_CHECK(endAItem);
|
||||||
placeEndLabels(m_arrow->getFirstLineSegment(), m_endAName, m_endACardinality, end_a_item, m_arrow->getStartHeadLength());
|
placeEndLabels(m_arrow->getFirstLineSegment(), m_endAName, m_endACardinality, endAItem, m_arrow->getStartHeadLength());
|
||||||
QGraphicsItem *end_b_item = m_diagramSceneModel->getGraphicsItem(m_association->getEndB());
|
QGraphicsItem *endBItem = m_diagramSceneModel->getGraphicsItem(m_association->getEndB());
|
||||||
QMT_CHECK(end_b_item);
|
QMT_CHECK(endBItem);
|
||||||
placeEndLabels(m_arrow->getLastLineSegment(), m_endBName, m_endBCardinality, end_b_item, m_arrow->getEndHeadLength());
|
placeEndLabels(m_arrow->getLastLineSegment(), m_endBName, m_endBCardinality, endBItem, m_arrow->getEndHeadLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssociationItem::updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &other_end, QGraphicsSimpleTextItem **end_name, QGraphicsSimpleTextItem **end_cardinality, const Style *style)
|
void AssociationItem::updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &otherEnd, QGraphicsSimpleTextItem **endName, QGraphicsSimpleTextItem **endCardinality, const Style *style)
|
||||||
{
|
{
|
||||||
Q_UNUSED(end);
|
Q_UNUSED(end);
|
||||||
|
|
||||||
if (!other_end.getName().isEmpty()) {
|
if (!otherEnd.getName().isEmpty()) {
|
||||||
if (!*end_name) {
|
if (!*endName) {
|
||||||
*end_name = new QGraphicsSimpleTextItem(this);
|
*endName = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
}
|
||||||
(*end_name)->setFont(style->getSmallFont());
|
(*endName)->setFont(style->getSmallFont());
|
||||||
(*end_name)->setBrush(style->getTextBrush());
|
(*endName)->setBrush(style->getTextBrush());
|
||||||
(*end_name)->setText(other_end.getName());
|
(*endName)->setText(otherEnd.getName());
|
||||||
} else if (*end_name) {
|
} else if (*endName) {
|
||||||
(*end_name)->scene()->removeItem(*end_name);
|
(*endName)->scene()->removeItem(*endName);
|
||||||
delete *end_name;
|
delete *endName;
|
||||||
*end_name = 0;
|
*endName = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!other_end.getCardinality().isEmpty()) {
|
if (!otherEnd.getCardinality().isEmpty()) {
|
||||||
if (!*end_cardinality) {
|
if (!*endCardinality) {
|
||||||
*end_cardinality = new QGraphicsSimpleTextItem(this);
|
*endCardinality = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
}
|
||||||
(*end_cardinality)->setFont(style->getSmallFont());
|
(*endCardinality)->setFont(style->getSmallFont());
|
||||||
(*end_cardinality)->setBrush(style->getTextBrush());
|
(*endCardinality)->setBrush(style->getTextBrush());
|
||||||
(*end_cardinality)->setText(other_end.getCardinality());
|
(*endCardinality)->setText(otherEnd.getCardinality());
|
||||||
} else if (*end_cardinality) {
|
} else if (*endCardinality) {
|
||||||
(*end_cardinality)->scene()->removeItem(*end_cardinality);
|
(*endCardinality)->scene()->removeItem(*endCardinality);
|
||||||
delete *end_cardinality;
|
delete *endCardinality;
|
||||||
*end_cardinality = 0;
|
*endCardinality = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssociationItem::placeEndLabels(const QLineF &line_segment, QGraphicsItem *end_name, QGraphicsItem *end_cardinality, QGraphicsItem *end_item, double head_length)
|
void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *endName, QGraphicsItem *endCardinality, QGraphicsItem *endItem, double headLength)
|
||||||
{
|
{
|
||||||
const double HEAD_OFFSET = head_length + 6.0;
|
const double HEAD_OFFSET = headLength + 6.0;
|
||||||
const double SIDE_OFFSET = 4.0;
|
const double SIDE_OFFSET = 4.0;
|
||||||
QPointF head_offset = QPointF(HEAD_OFFSET, 0);
|
QPointF headOffset = QPointF(HEAD_OFFSET, 0);
|
||||||
QPointF side_offset = QPointF(0.0, SIDE_OFFSET);
|
QPointF sideOffset = QPointF(0.0, SIDE_OFFSET);
|
||||||
|
|
||||||
double angle = GeometryUtilities::calcAngle(line_segment);
|
double angle = GeometryUtilities::calcAngle(lineSegment);
|
||||||
if (angle >= -5 && angle <= 5) {
|
if (angle >= -5 && angle <= 5) {
|
||||||
if (end_name) {
|
if (endName) {
|
||||||
end_name->setPos(line_segment.p1() + head_offset + side_offset);
|
endName->setPos(lineSegment.p1() + headOffset + sideOffset);
|
||||||
}
|
}
|
||||||
if (end_cardinality) {
|
if (endCardinality) {
|
||||||
end_cardinality->setPos(line_segment.p1() + head_offset - side_offset - end_cardinality->boundingRect().bottomLeft());
|
endCardinality->setPos(lineSegment.p1() + headOffset - sideOffset - endCardinality->boundingRect().bottomLeft());
|
||||||
}
|
}
|
||||||
} else if (angle <= -175 || angle >= 175) {
|
} else if (angle <= -175 || angle >= 175) {
|
||||||
if (end_name) {
|
if (endName) {
|
||||||
end_name->setPos(line_segment.p1() - head_offset + side_offset - end_name->boundingRect().topRight());
|
endName->setPos(lineSegment.p1() - headOffset + sideOffset - endName->boundingRect().topRight());
|
||||||
}
|
}
|
||||||
if (end_cardinality) {
|
if (endCardinality) {
|
||||||
end_cardinality->setPos(line_segment.p1() - head_offset - side_offset - end_cardinality->boundingRect().bottomRight());
|
endCardinality->setPos(lineSegment.p1() - headOffset - sideOffset - endCardinality->boundingRect().bottomRight());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
if (end_cardinality) {
|
if (endCardinality) {
|
||||||
rect = end_cardinality->boundingRect();
|
rect = endCardinality->boundingRect();
|
||||||
}
|
}
|
||||||
if (end_name) {
|
if (endName) {
|
||||||
rect = rect.united(end_name->boundingRect().translated(rect.bottomLeft()));
|
rect = rect.united(endName->boundingRect().translated(rect.bottomLeft()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF rect_placement;
|
QPointF rectPlacement;
|
||||||
GeometryUtilities::Side aligned_side = GeometryUtilities::SIDE_UNSPECIFIED;
|
GeometryUtilities::Side alignedSide = GeometryUtilities::SIDE_UNSPECIFIED;
|
||||||
|
|
||||||
if (IIntersectionable *object_item = dynamic_cast<IIntersectionable *>(end_item)) {
|
if (IIntersectionable *objectItem = dynamic_cast<IIntersectionable *>(endItem)) {
|
||||||
QPointF intersection_point;
|
QPointF intersectionPoint;
|
||||||
QLineF intersection_line;
|
QLineF intersectionLine;
|
||||||
|
|
||||||
if (object_item->intersectShapeWithLine(GeometryUtilities::stretch(line_segment.translated(pos()), 2.0, 0.0), &intersection_point, &intersection_line)) {
|
if (objectItem->intersectShapeWithLine(GeometryUtilities::stretch(lineSegment.translated(pos()), 2.0, 0.0), &intersectionPoint, &intersectionLine)) {
|
||||||
if (!GeometryUtilities::placeRectAtLine(rect, line_segment, HEAD_OFFSET, SIDE_OFFSET, intersection_line, &rect_placement, &aligned_side)) {
|
if (!GeometryUtilities::placeRectAtLine(rect, lineSegment, HEAD_OFFSET, SIDE_OFFSET, intersectionLine, &rectPlacement, &alignedSide)) {
|
||||||
rect_placement = intersection_point;
|
rectPlacement = intersectionPoint;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rect_placement = line_segment.p1();
|
rectPlacement = lineSegment.p1();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rect_placement = end_item->pos();
|
rectPlacement = endItem->pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end_cardinality) {
|
if (endCardinality) {
|
||||||
if (aligned_side == GeometryUtilities::SIDE_RIGHT) {
|
if (alignedSide == GeometryUtilities::SIDE_RIGHT) {
|
||||||
end_cardinality->setPos(rect_placement + QPointF(rect.width() - end_cardinality->boundingRect().width(), 0.0));
|
endCardinality->setPos(rectPlacement + QPointF(rect.width() - endCardinality->boundingRect().width(), 0.0));
|
||||||
} else {
|
} else {
|
||||||
end_cardinality->setPos(rect_placement);
|
endCardinality->setPos(rectPlacement);
|
||||||
}
|
}
|
||||||
rect_placement += end_cardinality->boundingRect().bottomLeft();
|
rectPlacement += endCardinality->boundingRect().bottomLeft();
|
||||||
}
|
}
|
||||||
if (end_name) {
|
if (endName) {
|
||||||
if (aligned_side == GeometryUtilities::SIDE_RIGHT) {
|
if (alignedSide == GeometryUtilities::SIDE_RIGHT) {
|
||||||
end_name->setPos(rect_placement + QPointF(rect.width() - end_name->boundingRect().width(), 0.0));
|
endName->setPos(rectPlacement + QPointF(rect.width() - endName->boundingRect().width(), 0.0));
|
||||||
} else {
|
} else {
|
||||||
end_name->setPos(rect_placement);
|
endName->setPos(rectPlacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class AssociationItem :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AssociationItem(DAssociation *association, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
AssociationItem(DAssociation *association, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~AssociationItem();
|
~AssociationItem();
|
||||||
|
|
||||||
@@ -59,9 +59,9 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &other_end, QGraphicsSimpleTextItem **end_name, QGraphicsSimpleTextItem **end_cardinality, const Style *style);
|
void updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &otherEnd, QGraphicsSimpleTextItem **endName, QGraphicsSimpleTextItem **endCardinality, const Style *style);
|
||||||
|
|
||||||
void placeEndLabels(const QLineF &line_segment, QGraphicsItem *end_name, QGraphicsItem *end_cardinality, QGraphicsItem *end_item, double head_length);
|
void placeEndLabels(const QLineF &lineSegment, QGraphicsItem *endName, QGraphicsItem *endCardinality, QGraphicsItem *endItem, double headLength);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BoundaryItem::BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
BoundaryItem::BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_boundary(boundary),
|
m_boundary(boundary),
|
||||||
m_diagramSceneModel(diagram_scene_model),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
m_secondarySelected(false),
|
m_secondarySelected(false),
|
||||||
m_focusSelected(false),
|
m_focusSelected(false),
|
||||||
m_selectionMarker(0),
|
m_selectionMarker(0),
|
||||||
@@ -177,66 +177,66 @@ QSizeF BoundaryItem::getMinimumSize() const
|
|||||||
return calcMinimumGeometry();
|
return calcMinimumGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::setPosAndRect(const QPointF &original_pos, const QRectF &original_rect, const QPointF &top_left_delta, const QPointF &bottom_right_delta)
|
void BoundaryItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta)
|
||||||
{
|
{
|
||||||
QPointF new_pos = original_pos;
|
QPointF newPos = originalPos;
|
||||||
QRectF new_rect = original_rect;
|
QRectF newRect = originalRect;
|
||||||
GeometryUtilities::adjustPosAndRect(&new_pos, &new_rect, top_left_delta, bottom_right_delta, QPointF(0.5, 0.5));
|
GeometryUtilities::adjustPosAndRect(&newPos, &newRect, topLeftDelta, bottomRightDelta, QPointF(0.5, 0.5));
|
||||||
if (new_pos != m_boundary->getPos() || new_rect != m_boundary->getRect()) {
|
if (newPos != m_boundary->getPos() || newRect != m_boundary->getRect()) {
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
||||||
m_boundary->setPos(new_pos);
|
m_boundary->setPos(newPos);
|
||||||
m_boundary->setRect(new_rect);
|
m_boundary->setRect(newRect);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::alignItemSizeToRaster(IResizable::Side adjust_horizontal_side, IResizable::Side adjust_vertical_side, double raster_width, double raster_height)
|
void BoundaryItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide, IResizable::Side adjustVerticalSide, double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
QPointF pos = m_boundary->getPos();
|
QPointF pos = m_boundary->getPos();
|
||||||
QRectF rect = m_boundary->getRect();
|
QRectF rect = m_boundary->getRect();
|
||||||
|
|
||||||
double horiz_delta = rect.width() - qRound(rect.width() / raster_width) * raster_width;
|
double horizDelta = rect.width() - qRound(rect.width() / rasterWidth) * rasterWidth;
|
||||||
double vert_delta = rect.height() - qRound(rect.height() / raster_height) * raster_height;
|
double vertDelta = rect.height() - qRound(rect.height() / rasterHeight) * rasterHeight;
|
||||||
|
|
||||||
// make sure the new size is at least the minimum size
|
// make sure the new size is at least the minimum size
|
||||||
QSizeF minimum_size = getMinimumSize();
|
QSizeF minimumSize = getMinimumSize();
|
||||||
while (rect.width() + horiz_delta < minimum_size.width()) {
|
while (rect.width() + horizDelta < minimumSize.width()) {
|
||||||
horiz_delta += raster_width;
|
horizDelta += rasterWidth;
|
||||||
}
|
}
|
||||||
while (rect.height() + vert_delta < minimum_size.height()) {
|
while (rect.height() + vertDelta < minimumSize.height()) {
|
||||||
vert_delta += raster_height;
|
vertDelta += rasterHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
double left_delta = 0.0;
|
double leftDelta = 0.0;
|
||||||
double right_delta = 0.0;
|
double rightDelta = 0.0;
|
||||||
double top_delta = 0.0;
|
double topDelta = 0.0;
|
||||||
double bottom_delta = 0.0;
|
double bottomDelta = 0.0;
|
||||||
|
|
||||||
switch (adjust_horizontal_side) {
|
switch (adjustHorizontalSide) {
|
||||||
case IResizable::SIDE_NONE:
|
case IResizable::SIDE_NONE:
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_LEFT_OR_TOP:
|
case IResizable::SIDE_LEFT_OR_TOP:
|
||||||
left_delta = horiz_delta;
|
leftDelta = horizDelta;
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
||||||
right_delta = -horiz_delta;
|
rightDelta = -horizDelta;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (adjust_vertical_side) {
|
switch (adjustVerticalSide) {
|
||||||
case IResizable::SIDE_NONE:
|
case IResizable::SIDE_NONE:
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_LEFT_OR_TOP:
|
case IResizable::SIDE_LEFT_OR_TOP:
|
||||||
top_delta = vert_delta;
|
topDelta = vertDelta;
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
||||||
bottom_delta = -vert_delta;
|
bottomDelta = -vertDelta;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF top_left_delta(left_delta, top_delta);
|
QPointF topLeftDelta(leftDelta, topDelta);
|
||||||
QPointF bottom_right_delta(right_delta, bottom_delta);
|
QPointF bottomRightDelta(rightDelta, bottomDelta);
|
||||||
setPosAndRect(pos, rect, top_left_delta, bottom_right_delta);
|
setPosAndRect(pos, rect, topLeftDelta, bottomRightDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::moveDelta(const QPointF &delta)
|
void BoundaryItem::moveDelta(const QPointF &delta)
|
||||||
@@ -246,17 +246,17 @@ void BoundaryItem::moveDelta(const QPointF &delta)
|
|||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::alignItemPositionToRaster(double raster_width, double raster_height)
|
void BoundaryItem::alignItemPositionToRaster(double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
QPointF pos = m_boundary->getPos();
|
QPointF pos = m_boundary->getPos();
|
||||||
QRectF rect = m_boundary->getRect();
|
QRectF rect = m_boundary->getRect();
|
||||||
QPointF top_left = pos + rect.topLeft();
|
QPointF topLeft = pos + rect.topLeft();
|
||||||
|
|
||||||
double left_delta = qRound(top_left.x() / raster_width) * raster_width - top_left.x();
|
double leftDelta = qRound(topLeft.x() / rasterWidth) * rasterWidth - topLeft.x();
|
||||||
double top_delta = qRound(top_left.y() / raster_height) * raster_height - top_left.y();
|
double topDelta = qRound(topLeft.y() / rasterHeight) * rasterHeight - topLeft.y();
|
||||||
QPointF top_left_delta(left_delta, top_delta);
|
QPointF topLeftDelta(leftDelta, topDelta);
|
||||||
|
|
||||||
setPosAndRect(pos, rect, top_left_delta, top_left_delta);
|
setPosAndRect(pos, rect, topLeftDelta, topLeftDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoundaryItem::isSecondarySelected() const
|
bool BoundaryItem::isSecondarySelected() const
|
||||||
@@ -264,10 +264,10 @@ bool BoundaryItem::isSecondarySelected() const
|
|||||||
return m_secondarySelected;
|
return m_secondarySelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::setSecondarySelected(bool secondary_selected)
|
void BoundaryItem::setSecondarySelected(bool secondarySelected)
|
||||||
{
|
{
|
||||||
if (m_secondarySelected != secondary_selected) {
|
if (m_secondarySelected != secondarySelected) {
|
||||||
m_secondarySelected = secondary_selected;
|
m_secondarySelected = secondarySelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -277,10 +277,10 @@ bool BoundaryItem::isFocusSelected() const
|
|||||||
return m_focusSelected;
|
return m_focusSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::setFocusSelected(bool focus_selected)
|
void BoundaryItem::setFocusSelected(bool focusSelected)
|
||||||
{
|
{
|
||||||
if (m_focusSelected != focus_selected) {
|
if (m_focusSelected != focusSelected) {
|
||||||
m_focusSelected = focus_selected;
|
m_focusSelected = focusSelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,10 +340,10 @@ void BoundaryItem::updateSelectionMarker()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::updateSelectionMarkerGeometry(const QRectF &boundary_rect)
|
void BoundaryItem::updateSelectionMarkerGeometry(const QRectF &boundaryRect)
|
||||||
{
|
{
|
||||||
if (m_selectionMarker) {
|
if (m_selectionMarker) {
|
||||||
m_selectionMarker->setRect(boundary_rect);
|
m_selectionMarker->setRect(boundaryRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,10 +369,10 @@ void BoundaryItem::onContentsChanged()
|
|||||||
m_onChanged = true;
|
m_onChanged = true;
|
||||||
|
|
||||||
if (!m_onUpdate) {
|
if (!m_onUpdate) {
|
||||||
QString plain_text = m_textItem->toPlainText();
|
QString plainText = m_textItem->toPlainText();
|
||||||
if (m_boundary->getText() != plain_text) {
|
if (m_boundary->getText() != plainText) {
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
||||||
m_boundary->setText(plain_text);
|
m_boundary->setText(plainText);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_boundary, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,14 +387,14 @@ QSizeF BoundaryItem::calcMinimumGeometry() const
|
|||||||
|
|
||||||
if (m_textItem) {
|
if (m_textItem) {
|
||||||
m_textItem->setTextWidth(-1);
|
m_textItem->setTextWidth(-1);
|
||||||
QSizeF text_size = m_textItem->document()->size();
|
QSizeF textSize = m_textItem->document()->size();
|
||||||
qreal text_width = text_size.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
qreal textWidth = textSize.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
||||||
if (text_width > width) {
|
if (textWidth > width) {
|
||||||
width = text_width;
|
width = textWidth;
|
||||||
}
|
}
|
||||||
qreal text_height = text_size.height() + 2 * CONTENTS_BORDER_VERTICAL;
|
qreal textHeight = textSize.height() + 2 * CONTENTS_BORDER_VERTICAL;
|
||||||
if (text_height > height) {
|
if (textHeight > height) {
|
||||||
height = text_height;
|
height = textHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
|
return GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
|
||||||
@@ -408,21 +408,21 @@ void BoundaryItem::updateGeometry()
|
|||||||
qreal width = geometry.width();
|
qreal width = geometry.width();
|
||||||
qreal height = geometry.height();
|
qreal height = geometry.height();
|
||||||
|
|
||||||
qreal text_width = 0.0;
|
qreal textWidth = 0.0;
|
||||||
qreal text_height = 0.0;
|
qreal textHeight = 0.0;
|
||||||
if (m_textItem) {
|
if (m_textItem) {
|
||||||
m_textItem->setTextWidth(-1);
|
m_textItem->setTextWidth(-1);
|
||||||
QSizeF text_size = m_textItem->document()->size();
|
QSizeF textSize = m_textItem->document()->size();
|
||||||
text_width = text_size.width();
|
textWidth = textSize.width();
|
||||||
text_height = text_size.height();
|
textHeight = textSize.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF boundary_rect = m_boundary->getRect();
|
QRectF boundaryRect = m_boundary->getRect();
|
||||||
if (boundary_rect.width() > width) {
|
if (boundaryRect.width() > width) {
|
||||||
width = boundary_rect.width();
|
width = boundaryRect.width();
|
||||||
}
|
}
|
||||||
if (boundary_rect.height() > height) {
|
if (boundaryRect.height() > height) {
|
||||||
height = boundary_rect.height();
|
height = boundaryRect.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update sizes and positions
|
// update sizes and positions
|
||||||
@@ -443,11 +443,11 @@ void BoundaryItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_noTextItem) {
|
if (m_noTextItem) {
|
||||||
m_noTextItem->setRect(QRectF(-text_width / 2, top + CONTENTS_BORDER_VERTICAL, text_width, text_height));
|
m_noTextItem->setRect(QRectF(-textWidth / 2, top + CONTENTS_BORDER_VERTICAL, textWidth, textHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_textItem) {
|
if (m_textItem) {
|
||||||
m_textItem->setPos(-text_width / 2.0, top + CONTENTS_BORDER_VERTICAL);
|
m_textItem->setPos(-textWidth / 2.0, top + CONTENTS_BORDER_VERTICAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class BoundaryItem :
|
|||||||
class BoundaryTextItem;
|
class BoundaryTextItem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~BoundaryItem();
|
~BoundaryItem();
|
||||||
|
|
||||||
@@ -85,25 +85,25 @@ public:
|
|||||||
|
|
||||||
QSizeF getMinimumSize() const;
|
QSizeF getMinimumSize() const;
|
||||||
|
|
||||||
void setPosAndRect(const QPointF &original_pos, const QRectF &original_rect, const QPointF &top_left_delta, const QPointF &bottom_right_delta);
|
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
||||||
|
|
||||||
void alignItemSizeToRaster(Side adjust_horizontal_side, Side adjust_vertical_side, double raster_width, double raster_height);
|
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double raster_width, double raster_height);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondary_selected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focus_selected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ protected:
|
|||||||
|
|
||||||
void updateSelectionMarker();
|
void updateSelectionMarker();
|
||||||
|
|
||||||
void updateSelectionMarkerGeometry(const QRectF &boundary_rect);
|
void updateSelectionMarkerGeometry(const QRectF &boundaryRect);
|
||||||
|
|
||||||
const Style *getAdaptedStyle();
|
const Style *getAdaptedStyle();
|
||||||
|
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ static const qreal BODY_VERT_BORDER = 4.0;
|
|||||||
static const qreal BODY_HORIZ_BORDER = 4.0;
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
ClassItem::ClassItem(DClass *klass, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
ClassItem::ClassItem(DClass *klass, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(klass, diagram_scene_model, parent),
|
: ObjectItem(klass, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
m_shape(0),
|
m_shape(0),
|
||||||
m_namespace(0),
|
m_namespace(0),
|
||||||
@@ -95,12 +95,12 @@ void ClassItem::update()
|
|||||||
|
|
||||||
updateStereotypeIconDisplay();
|
updateStereotypeIconDisplay();
|
||||||
|
|
||||||
DClass *diagram_class = dynamic_cast<DClass *>(getObject());
|
DClass *diagramClass = dynamic_cast<DClass *>(getObject());
|
||||||
QMT_CHECK(diagram_class);
|
QMT_CHECK(diagramClass);
|
||||||
|
|
||||||
const Style *style = getAdaptedStyle(getStereotypeIconId());
|
const Style *style = getAdaptedStyle(getStereotypeIconId());
|
||||||
|
|
||||||
if (diagram_class->getShowAllMembers()) {
|
if (diagramClass->getShowAllMembers()) {
|
||||||
updateMembers(style);
|
updateMembers(style);
|
||||||
} else {
|
} else {
|
||||||
m_attributesText.clear();
|
m_attributesText.clear();
|
||||||
@@ -141,25 +141,25 @@ void ClassItem::update()
|
|||||||
updateStereotypes(getStereotypeIconId(), getStereotypeIconDisplay(), style);
|
updateStereotypes(getStereotypeIconId(), getStereotypeIconDisplay(), style);
|
||||||
|
|
||||||
// namespace
|
// namespace
|
||||||
if (!diagram_class->getNamespace().isEmpty()) {
|
if (!diagramClass->getNamespace().isEmpty()) {
|
||||||
if (!m_namespace) {
|
if (!m_namespace) {
|
||||||
m_namespace = new QGraphicsSimpleTextItem(this);
|
m_namespace = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
}
|
||||||
m_namespace->setFont(style->getSmallFont());
|
m_namespace->setFont(style->getSmallFont());
|
||||||
m_namespace->setBrush(style->getTextBrush());
|
m_namespace->setBrush(style->getTextBrush());
|
||||||
m_namespace->setText(diagram_class->getNamespace());
|
m_namespace->setText(diagramClass->getNamespace());
|
||||||
} else if (m_namespace) {
|
} else if (m_namespace) {
|
||||||
m_namespace->scene()->removeItem(m_namespace);
|
m_namespace->scene()->removeItem(m_namespace);
|
||||||
delete m_namespace;
|
delete m_namespace;
|
||||||
m_namespace = 0;
|
m_namespace = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DClass::TemplateDisplay template_display = diagram_class->getTemplateDisplay();
|
DClass::TemplateDisplay templateDisplay = diagramClass->getTemplateDisplay();
|
||||||
if (template_display == DClass::TEMPLATE_SMART) {
|
if (templateDisplay == DClass::TEMPLATE_SMART) {
|
||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
template_display = DClass::TEMPLATE_NAME;
|
templateDisplay = DClass::TEMPLATE_NAME;
|
||||||
} else {
|
} else {
|
||||||
template_display = DClass::TEMPLATE_BOX;
|
templateDisplay = DClass::TEMPLATE_BOX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,11 +169,11 @@ void ClassItem::update()
|
|||||||
}
|
}
|
||||||
m_className->setFont(style->getHeaderFont());
|
m_className->setFont(style->getHeaderFont());
|
||||||
m_className->setBrush(style->getTextBrush());
|
m_className->setBrush(style->getTextBrush());
|
||||||
if (template_display == DClass::TEMPLATE_NAME && !diagram_class->getTemplateParameters().isEmpty()) {
|
if (templateDisplay == DClass::TEMPLATE_NAME && !diagramClass->getTemplateParameters().isEmpty()) {
|
||||||
QString name = getObject()->getName();
|
QString name = getObject()->getName();
|
||||||
name += QLatin1Char('<');
|
name += QLatin1Char('<');
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach (const QString &p, diagram_class->getTemplateParameters()) {
|
foreach (const QString &p, diagramClass->getTemplateParameters()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
name += QLatin1Char(',');
|
name += QLatin1Char(',');
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ void ClassItem::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// template parameters
|
// template parameters
|
||||||
if (template_display == DClass::TEMPLATE_BOX && !diagram_class->getTemplateParameters().isEmpty()) {
|
if (templateDisplay == DClass::TEMPLATE_BOX && !diagramClass->getTemplateParameters().isEmpty()) {
|
||||||
if (!m_templateParameterBox) {
|
if (!m_templateParameterBox) {
|
||||||
m_templateParameterBox = new TemplateParameterBox(this);
|
m_templateParameterBox = new TemplateParameterBox(this);
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ void ClassItem::update()
|
|||||||
m_templateParameterBox->setBrush(QBrush(Qt::white));
|
m_templateParameterBox->setBrush(QBrush(Qt::white));
|
||||||
m_templateParameterBox->setFont(style->getSmallFont());
|
m_templateParameterBox->setFont(style->getSmallFont());
|
||||||
m_templateParameterBox->setTextBrush(style->getTextBrush());
|
m_templateParameterBox->setTextBrush(style->getTextBrush());
|
||||||
m_templateParameterBox->setTemplateParameters(diagram_class->getTemplateParameters());
|
m_templateParameterBox->setTemplateParameters(diagramClass->getTemplateParameters());
|
||||||
} else if (m_templateParameterBox) {
|
} else if (m_templateParameterBox) {
|
||||||
m_templateParameterBox->scene()->removeItem(m_templateParameterBox);
|
m_templateParameterBox->scene()->removeItem(m_templateParameterBox);
|
||||||
delete m_templateParameterBox;
|
delete m_templateParameterBox;
|
||||||
@@ -297,7 +297,7 @@ void ClassItem::update()
|
|||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClassItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const
|
bool ClassItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const
|
||||||
{
|
{
|
||||||
QPolygonF polygon;
|
QPolygonF polygon;
|
||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
@@ -312,7 +312,7 @@ bool ClassItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection
|
|||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
}
|
}
|
||||||
return GeometryUtilities::intersect(polygon, line, intersection_point, intersection_line);
|
return GeometryUtilities::intersect(polygon, line, intersectionPoint, intersectionLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF ClassItem::getMinimumSize() const
|
QSizeF ClassItem::getMinimumSize() const
|
||||||
@@ -325,28 +325,28 @@ QPointF ClassItem::getRelationStartPos() const
|
|||||||
return pos();
|
return pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassItem::relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points)
|
void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints)
|
||||||
{
|
{
|
||||||
DElement *target_element = getDiagramSceneModel()->findTopmostElement(to_scene_pos);
|
DElement *targetElement = getDiagramSceneModel()->findTopmostElement(toScenePos);
|
||||||
if (target_element) {
|
if (targetElement) {
|
||||||
if (id == QLatin1String("inheritance")) {
|
if (id == QLatin1String("inheritance")) {
|
||||||
DClass *base_class = dynamic_cast<DClass *>(target_element);
|
DClass *baseClass = dynamic_cast<DClass *>(targetElement);
|
||||||
if (base_class) {
|
if (baseClass) {
|
||||||
DClass *derived_class = dynamic_cast<DClass *>(getObject());
|
DClass *derivedClass = dynamic_cast<DClass *>(getObject());
|
||||||
QMT_CHECK(derived_class);
|
QMT_CHECK(derivedClass);
|
||||||
getDiagramSceneModel()->getDiagramSceneController()->createInheritance(derived_class, base_class, intermediate_points, getDiagramSceneModel()->getDiagram());
|
getDiagramSceneModel()->getDiagramSceneController()->createInheritance(derivedClass, baseClass, intermediatePoints, getDiagramSceneModel()->getDiagram());
|
||||||
}
|
}
|
||||||
} else if (id == QLatin1String("dependency")) {
|
} else if (id == QLatin1String("dependency")) {
|
||||||
DObject *dependant_object = dynamic_cast<DObject *>(target_element);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependant_object) {
|
if (dependantObject) {
|
||||||
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependant_object, intermediate_points, getDiagramSceneModel()->getDiagram());
|
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependantObject, intermediatePoints, getDiagramSceneModel()->getDiagram());
|
||||||
}
|
}
|
||||||
} else if (id == QLatin1String("association")) {
|
} else if (id == QLatin1String("association")) {
|
||||||
DClass *assoziated_class = dynamic_cast<DClass *>(target_element);
|
DClass *assoziatedClass = dynamic_cast<DClass *>(targetElement);
|
||||||
if (assoziated_class) {
|
if (assoziatedClass) {
|
||||||
DClass *derived_class = dynamic_cast<DClass *>(getObject());
|
DClass *derivedClass = dynamic_cast<DClass *>(getObject());
|
||||||
QMT_CHECK(derived_class);
|
QMT_CHECK(derivedClass);
|
||||||
getDiagramSceneModel()->getDiagramSceneController()->createAssociation(derived_class, assoziated_class, intermediate_points, getDiagramSceneModel()->getDiagram());
|
getDiagramSceneModel()->getDiagramSceneController()->createAssociation(derivedClass, assoziatedClass, intermediatePoints, getDiagramSceneModel()->getDiagram());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,9 +364,9 @@ bool ClassItem::extendContextMenu(QMenu *menu)
|
|||||||
|
|
||||||
bool ClassItem::handleSelectedContextMenuAction(QAction *action)
|
bool ClassItem::handleSelectedContextMenuAction(QAction *action)
|
||||||
{
|
{
|
||||||
ContextMenuAction *klass_action = dynamic_cast<ContextMenuAction *>(action);
|
ContextMenuAction *klassAction = dynamic_cast<ContextMenuAction *>(action);
|
||||||
if (klass_action) {
|
if (klassAction) {
|
||||||
if (klass_action->getId() == QStringLiteral("showDefinition")) {
|
if (klassAction->getId() == QStringLiteral("showDefinition")) {
|
||||||
getDiagramSceneModel()->getDiagramSceneController()->getElementTasks()->openClassDefinition(getObject(), getDiagramSceneModel()->getDiagram());
|
getDiagramSceneModel()->getDiagramSceneController()->getElementTasks()->openClassDefinition(getObject(), getDiagramSceneModel()->getDiagram());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -384,13 +384,13 @@ QSizeF ClassItem::calcMinimumGeometry() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
width = std::max(width, stereotype_icon_item->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, stereotypeIconItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
height += stereotype_icon_item->boundingRect().height();
|
height += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
width = std::max(width, stereotypes_item->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, stereotypesItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
height += stereotypes_item->boundingRect().height();
|
height += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_namespace) {
|
if (m_namespace) {
|
||||||
width = std::max(width, m_namespace->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, m_namespace->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
@@ -480,13 +480,13 @@ void ClassItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
stereotype_icon_item->setPos(right - stereotype_icon_item->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
stereotypeIconItem->setPos(right - stereotypeIconItem->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
||||||
y += stereotype_icon_item->boundingRect().height();
|
y += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
stereotypes_item->setPos(-stereotypes_item->boundingRect().width() / 2.0, y);
|
stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
|
||||||
y += stereotypes_item->boundingRect().height();
|
y += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_namespace) {
|
if (m_namespace) {
|
||||||
m_namespace->setPos(-m_namespace->boundingRect().width() / 2.0, y);
|
m_namespace->setPos(-m_namespace->boundingRect().width() / 2.0, y);
|
||||||
@@ -564,22 +564,22 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
m_attributesText.clear();
|
m_attributesText.clear();
|
||||||
m_methodsText.clear();
|
m_methodsText.clear();
|
||||||
|
|
||||||
MClassMember::Visibility attributes_visibility = MClassMember::VISIBILITY_UNDEFINED;
|
MClassMember::Visibility attributesVisibility = MClassMember::VISIBILITY_UNDEFINED;
|
||||||
MClassMember::Visibility methods_visibility = MClassMember::VISIBILITY_UNDEFINED;
|
MClassMember::Visibility methodsVisibility = MClassMember::VISIBILITY_UNDEFINED;
|
||||||
QString attributes_group;
|
QString attributesGroup;
|
||||||
QString methods_group;
|
QString methodsGroup;
|
||||||
|
|
||||||
MClassMember::Visibility *current_visibility = 0;
|
MClassMember::Visibility *currentVisibility = 0;
|
||||||
QString *current_group = 0;
|
QString *currentGroup = 0;
|
||||||
QString *text = 0;
|
QString *text = 0;
|
||||||
|
|
||||||
DClass *dclass = dynamic_cast<DClass *>(getObject());
|
DClass *dclass = dynamic_cast<DClass *>(getObject());
|
||||||
QMT_CHECK(dclass);
|
QMT_CHECK(dclass);
|
||||||
|
|
||||||
// TODO move bool have_icon_fonts into class Style?
|
// TODO move bool haveIconFonts into class Style?
|
||||||
bool have_icon_fonts = false; // style->getNormalFont().family() == QStringLiteral("Modelling");
|
bool haveIconFonts = false; // style->getNormalFont().family() == QStringLiteral("Modelling");
|
||||||
// TODO any reason to show visibility as group instead of per member?
|
// TODO any reason to show visibility as group instead of per member?
|
||||||
bool use_group_visibility = false;
|
bool useGroupVisibility = false;
|
||||||
|
|
||||||
foreach (const MClassMember &member, dclass->getMembers()) {
|
foreach (const MClassMember &member, dclass->getMembers()) {
|
||||||
|
|
||||||
@@ -588,13 +588,13 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
break;
|
break;
|
||||||
case MClassMember::MEMBER_ATTRIBUTE:
|
case MClassMember::MEMBER_ATTRIBUTE:
|
||||||
current_visibility = &attributes_visibility;
|
currentVisibility = &attributesVisibility;
|
||||||
current_group = &attributes_group;
|
currentGroup = &attributesGroup;
|
||||||
text = &m_attributesText;
|
text = &m_attributesText;
|
||||||
break;
|
break;
|
||||||
case MClassMember::MEMBER_METHOD:
|
case MClassMember::MEMBER_METHOD:
|
||||||
current_visibility = &methods_visibility;
|
currentVisibility = &methodsVisibility;
|
||||||
current_group = &methods_group;
|
currentGroup = &methodsGroup;
|
||||||
text = &m_methodsText;
|
text = &m_methodsText;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -603,10 +603,10 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
*text += QStringLiteral("<br/>");
|
*text += QStringLiteral("<br/>");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool add_newline = false;
|
bool addNewline = false;
|
||||||
bool add_space = false;
|
bool addSpace = false;
|
||||||
if (member.getVisibility() != *current_visibility) {
|
if (member.getVisibility() != *currentVisibility) {
|
||||||
if (use_group_visibility) {
|
if (useGroupVisibility) {
|
||||||
if (member.getVisibility() != MClassMember::VISIBILITY_UNDEFINED) {
|
if (member.getVisibility() != MClassMember::VISIBILITY_UNDEFINED) {
|
||||||
QString vis;
|
QString vis;
|
||||||
switch (member.getVisibility()) {
|
switch (member.getVisibility()) {
|
||||||
@@ -635,82 +635,82 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*text += vis;
|
*text += vis;
|
||||||
add_newline = true;
|
addNewline = true;
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*current_visibility = member.getVisibility();
|
*currentVisibility = member.getVisibility();
|
||||||
}
|
}
|
||||||
if (member.getGroup() != current_group) {
|
if (member.getGroup() != currentGroup) {
|
||||||
if (add_space) {
|
if (addSpace) {
|
||||||
*text += QStringLiteral(" ");
|
*text += QStringLiteral(" ");
|
||||||
}
|
}
|
||||||
*text += QString(QStringLiteral("[%1]")).arg(member.getGroup());
|
*text += QString(QStringLiteral("[%1]")).arg(member.getGroup());
|
||||||
add_newline = true;
|
addNewline = true;
|
||||||
*current_group = member.getGroup();
|
*currentGroup = member.getGroup();
|
||||||
}
|
}
|
||||||
if (add_newline) {
|
if (addNewline) {
|
||||||
*text += QStringLiteral("<br/>");
|
*text += QStringLiteral("<br/>");
|
||||||
}
|
}
|
||||||
|
|
||||||
add_space = false;
|
addSpace = false;
|
||||||
bool have_signal = false;
|
bool haveSignal = false;
|
||||||
bool have_slot = false;
|
bool haveSlot = false;
|
||||||
if (!use_group_visibility) {
|
if (!useGroupVisibility) {
|
||||||
if (member.getVisibility() != MClassMember::VISIBILITY_UNDEFINED) {
|
if (member.getVisibility() != MClassMember::VISIBILITY_UNDEFINED) {
|
||||||
QString vis;
|
QString vis;
|
||||||
switch (member.getVisibility()) {
|
switch (member.getVisibility()) {
|
||||||
case MClassMember::VISIBILITY_UNDEFINED:
|
case MClassMember::VISIBILITY_UNDEFINED:
|
||||||
break;
|
break;
|
||||||
case MClassMember::VISIBILITY_PUBLIC:
|
case MClassMember::VISIBILITY_PUBLIC:
|
||||||
vis = have_icon_fonts ? QString(QChar(0xe990)) : QStringLiteral("+");
|
vis = haveIconFonts ? QString(QChar(0xe990)) : QStringLiteral("+");
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
break;
|
break;
|
||||||
case MClassMember::VISIBILITY_PROTECTED:
|
case MClassMember::VISIBILITY_PROTECTED:
|
||||||
vis = have_icon_fonts ? QString(QChar(0xe98e)) : QStringLiteral("#");
|
vis = haveIconFonts ? QString(QChar(0xe98e)) : QStringLiteral("#");
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
break;
|
break;
|
||||||
case MClassMember::VISIBILITY_PRIVATE:
|
case MClassMember::VISIBILITY_PRIVATE:
|
||||||
vis = have_icon_fonts ? QString(QChar(0xe98f)) : QStringLiteral("-");
|
vis = haveIconFonts ? QString(QChar(0xe98f)) : QStringLiteral("-");
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
break;
|
break;
|
||||||
case MClassMember::VISIBILITY_SIGNALS:
|
case MClassMember::VISIBILITY_SIGNALS:
|
||||||
vis = have_icon_fonts ? QString(QChar(0xe994)) : QStringLiteral(">");
|
vis = haveIconFonts ? QString(QChar(0xe994)) : QStringLiteral(">");
|
||||||
have_signal = true;
|
haveSignal = true;
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
break;
|
break;
|
||||||
case MClassMember::VISIBILITY_PRIVATE_SLOTS:
|
case MClassMember::VISIBILITY_PRIVATE_SLOTS:
|
||||||
vis = have_icon_fonts ? QString(QChar(0xe98f)) + QChar(0xe9cb)
|
vis = haveIconFonts ? QString(QChar(0xe98f)) + QChar(0xe9cb)
|
||||||
: QStringLiteral("-$");
|
: QStringLiteral("-$");
|
||||||
have_slot = true;
|
haveSlot = true;
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
break;
|
break;
|
||||||
case MClassMember::VISIBILITY_PROTECTED_SLOTS:
|
case MClassMember::VISIBILITY_PROTECTED_SLOTS:
|
||||||
vis = have_icon_fonts ? QString(QChar(0xe98e)) + QChar(0xe9cb)
|
vis = haveIconFonts ? QString(QChar(0xe98e)) + QChar(0xe9cb)
|
||||||
: QStringLiteral("#$");
|
: QStringLiteral("#$");
|
||||||
have_slot = true;
|
haveSlot = true;
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
break;
|
break;
|
||||||
case MClassMember::VISIBILITY_PUBLIC_SLOTS:
|
case MClassMember::VISIBILITY_PUBLIC_SLOTS:
|
||||||
vis = have_icon_fonts ? QString(QChar(0xe990)) + QChar(0xe9cb)
|
vis = haveIconFonts ? QString(QChar(0xe990)) + QChar(0xe9cb)
|
||||||
: QStringLiteral("+$");
|
: QStringLiteral("+$");
|
||||||
have_slot = true;
|
haveSlot = true;
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*text += vis;
|
*text += vis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (member.getProperties() & MClassMember::PROPERTY_QSIGNAL && !have_signal) {
|
if (member.getProperties() & MClassMember::PROPERTY_QSIGNAL && !haveSignal) {
|
||||||
*text += have_icon_fonts ? QString(QChar(0xe994)) : QStringLiteral(">");
|
*text += haveIconFonts ? QString(QChar(0xe994)) : QStringLiteral(">");
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
}
|
}
|
||||||
if (member.getProperties() & MClassMember::PROPERTY_QSLOT && !have_slot) {
|
if (member.getProperties() & MClassMember::PROPERTY_QSLOT && !haveSlot) {
|
||||||
*text += have_icon_fonts ? QString(QChar(0xe9cb)) : QStringLiteral("$");
|
*text += haveIconFonts ? QString(QChar(0xe9cb)) : QStringLiteral("$");
|
||||||
add_space = true;
|
addSpace = true;
|
||||||
}
|
}
|
||||||
if (add_space) {
|
if (addSpace) {
|
||||||
*text += QStringLiteral(" ");
|
*text += QStringLiteral(" ");
|
||||||
}
|
}
|
||||||
if (member.getProperties() & MClassMember::PROPERTY_QINVOKABLE) {
|
if (member.getProperties() & MClassMember::PROPERTY_QINVOKABLE) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class ClassItem :
|
|||||||
public IRelationable
|
public IRelationable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClassItem(DClass *klass, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
ClassItem(DClass *klass, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ClassItem();
|
~ClassItem();
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
QPointF getRelationStartPos() const;
|
QPointF getRelationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ static const qreal BODY_VERT_BORDER = 4.0;
|
|||||||
static const qreal BODY_HORIZ_BORDER = 4.0;
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
ComponentItem::ComponentItem(DComponent *component, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
ComponentItem::ComponentItem(DComponent *component, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(component, diagram_scene_model, parent),
|
: ObjectItem(component, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
m_shape(0),
|
m_shape(0),
|
||||||
m_upperRect(0),
|
m_upperRect(0),
|
||||||
@@ -107,7 +107,7 @@ void ComponentItem::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// shape
|
// shape
|
||||||
bool delete_rects = false;
|
bool deleteRects = false;
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (!m_shape) {
|
if (!m_shape) {
|
||||||
m_shape = new QGraphicsRectItem(this);
|
m_shape = new QGraphicsRectItem(this);
|
||||||
@@ -129,17 +129,17 @@ void ComponentItem::update()
|
|||||||
m_lowerRect->setPen(style->getOuterLinePen());
|
m_lowerRect->setPen(style->getOuterLinePen());
|
||||||
m_lowerRect->setZValue(SHAPE_DETAILS_ZVALUE);
|
m_lowerRect->setZValue(SHAPE_DETAILS_ZVALUE);
|
||||||
} else {
|
} else {
|
||||||
delete_rects = true;
|
deleteRects = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delete_rects = true;
|
deleteRects = true;
|
||||||
if (m_shape) {
|
if (m_shape) {
|
||||||
m_shape->scene()->removeItem(m_shape);
|
m_shape->scene()->removeItem(m_shape);
|
||||||
delete m_shape;
|
delete m_shape;
|
||||||
m_shape = 0;
|
m_shape = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delete_rects) {
|
if (deleteRects) {
|
||||||
if (m_lowerRect) {
|
if (m_lowerRect) {
|
||||||
m_lowerRect->scene()->removeItem(m_lowerRect);
|
m_lowerRect->scene()->removeItem(m_lowerRect);
|
||||||
delete m_lowerRect;
|
delete m_lowerRect;
|
||||||
@@ -200,11 +200,11 @@ void ComponentItem::update()
|
|||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComponentItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const
|
bool ComponentItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const
|
||||||
{
|
{
|
||||||
QPolygonF polygon;
|
QPolygonF polygon;
|
||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
// TODO use custom_icon path as shape
|
// TODO use customIcon path as shape
|
||||||
QRectF rect = getObject()->getRect();
|
QRectF rect = getObject()->getRect();
|
||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
@@ -225,7 +225,7 @@ bool ComponentItem::intersectShapeWithLine(const QLineF &line, QPointF *intersec
|
|||||||
<< rect.bottomLeft() + QPointF(0, UPPER_RECT_Y)
|
<< rect.bottomLeft() + QPointF(0, UPPER_RECT_Y)
|
||||||
<< rect.topLeft();
|
<< rect.topLeft();
|
||||||
}
|
}
|
||||||
return GeometryUtilities::intersect(polygon, line, intersection_point, intersection_line);
|
return GeometryUtilities::intersect(polygon, line, intersectionPoint, intersectionLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF ComponentItem::getMinimumSize() const
|
QSizeF ComponentItem::getMinimumSize() const
|
||||||
@@ -233,14 +233,14 @@ QSizeF ComponentItem::getMinimumSize() const
|
|||||||
return calcMinimumGeometry();
|
return calcMinimumGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> ComponentItem::getHorizontalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> ComponentItem::getHorizontalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
return ObjectItem::getHorizontalLatches(action, grabbed_item);
|
return ObjectItem::getHorizontalLatches(action, grabbedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> ComponentItem::getVerticalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> ComponentItem::getVerticalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
return ObjectItem::getVerticalLatches(action, grabbed_item);
|
return ObjectItem::getVerticalLatches(action, grabbedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -264,14 +264,14 @@ QPointF ComponentItem::getRelationStartPos() const
|
|||||||
return pos();
|
return pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentItem::relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points)
|
void ComponentItem::relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints)
|
||||||
{
|
{
|
||||||
DElement *target_element = getDiagramSceneModel()->findTopmostElement(to_scene_pos);
|
DElement *targetElement = getDiagramSceneModel()->findTopmostElement(toScenePos);
|
||||||
if (target_element) {
|
if (targetElement) {
|
||||||
if (id == QStringLiteral("dependency")) {
|
if (id == QStringLiteral("dependency")) {
|
||||||
DObject *dependant_object = dynamic_cast<DObject *>(target_element);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependant_object) {
|
if (dependantObject) {
|
||||||
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependant_object, intermediate_points, getDiagramSceneModel()->getDiagram());
|
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependantObject, intermediatePoints, getDiagramSceneModel()->getDiagram());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,9 +279,9 @@ void ComponentItem::relationDrawn(const QString &id, const QPointF &to_scene_pos
|
|||||||
|
|
||||||
bool ComponentItem::hasPlainShape() const
|
bool ComponentItem::hasPlainShape() const
|
||||||
{
|
{
|
||||||
DComponent *diagram_component = dynamic_cast<DComponent *>(getObject());
|
DComponent *diagramComponent = dynamic_cast<DComponent *>(getObject());
|
||||||
QMT_CHECK(diagram_component);
|
QMT_CHECK(diagramComponent);
|
||||||
return diagram_component->getPlainShape();
|
return diagramComponent->getPlainShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF ComponentItem::calcMinimumGeometry() const
|
QSizeF ComponentItem::calcMinimumGeometry() const
|
||||||
@@ -294,13 +294,13 @@ QSizeF ComponentItem::calcMinimumGeometry() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
width = std::max(width, stereotype_icon_item->boundingRect().width());
|
width = std::max(width, stereotypeIconItem->boundingRect().width());
|
||||||
height += stereotype_icon_item->boundingRect().height();
|
height += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
width = std::max(width, stereotypes_item->boundingRect().width());
|
width = std::max(width, stereotypesItem->boundingRect().width());
|
||||||
height += stereotypes_item->boundingRect().height();
|
height += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_componentName) {
|
if (m_componentName) {
|
||||||
width = std::max(width, m_componentName->boundingRect().width());
|
width = std::max(width, m_componentName->boundingRect().width());
|
||||||
@@ -313,9 +313,9 @@ QSizeF ComponentItem::calcMinimumGeometry() const
|
|||||||
|
|
||||||
if (!hasPlainShape()) {
|
if (!hasPlainShape()) {
|
||||||
width = RECT_WIDTH * 0.5 + BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER + RECT_WIDTH * 0.5;
|
width = RECT_WIDTH * 0.5 + BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER + RECT_WIDTH * 0.5;
|
||||||
double min_height = UPPER_RECT_Y + RECT_HEIGHT + RECT_Y_DISTANCE + RECT_HEIGHT + LOWER_RECT_MIN_Y;
|
double minHeight = UPPER_RECT_Y + RECT_HEIGHT + RECT_Y_DISTANCE + RECT_HEIGHT + LOWER_RECT_MIN_Y;
|
||||||
if (height < min_height) {
|
if (height < minHeight) {
|
||||||
height = min_height;
|
height = minHeight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
width = BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER;
|
width = BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER;
|
||||||
@@ -375,25 +375,25 @@ void ComponentItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_upperRect) {
|
if (m_upperRect) {
|
||||||
QRectF upper_rect(0, 0, RECT_WIDTH, RECT_HEIGHT);
|
QRectF upperRect(0, 0, RECT_WIDTH, RECT_HEIGHT);
|
||||||
m_upperRect->setRect(upper_rect);
|
m_upperRect->setRect(upperRect);
|
||||||
m_upperRect->setPos(left - RECT_WIDTH * 0.5, top + UPPER_RECT_Y);
|
m_upperRect->setPos(left - RECT_WIDTH * 0.5, top + UPPER_RECT_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_lowerRect) {
|
if (m_lowerRect) {
|
||||||
QRectF lower_rect(0, 0, RECT_WIDTH, RECT_HEIGHT);
|
QRectF lowerRect(0, 0, RECT_WIDTH, RECT_HEIGHT);
|
||||||
m_lowerRect->setRect(lower_rect);
|
m_lowerRect->setRect(lowerRect);
|
||||||
m_lowerRect->setPos(left - RECT_WIDTH * 0.5, top + UPPER_RECT_Y + RECT_HEIGHT + RECT_Y_DISTANCE);
|
m_lowerRect->setPos(left - RECT_WIDTH * 0.5, top + UPPER_RECT_Y + RECT_HEIGHT + RECT_Y_DISTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
stereotype_icon_item->setPos(right - stereotype_icon_item->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
stereotypeIconItem->setPos(right - stereotypeIconItem->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
||||||
y += stereotype_icon_item->boundingRect().height();
|
y += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
stereotypes_item->setPos(-stereotypes_item->boundingRect().width() / 2.0, y);
|
stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
|
||||||
y += stereotypes_item->boundingRect().height();
|
y += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_componentName) {
|
if (m_componentName) {
|
||||||
m_componentName->setPos(-m_componentName->boundingRect().width() / 2.0, y);
|
m_componentName->setPos(-m_componentName->boundingRect().width() / 2.0, y);
|
||||||
@@ -403,8 +403,8 @@ void ComponentItem::updateGeometry()
|
|||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
m_contextLabel->resetMaxWidth();
|
m_contextLabel->resetMaxWidth();
|
||||||
} else {
|
} else {
|
||||||
double max_context_width = width - 2 * BODY_HORIZ_BORDER - (hasPlainShape() ? 0 : RECT_WIDTH);
|
double maxContextWidth = width - 2 * BODY_HORIZ_BORDER - (hasPlainShape() ? 0 : RECT_WIDTH);
|
||||||
m_contextLabel->setMaxWidth(max_context_width);
|
m_contextLabel->setMaxWidth(maxContextWidth);
|
||||||
}
|
}
|
||||||
m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
|
m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
|
||||||
y += m_contextLabel->boundingRect().height();
|
y += m_contextLabel->boundingRect().height();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class ComponentItem :
|
|||||||
public IRelationable
|
public IRelationable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComponentItem(DComponent *component, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
ComponentItem(DComponent *component, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ComponentItem();
|
~ComponentItem();
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -74,15 +74,15 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QList<Latch> getHorizontalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getHorizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> getVerticalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getVerticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QPointF getRelationStartPos() const;
|
QPointF getRelationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ static const qreal BODY_HORIZ_BORDER = 4.0;
|
|||||||
static const qreal BODY_VERT_BORDER = 4.0;
|
static const qreal BODY_VERT_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
DiagramItem::DiagramItem(DDiagram *diagram, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
DiagramItem::DiagramItem(DDiagram *diagram, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(diagram, diagram_scene_model, parent),
|
: ObjectItem(diagram, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
m_body(0),
|
m_body(0),
|
||||||
m_fold(0),
|
m_fold(0),
|
||||||
@@ -141,11 +141,11 @@ void DiagramItem::update()
|
|||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const
|
bool DiagramItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const
|
||||||
{
|
{
|
||||||
QPolygonF polygon;
|
QPolygonF polygon;
|
||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
// TODO use custom_icon path as shape
|
// TODO use customIcon path as shape
|
||||||
QRectF rect = getObject()->getRect();
|
QRectF rect = getObject()->getRect();
|
||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
@@ -154,7 +154,7 @@ bool DiagramItem::intersectShapeWithLine(const QLineF &line, QPointF *intersecti
|
|||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
}
|
}
|
||||||
return GeometryUtilities::intersect(polygon, line, intersection_point, intersection_line);
|
return GeometryUtilities::intersect(polygon, line, intersectionPoint, intersectionLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF DiagramItem::getMinimumSize() const
|
QSizeF DiagramItem::getMinimumSize() const
|
||||||
@@ -172,15 +172,15 @@ QSizeF DiagramItem::calcMinimumGeometry() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
width = std::max(width, stereotype_icon_item->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, stereotypeIconItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
height += std::max(FOLD_HEIGHT, stereotype_icon_item->boundingRect().height());
|
height += std::max(FOLD_HEIGHT, stereotypeIconItem->boundingRect().height());
|
||||||
} else {
|
} else {
|
||||||
height += FOLD_HEIGHT;
|
height += FOLD_HEIGHT;
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
width = std::max(width, stereotypes_item->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, stereotypesItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
height += stereotypes_item->boundingRect().height();
|
height += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_diagramName) {
|
if (m_diagramName) {
|
||||||
width = std::max(width, m_diagramName->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, m_diagramName->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
@@ -245,36 +245,36 @@ void DiagramItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_body) {
|
if (m_body) {
|
||||||
QPolygonF body_polygon;
|
QPolygonF bodyPolygon;
|
||||||
body_polygon
|
bodyPolygon
|
||||||
<< rect.topLeft()
|
<< rect.topLeft()
|
||||||
<< rect.topRight() + QPointF(-FOLD_WIDTH, 0.0)
|
<< rect.topRight() + QPointF(-FOLD_WIDTH, 0.0)
|
||||||
<< rect.topRight() + QPointF(0.0, FOLD_HEIGHT)
|
<< rect.topRight() + QPointF(0.0, FOLD_HEIGHT)
|
||||||
<< rect.bottomRight()
|
<< rect.bottomRight()
|
||||||
<< rect.bottomLeft();
|
<< rect.bottomLeft();
|
||||||
m_body->setPolygon(body_polygon);
|
m_body->setPolygon(bodyPolygon);
|
||||||
}
|
}
|
||||||
if (m_fold) {
|
if (m_fold) {
|
||||||
QPolygonF fold_polygon;
|
QPolygonF foldPolygon;
|
||||||
fold_polygon
|
foldPolygon
|
||||||
<< rect.topRight() + QPointF(-FOLD_WIDTH, 0.0)
|
<< rect.topRight() + QPointF(-FOLD_WIDTH, 0.0)
|
||||||
<< rect.topRight() + QPointF(0.0, FOLD_HEIGHT)
|
<< rect.topRight() + QPointF(0.0, FOLD_HEIGHT)
|
||||||
<< rect.topRight() + QPointF(-FOLD_WIDTH, FOLD_HEIGHT);
|
<< rect.topRight() + QPointF(-FOLD_WIDTH, FOLD_HEIGHT);
|
||||||
m_fold->setPolygon(fold_polygon);
|
m_fold->setPolygon(foldPolygon);
|
||||||
}
|
}
|
||||||
|
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
stereotype_icon_item->setPos(left + BODY_HORIZ_BORDER, y);
|
stereotypeIconItem->setPos(left + BODY_HORIZ_BORDER, y);
|
||||||
y += std::max(FOLD_HEIGHT, stereotype_icon_item->boundingRect().height());
|
y += std::max(FOLD_HEIGHT, stereotypeIconItem->boundingRect().height());
|
||||||
} else {
|
} else {
|
||||||
y += FOLD_HEIGHT;
|
y += FOLD_HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
stereotypes_item->setPos(-stereotypes_item->boundingRect().width() / 2.0, y);
|
stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
|
||||||
y += stereotypes_item->boundingRect().height();
|
y += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_diagramName) {
|
if (m_diagramName) {
|
||||||
m_diagramName->setPos(-m_diagramName->boundingRect().width() / 2.0, y);
|
m_diagramName->setPos(-m_diagramName->boundingRect().width() / 2.0, y);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class DiagramItem :
|
|||||||
public ObjectItem
|
public ObjectItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DiagramItem(DDiagram *diagram, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
explicit DiagramItem(DDiagram *diagram, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~DiagramItem();
|
~DiagramItem();
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ static const qreal BODY_VERT_BORDER = 4.0;
|
|||||||
static const qreal BODY_HORIZ_BORDER = 4.0;
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
ItemItem::ItemItem(DItem *item, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
ItemItem::ItemItem(DItem *item, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(item, diagram_scene_model, parent),
|
: ObjectItem(item, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
m_shape(0),
|
m_shape(0),
|
||||||
m_itemName(0),
|
m_itemName(0),
|
||||||
@@ -81,9 +81,9 @@ void ItemItem::update()
|
|||||||
|
|
||||||
updateStereotypeIconDisplay();
|
updateStereotypeIconDisplay();
|
||||||
|
|
||||||
DItem *diagram_item = dynamic_cast<DItem *>(getObject());
|
DItem *diagramItem = dynamic_cast<DItem *>(getObject());
|
||||||
Q_UNUSED(diagram_item); // avoid warning about unsed variable
|
Q_UNUSED(diagramItem); // avoid warning about unsed variable
|
||||||
QMT_CHECK(diagram_item);
|
QMT_CHECK(diagramItem);
|
||||||
|
|
||||||
const Style *style = getAdaptedStyle(getShapeIconId());
|
const Style *style = getAdaptedStyle(getShapeIconId());
|
||||||
|
|
||||||
@@ -166,11 +166,11 @@ void ItemItem::update()
|
|||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ItemItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const
|
bool ItemItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const
|
||||||
{
|
{
|
||||||
QPolygonF polygon;
|
QPolygonF polygon;
|
||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
// TODO use custom_icon path as shape
|
// TODO use customIcon path as shape
|
||||||
QRectF rect = getObject()->getRect();
|
QRectF rect = getObject()->getRect();
|
||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
@@ -179,7 +179,7 @@ bool ItemItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection_
|
|||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
}
|
}
|
||||||
return GeometryUtilities::intersect(polygon, line, intersection_point, intersection_line);
|
return GeometryUtilities::intersect(polygon, line, intersectionPoint, intersectionLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF ItemItem::getMinimumSize() const
|
QSizeF ItemItem::getMinimumSize() const
|
||||||
@@ -187,14 +187,14 @@ QSizeF ItemItem::getMinimumSize() const
|
|||||||
return calcMinimumGeometry();
|
return calcMinimumGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> ItemItem::getHorizontalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> ItemItem::getHorizontalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
return ObjectItem::getHorizontalLatches(action, grabbed_item);
|
return ObjectItem::getHorizontalLatches(action, grabbedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> ItemItem::getVerticalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> ItemItem::getVerticalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
return ObjectItem::getVerticalLatches(action, grabbed_item);
|
return ObjectItem::getVerticalLatches(action, grabbedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF ItemItem::getRelationStartPos() const
|
QPointF ItemItem::getRelationStartPos() const
|
||||||
@@ -202,14 +202,14 @@ QPointF ItemItem::getRelationStartPos() const
|
|||||||
return pos();
|
return pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemItem::relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points)
|
void ItemItem::relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints)
|
||||||
{
|
{
|
||||||
DElement *target_element = getDiagramSceneModel()->findTopmostElement(to_scene_pos);
|
DElement *targetElement = getDiagramSceneModel()->findTopmostElement(toScenePos);
|
||||||
if (target_element) {
|
if (targetElement) {
|
||||||
if (id == QStringLiteral("dependency")) {
|
if (id == QStringLiteral("dependency")) {
|
||||||
DObject *dependant_object = dynamic_cast<DObject *>(target_element);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependant_object) {
|
if (dependantObject) {
|
||||||
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependant_object, intermediate_points, getDiagramSceneModel()->getDiagram());
|
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependantObject, intermediatePoints, getDiagramSceneModel()->getDiagram());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,13 +225,13 @@ QSizeF ItemItem::calcMinimumGeometry() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
width = std::max(width, stereotype_icon_item->boundingRect().width());
|
width = std::max(width, stereotypeIconItem->boundingRect().width());
|
||||||
height += stereotype_icon_item->boundingRect().height();
|
height += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
width = std::max(width, stereotypes_item->boundingRect().width());
|
width = std::max(width, stereotypesItem->boundingRect().width());
|
||||||
height += stereotypes_item->boundingRect().height();
|
height += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_itemName) {
|
if (m_itemName) {
|
||||||
width = std::max(width, m_itemName->boundingRect().width());
|
width = std::max(width, m_itemName->boundingRect().width());
|
||||||
@@ -298,13 +298,13 @@ void ItemItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
stereotype_icon_item->setPos(right - stereotype_icon_item->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
stereotypeIconItem->setPos(right - stereotypeIconItem->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
||||||
y += stereotype_icon_item->boundingRect().height();
|
y += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
stereotypes_item->setPos(-stereotypes_item->boundingRect().width() / 2.0, y);
|
stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
|
||||||
y += stereotypes_item->boundingRect().height();
|
y += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_itemName) {
|
if (m_itemName) {
|
||||||
m_itemName->setPos(-m_itemName->boundingRect().width() / 2.0, y);
|
m_itemName->setPos(-m_itemName->boundingRect().width() / 2.0, y);
|
||||||
@@ -314,8 +314,8 @@ void ItemItem::updateGeometry()
|
|||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
m_contextLabel->resetMaxWidth();
|
m_contextLabel->resetMaxWidth();
|
||||||
} else {
|
} else {
|
||||||
double max_context_width = width - 2 * BODY_HORIZ_BORDER;
|
double maxContextWidth = width - 2 * BODY_HORIZ_BORDER;
|
||||||
m_contextLabel->setMaxWidth(max_context_width);
|
m_contextLabel->setMaxWidth(maxContextWidth);
|
||||||
}
|
}
|
||||||
m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
|
m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
|
||||||
y += m_contextLabel->boundingRect().height();
|
y += m_contextLabel->boundingRect().height();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class ItemItem :
|
|||||||
public IRelationable
|
public IRelationable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ItemItem(DItem *item, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
ItemItem(DItem *item, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ItemItem();
|
~ItemItem();
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -74,15 +74,15 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QList<Latch> getHorizontalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getHorizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> getVerticalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getVerticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QPointF getRelationStartPos() const;
|
QPointF getRelationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -62,10 +62,10 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
ObjectItem::ObjectItem(DObject *object, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
ObjectItem::ObjectItem(DObject *object, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_object(object),
|
m_object(object),
|
||||||
m_diagramSceneModel(diagram_scene_model),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
m_secondarySelected(false),
|
m_secondarySelected(false),
|
||||||
m_focusSelected(false),
|
m_focusSelected(false),
|
||||||
m_stereotypeIconDisplay(StereotypeIcon::DISPLAY_LABEL),
|
m_stereotypeIconDisplay(StereotypeIcon::DISPLAY_LABEL),
|
||||||
@@ -104,69 +104,69 @@ QRectF ObjectItem::getRect() const
|
|||||||
return m_object->getRect();
|
return m_object->getRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::setPosAndRect(const QPointF &original_pos, const QRectF &original_rect, const QPointF &top_left_delta, const QPointF &bottom_right_delta)
|
void ObjectItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta)
|
||||||
{
|
{
|
||||||
QPointF new_pos = original_pos;
|
QPointF newPos = originalPos;
|
||||||
QRectF new_rect = original_rect;
|
QRectF newRect = originalRect;
|
||||||
GeometryUtilities::adjustPosAndRect(&new_pos, &new_rect, top_left_delta, bottom_right_delta, QPointF(0.5, 0.5));
|
GeometryUtilities::adjustPosAndRect(&newPos, &newRect, topLeftDelta, bottomRightDelta, QPointF(0.5, 0.5));
|
||||||
if (new_pos != m_object->getPos() || new_rect != m_object->getRect()) {
|
if (newPos != m_object->getPos() || newRect != m_object->getRect()) {
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_object, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_object, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
||||||
m_object->setPos(new_pos);
|
m_object->setPos(newPos);
|
||||||
if (new_rect.size() != m_object->getRect().size()) {
|
if (newRect.size() != m_object->getRect().size()) {
|
||||||
m_object->setAutoSize(false);
|
m_object->setAutoSize(false);
|
||||||
}
|
}
|
||||||
m_object->setRect(new_rect);
|
m_object->setRect(newRect);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_object, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_object, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::alignItemSizeToRaster(IResizable::Side adjust_horizontal_side, IResizable::Side adjust_vertical_side, double raster_width, double raster_height)
|
void ObjectItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide, IResizable::Side adjustVerticalSide, double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
QPointF pos = m_object->getPos();
|
QPointF pos = m_object->getPos();
|
||||||
QRectF rect = m_object->getRect();
|
QRectF rect = m_object->getRect();
|
||||||
|
|
||||||
double horiz_delta = rect.width() - qRound(rect.width() / raster_width) * raster_width;
|
double horizDelta = rect.width() - qRound(rect.width() / rasterWidth) * rasterWidth;
|
||||||
double vert_delta = rect.height() - qRound(rect.height() / raster_height) * raster_height;
|
double vertDelta = rect.height() - qRound(rect.height() / rasterHeight) * rasterHeight;
|
||||||
|
|
||||||
// make sure the new size is at least the minimum size
|
// make sure the new size is at least the minimum size
|
||||||
QSizeF minimum_size = getMinimumSize();
|
QSizeF minimumSize = getMinimumSize();
|
||||||
while (rect.width() + horiz_delta < minimum_size.width()) {
|
while (rect.width() + horizDelta < minimumSize.width()) {
|
||||||
horiz_delta += raster_width;
|
horizDelta += rasterWidth;
|
||||||
}
|
}
|
||||||
while (rect.height() + vert_delta < minimum_size.height()) {
|
while (rect.height() + vertDelta < minimumSize.height()) {
|
||||||
vert_delta += raster_height;
|
vertDelta += rasterHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
double left_delta = 0.0;
|
double leftDelta = 0.0;
|
||||||
double right_delta = 0.0;
|
double rightDelta = 0.0;
|
||||||
double top_delta = 0.0;
|
double topDelta = 0.0;
|
||||||
double bottom_delta = 0.0;
|
double bottomDelta = 0.0;
|
||||||
|
|
||||||
switch (adjust_horizontal_side) {
|
switch (adjustHorizontalSide) {
|
||||||
case IResizable::SIDE_NONE:
|
case IResizable::SIDE_NONE:
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_LEFT_OR_TOP:
|
case IResizable::SIDE_LEFT_OR_TOP:
|
||||||
left_delta = horiz_delta;
|
leftDelta = horizDelta;
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
||||||
right_delta = -horiz_delta;
|
rightDelta = -horizDelta;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (adjust_vertical_side) {
|
switch (adjustVerticalSide) {
|
||||||
case IResizable::SIDE_NONE:
|
case IResizable::SIDE_NONE:
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_LEFT_OR_TOP:
|
case IResizable::SIDE_LEFT_OR_TOP:
|
||||||
top_delta = vert_delta;
|
topDelta = vertDelta;
|
||||||
break;
|
break;
|
||||||
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
case IResizable::SIDE_RIGHT_OR_BOTTOM:
|
||||||
bottom_delta = -vert_delta;
|
bottomDelta = -vertDelta;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF top_left_delta(left_delta, top_delta);
|
QPointF topLeftDelta(leftDelta, topDelta);
|
||||||
QPointF bottom_right_delta(right_delta, bottom_delta);
|
QPointF bottomRightDelta(rightDelta, bottomDelta);
|
||||||
setPosAndRect(pos, rect, top_left_delta, bottom_right_delta);
|
setPosAndRect(pos, rect, topLeftDelta, bottomRightDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::moveDelta(const QPointF &delta)
|
void ObjectItem::moveDelta(const QPointF &delta)
|
||||||
@@ -176,17 +176,17 @@ void ObjectItem::moveDelta(const QPointF &delta)
|
|||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_object, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_object, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::alignItemPositionToRaster(double raster_width, double raster_height)
|
void ObjectItem::alignItemPositionToRaster(double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
QPointF pos = m_object->getPos();
|
QPointF pos = m_object->getPos();
|
||||||
QRectF rect = m_object->getRect();
|
QRectF rect = m_object->getRect();
|
||||||
QPointF top_left = pos + rect.topLeft();
|
QPointF topLeft = pos + rect.topLeft();
|
||||||
|
|
||||||
double left_delta = qRound(top_left.x() / raster_width) * raster_width - top_left.x();
|
double leftDelta = qRound(topLeft.x() / rasterWidth) * rasterWidth - topLeft.x();
|
||||||
double top_delta = qRound(top_left.y() / raster_height) * raster_height - top_left.y();
|
double topDelta = qRound(topLeft.y() / rasterHeight) * rasterHeight - topLeft.y();
|
||||||
QPointF top_left_delta(left_delta, top_delta);
|
QPointF topLeftDelta(leftDelta, topDelta);
|
||||||
|
|
||||||
setPosAndRect(pos, rect, top_left_delta, top_left_delta);
|
setPosAndRect(pos, rect, topLeftDelta, topLeftDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectItem::isSecondarySelected() const
|
bool ObjectItem::isSecondarySelected() const
|
||||||
@@ -194,10 +194,10 @@ bool ObjectItem::isSecondarySelected() const
|
|||||||
return m_secondarySelected;
|
return m_secondarySelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::setSecondarySelected(bool secondary_selected)
|
void ObjectItem::setSecondarySelected(bool secondarySelected)
|
||||||
{
|
{
|
||||||
if (m_secondarySelected != secondary_selected) {
|
if (m_secondarySelected != secondarySelected) {
|
||||||
m_secondarySelected = secondary_selected;
|
m_secondarySelected = secondarySelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,17 +207,17 @@ bool ObjectItem::isFocusSelected() const
|
|||||||
return m_focusSelected;
|
return m_focusSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::setFocusSelected(bool focus_selected)
|
void ObjectItem::setFocusSelected(bool focusSelected)
|
||||||
{
|
{
|
||||||
if (m_focusSelected != focus_selected) {
|
if (m_focusSelected != focusSelected) {
|
||||||
m_focusSelected = focus_selected;
|
m_focusSelected = focusSelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> ObjectItem::getHorizontalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> ObjectItem::getHorizontalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(grabbed_item);
|
Q_UNUSED(grabbedItem);
|
||||||
|
|
||||||
QRectF rect = getObject()->getRect();
|
QRectF rect = getObject()->getRect();
|
||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
@@ -244,9 +244,9 @@ QList<ILatchable::Latch> ObjectItem::getHorizontalLatches(ILatchable::Action act
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> ObjectItem::getVerticalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> ObjectItem::getVerticalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(grabbed_item);
|
Q_UNUSED(grabbedItem);
|
||||||
|
|
||||||
QRectF rect = getObject()->getRect();
|
QRectF rect = getObject()->getRect();
|
||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
@@ -273,13 +273,13 @@ QList<ILatchable::Latch> ObjectItem::getVerticalLatches(ILatchable::Action actio
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::align(IAlignable::AlignType align_type, const QString &identifier)
|
void ObjectItem::align(IAlignable::AlignType alignType, const QString &identifier)
|
||||||
{
|
{
|
||||||
Q_UNUSED(identifier); // avoid warning in release mode
|
Q_UNUSED(identifier); // avoid warning in release mode
|
||||||
|
|
||||||
// subclasses may support other identifiers than the standard ones.
|
// subclasses may support other identifiers than the standard ones.
|
||||||
// but this implementation does not. So assert the names.
|
// but this implementation does not. So assert the names.
|
||||||
switch (align_type) {
|
switch (alignType) {
|
||||||
case IAlignable::ALIGN_LEFT:
|
case IAlignable::ALIGN_LEFT:
|
||||||
QMT_CHECK(identifier == QStringLiteral("left"));
|
QMT_CHECK(identifier == QStringLiteral("left"));
|
||||||
m_diagramSceneModel->getDiagramSceneController()->alignLeft(m_object, m_diagramSceneModel->getSelectedElements(), m_diagramSceneModel->getDiagram());
|
m_diagramSceneModel->getDiagramSceneController()->alignLeft(m_object, m_diagramSceneModel->getSelectedElements(), m_diagramSceneModel->getDiagram());
|
||||||
@@ -324,27 +324,27 @@ void ObjectItem::align(IAlignable::AlignType align_type, const QString &identifi
|
|||||||
|
|
||||||
void ObjectItem::updateStereotypeIconDisplay()
|
void ObjectItem::updateStereotypeIconDisplay()
|
||||||
{
|
{
|
||||||
StereotypeDisplayVisitor stereotype_display_visitor;
|
StereotypeDisplayVisitor stereotypeDisplayVisitor;
|
||||||
stereotype_display_visitor.setModelController(m_diagramSceneModel->getDiagramSceneController()->getModelController());
|
stereotypeDisplayVisitor.setModelController(m_diagramSceneModel->getDiagramSceneController()->getModelController());
|
||||||
stereotype_display_visitor.setStereotypeController(m_diagramSceneModel->getStereotypeController());
|
stereotypeDisplayVisitor.setStereotypeController(m_diagramSceneModel->getStereotypeController());
|
||||||
m_object->accept(&stereotype_display_visitor);
|
m_object->accept(&stereotypeDisplayVisitor);
|
||||||
m_stereotypeIconId = stereotype_display_visitor.getStereotypeIconId();
|
m_stereotypeIconId = stereotypeDisplayVisitor.getStereotypeIconId();
|
||||||
m_shapeIconId = stereotype_display_visitor.getShapeIconId();
|
m_shapeIconId = stereotypeDisplayVisitor.getShapeIconId();
|
||||||
m_stereotypeIconDisplay = stereotype_display_visitor.getStereotypeIconDisplay();
|
m_stereotypeIconDisplay = stereotypeDisplayVisitor.getStereotypeIconDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::updateStereotypes(const QString &stereotype_icon_id, StereotypeIcon::Display stereotype_display, const Style *style)
|
void ObjectItem::updateStereotypes(const QString &stereotypeIconId, StereotypeIcon::Display stereotypeDisplay, const Style *style)
|
||||||
{
|
{
|
||||||
QList<QString> stereotypes = m_object->getStereotypes();
|
QList<QString> stereotypes = m_object->getStereotypes();
|
||||||
if (!stereotype_icon_id.isEmpty()
|
if (!stereotypeIconId.isEmpty()
|
||||||
&& (stereotype_display == StereotypeIcon::DISPLAY_DECORATION || stereotype_display == StereotypeIcon::DISPLAY_ICON)) {
|
&& (stereotypeDisplay == StereotypeIcon::DISPLAY_DECORATION || stereotypeDisplay == StereotypeIcon::DISPLAY_ICON)) {
|
||||||
stereotypes = m_diagramSceneModel->getStereotypeController()->filterStereotypesByIconId(stereotype_icon_id, stereotypes);
|
stereotypes = m_diagramSceneModel->getStereotypeController()->filterStereotypesByIconId(stereotypeIconId, stereotypes);
|
||||||
}
|
}
|
||||||
if (!stereotype_icon_id.isEmpty() && stereotype_display == StereotypeIcon::DISPLAY_DECORATION) {
|
if (!stereotypeIconId.isEmpty() && stereotypeDisplay == StereotypeIcon::DISPLAY_DECORATION) {
|
||||||
if (!m_stereotypeIcon) {
|
if (!m_stereotypeIcon) {
|
||||||
m_stereotypeIcon = new CustomIconItem(m_diagramSceneModel, this);
|
m_stereotypeIcon = new CustomIconItem(m_diagramSceneModel, this);
|
||||||
}
|
}
|
||||||
m_stereotypeIcon->setStereotypeIconId(stereotype_icon_id);
|
m_stereotypeIcon->setStereotypeIconId(stereotypeIconId);
|
||||||
m_stereotypeIcon->setBaseSize(QSizeF(m_stereotypeIcon->getShapeWidth(), m_stereotypeIcon->getShapeHeight()));
|
m_stereotypeIcon->setBaseSize(QSizeF(m_stereotypeIcon->getShapeWidth(), m_stereotypeIcon->getShapeHeight()));
|
||||||
m_stereotypeIcon->setBrush(style->getFillBrush());
|
m_stereotypeIcon->setBrush(style->getFillBrush());
|
||||||
m_stereotypeIcon->setPen(style->getInnerLinePen());
|
m_stereotypeIcon->setPen(style->getInnerLinePen());
|
||||||
@@ -353,7 +353,7 @@ void ObjectItem::updateStereotypes(const QString &stereotype_icon_id, Stereotype
|
|||||||
delete m_stereotypeIcon;
|
delete m_stereotypeIcon;
|
||||||
m_stereotypeIcon = 0;
|
m_stereotypeIcon = 0;
|
||||||
}
|
}
|
||||||
if (stereotype_display != StereotypeIcon::DISPLAY_NONE && !stereotypes.isEmpty()) {
|
if (stereotypeDisplay != StereotypeIcon::DISPLAY_NONE && !stereotypes.isEmpty()) {
|
||||||
if (!m_stereotypes) {
|
if (!m_stereotypes) {
|
||||||
m_stereotypes = new StereotypesItem(this);
|
m_stereotypes = new StereotypesItem(this);
|
||||||
}
|
}
|
||||||
@@ -367,42 +367,42 @@ void ObjectItem::updateStereotypes(const QString &stereotype_icon_id, Stereotype
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF ObjectItem::getStereotypeIconMinimumSize(const StereotypeIcon &stereotype_icon, qreal minimum_width, qreal minimum_height) const
|
QSizeF ObjectItem::getStereotypeIconMinimumSize(const StereotypeIcon &stereotypeIcon, qreal minimumWidth, qreal minimumHeight) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(minimum_width);
|
Q_UNUSED(minimumWidth);
|
||||||
|
|
||||||
qreal width = 0.0;
|
qreal width = 0.0;
|
||||||
qreal height = 0.0;
|
qreal height = 0.0;
|
||||||
if (stereotype_icon.hasMinWidth() && !stereotype_icon.hasMinHeight()) {
|
if (stereotypeIcon.hasMinWidth() && !stereotypeIcon.hasMinHeight()) {
|
||||||
width = stereotype_icon.getMinWidth();
|
width = stereotypeIcon.getMinWidth();
|
||||||
if (stereotype_icon.getSizeLock() == StereotypeIcon::LOCK_HEIGHT || stereotype_icon.getSizeLock() == StereotypeIcon::LOCK_SIZE) {
|
if (stereotypeIcon.getSizeLock() == StereotypeIcon::LOCK_HEIGHT || stereotypeIcon.getSizeLock() == StereotypeIcon::LOCK_SIZE) {
|
||||||
height = stereotype_icon.getMinHeight();
|
height = stereotypeIcon.getMinHeight();
|
||||||
} else {
|
} else {
|
||||||
height = width * stereotype_icon.getHeight() / stereotype_icon.getWidth();
|
height = width * stereotypeIcon.getHeight() / stereotypeIcon.getWidth();
|
||||||
}
|
}
|
||||||
} else if (!stereotype_icon.hasMinWidth() && stereotype_icon.hasMinHeight()) {
|
} else if (!stereotypeIcon.hasMinWidth() && stereotypeIcon.hasMinHeight()) {
|
||||||
height = stereotype_icon.getMinHeight();
|
height = stereotypeIcon.getMinHeight();
|
||||||
if (stereotype_icon.getSizeLock() == StereotypeIcon::LOCK_WIDTH || stereotype_icon.getSizeLock() == StereotypeIcon::LOCK_SIZE) {
|
if (stereotypeIcon.getSizeLock() == StereotypeIcon::LOCK_WIDTH || stereotypeIcon.getSizeLock() == StereotypeIcon::LOCK_SIZE) {
|
||||||
width = stereotype_icon.getMinWidth();
|
width = stereotypeIcon.getMinWidth();
|
||||||
} else {
|
} else {
|
||||||
width = height * stereotype_icon.getWidth() / stereotype_icon.getHeight();
|
width = height * stereotypeIcon.getWidth() / stereotypeIcon.getHeight();
|
||||||
}
|
}
|
||||||
} else if (stereotype_icon.hasMinWidth() && stereotype_icon.hasMinHeight()) {
|
} else if (stereotypeIcon.hasMinWidth() && stereotypeIcon.hasMinHeight()) {
|
||||||
if (stereotype_icon.getSizeLock() == StereotypeIcon::LOCK_RATIO) {
|
if (stereotypeIcon.getSizeLock() == StereotypeIcon::LOCK_RATIO) {
|
||||||
width = stereotype_icon.getMinWidth();
|
width = stereotypeIcon.getMinWidth();
|
||||||
height = width * stereotype_icon.getHeight() / stereotype_icon.getWidth();
|
height = width * stereotypeIcon.getHeight() / stereotypeIcon.getWidth();
|
||||||
if (height < stereotype_icon.getMinHeight()) {
|
if (height < stereotypeIcon.getMinHeight()) {
|
||||||
height = stereotype_icon.getMinHeight();
|
height = stereotypeIcon.getMinHeight();
|
||||||
width = height * stereotype_icon.getWidth() / stereotype_icon.getHeight();
|
width = height * stereotypeIcon.getWidth() / stereotypeIcon.getHeight();
|
||||||
QMT_CHECK(width <= stereotype_icon.getMinWidth());
|
QMT_CHECK(width <= stereotypeIcon.getMinWidth());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
width = stereotype_icon.getMinWidth();
|
width = stereotypeIcon.getMinWidth();
|
||||||
height = stereotype_icon.getMinHeight();
|
height = stereotypeIcon.getMinHeight();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
height = minimum_height;
|
height = minimumHeight;
|
||||||
width = height * stereotype_icon.getWidth() / stereotype_icon.getHeight();
|
width = height * stereotypeIcon.getWidth() / stereotypeIcon.getHeight();
|
||||||
}
|
}
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
}
|
}
|
||||||
@@ -412,41 +412,41 @@ void ObjectItem::updateDepth()
|
|||||||
setZValue(m_object->getDepth());
|
setZValue(m_object->getDepth());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::updateSelectionMarker(CustomIconItem *custom_icon_item)
|
void ObjectItem::updateSelectionMarker(CustomIconItem *customIconItem)
|
||||||
{
|
{
|
||||||
if (custom_icon_item) {
|
if (customIconItem) {
|
||||||
StereotypeIcon stereotype_icon = custom_icon_item->getStereotypeIcon();
|
StereotypeIcon stereotypeIcon = customIconItem->getStereotypeIcon();
|
||||||
ResizeFlags resize_flags = RESIZE_UNLOCKED;
|
ResizeFlags resizeFlags = RESIZE_UNLOCKED;
|
||||||
switch (stereotype_icon.getSizeLock()) {
|
switch (stereotypeIcon.getSizeLock()) {
|
||||||
case StereotypeIcon::LOCK_NONE:
|
case StereotypeIcon::LOCK_NONE:
|
||||||
resize_flags = RESIZE_UNLOCKED;
|
resizeFlags = RESIZE_UNLOCKED;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::LOCK_WIDTH:
|
case StereotypeIcon::LOCK_WIDTH:
|
||||||
resize_flags = RESIZE_LOCKED_WIDTH;
|
resizeFlags = RESIZE_LOCKED_WIDTH;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::LOCK_HEIGHT:
|
case StereotypeIcon::LOCK_HEIGHT:
|
||||||
resize_flags = RESIZE_LOCKED_HEIGHT;
|
resizeFlags = RESIZE_LOCKED_HEIGHT;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::LOCK_SIZE:
|
case StereotypeIcon::LOCK_SIZE:
|
||||||
resize_flags = RESIZE_LOCKED_SIZE;
|
resizeFlags = RESIZE_LOCKED_SIZE;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::LOCK_RATIO:
|
case StereotypeIcon::LOCK_RATIO:
|
||||||
resize_flags = RESIZE_LOCKED_RATIO;
|
resizeFlags = RESIZE_LOCKED_RATIO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
updateSelectionMarker(resize_flags);
|
updateSelectionMarker(resizeFlags);
|
||||||
} else {
|
} else {
|
||||||
updateSelectionMarker(RESIZE_UNLOCKED);
|
updateSelectionMarker(RESIZE_UNLOCKED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::updateSelectionMarker(ResizeFlags resize_flags)
|
void ObjectItem::updateSelectionMarker(ResizeFlags resizeFlags)
|
||||||
{
|
{
|
||||||
if ((isSelected() || isSecondarySelected()) && resize_flags != RESIZE_LOCKED_SIZE) {
|
if ((isSelected() || isSecondarySelected()) && resizeFlags != RESIZE_LOCKED_SIZE) {
|
||||||
if (!m_selectionMarker) {
|
if (!m_selectionMarker) {
|
||||||
m_selectionMarker = new RectangularSelectionItem(this, this);
|
m_selectionMarker = new RectangularSelectionItem(this, this);
|
||||||
}
|
}
|
||||||
switch (resize_flags) {
|
switch (resizeFlags) {
|
||||||
case RESIZE_UNLOCKED:
|
case RESIZE_UNLOCKED:
|
||||||
m_selectionMarker->setFreedom(RectangularSelectionItem::FREEDOM_ANY);
|
m_selectionMarker->setFreedom(RectangularSelectionItem::FREEDOM_ANY);
|
||||||
break;
|
break;
|
||||||
@@ -474,10 +474,10 @@ void ObjectItem::updateSelectionMarker(ResizeFlags resize_flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::updateSelectionMarkerGeometry(const QRectF &object_rect)
|
void ObjectItem::updateSelectionMarkerGeometry(const QRectF &objectRect)
|
||||||
{
|
{
|
||||||
if (m_selectionMarker) {
|
if (m_selectionMarker) {
|
||||||
m_selectionMarker->setRect(object_rect);
|
m_selectionMarker->setRect(objectRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,65 +513,65 @@ void ObjectItem::updateAlignmentButtons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::updateAlignmentButtonsGeometry(const QRectF &object_rect)
|
void ObjectItem::updateAlignmentButtonsGeometry(const QRectF &objectRect)
|
||||||
{
|
{
|
||||||
if (m_horizontalAlignButtons) {
|
if (m_horizontalAlignButtons) {
|
||||||
m_horizontalAlignButtons->clear();
|
m_horizontalAlignButtons->clear();
|
||||||
m_horizontalAlignButtons->setPos(mapToScene(QPointF(0.0, object_rect.top() - AlignButtonsItem::NORMAL_BUTTON_HEIGHT - AlignButtonsItem::VERTICAL_DISTANCE_TO_OBEJCT)));
|
m_horizontalAlignButtons->setPos(mapToScene(QPointF(0.0, objectRect.top() - AlignButtonsItem::NORMAL_BUTTON_HEIGHT - AlignButtonsItem::VERTICAL_DISTANCE_TO_OBEJCT)));
|
||||||
foreach (const ILatchable::Latch &latch, getHorizontalLatches(ILatchable::MOVE, true)) {
|
foreach (const ILatchable::Latch &latch, getHorizontalLatches(ILatchable::MOVE, true)) {
|
||||||
m_horizontalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(latch.m_pos, 0.0)).x());
|
m_horizontalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(latch.m_pos, 0.0)).x());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_verticalAlignButtons) {
|
if (m_verticalAlignButtons) {
|
||||||
m_verticalAlignButtons->clear();
|
m_verticalAlignButtons->clear();
|
||||||
m_verticalAlignButtons->setPos(mapToScene(QPointF(object_rect.left() - AlignButtonsItem::NORMAL_BUTTON_WIDTH - AlignButtonsItem::HORIZONTAL_DISTANCE_TO_OBJECT, 0.0)));
|
m_verticalAlignButtons->setPos(mapToScene(QPointF(objectRect.left() - AlignButtonsItem::NORMAL_BUTTON_WIDTH - AlignButtonsItem::HORIZONTAL_DISTANCE_TO_OBJECT, 0.0)));
|
||||||
foreach (const ILatchable::Latch &latch, getVerticalLatches(ILatchable::MOVE, true)) {
|
foreach (const ILatchable::Latch &latch, getVerticalLatches(ILatchable::MOVE, true)) {
|
||||||
m_verticalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(0.0, latch.m_pos)).y());
|
m_verticalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(0.0, latch.m_pos)).y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IAlignable::AlignType ObjectItem::translateLatchTypeToAlignType(ILatchable::LatchType latch_type)
|
IAlignable::AlignType ObjectItem::translateLatchTypeToAlignType(ILatchable::LatchType latchType)
|
||||||
{
|
{
|
||||||
IAlignable::AlignType align_type = IAlignable::ALIGN_LEFT;
|
IAlignable::AlignType alignType = IAlignable::ALIGN_LEFT;
|
||||||
switch (latch_type) {
|
switch (latchType) {
|
||||||
case ILatchable::LEFT:
|
case ILatchable::LEFT:
|
||||||
align_type = IAlignable::ALIGN_LEFT;
|
alignType = IAlignable::ALIGN_LEFT;
|
||||||
break;
|
break;
|
||||||
case ILatchable::TOP:
|
case ILatchable::TOP:
|
||||||
align_type = IAlignable::ALIGN_TOP;
|
alignType = IAlignable::ALIGN_TOP;
|
||||||
break;
|
break;
|
||||||
case ILatchable::RIGHT:
|
case ILatchable::RIGHT:
|
||||||
align_type = IAlignable::ALIGN_RIGHT;
|
alignType = IAlignable::ALIGN_RIGHT;
|
||||||
break;
|
break;
|
||||||
case ILatchable::BOTTOM:
|
case ILatchable::BOTTOM:
|
||||||
align_type = IAlignable::ALIGN_BOTTOM;
|
alignType = IAlignable::ALIGN_BOTTOM;
|
||||||
break;
|
break;
|
||||||
case ILatchable::HCENTER:
|
case ILatchable::HCENTER:
|
||||||
align_type = IAlignable::ALIGN_HCENTER;
|
alignType = IAlignable::ALIGN_HCENTER;
|
||||||
break;
|
break;
|
||||||
case ILatchable::VCENTER:
|
case ILatchable::VCENTER:
|
||||||
align_type = IAlignable::ALIGN_VCENTER;
|
alignType = IAlignable::ALIGN_VCENTER;
|
||||||
break;
|
break;
|
||||||
case ILatchable::NONE:
|
case ILatchable::NONE:
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return align_type;
|
return alignType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Style *ObjectItem::getAdaptedStyle(const QString &stereotype_icon_id)
|
const Style *ObjectItem::getAdaptedStyle(const QString &stereotypeIconId)
|
||||||
{
|
{
|
||||||
QList<const DObject *> colliding_objects;
|
QList<const DObject *> collidingObjects;
|
||||||
foreach (const QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::COLLIDING_ITEMS)) {
|
foreach (const QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::COLLIDING_ITEMS)) {
|
||||||
if (const ObjectItem *object_item = dynamic_cast<const ObjectItem *>(item)) {
|
if (const ObjectItem *objectItem = dynamic_cast<const ObjectItem *>(item)) {
|
||||||
colliding_objects.append(object_item->getObject());
|
collidingObjects.append(objectItem->getObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QColor base_color;
|
QColor baseColor;
|
||||||
if (!stereotype_icon_id.isEmpty()) {
|
if (!stereotypeIconId.isEmpty()) {
|
||||||
StereotypeIcon stereotype_icon = m_diagramSceneModel->getStereotypeController()->findStereotypeIcon(stereotype_icon_id);
|
StereotypeIcon stereotypeIcon = m_diagramSceneModel->getStereotypeController()->findStereotypeIcon(stereotypeIconId);
|
||||||
base_color = stereotype_icon.getBaseColor();
|
baseColor = stereotypeIcon.getBaseColor();
|
||||||
}
|
}
|
||||||
return m_diagramSceneModel->getStyleController()->adaptObjectStyle(
|
return m_diagramSceneModel->getStyleController()->adaptObjectStyle(
|
||||||
StyledObject(getObject(),
|
StyledObject(getObject(),
|
||||||
@@ -579,9 +579,9 @@ const Style *ObjectItem::getAdaptedStyle(const QString &stereotype_icon_id)
|
|||||||
getObject()->getVisualPrimaryRole(),
|
getObject()->getVisualPrimaryRole(),
|
||||||
getObject()->getVisualSecondaryRole(),
|
getObject()->getVisualSecondaryRole(),
|
||||||
getObject()->isVisualEmphasized(),
|
getObject()->isVisualEmphasized(),
|
||||||
base_color,
|
baseColor,
|
||||||
getObject()->getDepth()),
|
getObject()->getDepth()),
|
||||||
colliding_objects));
|
collidingObjects));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectItem::showContext() const
|
bool ObjectItem::showContext() const
|
||||||
@@ -595,8 +595,8 @@ bool ObjectItem::showContext() const
|
|||||||
MObject *owner = mobject->getOwner();
|
MObject *owner = mobject->getOwner();
|
||||||
if (owner) {
|
if (owner) {
|
||||||
foreach (QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::COLLIDING_OUTER_ITEMS)) {
|
foreach (QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::COLLIDING_OUTER_ITEMS)) {
|
||||||
if (ObjectItem *object_item = dynamic_cast<ObjectItem *>(item)) {
|
if (ObjectItem *objectItem = dynamic_cast<ObjectItem *>(item)) {
|
||||||
if (object_item->getObject()->getModelUid().isValid() && object_item->getObject()->getModelUid() == owner->getUid()) {
|
if (objectItem->getObject()->getModelUid().isValid() && objectItem->getObject()->getModelUid() == owner->getUid()) {
|
||||||
showContext = false;
|
showContext = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -659,43 +659,43 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||||||
{
|
{
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
||||||
bool add_separator = false;
|
bool addSeparator = false;
|
||||||
if (getDiagramSceneModel()->getDiagramSceneController()->getElementTasks()->hasDiagram(m_object, m_diagramSceneModel->getDiagram())) {
|
if (getDiagramSceneModel()->getDiagramSceneController()->getElementTasks()->hasDiagram(m_object, m_diagramSceneModel->getDiagram())) {
|
||||||
menu.addAction(new ContextMenuAction(QObject::tr("Open Diagram"), QStringLiteral("openDiagram"), &menu));
|
menu.addAction(new ContextMenuAction(QObject::tr("Open Diagram"), QStringLiteral("openDiagram"), &menu));
|
||||||
add_separator = true;
|
addSeparator = true;
|
||||||
} else if (getDiagramSceneModel()->getDiagramSceneController()->getElementTasks()->mayCreateDiagram(m_object, m_diagramSceneModel->getDiagram())) {
|
} else if (getDiagramSceneModel()->getDiagramSceneController()->getElementTasks()->mayCreateDiagram(m_object, m_diagramSceneModel->getDiagram())) {
|
||||||
menu.addAction(new ContextMenuAction(QObject::tr("Create Diagram"), QStringLiteral("createDiagram"), &menu));
|
menu.addAction(new ContextMenuAction(QObject::tr("Create Diagram"), QStringLiteral("createDiagram"), &menu));
|
||||||
add_separator = true;
|
addSeparator = true;
|
||||||
}
|
}
|
||||||
if (extendContextMenu(&menu)) {
|
if (extendContextMenu(&menu)) {
|
||||||
add_separator = true;
|
addSeparator = true;
|
||||||
}
|
}
|
||||||
if (add_separator) {
|
if (addSeparator) {
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
}
|
}
|
||||||
menu.addAction(new ContextMenuAction(QObject::tr("Remove"), QStringLiteral("remove"), QKeySequence(QKeySequence::Delete), &menu));
|
menu.addAction(new ContextMenuAction(QObject::tr("Remove"), QStringLiteral("remove"), QKeySequence(QKeySequence::Delete), &menu));
|
||||||
menu.addAction(new ContextMenuAction(QObject::tr("Delete"), QStringLiteral("delete"), QKeySequence(Qt::CTRL + Qt::Key_D), &menu));
|
menu.addAction(new ContextMenuAction(QObject::tr("Delete"), QStringLiteral("delete"), QKeySequence(Qt::CTRL + Qt::Key_D), &menu));
|
||||||
//menu.addAction(new ContextMenuAction(QObject::tr("Select in Model Tree"), QStringLiteral("selectInModelTree"), &menu));
|
//menu.addAction(new ContextMenuAction(QObject::tr("Select in Model Tree"), QStringLiteral("selectInModelTree"), &menu));
|
||||||
QMenu align_menu;
|
QMenu alignMenu;
|
||||||
align_menu.setTitle(QObject::tr("Align Objects"));
|
alignMenu.setTitle(QObject::tr("Align Objects"));
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Align Left"), QStringLiteral("alignLeft"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Left"), QStringLiteral("alignLeft"), &alignMenu));
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Center Vertically"), QStringLiteral("centerVertically"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Center Vertically"), QStringLiteral("centerVertically"), &alignMenu));
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Align Right"), QStringLiteral("alignRight"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Right"), QStringLiteral("alignRight"), &alignMenu));
|
||||||
align_menu.addSeparator();
|
alignMenu.addSeparator();
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Align Top"), QStringLiteral("alignTop"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Top"), QStringLiteral("alignTop"), &alignMenu));
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Center Horizontally"), QStringLiteral("centerHorizontally"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Center Horizontally"), QStringLiteral("centerHorizontally"), &alignMenu));
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Align Bottom"), QStringLiteral("alignBottom"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Bottom"), QStringLiteral("alignBottom"), &alignMenu));
|
||||||
align_menu.addSeparator();
|
alignMenu.addSeparator();
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Same Width"), QStringLiteral("sameWidth"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Same Width"), QStringLiteral("sameWidth"), &alignMenu));
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Same Height"), QStringLiteral("sameHeight"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Same Height"), QStringLiteral("sameHeight"), &alignMenu));
|
||||||
align_menu.addAction(new ContextMenuAction(QObject::tr("Same Size"), QStringLiteral("sameSize"), &align_menu));
|
alignMenu.addAction(new ContextMenuAction(QObject::tr("Same Size"), QStringLiteral("sameSize"), &alignMenu));
|
||||||
align_menu.setEnabled(m_diagramSceneModel->hasMultiObjectsSelection());
|
alignMenu.setEnabled(m_diagramSceneModel->hasMultiObjectsSelection());
|
||||||
menu.addMenu(&align_menu);
|
menu.addMenu(&alignMenu);
|
||||||
|
|
||||||
QAction *selected_action = menu.exec(event->screenPos());
|
QAction *selectedAction = menu.exec(event->screenPos());
|
||||||
if (selected_action) {
|
if (selectedAction) {
|
||||||
if (!handleSelectedContextMenuAction(selected_action)) {
|
if (!handleSelectedContextMenuAction(selectedAction)) {
|
||||||
ContextMenuAction *action = dynamic_cast<ContextMenuAction *>(selected_action);
|
ContextMenuAction *action = dynamic_cast<ContextMenuAction *>(selectedAction);
|
||||||
QMT_CHECK(action);
|
QMT_CHECK(action);
|
||||||
if (action->getId() == QStringLiteral("openDiagram")) {
|
if (action->getId() == QStringLiteral("openDiagram")) {
|
||||||
m_diagramSceneModel->getDiagramSceneController()->getElementTasks()->openDiagram(m_object, m_diagramSceneModel->getDiagram());
|
m_diagramSceneModel->getDiagramSceneController()->getElementTasks()->openDiagram(m_object, m_diagramSceneModel->getDiagram());
|
||||||
@@ -740,19 +740,19 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||||||
|
|
||||||
QSizeF ObjectItem::getMinimumSize(const QSet<QGraphicsItem *> &items) const
|
QSizeF ObjectItem::getMinimumSize(const QSet<QGraphicsItem *> &items) const
|
||||||
{
|
{
|
||||||
QSizeF minimum_size(0.0, 0.0);
|
QSizeF minimumSize(0.0, 0.0);
|
||||||
foreach (QGraphicsItem *item, items) {
|
foreach (QGraphicsItem *item, items) {
|
||||||
if (IResizable *resizable = dynamic_cast<IResizable *>(item)) {
|
if (IResizable *resizable = dynamic_cast<IResizable *>(item)) {
|
||||||
QSizeF size = resizable->getMinimumSize();
|
QSizeF size = resizable->getMinimumSize();
|
||||||
if (size.width() > minimum_size.width()) {
|
if (size.width() > minimumSize.width()) {
|
||||||
minimum_size.setWidth(size.width());
|
minimumSize.setWidth(size.width());
|
||||||
}
|
}
|
||||||
if (size.height() > minimum_size.height()) {
|
if (size.height() > minimumSize.height()) {
|
||||||
minimum_size.setHeight(size.height());
|
minimumSize.setHeight(size.height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minimum_size;
|
return minimumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ObjectItem(DObject *object, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
ObjectItem(DObject *object, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ObjectItem();
|
~ObjectItem();
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const = 0;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -116,35 +116,35 @@ public:
|
|||||||
|
|
||||||
QSizeF getMinimumSize() const = 0;
|
QSizeF getMinimumSize() const = 0;
|
||||||
|
|
||||||
void setPosAndRect(const QPointF &original_pos, const QRectF &original_rect, const QPointF &top_left_delta, const QPointF &bottom_right_delta);
|
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
||||||
|
|
||||||
void alignItemSizeToRaster(Side adjust_horizontal_side, Side adjust_vertical_side, double raster_width, double raster_height);
|
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double raster_width, double raster_height);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondary_selected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focus_selected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QList<Latch> getHorizontalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getHorizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> getVerticalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getVerticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void align(AlignType align_type, const QString &identifier);
|
void align(AlignType alignType, const QString &identifier);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -156,29 +156,29 @@ protected:
|
|||||||
|
|
||||||
StereotypeIcon::Display getStereotypeIconDisplay() const { return m_stereotypeIconDisplay; }
|
StereotypeIcon::Display getStereotypeIconDisplay() const { return m_stereotypeIconDisplay; }
|
||||||
|
|
||||||
void updateStereotypes(const QString &stereotype_icon_id, StereotypeIcon::Display stereotype_display, const Style *style);
|
void updateStereotypes(const QString &stereotypeIconId, StereotypeIcon::Display stereotypeDisplay, const Style *style);
|
||||||
|
|
||||||
StereotypesItem *getStereotypesItem() const { return m_stereotypes; }
|
StereotypesItem *getStereotypesItem() const { return m_stereotypes; }
|
||||||
|
|
||||||
CustomIconItem *getStereotypeIconItem() const { return m_stereotypeIcon; }
|
CustomIconItem *getStereotypeIconItem() const { return m_stereotypeIcon; }
|
||||||
|
|
||||||
QSizeF getStereotypeIconMinimumSize(const StereotypeIcon &stereotype_icon, qreal minimum_width, qreal minimum_height) const;
|
QSizeF getStereotypeIconMinimumSize(const StereotypeIcon &stereotypeIcon, qreal minimumWidth, qreal minimumHeight) const;
|
||||||
|
|
||||||
void updateDepth();
|
void updateDepth();
|
||||||
|
|
||||||
void updateSelectionMarker(CustomIconItem *custom_icon_item);
|
void updateSelectionMarker(CustomIconItem *customIconItem);
|
||||||
|
|
||||||
void updateSelectionMarker(ResizeFlags resize_flags);
|
void updateSelectionMarker(ResizeFlags resizeFlags);
|
||||||
|
|
||||||
void updateSelectionMarkerGeometry(const QRectF &object_rect);
|
void updateSelectionMarkerGeometry(const QRectF &objectRect);
|
||||||
|
|
||||||
void updateAlignmentButtons();
|
void updateAlignmentButtons();
|
||||||
|
|
||||||
void updateAlignmentButtonsGeometry(const QRectF &object_rect);
|
void updateAlignmentButtonsGeometry(const QRectF &objectRect);
|
||||||
|
|
||||||
IAlignable::AlignType translateLatchTypeToAlignType(ILatchable::LatchType latch_type);
|
IAlignable::AlignType translateLatchTypeToAlignType(ILatchable::LatchType latchType);
|
||||||
|
|
||||||
const Style *getAdaptedStyle(const QString &stereotype_icon_id);
|
const Style *getAdaptedStyle(const QString &stereotypeIconId);
|
||||||
|
|
||||||
bool showContext() const;
|
bool showContext() const;
|
||||||
|
|
||||||
|
|||||||
@@ -65,9 +65,9 @@ static const qreal MINIMUM_AUTO_HEIGHT = 70.0;
|
|||||||
|
|
||||||
|
|
||||||
struct PackageItem::ShapeGeometry {
|
struct PackageItem::ShapeGeometry {
|
||||||
ShapeGeometry(const QSizeF &minimum_size, const QSizeF &minimum_tab_size)
|
ShapeGeometry(const QSizeF &minimumSize, const QSizeF &minimumTabSize)
|
||||||
: m_minimumSize(minimum_size),
|
: m_minimumSize(minimumSize),
|
||||||
m_minimumTabSize(minimum_tab_size)
|
m_minimumTabSize(minimumTabSize)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +76,8 @@ struct PackageItem::ShapeGeometry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PackageItem::PackageItem(DPackage *package, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
PackageItem::PackageItem(DPackage *package, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(package, diagram_scene_model, parent),
|
: ObjectItem(package, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
m_shape(0),
|
m_shape(0),
|
||||||
m_packageName(0),
|
m_packageName(0),
|
||||||
@@ -174,11 +174,11 @@ void PackageItem::update()
|
|||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackageItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const
|
bool PackageItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const
|
||||||
{
|
{
|
||||||
QPolygonF polygon;
|
QPolygonF polygon;
|
||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
// TODO use custom_icon path as shape
|
// TODO use customIcon path as shape
|
||||||
QRectF rect = getObject()->getRect();
|
QRectF rect = getObject()->getRect();
|
||||||
rect.translate(getObject()->getPos());
|
rect.translate(getObject()->getPos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
@@ -191,7 +191,7 @@ bool PackageItem::intersectShapeWithLine(const QLineF &line, QPointF *intersecti
|
|||||||
<< rect.topRight() + QPointF(0.0, shape.m_minimumTabSize.height())
|
<< rect.topRight() + QPointF(0.0, shape.m_minimumTabSize.height())
|
||||||
<< rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
<< rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
}
|
}
|
||||||
return GeometryUtilities::intersect(polygon, line, intersection_point, intersection_line);
|
return GeometryUtilities::intersect(polygon, line, intersectionPoint, intersectionLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF PackageItem::getMinimumSize() const
|
QSizeF PackageItem::getMinimumSize() const
|
||||||
@@ -200,14 +200,14 @@ QSizeF PackageItem::getMinimumSize() const
|
|||||||
return geometry.m_minimumSize;
|
return geometry.m_minimumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> PackageItem::getHorizontalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> PackageItem::getHorizontalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
return ObjectItem::getHorizontalLatches(action, grabbed_item);
|
return ObjectItem::getHorizontalLatches(action, grabbedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ILatchable::Latch> PackageItem::getVerticalLatches(ILatchable::Action action, bool grabbed_item) const
|
QList<ILatchable::Latch> PackageItem::getVerticalLatches(ILatchable::Action action, bool grabbedItem) const
|
||||||
{
|
{
|
||||||
return ObjectItem::getVerticalLatches(action, grabbed_item);
|
return ObjectItem::getVerticalLatches(action, grabbedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -232,14 +232,14 @@ QPointF PackageItem::getRelationStartPos() const
|
|||||||
return pos();
|
return pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageItem::relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points)
|
void PackageItem::relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints)
|
||||||
{
|
{
|
||||||
DElement *target_element = getDiagramSceneModel()->findTopmostElement(to_scene_pos);
|
DElement *targetElement = getDiagramSceneModel()->findTopmostElement(toScenePos);
|
||||||
if (target_element) {
|
if (targetElement) {
|
||||||
if (id == QStringLiteral("dependency")) {
|
if (id == QStringLiteral("dependency")) {
|
||||||
DObject *dependant_object = dynamic_cast<DObject *>(target_element);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependant_object) {
|
if (dependantObject) {
|
||||||
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependant_object, intermediate_points, getDiagramSceneModel()->getDiagram());
|
getDiagramSceneModel()->getDiagramSceneController()->createDependency(getObject(), dependantObject, intermediatePoints, getDiagramSceneModel()->getDiagram());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,43 +249,43 @@ PackageItem::ShapeGeometry PackageItem::calcMinimumGeometry() const
|
|||||||
{
|
{
|
||||||
double width = 0.0;
|
double width = 0.0;
|
||||||
double height = 0.0;
|
double height = 0.0;
|
||||||
double tab_height = 0.0;
|
double tabHeight = 0.0;
|
||||||
double tab_width = 0.0;
|
double tabWidth = 0.0;
|
||||||
|
|
||||||
if (m_customIcon) {
|
if (m_customIcon) {
|
||||||
return ShapeGeometry(getStereotypeIconMinimumSize(m_customIcon->getStereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT), QSizeF(tab_width, tab_height));
|
return ShapeGeometry(getStereotypeIconMinimumSize(m_customIcon->getStereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT), QSizeF(tabWidth, tabHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
double body_height = 0.0;
|
double bodyHeight = 0.0;
|
||||||
double body_width = 0.0;
|
double bodyWidth = 0.0;
|
||||||
|
|
||||||
tab_height += TAB_VERT_BORDER;
|
tabHeight += TAB_VERT_BORDER;
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
tab_width = std::max(tab_width, stereotypes_item->boundingRect().width() + 2 * TAB_HORIZ_BORDER);
|
tabWidth = std::max(tabWidth, stereotypesItem->boundingRect().width() + 2 * TAB_HORIZ_BORDER);
|
||||||
tab_height += stereotypes_item->boundingRect().height();
|
tabHeight += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_packageName) {
|
if (m_packageName) {
|
||||||
tab_width = std::max(tab_width, m_packageName->boundingRect().width() + 2 * TAB_HORIZ_BORDER);
|
tabWidth = std::max(tabWidth, m_packageName->boundingRect().width() + 2 * TAB_HORIZ_BORDER);
|
||||||
tab_height += m_packageName->boundingRect().height();
|
tabHeight += m_packageName->boundingRect().height();
|
||||||
}
|
}
|
||||||
tab_height += TAB_VERT_BORDER;
|
tabHeight += TAB_VERT_BORDER;
|
||||||
width = std::max(width, tab_width + TAB_MIN_RIGHT_SPACE);
|
width = std::max(width, tabWidth + TAB_MIN_RIGHT_SPACE);
|
||||||
height += tab_height;
|
height += tabHeight;
|
||||||
|
|
||||||
body_height = BODY_VERT_BORDER;
|
bodyHeight = BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
body_width = std::max(body_width, stereotype_icon_item->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
bodyWidth = std::max(bodyWidth, stereotypeIconItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
body_height += stereotype_icon_item->boundingRect().height();
|
bodyHeight += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_contextLabel) {
|
if (m_contextLabel) {
|
||||||
body_height += m_contextLabel->getHeight();
|
bodyHeight += m_contextLabel->getHeight();
|
||||||
}
|
}
|
||||||
body_height += BODY_VERT_BORDER;
|
bodyHeight += BODY_VERT_BORDER;
|
||||||
body_height = std::max(body_height, BODY_MIN_HEIGHT);
|
bodyHeight = std::max(bodyHeight, BODY_MIN_HEIGHT);
|
||||||
width = std::max(width, body_width);
|
width = std::max(width, bodyWidth);
|
||||||
height += body_height;
|
height += bodyHeight;
|
||||||
|
|
||||||
return ShapeGeometry(GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT), QSizeF(tab_width, tab_height));
|
return ShapeGeometry(GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT), QSizeF(tabWidth, tabHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageItem::updateGeometry()
|
void PackageItem::updateGeometry()
|
||||||
@@ -296,8 +296,8 @@ void PackageItem::updateGeometry()
|
|||||||
|
|
||||||
double width = geometry.m_minimumSize.width();
|
double width = geometry.m_minimumSize.width();
|
||||||
double height = geometry.m_minimumSize.height();
|
double height = geometry.m_minimumSize.height();
|
||||||
double tab_width = geometry.m_minimumTabSize.width();
|
double tabWidth = geometry.m_minimumTabSize.width();
|
||||||
double tab_height = geometry.m_minimumTabSize.height();
|
double tabHeight = geometry.m_minimumTabSize.height();
|
||||||
|
|
||||||
// calc width and height
|
// calc width and height
|
||||||
if (getObject()->hasAutoSize()) {
|
if (getObject()->hasAutoSize()) {
|
||||||
@@ -340,9 +340,9 @@ void PackageItem::updateGeometry()
|
|||||||
y += height;
|
y += height;
|
||||||
|
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
stereotypes_item->setPos(-stereotypes_item->boundingRect().width() / 2.0, y);
|
stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
|
||||||
y += stereotypes_item->boundingRect().height();
|
y += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_packageName) {
|
if (m_packageName) {
|
||||||
m_packageName->setPos(-m_packageName->boundingRect().width() / 2.0, y);
|
m_packageName->setPos(-m_packageName->boundingRect().width() / 2.0, y);
|
||||||
@@ -356,17 +356,17 @@ void PackageItem::updateGeometry()
|
|||||||
} else if (m_shape) {
|
} else if (m_shape) {
|
||||||
QPolygonF polygon;
|
QPolygonF polygon;
|
||||||
polygon << rect.topLeft()
|
polygon << rect.topLeft()
|
||||||
<< QPointF(left + tab_width, top)
|
<< QPointF(left + tabWidth, top)
|
||||||
<< QPointF(left + tab_width, top + tab_height)
|
<< QPointF(left + tabWidth, top + tabHeight)
|
||||||
<< QPointF(right, top + tab_height)
|
<< QPointF(right, top + tabHeight)
|
||||||
<< rect.bottomRight()
|
<< rect.bottomRight()
|
||||||
<< rect.bottomLeft();
|
<< rect.bottomLeft();
|
||||||
m_shape->setPolygon(polygon);
|
m_shape->setPolygon(polygon);
|
||||||
|
|
||||||
y += TAB_VERT_BORDER;
|
y += TAB_VERT_BORDER;
|
||||||
if (StereotypesItem *stereotypes_item = getStereotypesItem()) {
|
if (StereotypesItem *stereotypesItem = getStereotypesItem()) {
|
||||||
stereotypes_item->setPos(left + TAB_HORIZ_BORDER, y);
|
stereotypesItem->setPos(left + TAB_HORIZ_BORDER, y);
|
||||||
y += stereotypes_item->boundingRect().height();
|
y += stereotypesItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_packageName) {
|
if (m_packageName) {
|
||||||
m_packageName->setPos(left + TAB_HORIZ_BORDER, y);
|
m_packageName->setPos(left + TAB_HORIZ_BORDER, y);
|
||||||
@@ -374,9 +374,9 @@ void PackageItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
y += TAB_VERT_BORDER;
|
y += TAB_VERT_BORDER;
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotype_icon_item = getStereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = getStereotypeIconItem()) {
|
||||||
stereotype_icon_item->setPos(right - stereotype_icon_item->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
stereotypeIconItem->setPos(right - stereotypeIconItem->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
||||||
y += stereotype_icon_item->boundingRect().height();
|
y += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_contextLabel) {
|
if (m_contextLabel) {
|
||||||
m_contextLabel->setMaxWidth(width - 2 * BODY_HORIZ_BORDER);
|
m_contextLabel->setMaxWidth(width - 2 * BODY_HORIZ_BORDER);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class PackageItem :
|
|||||||
struct ShapeGeometry;
|
struct ShapeGeometry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PackageItem(DPackage *package, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
PackageItem(DPackage *package, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~PackageItem();
|
~PackageItem();
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersection_point, QLineF *intersection_line) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -76,15 +76,15 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QList<Latch> getHorizontalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getHorizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> getVerticalLatches(Action action, bool grabbed_item) const;
|
QList<Latch> getVerticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QPointF getRelationStartPos() const;
|
QPointF getRelationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &to_scene_pos, const QList<QPointF> &intermediate_points);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class RelationItem::ArrowConfigurator :
|
|||||||
public DConstVoidVisitor
|
public DConstVoidVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArrowConfigurator(DiagramSceneModel *diagram_scene_model, ArrowItem *arrow, const QList<QPointF> &points)
|
ArrowConfigurator(DiagramSceneModel *diagramSceneModel, ArrowItem *arrow, const QList<QPointF> &points)
|
||||||
: m_diagramSceneModel(diagram_scene_model),
|
: m_diagramSceneModel(diagramSceneModel),
|
||||||
m_arrow(arrow),
|
m_arrow(arrow),
|
||||||
m_points(points)
|
m_points(points)
|
||||||
{
|
{
|
||||||
@@ -75,21 +75,21 @@ public:
|
|||||||
{
|
{
|
||||||
Q_UNUSED(inheritance);
|
Q_UNUSED(inheritance);
|
||||||
|
|
||||||
DObject *base_object = m_diagramSceneModel->getDiagramController()->findElement<DObject>(inheritance->getBase(), m_diagramSceneModel->getDiagram());
|
DObject *baseObject = m_diagramSceneModel->getDiagramController()->findElement<DObject>(inheritance->getBase(), m_diagramSceneModel->getDiagram());
|
||||||
QMT_CHECK(base_object);
|
QMT_CHECK(baseObject);
|
||||||
bool base_is_interface = base_object->getStereotypes().contains(QStringLiteral("interface"));
|
bool baseIsInterface = baseObject->getStereotypes().contains(QStringLiteral("interface"));
|
||||||
bool lollipop_display = false;
|
bool lollipopDisplay = false;
|
||||||
if (base_is_interface) {
|
if (baseIsInterface) {
|
||||||
StereotypeDisplayVisitor stereotype_display_visitor;
|
StereotypeDisplayVisitor stereotypeDisplayVisitor;
|
||||||
stereotype_display_visitor.setModelController(m_diagramSceneModel->getDiagramSceneController()->getModelController());
|
stereotypeDisplayVisitor.setModelController(m_diagramSceneModel->getDiagramSceneController()->getModelController());
|
||||||
stereotype_display_visitor.setStereotypeController(m_diagramSceneModel->getStereotypeController());
|
stereotypeDisplayVisitor.setStereotypeController(m_diagramSceneModel->getStereotypeController());
|
||||||
base_object->accept(&stereotype_display_visitor);
|
baseObject->accept(&stereotypeDisplayVisitor);
|
||||||
lollipop_display = stereotype_display_visitor.getStereotypeDisplay() == DObject::STEREOTYPE_ICON;
|
lollipopDisplay = stereotypeDisplayVisitor.getStereotypeDisplay() == DObject::STEREOTYPE_ICON;
|
||||||
}
|
}
|
||||||
if (lollipop_display) {
|
if (lollipopDisplay) {
|
||||||
m_arrow->setShaft(ArrowItem::SHAFT_SOLID);
|
m_arrow->setShaft(ArrowItem::SHAFT_SOLID);
|
||||||
m_arrow->setEndHead(ArrowItem::HEAD_NONE);
|
m_arrow->setEndHead(ArrowItem::HEAD_NONE);
|
||||||
} else if (base_is_interface || inheritance->getStereotypes().contains(QStringLiteral("realize"))) {
|
} else if (baseIsInterface || inheritance->getStereotypes().contains(QStringLiteral("realize"))) {
|
||||||
m_arrow->setShaft(ArrowItem::SHAFT_DASHED);
|
m_arrow->setShaft(ArrowItem::SHAFT_DASHED);
|
||||||
m_arrow->setEndHead(ArrowItem::HEAD_TRIANGLE);
|
m_arrow->setEndHead(ArrowItem::HEAD_TRIANGLE);
|
||||||
} else {
|
} else {
|
||||||
@@ -105,19 +105,19 @@ public:
|
|||||||
{
|
{
|
||||||
Q_UNUSED(dependency);
|
Q_UNUSED(dependency);
|
||||||
|
|
||||||
ArrowItem::Head end_a_head = ArrowItem::HEAD_NONE;
|
ArrowItem::Head endAHead = ArrowItem::HEAD_NONE;
|
||||||
ArrowItem::Head end_b_head = ArrowItem::HEAD_NONE;
|
ArrowItem::Head endBHead = ArrowItem::HEAD_NONE;
|
||||||
bool is_realization = dependency->getStereotypes().contains(QStringLiteral("realize"));
|
bool isRealization = dependency->getStereotypes().contains(QStringLiteral("realize"));
|
||||||
switch (dependency->getDirection()) {
|
switch (dependency->getDirection()) {
|
||||||
case MDependency::A_TO_B:
|
case MDependency::A_TO_B:
|
||||||
end_b_head = is_realization ? ArrowItem::HEAD_TRIANGLE : ArrowItem::HEAD_OPEN;
|
endBHead = isRealization ? ArrowItem::HEAD_TRIANGLE : ArrowItem::HEAD_OPEN;
|
||||||
break;
|
break;
|
||||||
case MDependency::B_TO_A:
|
case MDependency::B_TO_A:
|
||||||
end_a_head = is_realization ? ArrowItem::HEAD_TRIANGLE : ArrowItem::HEAD_OPEN;
|
endAHead = isRealization ? ArrowItem::HEAD_TRIANGLE : ArrowItem::HEAD_OPEN;
|
||||||
break;
|
break;
|
||||||
case MDependency::BIDIRECTIONAL:
|
case MDependency::BIDIRECTIONAL:
|
||||||
end_a_head = ArrowItem::HEAD_OPEN;
|
endAHead = ArrowItem::HEAD_OPEN;
|
||||||
end_b_head = ArrowItem::HEAD_OPEN;
|
endBHead = ArrowItem::HEAD_OPEN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -125,8 +125,8 @@ public:
|
|||||||
|
|
||||||
m_arrow->setShaft(ArrowItem::SHAFT_DASHED);
|
m_arrow->setShaft(ArrowItem::SHAFT_DASHED);
|
||||||
m_arrow->setArrowSize(12.0);
|
m_arrow->setArrowSize(12.0);
|
||||||
m_arrow->setStartHead(end_a_head);
|
m_arrow->setStartHead(endAHead);
|
||||||
m_arrow->setEndHead(end_b_head);
|
m_arrow->setEndHead(endBHead);
|
||||||
m_arrow->setPoints(m_points);
|
m_arrow->setPoints(m_points);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,41 +138,41 @@ public:
|
|||||||
m_arrow->setArrowSize(12.0);
|
m_arrow->setArrowSize(12.0);
|
||||||
m_arrow->setDiamondSize(12.0);
|
m_arrow->setDiamondSize(12.0);
|
||||||
|
|
||||||
ArrowItem::Head end_a_head = ArrowItem::HEAD_NONE;
|
ArrowItem::Head endAHead = ArrowItem::HEAD_NONE;
|
||||||
ArrowItem::Head end_b_head = ArrowItem::HEAD_NONE;
|
ArrowItem::Head endBHead = ArrowItem::HEAD_NONE;
|
||||||
|
|
||||||
bool a_nav = association->getA().isNavigable();
|
bool aNav = association->getA().isNavigable();
|
||||||
bool b_nav = association->getB().isNavigable();
|
bool bNav = association->getB().isNavigable();
|
||||||
|
|
||||||
bool a_flat = association->getA().getKind() == MAssociationEnd::ASSOCIATION;
|
bool aFlat = association->getA().getKind() == MAssociationEnd::ASSOCIATION;
|
||||||
bool b_flat = association->getB().getKind() == MAssociationEnd::ASSOCIATION;
|
bool bFlat = association->getB().getKind() == MAssociationEnd::ASSOCIATION;
|
||||||
|
|
||||||
switch (association->getA().getKind()) {
|
switch (association->getA().getKind()) {
|
||||||
case MAssociationEnd::ASSOCIATION:
|
case MAssociationEnd::ASSOCIATION:
|
||||||
end_a_head = ((b_nav && !a_nav && b_flat) || (a_nav && b_nav && !b_flat)) ? ArrowItem::HEAD_FILLED_TRIANGLE : ArrowItem::HEAD_NONE;
|
endAHead = ((bNav && !aNav && bFlat) || (aNav && bNav && !bFlat)) ? ArrowItem::HEAD_FILLED_TRIANGLE : ArrowItem::HEAD_NONE;
|
||||||
break;
|
break;
|
||||||
case MAssociationEnd::AGGREGATION:
|
case MAssociationEnd::AGGREGATION:
|
||||||
end_a_head = association->getB().isNavigable() ? ArrowItem::HEAD_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_DIAMOND;
|
endAHead = association->getB().isNavigable() ? ArrowItem::HEAD_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_DIAMOND;
|
||||||
break;
|
break;
|
||||||
case MAssociationEnd::COMPOSITION:
|
case MAssociationEnd::COMPOSITION:
|
||||||
end_a_head = association->getB().isNavigable() ? ArrowItem::HEAD_FILLED_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_FILLED_DIAMOND;
|
endAHead = association->getB().isNavigable() ? ArrowItem::HEAD_FILLED_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_FILLED_DIAMOND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (association->getB().getKind()) {
|
switch (association->getB().getKind()) {
|
||||||
case MAssociationEnd::ASSOCIATION:
|
case MAssociationEnd::ASSOCIATION:
|
||||||
end_b_head = ((a_nav && !b_nav && a_flat) || (a_nav && b_nav && !a_flat)) ? ArrowItem::HEAD_FILLED_TRIANGLE : ArrowItem::HEAD_NONE;
|
endBHead = ((aNav && !bNav && aFlat) || (aNav && bNav && !aFlat)) ? ArrowItem::HEAD_FILLED_TRIANGLE : ArrowItem::HEAD_NONE;
|
||||||
break;
|
break;
|
||||||
case MAssociationEnd::AGGREGATION:
|
case MAssociationEnd::AGGREGATION:
|
||||||
end_b_head = association->getA().isNavigable() ? ArrowItem::HEAD_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_DIAMOND;
|
endBHead = association->getA().isNavigable() ? ArrowItem::HEAD_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_DIAMOND;
|
||||||
break;
|
break;
|
||||||
case MAssociationEnd::COMPOSITION:
|
case MAssociationEnd::COMPOSITION:
|
||||||
end_b_head = association->getA().isNavigable() ? ArrowItem::HEAD_FILLED_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_FILLED_DIAMOND;
|
endBHead = association->getA().isNavigable() ? ArrowItem::HEAD_FILLED_DIAMOND_FILLED_TRIANGLE : ArrowItem::HEAD_FILLED_DIAMOND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_arrow->setStartHead(end_a_head);
|
m_arrow->setStartHead(endAHead);
|
||||||
m_arrow->setEndHead(end_b_head);
|
m_arrow->setEndHead(endBHead);
|
||||||
m_arrow->setPoints(m_points);
|
m_arrow->setPoints(m_points);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,10 +186,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
RelationItem::RelationItem(DRelation *relation, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
RelationItem::RelationItem(DRelation *relation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_relation(relation),
|
m_relation(relation),
|
||||||
m_diagramSceneModel(diagram_scene_model),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
m_secondarySelected(false),
|
m_secondarySelected(false),
|
||||||
m_focusSelected(false),
|
m_focusSelected(false),
|
||||||
m_arrow(0),
|
m_arrow(0),
|
||||||
@@ -254,14 +254,14 @@ void RelationItem::moveDelta(const QPointF &delta)
|
|||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationItem::alignItemPositionToRaster(double raster_width, double raster_height)
|
void RelationItem::alignItemPositionToRaster(double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
||||||
QList<DRelation::IntermediatePoint> points;
|
QList<DRelation::IntermediatePoint> points;
|
||||||
foreach (const DRelation::IntermediatePoint &point, m_relation->getIntermediatePoints()) {
|
foreach (const DRelation::IntermediatePoint &point, m_relation->getIntermediatePoints()) {
|
||||||
QPointF pos = point.getPos();
|
QPointF pos = point.getPos();
|
||||||
double x = qRound(pos.x() / raster_width) * raster_width;
|
double x = qRound(pos.x() / rasterWidth) * rasterWidth;
|
||||||
double y = qRound(pos.y() / raster_height) * raster_height;
|
double y = qRound(pos.y() / rasterHeight) * rasterHeight;
|
||||||
points << DRelation::IntermediatePoint(QPointF(x,y));
|
points << DRelation::IntermediatePoint(QPointF(x,y));
|
||||||
}
|
}
|
||||||
m_relation->setIntermediatePoints(points);
|
m_relation->setIntermediatePoints(points);
|
||||||
@@ -273,10 +273,10 @@ bool RelationItem::isSecondarySelected() const
|
|||||||
return m_secondarySelected;
|
return m_secondarySelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationItem::setSecondarySelected(bool secondary_selected)
|
void RelationItem::setSecondarySelected(bool secondarySelected)
|
||||||
{
|
{
|
||||||
if (m_secondarySelected != secondary_selected) {
|
if (m_secondarySelected != secondarySelected) {
|
||||||
m_secondarySelected = secondary_selected;
|
m_secondarySelected = secondarySelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,10 +286,10 @@ bool RelationItem::isFocusSelected() const
|
|||||||
return m_focusSelected;
|
return m_focusSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationItem::setFocusSelected(bool focus_selected)
|
void RelationItem::setFocusSelected(bool focusSelected)
|
||||||
{
|
{
|
||||||
if (m_focusSelected != focus_selected) {
|
if (m_focusSelected != focusSelected) {
|
||||||
m_focusSelected = focus_selected;
|
m_focusSelected = focusSelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,21 +303,21 @@ QPointF RelationItem::getHandlePos(int index)
|
|||||||
// TODO implement
|
// TODO implement
|
||||||
return QPointF(0,0);
|
return QPointF(0,0);
|
||||||
} else {
|
} else {
|
||||||
QList<DRelation::IntermediatePoint> intermediate_points = m_relation->getIntermediatePoints();
|
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->getIntermediatePoints();
|
||||||
--index;
|
--index;
|
||||||
QMT_CHECK(index >= 0 && index < intermediate_points.size());
|
QMT_CHECK(index >= 0 && index < intermediatePoints.size());
|
||||||
return intermediate_points.at(index).getPos();
|
return intermediatePoints.at(index).getPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationItem::insertHandle(int before_index, const QPointF &pos)
|
void RelationItem::insertHandle(int beforeIndex, const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (before_index >= 1 && before_index <= m_relation->getIntermediatePoints().size() + 1) {
|
if (beforeIndex >= 1 && beforeIndex <= m_relation->getIntermediatePoints().size() + 1) {
|
||||||
QList<DRelation::IntermediatePoint> intermediate_points = m_relation->getIntermediatePoints();
|
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->getIntermediatePoints();
|
||||||
intermediate_points.insert(before_index - 1, DRelation::IntermediatePoint(pos));
|
intermediatePoints.insert(beforeIndex - 1, DRelation::IntermediatePoint(pos));
|
||||||
|
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MAJOR);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MAJOR);
|
||||||
m_relation->setIntermediatePoints(intermediate_points);
|
m_relation->setIntermediatePoints(intermediatePoints);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,11 +325,11 @@ void RelationItem::insertHandle(int before_index, const QPointF &pos)
|
|||||||
void RelationItem::deleteHandle(int index)
|
void RelationItem::deleteHandle(int index)
|
||||||
{
|
{
|
||||||
if (index >= 1 && index <= m_relation->getIntermediatePoints().size()) {
|
if (index >= 1 && index <= m_relation->getIntermediatePoints().size()) {
|
||||||
QList<DRelation::IntermediatePoint> intermediate_points = m_relation->getIntermediatePoints();
|
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->getIntermediatePoints();
|
||||||
intermediate_points.removeAt(index - 1);
|
intermediatePoints.removeAt(index - 1);
|
||||||
|
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MAJOR);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MAJOR);
|
||||||
m_relation->setIntermediatePoints(intermediate_points);
|
m_relation->setIntermediatePoints(intermediatePoints);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,35 +341,35 @@ void RelationItem::setHandlePos(int index, const QPointF &pos)
|
|||||||
} else if (index == m_relation->getIntermediatePoints().size() + 1) {
|
} else if (index == m_relation->getIntermediatePoints().size() + 1) {
|
||||||
// TODO implement
|
// TODO implement
|
||||||
} else {
|
} else {
|
||||||
QList<DRelation::IntermediatePoint> intermediate_points = m_relation->getIntermediatePoints();
|
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->getIntermediatePoints();
|
||||||
--index;
|
--index;
|
||||||
QMT_CHECK(index >= 0 && index < intermediate_points.size());
|
QMT_CHECK(index >= 0 && index < intermediatePoints.size());
|
||||||
intermediate_points[index].setPos(pos);
|
intermediatePoints[index].setPos(pos);
|
||||||
|
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
||||||
m_relation->setIntermediatePoints(intermediate_points);
|
m_relation->setIntermediatePoints(intermediatePoints);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationItem::alignHandleToRaster(int index, double raster_width, double raster_height)
|
void RelationItem::alignHandleToRaster(int index, double rasterWidth, double rasterHeight)
|
||||||
{
|
{
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
// TODO implement
|
// TODO implement
|
||||||
} else if (index ==m_relation->getIntermediatePoints().size() + 1) {
|
} else if (index ==m_relation->getIntermediatePoints().size() + 1) {
|
||||||
// TODO implement
|
// TODO implement
|
||||||
} else {
|
} else {
|
||||||
QList<DRelation::IntermediatePoint> intermediate_points = m_relation->getIntermediatePoints();
|
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->getIntermediatePoints();
|
||||||
--index;
|
--index;
|
||||||
QMT_CHECK(index >= 0 && index < intermediate_points.size());
|
QMT_CHECK(index >= 0 && index < intermediatePoints.size());
|
||||||
|
|
||||||
QPointF pos = intermediate_points.at(index).getPos();
|
QPointF pos = intermediatePoints.at(index).getPos();
|
||||||
double x = qRound(pos.x() / raster_width) * raster_width;
|
double x = qRound(pos.x() / rasterWidth) * rasterWidth;
|
||||||
double y = qRound(pos.y() / raster_height) * raster_height;
|
double y = qRound(pos.y() / rasterHeight) * rasterHeight;
|
||||||
intermediate_points[index].setPos(QPointF(x, y));
|
intermediatePoints[index].setPos(QPointF(x, y));
|
||||||
|
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_MINOR);
|
||||||
m_relation->setIntermediatePoints(intermediate_points);
|
m_relation->setIntermediatePoints(intermediatePoints);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,17 +389,17 @@ void RelationItem::update()
|
|||||||
|
|
||||||
void RelationItem::update(const Style *style)
|
void RelationItem::update(const Style *style)
|
||||||
{
|
{
|
||||||
QPointF end_b_pos = calcEndPoint(m_relation->getEndB(), m_relation->getEndA(), m_relation->getIntermediatePoints().size() - 1);
|
QPointF endBPos = calcEndPoint(m_relation->getEndB(), m_relation->getEndA(), m_relation->getIntermediatePoints().size() - 1);
|
||||||
QPointF end_a_pos = calcEndPoint(m_relation->getEndA(), end_b_pos, 0);
|
QPointF endAPos = calcEndPoint(m_relation->getEndA(), endBPos, 0);
|
||||||
|
|
||||||
setPos(end_a_pos);
|
setPos(endAPos);
|
||||||
|
|
||||||
QList<QPointF> points;
|
QList<QPointF> points;
|
||||||
points << (end_a_pos - end_a_pos);
|
points << (endAPos - endAPos);
|
||||||
foreach (const DRelation::IntermediatePoint &point, m_relation->getIntermediatePoints()) {
|
foreach (const DRelation::IntermediatePoint &point, m_relation->getIntermediatePoints()) {
|
||||||
points << (point.getPos() - end_a_pos);
|
points << (point.getPos() - endAPos);
|
||||||
}
|
}
|
||||||
points << (end_b_pos - end_a_pos);
|
points << (endBPos - endAPos);
|
||||||
|
|
||||||
ArrowConfigurator visitor(m_diagramSceneModel, m_arrow, points);
|
ArrowConfigurator visitor(m_diagramSceneModel, m_arrow, points);
|
||||||
m_relation->accept(&visitor);
|
m_relation->accept(&visitor);
|
||||||
@@ -469,71 +469,71 @@ void RelationItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
const Style *RelationItem::getAdaptedStyle()
|
const Style *RelationItem::getAdaptedStyle()
|
||||||
{
|
{
|
||||||
DObject *end_a_object = m_diagramSceneModel->getDiagramController()->findElement<DObject>(m_relation->getEndA(), m_diagramSceneModel->getDiagram());
|
DObject *endAObject = m_diagramSceneModel->getDiagramController()->findElement<DObject>(m_relation->getEndA(), m_diagramSceneModel->getDiagram());
|
||||||
DObject *end_b_object = m_diagramSceneModel->getDiagramController()->findElement<DObject>(m_relation->getEndB(), m_diagramSceneModel->getDiagram());
|
DObject *endBObject = m_diagramSceneModel->getDiagramController()->findElement<DObject>(m_relation->getEndB(), m_diagramSceneModel->getDiagram());
|
||||||
StyledRelation styled_relation(m_relation, end_a_object, end_b_object);
|
StyledRelation styledRelation(m_relation, endAObject, endBObject);
|
||||||
return m_diagramSceneModel->getStyleController()->adaptRelationStyle(styled_relation);
|
return m_diagramSceneModel->getStyleController()->adaptRelationStyle(styledRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF RelationItem::calcEndPoint(const Uid &end, const Uid &other_end, int nearest_intermediate_point_index)
|
QPointF RelationItem::calcEndPoint(const Uid &end, const Uid &otherEnd, int nearestIntermediatePointIndex)
|
||||||
{
|
{
|
||||||
QPointF other_end_pos;
|
QPointF otherEndPos;
|
||||||
if (nearest_intermediate_point_index >= 0 && nearest_intermediate_point_index < m_relation->getIntermediatePoints().size()) {
|
if (nearestIntermediatePointIndex >= 0 && nearestIntermediatePointIndex < m_relation->getIntermediatePoints().size()) {
|
||||||
// other_end_pos will not be used
|
// otherEndPos will not be used
|
||||||
} else {
|
} else {
|
||||||
DObject *end_other_object = m_diagramSceneModel->getDiagramController()->findElement<DObject>(other_end, m_diagramSceneModel->getDiagram());
|
DObject *endOtherObject = m_diagramSceneModel->getDiagramController()->findElement<DObject>(otherEnd, m_diagramSceneModel->getDiagram());
|
||||||
QMT_CHECK(end_other_object);
|
QMT_CHECK(endOtherObject);
|
||||||
other_end_pos = end_other_object->getPos();
|
otherEndPos = endOtherObject->getPos();
|
||||||
}
|
}
|
||||||
return calcEndPoint(end, other_end_pos, nearest_intermediate_point_index);
|
return calcEndPoint(end, otherEndPos, nearestIntermediatePointIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF RelationItem::calcEndPoint(const Uid &end, const QPointF &other_end_pos, int nearest_intermediate_point_index)
|
QPointF RelationItem::calcEndPoint(const Uid &end, const QPointF &otherEndPos, int nearestIntermediatePointIndex)
|
||||||
{
|
{
|
||||||
QGraphicsItem *end_item = m_diagramSceneModel->getGraphicsItem(end);
|
QGraphicsItem *endItem = m_diagramSceneModel->getGraphicsItem(end);
|
||||||
QMT_CHECK(end_item);
|
QMT_CHECK(endItem);
|
||||||
IIntersectionable *end_object_item = dynamic_cast<IIntersectionable *>(end_item);
|
IIntersectionable *endObjectItem = dynamic_cast<IIntersectionable *>(endItem);
|
||||||
QPointF end_pos;
|
QPointF endPos;
|
||||||
if (end_object_item) {
|
if (endObjectItem) {
|
||||||
DObject *end_object = m_diagramSceneModel->getDiagramController()->findElement<DObject>(end, m_diagramSceneModel->getDiagram());
|
DObject *endObject = m_diagramSceneModel->getDiagramController()->findElement<DObject>(end, m_diagramSceneModel->getDiagram());
|
||||||
QMT_CHECK(end_object);
|
QMT_CHECK(endObject);
|
||||||
bool prefer_axis = false;
|
bool preferAxis = false;
|
||||||
QPointF other_pos;
|
QPointF otherPos;
|
||||||
if (nearest_intermediate_point_index >= 0 && nearest_intermediate_point_index < m_relation->getIntermediatePoints().size()) {
|
if (nearestIntermediatePointIndex >= 0 && nearestIntermediatePointIndex < m_relation->getIntermediatePoints().size()) {
|
||||||
other_pos = m_relation->getIntermediatePoints().at(nearest_intermediate_point_index).getPos();
|
otherPos = m_relation->getIntermediatePoints().at(nearestIntermediatePointIndex).getPos();
|
||||||
prefer_axis = true;
|
preferAxis = true;
|
||||||
} else {
|
} else {
|
||||||
other_pos = other_end_pos;
|
otherPos = otherEndPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QLineF direct_line(end_object->getPos(), other_pos);
|
QLineF directLine(endObject->getPos(), otherPos);
|
||||||
if (prefer_axis) {
|
if (preferAxis) {
|
||||||
{
|
{
|
||||||
QPointF axis_direction = GeometryUtilities::calcPrimaryAxisDirection(direct_line);
|
QPointF axisDirection = GeometryUtilities::calcPrimaryAxisDirection(directLine);
|
||||||
QLineF axis(other_pos, other_pos + axis_direction);
|
QLineF axis(otherPos, otherPos + axisDirection);
|
||||||
QPointF projection = GeometryUtilities::calcProjection(axis, end_object->getPos());
|
QPointF projection = GeometryUtilities::calcProjection(axis, endObject->getPos());
|
||||||
QLineF projected_line(projection, other_pos);
|
QLineF projectedLine(projection, otherPos);
|
||||||
ok = end_object_item->intersectShapeWithLine(projected_line, &end_pos);
|
ok = endObjectItem->intersectShapeWithLine(projectedLine, &endPos);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
QPointF axis_direction = GeometryUtilities::calcSecondaryAxisDirection(direct_line);
|
QPointF axisDirection = GeometryUtilities::calcSecondaryAxisDirection(directLine);
|
||||||
QLineF axis(other_pos, other_pos + axis_direction);
|
QLineF axis(otherPos, otherPos + axisDirection);
|
||||||
QPointF projection = GeometryUtilities::calcProjection(axis, end_object->getPos());
|
QPointF projection = GeometryUtilities::calcProjection(axis, endObject->getPos());
|
||||||
QLineF projected_line(projection, other_pos);
|
QLineF projectedLine(projection, otherPos);
|
||||||
ok = end_object_item->intersectShapeWithLine(projected_line, &end_pos);
|
ok = endObjectItem->intersectShapeWithLine(projectedLine, &endPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
ok = end_object_item->intersectShapeWithLine(direct_line, &end_pos);
|
ok = endObjectItem->intersectShapeWithLine(directLine, &endPos);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
end_pos = end_item->pos();
|
endPos = endItem->pos();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
end_pos = end_item->pos();
|
endPos = endItem->pos();
|
||||||
}
|
}
|
||||||
return end_pos;
|
return endPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class RelationItem :
|
|||||||
class ArrowConfigurator;
|
class ArrowConfigurator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RelationItem(DRelation *relation, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
RelationItem(DRelation *relation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~RelationItem();
|
~RelationItem();
|
||||||
|
|
||||||
@@ -81,29 +81,29 @@ public:
|
|||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double raster_width, double raster_height);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondary_selected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focus_selected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QPointF getHandlePos(int index);
|
QPointF getHandlePos(int index);
|
||||||
|
|
||||||
void insertHandle(int before_index, const QPointF &pos);
|
void insertHandle(int beforeIndex, const QPointF &pos);
|
||||||
|
|
||||||
void deleteHandle(int index);
|
void deleteHandle(int index);
|
||||||
|
|
||||||
void setHandlePos(int index, const QPointF &pos);
|
void setHandlePos(int index, const QPointF &pos);
|
||||||
|
|
||||||
void alignHandleToRaster(int index, double raster_width, double raster_height);
|
void alignHandleToRaster(int index, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -125,9 +125,9 @@ private:
|
|||||||
|
|
||||||
const Style *getAdaptedStyle();
|
const Style *getAdaptedStyle();
|
||||||
|
|
||||||
QPointF calcEndPoint(const Uid &end, const Uid &other_end, int nearest_intermediate_point_index);
|
QPointF calcEndPoint(const Uid &end, const Uid &otherEnd, int nearestIntermediatePointIndex);
|
||||||
|
|
||||||
QPointF calcEndPoint(const Uid &end, const QPointF &other_end_pos, int nearest_intermediate_point_index);
|
QPointF calcEndPoint(const Uid &end, const QPointF &otherEndPos, int nearestIntermediatePointIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -57,14 +57,14 @@ StereotypeDisplayVisitor::~StereotypeDisplayVisitor()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDisplayVisitor::setModelController(ModelController *model_controller)
|
void StereotypeDisplayVisitor::setModelController(ModelController *modelController)
|
||||||
{
|
{
|
||||||
m_modelController = model_controller;
|
m_modelController = modelController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDisplayVisitor::setStereotypeController(StereotypeController *stereotype_controller)
|
void StereotypeDisplayVisitor::setStereotypeController(StereotypeController *stereotypeController)
|
||||||
{
|
{
|
||||||
m_stereotypeController = stereotype_controller;
|
m_stereotypeController = stereotypeController;
|
||||||
}
|
}
|
||||||
|
|
||||||
StereotypeIcon::Display StereotypeDisplayVisitor::getStereotypeIconDisplay() const
|
StereotypeIcon::Display StereotypeDisplayVisitor::getStereotypeIconDisplay() const
|
||||||
@@ -87,39 +87,39 @@ StereotypeIcon::Display StereotypeDisplayVisitor::getStereotypeIconDisplay() con
|
|||||||
|
|
||||||
void StereotypeDisplayVisitor::visitDObject(const DObject *object)
|
void StereotypeDisplayVisitor::visitDObject(const DObject *object)
|
||||||
{
|
{
|
||||||
DObject::StereotypeDisplay stereotype_display = object->getStereotypeDisplay();
|
DObject::StereotypeDisplay stereotypeDisplay = object->getStereotypeDisplay();
|
||||||
m_stereotypeIconId = m_stereotypeController->findStereotypeIconId(m_stereotypeIconElement, object->getStereotypes());
|
m_stereotypeIconId = m_stereotypeController->findStereotypeIconId(m_stereotypeIconElement, object->getStereotypes());
|
||||||
|
|
||||||
if (m_stereotypeIconId.isEmpty() && stereotype_display == DObject::STEREOTYPE_ICON) {
|
if (m_stereotypeIconId.isEmpty() && stereotypeDisplay == DObject::STEREOTYPE_ICON) {
|
||||||
stereotype_display = DObject::STEREOTYPE_LABEL;
|
stereotypeDisplay = DObject::STEREOTYPE_LABEL;
|
||||||
} else if (!m_stereotypeIconId.isEmpty() && stereotype_display == DObject::STEREOTYPE_SMART) {
|
} else if (!m_stereotypeIconId.isEmpty() && stereotypeDisplay == DObject::STEREOTYPE_SMART) {
|
||||||
StereotypeIcon stereotype_icon = m_stereotypeController->findStereotypeIcon(m_stereotypeIconId);
|
StereotypeIcon stereotypeIcon = m_stereotypeController->findStereotypeIcon(m_stereotypeIconId);
|
||||||
StereotypeIcon::Display icon_display = stereotype_icon.getDisplay();
|
StereotypeIcon::Display iconDisplay = stereotypeIcon.getDisplay();
|
||||||
switch (icon_display) {
|
switch (iconDisplay) {
|
||||||
case StereotypeIcon::DISPLAY_NONE:
|
case StereotypeIcon::DISPLAY_NONE:
|
||||||
stereotype_display = DObject::STEREOTYPE_NONE;
|
stereotypeDisplay = DObject::STEREOTYPE_NONE;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::DISPLAY_LABEL:
|
case StereotypeIcon::DISPLAY_LABEL:
|
||||||
stereotype_display = DObject::STEREOTYPE_LABEL;
|
stereotypeDisplay = DObject::STEREOTYPE_LABEL;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::DISPLAY_DECORATION:
|
case StereotypeIcon::DISPLAY_DECORATION:
|
||||||
stereotype_display = DObject::STEREOTYPE_DECORATION;
|
stereotypeDisplay = DObject::STEREOTYPE_DECORATION;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::DISPLAY_ICON:
|
case StereotypeIcon::DISPLAY_ICON:
|
||||||
stereotype_display = DObject::STEREOTYPE_ICON;
|
stereotypeDisplay = DObject::STEREOTYPE_ICON;
|
||||||
break;
|
break;
|
||||||
case StereotypeIcon::DISPLAY_SMART:
|
case StereotypeIcon::DISPLAY_SMART:
|
||||||
stereotype_display = m_stereotypeSmartDisplay;
|
stereotypeDisplay = m_stereotypeSmartDisplay;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stereotype_display == DObject::STEREOTYPE_SMART) {
|
if (stereotypeDisplay == DObject::STEREOTYPE_SMART) {
|
||||||
stereotype_display = DObject::STEREOTYPE_LABEL;
|
stereotypeDisplay = DObject::STEREOTYPE_LABEL;
|
||||||
}
|
}
|
||||||
if (stereotype_display == DObject::STEREOTYPE_ICON && m_shapeIconId.isEmpty()) {
|
if (stereotypeDisplay == DObject::STEREOTYPE_ICON && m_shapeIconId.isEmpty()) {
|
||||||
m_shapeIconId = m_stereotypeIconId;
|
m_shapeIconId = m_stereotypeIconId;
|
||||||
}
|
}
|
||||||
m_stereotypeDisplay = stereotype_display;
|
m_stereotypeDisplay = stereotypeDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDisplayVisitor::visitDPackage(const DPackage *package)
|
void StereotypeDisplayVisitor::visitDPackage(const DPackage *package)
|
||||||
@@ -132,12 +132,12 @@ void StereotypeDisplayVisitor::visitDPackage(const DPackage *package)
|
|||||||
void StereotypeDisplayVisitor::visitDClass(const DClass *klass)
|
void StereotypeDisplayVisitor::visitDClass(const DClass *klass)
|
||||||
{
|
{
|
||||||
m_stereotypeIconElement = StereotypeIcon::ELEMENT_CLASS;
|
m_stereotypeIconElement = StereotypeIcon::ELEMENT_CLASS;
|
||||||
MClass *model_klass = m_modelController->findObject<MClass>(klass->getModelUid());
|
MClass *modelKlass = m_modelController->findObject<MClass>(klass->getModelUid());
|
||||||
bool has_members = false;
|
bool hasMembers = false;
|
||||||
if (!model_klass->getMembers().isEmpty() && klass->getShowAllMembers()) {
|
if (!modelKlass->getMembers().isEmpty() && klass->getShowAllMembers()) {
|
||||||
has_members = true;
|
hasMembers = true;
|
||||||
}
|
}
|
||||||
m_stereotypeSmartDisplay = has_members ? DObject::STEREOTYPE_DECORATION : DObject::STEREOTYPE_ICON;
|
m_stereotypeSmartDisplay = hasMembers ? DObject::STEREOTYPE_DECORATION : DObject::STEREOTYPE_ICON;
|
||||||
visitDObject(klass);
|
visitDObject(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setModelController(ModelController *model_controller);
|
void setModelController(ModelController *modelController);
|
||||||
|
|
||||||
void setStereotypeController(StereotypeController *stereotype_controller);
|
void setStereotypeController(StereotypeController *stereotypeController);
|
||||||
|
|
||||||
DObject::StereotypeDisplay getStereotypeDisplay() const { return m_stereotypeDisplay; }
|
DObject::StereotypeDisplay getStereotypeDisplay() const { return m_stereotypeDisplay; }
|
||||||
|
|
||||||
|
|||||||
@@ -72,28 +72,28 @@ LatchController::~LatchController()
|
|||||||
delete m_horizontalAlignLine;
|
delete m_horizontalAlignLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LatchController::setDiagramSceneModel(DiagramSceneModel *diagram_scene_model)
|
void LatchController::setDiagramSceneModel(DiagramSceneModel *diagramSceneModel)
|
||||||
{
|
{
|
||||||
m_diagramSceneModel = diagram_scene_model;
|
m_diagramSceneModel = diagramSceneModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LatchController::addToGraphicsScene(QGraphicsScene *graphics_scene)
|
void LatchController::addToGraphicsScene(QGraphicsScene *graphicsScene)
|
||||||
{
|
{
|
||||||
QMT_CHECK(graphics_scene);
|
QMT_CHECK(graphicsScene);
|
||||||
graphics_scene->addItem(m_horizontalAlignLine);
|
graphicsScene->addItem(m_horizontalAlignLine);
|
||||||
graphics_scene->addItem(m_verticalAlignLine);
|
graphicsScene->addItem(m_verticalAlignLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LatchController::removeFromGraphicsScene(QGraphicsScene *graphics_scene)
|
void LatchController::removeFromGraphicsScene(QGraphicsScene *graphicsScene)
|
||||||
{
|
{
|
||||||
Q_UNUSED(graphics_scene); // avoid warning in release mode
|
Q_UNUSED(graphicsScene); // avoid warning in release mode
|
||||||
|
|
||||||
if (m_verticalAlignLine->scene()) {
|
if (m_verticalAlignLine->scene()) {
|
||||||
QMT_CHECK(graphics_scene == m_verticalAlignLine->scene());
|
QMT_CHECK(graphicsScene == m_verticalAlignLine->scene());
|
||||||
m_verticalAlignLine->scene()->removeItem(m_verticalAlignLine);
|
m_verticalAlignLine->scene()->removeItem(m_verticalAlignLine);
|
||||||
}
|
}
|
||||||
if (m_horizontalAlignLine->scene()) {
|
if (m_horizontalAlignLine->scene()) {
|
||||||
QMT_CHECK(graphics_scene == m_horizontalAlignLine->scene());
|
QMT_CHECK(graphicsScene == m_horizontalAlignLine->scene());
|
||||||
m_horizontalAlignLine->scene()->removeItem(m_horizontalAlignLine);
|
m_horizontalAlignLine->scene()->removeItem(m_horizontalAlignLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,51 +119,51 @@ void LatchController::mouseMoveEventLatching(QGraphicsSceneMouseEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ILatchable *palped_latchable = dynamic_cast<ILatchable *>(m_diagramSceneModel->getFocusItem());
|
ILatchable *palpedLatchable = dynamic_cast<ILatchable *>(m_diagramSceneModel->getFocusItem());
|
||||||
if (!palped_latchable) {
|
if (!palpedLatchable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ILatchable::Action horiz_action = ILatchable::MOVE;
|
ILatchable::Action horizAction = ILatchable::MOVE;
|
||||||
ILatchable::Action vert_action = ILatchable::MOVE;
|
ILatchable::Action vertAction = ILatchable::MOVE;
|
||||||
|
|
||||||
QList<ILatchable::Latch> palped_horizontals = palped_latchable->getHorizontalLatches(horiz_action, true);
|
QList<ILatchable::Latch> palpedHorizontals = palpedLatchable->getHorizontalLatches(horizAction, true);
|
||||||
QList<ILatchable::Latch> palped_verticals = palped_latchable->getVerticalLatches(vert_action, true);
|
QList<ILatchable::Latch> palpedVerticals = palpedLatchable->getVerticalLatches(vertAction, true);
|
||||||
|
|
||||||
qreal horiz_min_dist = 10.0;
|
qreal horizMinDist = 10.0;
|
||||||
ILatchable::Latch best_horiz_latch;
|
ILatchable::Latch bestHorizLatch;
|
||||||
bool found_best_horiz = false;
|
bool foundBestHoriz = false;
|
||||||
qreal vert_min_dist = 10.0;
|
qreal vertMinDist = 10.0;
|
||||||
ILatchable::Latch best_vert_latch;
|
ILatchable::Latch bestVertLatch;
|
||||||
bool found_best_vert = false;
|
bool foundBestVert = false;
|
||||||
|
|
||||||
foreach (QGraphicsItem *item, m_diagramSceneModel->getGraphicsItems()) {
|
foreach (QGraphicsItem *item, m_diagramSceneModel->getGraphicsItems()) {
|
||||||
if (item != m_diagramSceneModel->getFocusItem() && !m_diagramSceneModel->isSelectedItem(item)) {
|
if (item != m_diagramSceneModel->getFocusItem() && !m_diagramSceneModel->isSelectedItem(item)) {
|
||||||
if (ILatchable *latchable = dynamic_cast<ILatchable *>(item)) {
|
if (ILatchable *latchable = dynamic_cast<ILatchable *>(item)) {
|
||||||
QList<ILatchable::Latch> horizontals = latchable->getHorizontalLatches(horiz_action, false);
|
QList<ILatchable::Latch> horizontals = latchable->getHorizontalLatches(horizAction, false);
|
||||||
foreach (const ILatchable::Latch &palped_latch, palped_horizontals) {
|
foreach (const ILatchable::Latch &palpedLatch, palpedHorizontals) {
|
||||||
foreach (const ILatchable::Latch &latch, horizontals) {
|
foreach (const ILatchable::Latch &latch, horizontals) {
|
||||||
if (palped_latch.m_latchType == latch.m_latchType) {
|
if (palpedLatch.m_latchType == latch.m_latchType) {
|
||||||
// calculate distance and minimal distance with sign because this is needed later to move the objects
|
// calculate distance and minimal distance with sign because this is needed later to move the objects
|
||||||
qreal dist = latch.m_pos - palped_latch.m_pos;
|
qreal dist = latch.m_pos - palpedLatch.m_pos;
|
||||||
if (qAbs(dist) < qAbs(horiz_min_dist)) {
|
if (qAbs(dist) < qAbs(horizMinDist)) {
|
||||||
horiz_min_dist = dist;
|
horizMinDist = dist;
|
||||||
best_horiz_latch = latch;
|
bestHorizLatch = latch;
|
||||||
found_best_horiz = true;
|
foundBestHoriz = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QList<ILatchable::Latch> verticals = latchable->getVerticalLatches(vert_action, false);
|
QList<ILatchable::Latch> verticals = latchable->getVerticalLatches(vertAction, false);
|
||||||
foreach (const ILatchable::Latch &palped_latch, palped_verticals) {
|
foreach (const ILatchable::Latch &palpedLatch, palpedVerticals) {
|
||||||
foreach (const ILatchable::Latch &latch, verticals) {
|
foreach (const ILatchable::Latch &latch, verticals) {
|
||||||
if (palped_latch.m_latchType == latch.m_latchType) {
|
if (palpedLatch.m_latchType == latch.m_latchType) {
|
||||||
// calculate distance and minimal distance with sign because this is needed later to move the objects
|
// calculate distance and minimal distance with sign because this is needed later to move the objects
|
||||||
qreal dist = latch.m_pos - palped_latch.m_pos;
|
qreal dist = latch.m_pos - palpedLatch.m_pos;
|
||||||
if (qAbs(dist) < qAbs(vert_min_dist)) {
|
if (qAbs(dist) < qAbs(vertMinDist)) {
|
||||||
vert_min_dist = dist;
|
vertMinDist = dist;
|
||||||
best_vert_latch = latch;
|
bestVertLatch = latch;
|
||||||
found_best_vert = true;
|
foundBestVert = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,16 +172,16 @@ void LatchController::mouseMoveEventLatching(QGraphicsSceneMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_best_horiz) {
|
if (foundBestHoriz) {
|
||||||
switch (best_horiz_latch.m_latchType) {
|
switch (bestHorizLatch.m_latchType) {
|
||||||
case ILatchable::LEFT:
|
case ILatchable::LEFT:
|
||||||
case ILatchable::RIGHT:
|
case ILatchable::RIGHT:
|
||||||
case ILatchable::HCENTER:
|
case ILatchable::HCENTER:
|
||||||
m_verticalAlignLine->setLine(best_horiz_latch.m_pos, best_horiz_latch.m_otherPos1, best_horiz_latch.m_otherPos2);
|
m_verticalAlignLine->setLine(bestHorizLatch.m_pos, bestHorizLatch.m_otherPos1, bestHorizLatch.m_otherPos2);
|
||||||
m_verticalAlignLine->setVisible(true);
|
m_verticalAlignLine->setVisible(true);
|
||||||
m_foundHorizontalLatch = true;
|
m_foundHorizontalLatch = true;
|
||||||
m_horizontalLatch = best_horiz_latch;
|
m_horizontalLatch = bestHorizLatch;
|
||||||
m_horizontalDist = horiz_min_dist;
|
m_horizontalDist = horizMinDist;
|
||||||
break;
|
break;
|
||||||
case ILatchable::NONE:
|
case ILatchable::NONE:
|
||||||
case ILatchable::TOP:
|
case ILatchable::TOP:
|
||||||
@@ -194,16 +194,16 @@ void LatchController::mouseMoveEventLatching(QGraphicsSceneMouseEvent *event)
|
|||||||
m_verticalAlignLine->setVisible(false);
|
m_verticalAlignLine->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_best_vert) {
|
if (foundBestVert) {
|
||||||
switch (best_vert_latch.m_latchType) {
|
switch (bestVertLatch.m_latchType) {
|
||||||
case ILatchable::TOP:
|
case ILatchable::TOP:
|
||||||
case ILatchable::BOTTOM:
|
case ILatchable::BOTTOM:
|
||||||
case ILatchable::VCENTER:
|
case ILatchable::VCENTER:
|
||||||
m_horizontalAlignLine->setLine(best_vert_latch.m_pos, best_vert_latch.m_otherPos1, best_vert_latch.m_otherPos2);
|
m_horizontalAlignLine->setLine(bestVertLatch.m_pos, bestVertLatch.m_otherPos1, bestVertLatch.m_otherPos2);
|
||||||
m_horizontalAlignLine->setVisible(true);
|
m_horizontalAlignLine->setVisible(true);
|
||||||
m_foundVerticalLatch = true;
|
m_foundVerticalLatch = true;
|
||||||
m_verticalLatch = best_vert_latch;
|
m_verticalLatch = bestVertLatch;
|
||||||
m_verticalDist = vert_min_dist;
|
m_verticalDist = vertMinDist;
|
||||||
break;
|
break;
|
||||||
case ILatchable::NONE:
|
case ILatchable::NONE:
|
||||||
case ILatchable::LEFT:
|
case ILatchable::LEFT:
|
||||||
@@ -228,12 +228,12 @@ void LatchController::mouseReleaseEventLatching(QGraphicsSceneMouseEvent *event)
|
|||||||
case ILatchable::HCENTER:
|
case ILatchable::HCENTER:
|
||||||
foreach (QGraphicsItem *item, m_diagramSceneModel->getSelectedItems()) {
|
foreach (QGraphicsItem *item, m_diagramSceneModel->getSelectedItems()) {
|
||||||
DElement *element = m_diagramSceneModel->getElement(item);
|
DElement *element = m_diagramSceneModel->getElement(item);
|
||||||
if (DObject *selected_object = dynamic_cast<DObject *>(element)) {
|
if (DObject *selectedObject = dynamic_cast<DObject *>(element)) {
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(selected_object, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(selectedObject, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
||||||
QPointF new_pos = selected_object->getPos();
|
QPointF newPos = selectedObject->getPos();
|
||||||
new_pos.setX(new_pos.x() + m_horizontalDist);
|
newPos.setX(newPos.x() + m_horizontalDist);
|
||||||
selected_object->setPos(new_pos);
|
selectedObject->setPos(newPos);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(selected_object, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(selectedObject, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -253,12 +253,12 @@ void LatchController::mouseReleaseEventLatching(QGraphicsSceneMouseEvent *event)
|
|||||||
case ILatchable::VCENTER:
|
case ILatchable::VCENTER:
|
||||||
foreach (QGraphicsItem *item, m_diagramSceneModel->getSelectedItems()) {
|
foreach (QGraphicsItem *item, m_diagramSceneModel->getSelectedItems()) {
|
||||||
DElement *element = m_diagramSceneModel->getElement(item);
|
DElement *element = m_diagramSceneModel->getElement(item);
|
||||||
if (DObject *selected_object = dynamic_cast<DObject *>(element)) {
|
if (DObject *selectedObject = dynamic_cast<DObject *>(element)) {
|
||||||
m_diagramSceneModel->getDiagramController()->startUpdateElement(selected_object, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
m_diagramSceneModel->getDiagramController()->startUpdateElement(selectedObject, m_diagramSceneModel->getDiagram(), DiagramController::UPDATE_GEOMETRY);
|
||||||
QPointF new_pos = selected_object->getPos();
|
QPointF newPos = selectedObject->getPos();
|
||||||
new_pos.setY(new_pos.y() + m_verticalDist);
|
newPos.setY(newPos.y() + m_verticalDist);
|
||||||
selected_object->setPos(new_pos);
|
selectedObject->setPos(newPos);
|
||||||
m_diagramSceneModel->getDiagramController()->finishUpdateElement(selected_object, m_diagramSceneModel->getDiagram(), false);
|
m_diagramSceneModel->getDiagramController()->finishUpdateElement(selectedObject, m_diagramSceneModel->getDiagram(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setDiagramSceneModel(DiagramSceneModel *diagram_scene_model);
|
void setDiagramSceneModel(DiagramSceneModel *diagramSceneModel);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void addToGraphicsScene(QGraphicsScene *graphics_scene);
|
void addToGraphicsScene(QGraphicsScene *graphicsScene);
|
||||||
|
|
||||||
void removeFromGraphicsScene(QGraphicsScene *graphics_scene);
|
void removeFromGraphicsScene(QGraphicsScene *graphicsScene);
|
||||||
|
|
||||||
void mousePressEventLatching(QGraphicsSceneMouseEvent *event);
|
void mousePressEventLatching(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ class AlignButtonsItem::AlignButtonItem :
|
|||||||
public QGraphicsRectItem
|
public QGraphicsRectItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AlignButtonItem(IAlignable::AlignType align_type, const QString &identifier, IAlignable *alignable, QGraphicsItem *parent)
|
AlignButtonItem(IAlignable::AlignType alignType, const QString &identifier, IAlignable *alignable, QGraphicsItem *parent)
|
||||||
: QGraphicsRectItem(parent),
|
: QGraphicsRectItem(parent),
|
||||||
m_alignType(align_type),
|
m_alignType(alignType),
|
||||||
m_identifier(identifier),
|
m_identifier(identifier),
|
||||||
m_alignable(alignable),
|
m_alignable(alignable),
|
||||||
m_pixmapItem(new QGraphicsPixmapItem(this))
|
m_pixmapItem(new QGraphicsPixmapItem(this))
|
||||||
@@ -138,49 +138,49 @@ void AlignButtonsItem::clear()
|
|||||||
m_alignItems.clear();
|
m_alignItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlignButtonsItem::addButton(IAlignable::AlignType align_type, const QString &identifier, qreal pos)
|
void AlignButtonsItem::addButton(IAlignable::AlignType alignType, const QString &identifier, qreal pos)
|
||||||
{
|
{
|
||||||
AlignButtonItem *item = new AlignButtonItem(align_type, identifier, m_alignable, this);
|
AlignButtonItem *item = new AlignButtonItem(alignType, identifier, m_alignable, this);
|
||||||
switch (align_type) {
|
switch (alignType) {
|
||||||
case IAlignable::ALIGN_LEFT:
|
case IAlignable::ALIGN_LEFT:
|
||||||
{
|
{
|
||||||
static const QPixmap align_left_pixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-left.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
static const QPixmap alignLeftPixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-left.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
item->setPixmap(align_left_pixmap);
|
item->setPixmap(alignLeftPixmap);
|
||||||
item->setPos(pos - INNER_BORDER - 3.0, 0); // subtract additional shift of image within pixmap
|
item->setPos(pos - INNER_BORDER - 3.0, 0); // subtract additional shift of image within pixmap
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IAlignable::ALIGN_RIGHT:
|
case IAlignable::ALIGN_RIGHT:
|
||||||
{
|
{
|
||||||
static const QPixmap align_right_pixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-right.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
static const QPixmap alignRightPixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-right.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
item->setPixmap(align_right_pixmap);
|
item->setPixmap(alignRightPixmap);
|
||||||
item->setPos(pos - item->boundingRect().width() + INNER_BORDER + 3.0, 0);
|
item->setPos(pos - item->boundingRect().width() + INNER_BORDER + 3.0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IAlignable::ALIGN_TOP:
|
case IAlignable::ALIGN_TOP:
|
||||||
{
|
{
|
||||||
static const QPixmap align_top_pixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-top.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
static const QPixmap alignTopPixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-top.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
item->setPixmap(align_top_pixmap);
|
item->setPixmap(alignTopPixmap);
|
||||||
item->setPos(0, pos - INNER_BORDER - 3.0);
|
item->setPos(0, pos - INNER_BORDER - 3.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IAlignable::ALIGN_BOTTOM:
|
case IAlignable::ALIGN_BOTTOM:
|
||||||
{
|
{
|
||||||
static const QPixmap align_bottom_pixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-bottom.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
static const QPixmap alignBottomPixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-bottom.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
item->setPixmap(align_bottom_pixmap);
|
item->setPixmap(alignBottomPixmap);
|
||||||
item->setPos(0, pos - item->boundingRect().height() + INNER_BORDER + 3.0);
|
item->setPos(0, pos - item->boundingRect().height() + INNER_BORDER + 3.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IAlignable::ALIGN_HCENTER:
|
case IAlignable::ALIGN_HCENTER:
|
||||||
{
|
{
|
||||||
static const QPixmap align_horizontal_pixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-horizontal.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
static const QPixmap alignHorizontalPixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-horizontal.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
item->setPixmap(align_horizontal_pixmap);
|
item->setPixmap(alignHorizontalPixmap);
|
||||||
item->setPos(pos - item->boundingRect().center().x(), 0);
|
item->setPos(pos - item->boundingRect().center().x(), 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IAlignable::ALIGN_VCENTER:
|
case IAlignable::ALIGN_VCENTER:
|
||||||
{
|
{
|
||||||
static const QPixmap align_vertical_pixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-vertical.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
static const QPixmap alignVerticalPixmap = QPixmap(QStringLiteral(":/modelinglib/25x25/align-vertical.png")).scaled(NORMAL_PIXMAP_WIDTH, NORMAL_PIXMAP_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
item->setPixmap(align_vertical_pixmap);
|
item->setPixmap(alignVerticalPixmap);
|
||||||
item->setPos(0, pos - item->boundingRect().center().y());
|
item->setPos(0, pos - item->boundingRect().center().y());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void addButton(IAlignable::AlignType align_type, const QString &identifier, qreal pos);
|
void addButton(IAlignable::AlignType alignType, const QString &identifier, qreal pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -56,20 +56,20 @@ void AlignLineItem::setLine(qreal pos)
|
|||||||
setLine(pos, 0.0, 0.0);
|
setLine(pos, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlignLineItem::setLine(qreal pos, qreal other_pos1, qreal other_pos2)
|
void AlignLineItem::setLine(qreal pos, qreal otherPos1, qreal otherPos2)
|
||||||
{
|
{
|
||||||
QRectF scene_rect = scene()->sceneRect();
|
QRectF sceneRect = scene()->sceneRect();
|
||||||
switch (m_direction) {
|
switch (m_direction) {
|
||||||
case HORIZONTAL:
|
case HORIZONTAL:
|
||||||
m_alignLine->setLine(scene_rect.left() + 1.0, pos, scene_rect.right() - 1.0, pos);
|
m_alignLine->setLine(sceneRect.left() + 1.0, pos, sceneRect.right() - 1.0, pos);
|
||||||
m_highlightLine->setLine(other_pos1, pos, other_pos2, pos);
|
m_highlightLine->setLine(otherPos1, pos, otherPos2, pos);
|
||||||
break;
|
break;
|
||||||
case VERTICAL:
|
case VERTICAL:
|
||||||
m_alignLine->setLine(pos, scene_rect.top() + 1.0, pos, scene_rect.bottom() - 1.0);
|
m_alignLine->setLine(pos, sceneRect.top() + 1.0, pos, sceneRect.bottom() - 1.0);
|
||||||
m_highlightLine->setLine(pos, other_pos1, pos, other_pos2);
|
m_highlightLine->setLine(pos, otherPos1, pos, otherPos2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_highlightLine->setVisible(other_pos1 - other_pos2 != 0);
|
m_highlightLine->setVisible(otherPos1 - otherPos2 != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF AlignLineItem::boundingRect() const
|
QRectF AlignLineItem::boundingRect() const
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
void setLine(qreal pos);
|
void setLine(qreal pos);
|
||||||
|
|
||||||
void setLine(qreal pos, qreal other_pos1, qreal other_pos2);
|
void setLine(qreal pos, qreal otherPos1, qreal otherPos2);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -91,17 +91,17 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setArrowSize(double arrow_size)
|
void setArrowSize(double arrowSize)
|
||||||
{
|
{
|
||||||
if (m_arrowSize != arrow_size) {
|
if (m_arrowSize != arrowSize) {
|
||||||
m_arrowSize = arrow_size;
|
m_arrowSize = arrowSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDiamondSize(double diamond_size)
|
void setDiamondSize(double diamondSize)
|
||||||
{
|
{
|
||||||
if (m_diamondSize != diamond_size) {
|
if (m_diamondSize != diamondSize) {
|
||||||
m_diamondSize = diamond_size;
|
m_diamondSize = diamondSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,28 +187,28 @@ public:
|
|||||||
|
|
||||||
void update(const Style *style)
|
void update(const Style *style)
|
||||||
{
|
{
|
||||||
bool has_arrow = false;
|
bool hasArrow = false;
|
||||||
bool has_diamond = false;
|
bool hasDiamond = false;
|
||||||
switch (m_head) {
|
switch (m_head) {
|
||||||
case ArrowItem::HEAD_NONE:
|
case ArrowItem::HEAD_NONE:
|
||||||
break;
|
break;
|
||||||
case ArrowItem::HEAD_OPEN:
|
case ArrowItem::HEAD_OPEN:
|
||||||
case ArrowItem::HEAD_TRIANGLE:
|
case ArrowItem::HEAD_TRIANGLE:
|
||||||
case ArrowItem::HEAD_FILLED_TRIANGLE:
|
case ArrowItem::HEAD_FILLED_TRIANGLE:
|
||||||
has_arrow = true;
|
hasArrow = true;
|
||||||
break;
|
break;
|
||||||
case ArrowItem::HEAD_DIAMOND:
|
case ArrowItem::HEAD_DIAMOND:
|
||||||
case ArrowItem::HEAD_FILLED_DIAMOND:
|
case ArrowItem::HEAD_FILLED_DIAMOND:
|
||||||
has_diamond = true;
|
hasDiamond = true;
|
||||||
break;
|
break;
|
||||||
case ArrowItem::HEAD_DIAMOND_FILLED_TRIANGLE:
|
case ArrowItem::HEAD_DIAMOND_FILLED_TRIANGLE:
|
||||||
case ArrowItem::HEAD_FILLED_DIAMOND_FILLED_TRIANGLE:
|
case ArrowItem::HEAD_FILLED_DIAMOND_FILLED_TRIANGLE:
|
||||||
has_arrow = true;
|
hasArrow = true;
|
||||||
has_diamond = true;
|
hasDiamond = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_arrow) {
|
if (hasArrow) {
|
||||||
if (!m_arrowItem) {
|
if (!m_arrowItem) {
|
||||||
m_arrowItem = new ArrowItem::GraphicsPathItem(this);
|
m_arrowItem = new ArrowItem::GraphicsPathItem(this);
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ public:
|
|||||||
if (m_head != ArrowItem::HEAD_OPEN) {
|
if (m_head != ArrowItem::HEAD_OPEN) {
|
||||||
path.closeSubpath();
|
path.closeSubpath();
|
||||||
}
|
}
|
||||||
if (has_diamond) {
|
if (hasDiamond) {
|
||||||
path.translate(-calcDiamondLength(), 0.0);
|
path.translate(-calcDiamondLength(), 0.0);
|
||||||
}
|
}
|
||||||
m_arrowItem->setPath(path);
|
m_arrowItem->setPath(path);
|
||||||
@@ -239,7 +239,7 @@ public:
|
|||||||
m_arrowItem = 0;
|
m_arrowItem = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_diamond) {
|
if (hasDiamond) {
|
||||||
if (!m_diamondItem) {
|
if (!m_diamondItem) {
|
||||||
m_diamondItem = new ArrowItem::GraphicsPathItem(this);
|
m_diamondItem = new ArrowItem::GraphicsPathItem(this);
|
||||||
}
|
}
|
||||||
@@ -329,17 +329,17 @@ void ArrowItem::setShaft(ArrowItem::Shaft shaft)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrowItem::setArrowSize(double arrow_size)
|
void ArrowItem::setArrowSize(double arrowSize)
|
||||||
{
|
{
|
||||||
if (m_arrowSize != arrow_size) {
|
if (m_arrowSize != arrowSize) {
|
||||||
m_arrowSize = arrow_size;
|
m_arrowSize = arrowSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrowItem::setDiamondSize(double diamond_size)
|
void ArrowItem::setDiamondSize(double diamondSize)
|
||||||
{
|
{
|
||||||
if (m_diamondSize != diamond_size) {
|
if (m_diamondSize != diamondSize) {
|
||||||
m_diamondSize = diamond_size;
|
m_diamondSize = diamondSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,42 +464,42 @@ void ArrowItem::updateShaft(const Style *style)
|
|||||||
m_shaftItem->setPen(pen);
|
m_shaftItem->setPen(pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrowItem::updateHead(GraphicsHeadItem **head_item, Head head, const Style *style)
|
void ArrowItem::updateHead(GraphicsHeadItem **headItem, Head head, const Style *style)
|
||||||
{
|
{
|
||||||
if (head == HEAD_NONE) {
|
if (head == HEAD_NONE) {
|
||||||
if (*head_item) {
|
if (*headItem) {
|
||||||
if ((*head_item)->scene()) {
|
if ((*headItem)->scene()) {
|
||||||
(*head_item)->scene()->removeItem(*head_item);
|
(*headItem)->scene()->removeItem(*headItem);
|
||||||
}
|
}
|
||||||
delete *head_item;
|
delete *headItem;
|
||||||
*head_item = 0;
|
*headItem = 0;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!*head_item) {
|
if (!*headItem) {
|
||||||
*head_item = new GraphicsHeadItem(this);
|
*headItem = new GraphicsHeadItem(this);
|
||||||
}
|
}
|
||||||
(*head_item)->setArrowSize(m_arrowSize);
|
(*headItem)->setArrowSize(m_arrowSize);
|
||||||
(*head_item)->setDiamondSize(m_diamondSize);
|
(*headItem)->setDiamondSize(m_diamondSize);
|
||||||
(*head_item)->setHead(head);
|
(*headItem)->setHead(head);
|
||||||
(*head_item)->update(style);
|
(*headItem)->update(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrowItem::updateHeadGeometry(GraphicsHeadItem **head_item, const QPointF &pos, const QPointF &other_pos)
|
void ArrowItem::updateHeadGeometry(GraphicsHeadItem **headItem, const QPointF &pos, const QPointF &otherPos)
|
||||||
{
|
{
|
||||||
if (!*head_item) {
|
if (!*headItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*head_item)->setPos(pos);
|
(*headItem)->setPos(pos);
|
||||||
|
|
||||||
QVector2D direction_vector(pos - other_pos);
|
QVector2D directionVector(pos - otherPos);
|
||||||
direction_vector.normalize();
|
directionVector.normalize();
|
||||||
double angle = qAcos(direction_vector.x()) * 180.0 / 3.1415926535;
|
double angle = qAcos(directionVector.x()) * 180.0 / 3.1415926535;
|
||||||
if (direction_vector.y() > 0.0) {
|
if (directionVector.y() > 0.0) {
|
||||||
angle = -angle;
|
angle = -angle;
|
||||||
}
|
}
|
||||||
(*head_item)->setRotation(-angle);
|
(*headItem)->setRotation(-angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrowItem::updateGeometry()
|
void ArrowItem::updateGeometry()
|
||||||
@@ -512,10 +512,10 @@ void ArrowItem::updateGeometry()
|
|||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
if (m_startHeadItem) {
|
if (m_startHeadItem) {
|
||||||
QVector2D start_direction_vector(m_points[1] - m_points[0]);
|
QVector2D startDirectionVector(m_points[1] - m_points[0]);
|
||||||
start_direction_vector.normalize();
|
startDirectionVector.normalize();
|
||||||
start_direction_vector *= m_startHeadItem->calcHeadLength();
|
startDirectionVector *= m_startHeadItem->calcHeadLength();
|
||||||
path.moveTo(m_points[0] + start_direction_vector.toPointF());
|
path.moveTo(m_points[0] + startDirectionVector.toPointF());
|
||||||
} else {
|
} else {
|
||||||
path.moveTo(m_points[0]);
|
path.moveTo(m_points[0]);
|
||||||
}
|
}
|
||||||
@@ -525,10 +525,10 @@ void ArrowItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_endHeadItem) {
|
if (m_endHeadItem) {
|
||||||
QVector2D end_direction_vector(m_points[m_points.size() - 1] - m_points[m_points.size() - 2]);
|
QVector2D endDirectionVector(m_points[m_points.size() - 1] - m_points[m_points.size() - 2]);
|
||||||
end_direction_vector.normalize();
|
endDirectionVector.normalize();
|
||||||
end_direction_vector *= m_endHeadItem->calcHeadLength();
|
endDirectionVector *= m_endHeadItem->calcHeadLength();
|
||||||
path.lineTo(m_points[m_points.size() - 1] - end_direction_vector.toPointF());
|
path.lineTo(m_points[m_points.size() - 1] - endDirectionVector.toPointF());
|
||||||
} else {
|
} else {
|
||||||
path.lineTo(m_points[m_points.size() - 1]);
|
path.lineTo(m_points[m_points.size() - 1]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ public:
|
|||||||
|
|
||||||
void setShaft(Shaft shaft);
|
void setShaft(Shaft shaft);
|
||||||
|
|
||||||
void setArrowSize(double arrow_size);
|
void setArrowSize(double arrowSize);
|
||||||
|
|
||||||
void setDiamondSize(double diamond_size);
|
void setDiamondSize(double diamondSize);
|
||||||
|
|
||||||
void setStartHead(Head head);
|
void setStartHead(Head head);
|
||||||
|
|
||||||
@@ -115,9 +115,9 @@ private:
|
|||||||
|
|
||||||
void updateShaft(const Style *style);
|
void updateShaft(const Style *style);
|
||||||
|
|
||||||
void updateHead(GraphicsHeadItem **head_item, Head head, const Style *style);
|
void updateHead(GraphicsHeadItem **headItem, Head head, const Style *style);
|
||||||
|
|
||||||
void updateHeadGeometry(GraphicsHeadItem **head_item, const QPointF &pos, const QPointF &other_pos);
|
void updateHeadGeometry(GraphicsHeadItem **headItem, const QPointF &pos, const QPointF &otherPos);
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ ContextLabelItem::~ContextLabelItem()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextLabelItem::setMaxWidth(double max_width)
|
void ContextLabelItem::setMaxWidth(double maxWidth)
|
||||||
{
|
{
|
||||||
if (m_maxWidth != max_width) {
|
if (m_maxWidth != maxWidth) {
|
||||||
m_maxWidth = max_width;
|
m_maxWidth = maxWidth;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,12 +77,12 @@ void ContextLabelItem::update()
|
|||||||
{
|
{
|
||||||
setText(QString(QStringLiteral("(from %1)")).arg(m_context));
|
setText(QString(QStringLiteral("(from %1)")).arg(m_context));
|
||||||
if (m_maxWidth > 0.0) {
|
if (m_maxWidth > 0.0) {
|
||||||
double context_width = boundingRect().width();
|
double contextWidth = boundingRect().width();
|
||||||
if (context_width > m_maxWidth) {
|
if (contextWidth > m_maxWidth) {
|
||||||
setText(QString(QStringLiteral("(%1)")).arg(m_context));
|
setText(QString(QStringLiteral("(%1)")).arg(m_context));
|
||||||
context_width = boundingRect().width();
|
contextWidth = boundingRect().width();
|
||||||
}
|
}
|
||||||
if (context_width > m_maxWidth) {
|
if (contextWidth > m_maxWidth) {
|
||||||
QFontMetricsF metrics(font());
|
QFontMetricsF metrics(font());
|
||||||
setText(metrics.elidedText(QString(QStringLiteral("(%1)")).arg(m_context), Qt::ElideMiddle, m_maxWidth));
|
setText(metrics.elidedText(QString(QStringLiteral("(%1)")).arg(m_context), Qt::ElideMiddle, m_maxWidth));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setMaxWidth(double max_width);
|
void setMaxWidth(double maxWidth);
|
||||||
|
|
||||||
void resetMaxWidth();
|
void resetMaxWidth();
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,9 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
CustomIconItem::CustomIconItem(DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
CustomIconItem::CustomIconItem(DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_diagramSceneModel(diagram_scene_model),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
m_baseSize(20, 20),
|
m_baseSize(20, 20),
|
||||||
m_actualSize(20, 20)
|
m_actualSize(20, 20)
|
||||||
{
|
{
|
||||||
@@ -52,24 +52,24 @@ CustomIconItem::~CustomIconItem()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomIconItem::setStereotypeIconId(const QString &stereotype_icon_id)
|
void CustomIconItem::setStereotypeIconId(const QString &stereotypeIconId)
|
||||||
{
|
{
|
||||||
if (m_stereotypeIconId != stereotype_icon_id) {
|
if (m_stereotypeIconId != stereotypeIconId) {
|
||||||
m_stereotypeIconId = stereotype_icon_id;
|
m_stereotypeIconId = stereotypeIconId;
|
||||||
m_stereotypeIcon = m_diagramSceneModel->getStereotypeController()->findStereotypeIcon(m_stereotypeIconId);
|
m_stereotypeIcon = m_diagramSceneModel->getStereotypeController()->findStereotypeIcon(m_stereotypeIconId);
|
||||||
m_baseSize = QSizeF(m_stereotypeIcon.getWidth(), m_stereotypeIcon.getHeight());
|
m_baseSize = QSizeF(m_stereotypeIcon.getWidth(), m_stereotypeIcon.getHeight());
|
||||||
m_actualSize = m_baseSize;
|
m_actualSize = m_baseSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomIconItem::setBaseSize(const QSizeF &base_size)
|
void CustomIconItem::setBaseSize(const QSizeF &baseSize)
|
||||||
{
|
{
|
||||||
m_baseSize = base_size;
|
m_baseSize = baseSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomIconItem::setActualSize(const QSizeF &actual_size)
|
void CustomIconItem::setActualSize(const QSizeF &actualSize)
|
||||||
{
|
{
|
||||||
m_actualSize = actual_size;
|
m_actualSize = actualSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomIconItem::setBrush(const QBrush &brush)
|
void CustomIconItem::setBrush(const QBrush &brush)
|
||||||
|
|||||||
@@ -51,17 +51,17 @@ class CustomIconItem :
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CustomIconItem(DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
CustomIconItem(DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~CustomIconItem();
|
~CustomIconItem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setStereotypeIconId(const QString &stereotype_icon_id);
|
void setStereotypeIconId(const QString &stereotypeIconId);
|
||||||
|
|
||||||
void setBaseSize(const QSizeF &base_size);
|
void setBaseSize(const QSizeF &baseSize);
|
||||||
|
|
||||||
void setActualSize(const QSizeF &actual_size);
|
void setActualSize(const QSizeF &actualSize);
|
||||||
|
|
||||||
void setBrush(const QBrush &brush);
|
void setBrush(const QBrush &brush);
|
||||||
|
|
||||||
|
|||||||
@@ -61,20 +61,20 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GraphicsHandleItem(int point_index, PathSelectionItem *parent)
|
GraphicsHandleItem(int pointIndex, PathSelectionItem *parent)
|
||||||
: QGraphicsRectItem(parent),
|
: QGraphicsRectItem(parent),
|
||||||
m_owner(parent),
|
m_owner(parent),
|
||||||
m_pointIndex(point_index),
|
m_pointIndex(pointIndex),
|
||||||
m_selection(NOT_SELECTED)
|
m_selection(NOT_SELECTED)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setPointSize(const QSizeF &point_size)
|
void setPointSize(const QSizeF &pointSize)
|
||||||
{
|
{
|
||||||
if (m_pointSize != point_size) {
|
if (m_pointSize != pointSize) {
|
||||||
m_pointSize = point_size;
|
m_pointSize = pointSize;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,12 +192,12 @@ QPainterPath PathSelectionItem::shape() const
|
|||||||
for (int i = 0; i < m_handles.size(); ++i) {
|
for (int i = 0; i < m_handles.size(); ++i) {
|
||||||
polygon.append(m_handles.at(i)->pos());
|
polygon.append(m_handles.at(i)->pos());
|
||||||
}
|
}
|
||||||
QPainterPath polygon_path;
|
QPainterPath polygonPath;
|
||||||
polygon_path.addPolygon(polygon);
|
polygonPath.addPolygon(polygon);
|
||||||
QPainterPathStroker ps;
|
QPainterPathStroker ps;
|
||||||
ps.setWidth(16.0);
|
ps.setWidth(16.0);
|
||||||
polygon_path = ps.createStroke(polygon_path);
|
polygonPath = ps.createStroke(polygonPath);
|
||||||
shape.addPath(polygon_path);
|
shape.addPath(polygonPath);
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,20 +221,20 @@ QList<QPointF> PathSelectionItem::getPoints() const
|
|||||||
void PathSelectionItem::setPoints(const QList<QPointF> &points)
|
void PathSelectionItem::setPoints(const QList<QPointF> &points)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
int point_index = 0;
|
int pointIndex = 0;
|
||||||
foreach (const QPointF &point, points) {
|
foreach (const QPointF &point, points) {
|
||||||
GraphicsHandleItem *handle;
|
GraphicsHandleItem *handle;
|
||||||
if (point_index >= m_handles.size()) {
|
if (pointIndex >= m_handles.size()) {
|
||||||
handle = new GraphicsHandleItem(point_index, this);
|
handle = new GraphicsHandleItem(pointIndex, this);
|
||||||
handle->setPointSize(m_pointSize);
|
handle->setPointSize(m_pointSize);
|
||||||
m_handles.append(handle);
|
m_handles.append(handle);
|
||||||
} else {
|
} else {
|
||||||
handle = m_handles.at(point_index);
|
handle = m_handles.at(pointIndex);
|
||||||
}
|
}
|
||||||
handle->setPos(point);
|
handle->setPos(point);
|
||||||
++point_index;
|
++pointIndex;
|
||||||
}
|
}
|
||||||
while (m_handles.size() > point_index) {
|
while (m_handles.size() > pointIndex) {
|
||||||
m_handles.last()->scene()->removeItem(m_handles.last());
|
m_handles.last()->scene()->removeItem(m_handles.last());
|
||||||
delete m_handles.last();
|
delete m_handles.last();
|
||||||
m_handles.removeLast();
|
m_handles.removeLast();
|
||||||
@@ -242,10 +242,10 @@ void PathSelectionItem::setPoints(const QList<QPointF> &points)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathSelectionItem::setSecondarySelected(bool secondary_selected)
|
void PathSelectionItem::setSecondarySelected(bool secondarySelected)
|
||||||
{
|
{
|
||||||
if (m_secondarySelected != secondary_selected) {
|
if (m_secondarySelected != secondarySelected) {
|
||||||
m_secondarySelected = secondary_selected;
|
m_secondarySelected = secondarySelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,34 +272,34 @@ void PathSelectionItem::update()
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (GraphicsHandleItem *handle, m_handles) {
|
foreach (GraphicsHandleItem *handle, m_handles) {
|
||||||
handle->setPointSize(m_pointSize);
|
handle->setPointSize(m_pointSize);
|
||||||
bool is_end_point = (i == 0 || i == m_handles.size() - 1);
|
bool isEndPoint = (i == 0 || i == m_handles.size() - 1);
|
||||||
handle->setSelection(m_secondarySelected
|
handle->setSelection(m_secondarySelected
|
||||||
? (is_end_point ? GraphicsHandleItem::NOT_SELECTED : GraphicsHandleItem::SECONDARY_SELECTED)
|
? (isEndPoint ? GraphicsHandleItem::NOT_SELECTED : GraphicsHandleItem::SECONDARY_SELECTED)
|
||||||
: GraphicsHandleItem::SELECTED);
|
: GraphicsHandleItem::SELECTED);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathSelectionItem::moveHandle(int point_index, const QPointF &delta_move, HandleStatus handle_status, HandleQualifier handle_qualifier)
|
void PathSelectionItem::moveHandle(int pointIndex, const QPointF &deltaMove, HandleStatus handleStatus, HandleQualifier handleQualifier)
|
||||||
{
|
{
|
||||||
Q_UNUSED(handle_status);
|
Q_UNUSED(handleStatus);
|
||||||
|
|
||||||
switch (handle_qualifier) {
|
switch (handleQualifier) {
|
||||||
case NONE:
|
case NONE:
|
||||||
{
|
{
|
||||||
if (handle_status == PRESS) {
|
if (handleStatus == PRESS) {
|
||||||
m_originalHandlePos = m_windable->getHandlePos(point_index);
|
m_originalHandlePos = m_windable->getHandlePos(pointIndex);
|
||||||
}
|
}
|
||||||
QPointF new_pos = m_originalHandlePos + delta_move;
|
QPointF newPos = m_originalHandlePos + deltaMove;
|
||||||
m_windable->setHandlePos(point_index, new_pos);
|
m_windable->setHandlePos(pointIndex, newPos);
|
||||||
if (handle_status == RELEASE) {
|
if (handleStatus == RELEASE) {
|
||||||
m_windable->alignHandleToRaster(point_index, RASTER_WIDTH, RASTER_HEIGHT);
|
m_windable->alignHandleToRaster(pointIndex, RASTER_WIDTH, RASTER_HEIGHT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DELETE_HANDLE:
|
case DELETE_HANDLE:
|
||||||
if (handle_status == PRESS) {
|
if (handleStatus == PRESS) {
|
||||||
m_windable->deleteHandle(point_index);
|
m_windable->deleteHandle(pointIndex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
|
|
||||||
void setPoints(const QList<QPointF> &points);
|
void setPoints(const QList<QPointF> &points);
|
||||||
|
|
||||||
void setSecondarySelected(bool secondary_selected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ private:
|
|||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void moveHandle(int point_index, const QPointF &delta_move, HandleStatus handle_status, HandleQualifier handle_qualifier);
|
void moveHandle(int pointIndex, const QPointF &deltaMove, HandleStatus handleStatus, HandleQualifier handleQualifier);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ public:
|
|||||||
setBrush(QBrush(Qt::black));
|
setBrush(QBrush(Qt::black));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSecondarySelected(bool secondary_selected)
|
void setSecondarySelected(bool secondarySelected)
|
||||||
{
|
{
|
||||||
if (secondary_selected != m_secondarySelected) {
|
if (secondarySelected != m_secondarySelected) {
|
||||||
m_secondarySelected = secondary_selected;
|
m_secondarySelected = secondarySelected;
|
||||||
if (secondary_selected) {
|
if (secondarySelected) {
|
||||||
setPen(QPen(Qt::lightGray));
|
setPen(QPen(Qt::lightGray));
|
||||||
setBrush(Qt::NoBrush);
|
setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
@@ -112,9 +112,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
RectangularSelectionItem::RectangularSelectionItem(IResizable *item_resizer, QGraphicsItem *parent)
|
RectangularSelectionItem::RectangularSelectionItem(IResizable *itemResizer, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_itemResizer(item_resizer),
|
m_itemResizer(itemResizer),
|
||||||
m_pointSize(QSizeF(9.0, 9.0)),
|
m_pointSize(QSizeF(9.0, 9.0)),
|
||||||
m_points(8),
|
m_points(8),
|
||||||
m_showBorder(false),
|
m_showBorder(false),
|
||||||
@@ -161,9 +161,9 @@ void RectangularSelectionItem::setPointSize(const QSizeF &size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangularSelectionItem::setShowBorder(bool show_border)
|
void RectangularSelectionItem::setShowBorder(bool showBorder)
|
||||||
{
|
{
|
||||||
m_showBorder = show_border;
|
m_showBorder = showBorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangularSelectionItem::setFreedom(Freedom freedom)
|
void RectangularSelectionItem::setFreedom(Freedom freedom)
|
||||||
@@ -171,10 +171,10 @@ void RectangularSelectionItem::setFreedom(Freedom freedom)
|
|||||||
m_freedom = freedom;
|
m_freedom = freedom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangularSelectionItem::setSecondarySelected(bool secondary_selected)
|
void RectangularSelectionItem::setSecondarySelected(bool secondarySelected)
|
||||||
{
|
{
|
||||||
if (secondary_selected != m_secondarySelected) {
|
if (secondarySelected != m_secondarySelected) {
|
||||||
m_secondarySelected = secondary_selected;
|
m_secondarySelected = secondarySelected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,15 +219,15 @@ void RectangularSelectionItem::update()
|
|||||||
m_points[i]->setSecondarySelected(m_secondarySelected);
|
m_points[i]->setSecondarySelected(m_secondarySelected);
|
||||||
m_points[i]->setVisible(visible);
|
m_points[i]->setVisible(visible);
|
||||||
}
|
}
|
||||||
double horiz_center = (m_rect.left() + m_rect.right()) * 0.5;
|
double horizCenter = (m_rect.left() + m_rect.right()) * 0.5;
|
||||||
double vert_center = (m_rect.top() + m_rect.bottom()) * 0.5;
|
double vertCenter = (m_rect.top() + m_rect.bottom()) * 0.5;
|
||||||
m_points[0]->setPos(pos() + m_rect.topLeft());
|
m_points[0]->setPos(pos() + m_rect.topLeft());
|
||||||
m_points[1]->setPos(pos() + QPointF(horiz_center, m_rect.top()));
|
m_points[1]->setPos(pos() + QPointF(horizCenter, m_rect.top()));
|
||||||
m_points[2]->setPos(pos() + m_rect.topRight());
|
m_points[2]->setPos(pos() + m_rect.topRight());
|
||||||
m_points[3]->setPos(pos() + QPointF(m_rect.left(), vert_center));
|
m_points[3]->setPos(pos() + QPointF(m_rect.left(), vertCenter));
|
||||||
m_points[4]->setPos(pos() + QPointF(m_rect.right(), vert_center));
|
m_points[4]->setPos(pos() + QPointF(m_rect.right(), vertCenter));
|
||||||
m_points[5]->setPos(pos() + m_rect.bottomLeft());
|
m_points[5]->setPos(pos() + m_rect.bottomLeft());
|
||||||
m_points[6]->setPos(pos() + QPointF(horiz_center, m_rect.bottom()));
|
m_points[6]->setPos(pos() + QPointF(horizCenter, m_rect.bottom()));
|
||||||
m_points[7]->setPos(pos() + m_rect.bottomRight());
|
m_points[7]->setPos(pos() + m_rect.bottomRight());
|
||||||
|
|
||||||
if (m_showBorder) {
|
if (m_showBorder) {
|
||||||
@@ -249,11 +249,11 @@ void RectangularSelectionItem::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangularSelectionItem::moveHandle(Handle handle, const QPointF &delta_move, HandleStatus handle_status, HandleQualifier handle_qualifier)
|
void RectangularSelectionItem::moveHandle(Handle handle, const QPointF &deltaMove, HandleStatus handleStatus, HandleQualifier handleQualifier)
|
||||||
{
|
{
|
||||||
Q_UNUSED(handle_qualifier);
|
Q_UNUSED(handleQualifier);
|
||||||
|
|
||||||
if (handle_status == PRESS) {
|
if (handleStatus == PRESS) {
|
||||||
m_originalResizePos = m_itemResizer->getPos();
|
m_originalResizePos = m_itemResizer->getPos();
|
||||||
m_originalResizeRect = m_itemResizer->getRect();
|
m_originalResizeRect = m_itemResizer->getRect();
|
||||||
}
|
}
|
||||||
@@ -289,34 +289,34 @@ void RectangularSelectionItem::moveHandle(Handle handle, const QPointF &delta_mo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF minimum_size = m_itemResizer->getMinimumSize();
|
QSizeF minimumSize = m_itemResizer->getMinimumSize();
|
||||||
|
|
||||||
QPointF top_left_delta;
|
QPointF topLeftDelta;
|
||||||
QPointF bottom_right_delta;
|
QPointF bottomRightDelta;
|
||||||
|
|
||||||
// calculate movements of corners
|
// calculate movements of corners
|
||||||
if (m_freedom == FREEDOM_KEEP_RATIO) {
|
if (m_freedom == FREEDOM_KEEP_RATIO) {
|
||||||
qreal minimum_length = qSqrt(minimum_size.width() * minimum_size.width() + minimum_size.height() * minimum_size.height());
|
qreal minimumLength = qSqrt(minimumSize.width() * minimumSize.width() + minimumSize.height() * minimumSize.height());
|
||||||
QPointF v(minimum_size.width() / minimum_length, minimum_size.height() / minimum_length);
|
QPointF v(minimumSize.width() / minimumLength, minimumSize.height() / minimumLength);
|
||||||
qreal delta_length = qSqrt(delta_move.x() * delta_move.x() + delta_move.y() * delta_move.y());
|
qreal deltaLength = qSqrt(deltaMove.x() * deltaMove.x() + deltaMove.y() * deltaMove.y());
|
||||||
switch (handle) {
|
switch (handle) {
|
||||||
case HANDLE_TOP_LEFT:
|
case HANDLE_TOP_LEFT:
|
||||||
if (delta_move.x() > 0 && delta_move.y() > 0) {
|
if (deltaMove.x() > 0 && deltaMove.y() > 0) {
|
||||||
top_left_delta = v * delta_length;
|
topLeftDelta = v * deltaLength;
|
||||||
} else if (delta_move.x() < 0 && delta_move.y() < 0) {
|
} else if (deltaMove.x() < 0 && deltaMove.y() < 0) {
|
||||||
top_left_delta = -(v * delta_length);
|
topLeftDelta = -(v * deltaLength);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HANDLE_TOP:
|
case HANDLE_TOP:
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
break;
|
break;
|
||||||
case HANDLE_TOP_RIGHT:
|
case HANDLE_TOP_RIGHT:
|
||||||
if (delta_move.x() > 0 && delta_move.y() < 0) {
|
if (deltaMove.x() > 0 && deltaMove.y() < 0) {
|
||||||
top_left_delta = QPointF(0.0, -(v.x() * delta_length));
|
topLeftDelta = QPointF(0.0, -(v.x() * deltaLength));
|
||||||
bottom_right_delta = QPointF(v.y() * delta_length, 0.0);
|
bottomRightDelta = QPointF(v.y() * deltaLength, 0.0);
|
||||||
} else if (delta_move.x() < 0 && delta_move.y() > 0) {
|
} else if (deltaMove.x() < 0 && deltaMove.y() > 0) {
|
||||||
top_left_delta = QPointF(0.0, v.x() * delta_length);
|
topLeftDelta = QPointF(0.0, v.x() * deltaLength);
|
||||||
bottom_right_delta = QPointF(-(v.y() * delta_length), 0.0);
|
bottomRightDelta = QPointF(-(v.y() * deltaLength), 0.0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HANDLE_LEFT:
|
case HANDLE_LEFT:
|
||||||
@@ -326,66 +326,66 @@ void RectangularSelectionItem::moveHandle(Handle handle, const QPointF &delta_mo
|
|||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
break;
|
break;
|
||||||
case HANDLE_BOTTOM_LEFT:
|
case HANDLE_BOTTOM_LEFT:
|
||||||
if (delta_move.x() < 0 && delta_move.y() > 0) {
|
if (deltaMove.x() < 0 && deltaMove.y() > 0) {
|
||||||
top_left_delta = QPointF(-(v.x() * delta_length), 0.0);
|
topLeftDelta = QPointF(-(v.x() * deltaLength), 0.0);
|
||||||
bottom_right_delta = QPointF(0.0, v.y() * delta_length);
|
bottomRightDelta = QPointF(0.0, v.y() * deltaLength);
|
||||||
} else if (delta_move.x() > 0 && delta_move.y() < 0) {
|
} else if (deltaMove.x() > 0 && deltaMove.y() < 0) {
|
||||||
top_left_delta = QPointF(v.x() * delta_length, 0.0);
|
topLeftDelta = QPointF(v.x() * deltaLength, 0.0);
|
||||||
bottom_right_delta = QPointF(0.0, -(v.y() * delta_length));
|
bottomRightDelta = QPointF(0.0, -(v.y() * deltaLength));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HANDLE_BOTTOM:
|
case HANDLE_BOTTOM:
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
break;
|
break;
|
||||||
case HANDLE_BOTTOM_RIGHT:
|
case HANDLE_BOTTOM_RIGHT:
|
||||||
if (delta_move.x() > 0 && delta_move.y() > 0) {
|
if (deltaMove.x() > 0 && deltaMove.y() > 0) {
|
||||||
bottom_right_delta = v * delta_length;
|
bottomRightDelta = v * deltaLength;
|
||||||
} else if (delta_move.x() < 0 && delta_move.y() < 0) {
|
} else if (deltaMove.x() < 0 && deltaMove.y() < 0) {
|
||||||
bottom_right_delta = -(v * delta_length);
|
bottomRightDelta = -(v * deltaLength);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (handle) {
|
switch (handle) {
|
||||||
case HANDLE_TOP_LEFT:
|
case HANDLE_TOP_LEFT:
|
||||||
top_left_delta = delta_move;
|
topLeftDelta = deltaMove;
|
||||||
break;
|
break;
|
||||||
case HANDLE_TOP:
|
case HANDLE_TOP:
|
||||||
top_left_delta = QPointF(0.0, delta_move.y());
|
topLeftDelta = QPointF(0.0, deltaMove.y());
|
||||||
break;
|
break;
|
||||||
case HANDLE_TOP_RIGHT:
|
case HANDLE_TOP_RIGHT:
|
||||||
top_left_delta = QPointF(0, delta_move.y());
|
topLeftDelta = QPointF(0, deltaMove.y());
|
||||||
bottom_right_delta = QPointF(delta_move.x(), 0.0);
|
bottomRightDelta = QPointF(deltaMove.x(), 0.0);
|
||||||
break;
|
break;
|
||||||
case HANDLE_LEFT:
|
case HANDLE_LEFT:
|
||||||
top_left_delta = QPointF(delta_move.x(), 0.0);
|
topLeftDelta = QPointF(deltaMove.x(), 0.0);
|
||||||
break;
|
break;
|
||||||
case HANDLE_RIGHT:
|
case HANDLE_RIGHT:
|
||||||
bottom_right_delta = QPointF(delta_move.x(), 0.0);
|
bottomRightDelta = QPointF(deltaMove.x(), 0.0);
|
||||||
break;
|
break;
|
||||||
case HANDLE_BOTTOM_LEFT:
|
case HANDLE_BOTTOM_LEFT:
|
||||||
top_left_delta = QPointF(delta_move.x(), 0.0);
|
topLeftDelta = QPointF(deltaMove.x(), 0.0);
|
||||||
bottom_right_delta = QPointF(0.0, delta_move.y());
|
bottomRightDelta = QPointF(0.0, deltaMove.y());
|
||||||
break;
|
break;
|
||||||
case HANDLE_BOTTOM:
|
case HANDLE_BOTTOM:
|
||||||
bottom_right_delta = QPointF(0.0, delta_move.y());
|
bottomRightDelta = QPointF(0.0, deltaMove.y());
|
||||||
break;
|
break;
|
||||||
case HANDLE_BOTTOM_RIGHT:
|
case HANDLE_BOTTOM_RIGHT:
|
||||||
bottom_right_delta = delta_move;
|
bottomRightDelta = deltaMove;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF new_rect = m_originalResizeRect.adjusted(top_left_delta.x(), top_left_delta.y(), bottom_right_delta.x(), bottom_right_delta.y());
|
QRectF newRect = m_originalResizeRect.adjusted(topLeftDelta.x(), topLeftDelta.y(), bottomRightDelta.x(), bottomRightDelta.y());
|
||||||
QSizeF size_delta = minimum_size - new_rect.size();
|
QSizeF sizeDelta = minimumSize - newRect.size();
|
||||||
|
|
||||||
// correct horizontal resize against minimum width
|
// correct horizontal resize against minimum width
|
||||||
switch (handle) {
|
switch (handle) {
|
||||||
case HANDLE_TOP_LEFT:
|
case HANDLE_TOP_LEFT:
|
||||||
case HANDLE_LEFT:
|
case HANDLE_LEFT:
|
||||||
case HANDLE_BOTTOM_LEFT:
|
case HANDLE_BOTTOM_LEFT:
|
||||||
if (size_delta.width() > 0.0) {
|
if (sizeDelta.width() > 0.0) {
|
||||||
top_left_delta.setX(top_left_delta.x() - size_delta.width());
|
topLeftDelta.setX(topLeftDelta.x() - sizeDelta.width());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HANDLE_TOP:
|
case HANDLE_TOP:
|
||||||
@@ -394,8 +394,8 @@ void RectangularSelectionItem::moveHandle(Handle handle, const QPointF &delta_mo
|
|||||||
case HANDLE_TOP_RIGHT:
|
case HANDLE_TOP_RIGHT:
|
||||||
case HANDLE_RIGHT:
|
case HANDLE_RIGHT:
|
||||||
case HANDLE_BOTTOM_RIGHT:
|
case HANDLE_BOTTOM_RIGHT:
|
||||||
if (size_delta.width() > 0.0) {
|
if (sizeDelta.width() > 0.0) {
|
||||||
bottom_right_delta.setX(bottom_right_delta.x() + size_delta.width());
|
bottomRightDelta.setX(bottomRightDelta.x() + sizeDelta.width());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -405,8 +405,8 @@ void RectangularSelectionItem::moveHandle(Handle handle, const QPointF &delta_mo
|
|||||||
case HANDLE_TOP_LEFT:
|
case HANDLE_TOP_LEFT:
|
||||||
case HANDLE_TOP:
|
case HANDLE_TOP:
|
||||||
case HANDLE_TOP_RIGHT:
|
case HANDLE_TOP_RIGHT:
|
||||||
if (size_delta.height() > 0.0) {
|
if (sizeDelta.height() > 0.0) {
|
||||||
top_left_delta.setY(top_left_delta.y() - size_delta.height());
|
topLeftDelta.setY(topLeftDelta.y() - sizeDelta.height());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HANDLE_LEFT:
|
case HANDLE_LEFT:
|
||||||
@@ -415,15 +415,15 @@ void RectangularSelectionItem::moveHandle(Handle handle, const QPointF &delta_mo
|
|||||||
case HANDLE_BOTTOM_LEFT:
|
case HANDLE_BOTTOM_LEFT:
|
||||||
case HANDLE_BOTTOM:
|
case HANDLE_BOTTOM:
|
||||||
case HANDLE_BOTTOM_RIGHT:
|
case HANDLE_BOTTOM_RIGHT:
|
||||||
if (size_delta.height() > 0.0) {
|
if (sizeDelta.height() > 0.0) {
|
||||||
bottom_right_delta.setY(bottom_right_delta.y() + size_delta.height());
|
bottomRightDelta.setY(bottomRightDelta.y() + sizeDelta.height());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_itemResizer->setPosAndRect(m_originalResizePos, m_originalResizeRect, top_left_delta, bottom_right_delta);
|
m_itemResizer->setPosAndRect(m_originalResizePos, m_originalResizeRect, topLeftDelta, bottomRightDelta);
|
||||||
|
|
||||||
if (handle_status == RELEASE) {
|
if (handleStatus == RELEASE) {
|
||||||
IResizable::Side horiz = IResizable::SIDE_NONE;
|
IResizable::Side horiz = IResizable::SIDE_NONE;
|
||||||
IResizable::Side vert = IResizable::SIDE_NONE;
|
IResizable::Side vert = IResizable::SIDE_NONE;
|
||||||
switch (handle) {
|
switch (handle) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RectangularSelectionItem(IResizable *item_resizer, QGraphicsItem *parent = 0);
|
RectangularSelectionItem(IResizable *itemResizer, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~RectangularSelectionItem();
|
~RectangularSelectionItem();
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
|
|
||||||
bool getShowBorder() const { return m_showBorder; }
|
bool getShowBorder() const { return m_showBorder; }
|
||||||
|
|
||||||
void setShowBorder(bool show_border);
|
void setShowBorder(bool showBorder);
|
||||||
|
|
||||||
Freedom getFreedom() const { return m_freedom; }
|
Freedom getFreedom() const { return m_freedom; }
|
||||||
|
|
||||||
@@ -118,13 +118,13 @@ public:
|
|||||||
|
|
||||||
bool isSecondarySelected() const { return m_secondarySelected; }
|
bool isSecondarySelected() const { return m_secondarySelected; }
|
||||||
|
|
||||||
void setSecondarySelected(bool secondary_selected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void moveHandle(Handle handle, const QPointF &delta_move, HandleStatus handle_status, HandleQualifier handle_qualifier);
|
void moveHandle(Handle handle, const QPointF &deltaMove, HandleStatus handleStatus, HandleQualifier handleQualifier);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -45,10 +45,10 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
RelationStarter::RelationStarter(IRelationable *owner, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent)
|
RelationStarter::RelationStarter(IRelationable *owner, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsRectItem(parent),
|
: QGraphicsRectItem(parent),
|
||||||
m_owner(owner),
|
m_owner(owner),
|
||||||
m_diagramSceneModel(diagram_scene_model),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
m_currentPreviewArrow(0)
|
m_currentPreviewArrow(0)
|
||||||
{
|
{
|
||||||
setBrush(QBrush(QColor(192, 192, 192)));
|
setBrush(QBrush(QColor(192, 192, 192)));
|
||||||
@@ -78,7 +78,7 @@ void RelationStarter::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationStarter::addArrow(const QString &id, ArrowItem::Shaft shaft, ArrowItem::Head end_head, ArrowItem::Head start_head)
|
void RelationStarter::addArrow(const QString &id, ArrowItem::Shaft shaft, ArrowItem::Head endHead, ArrowItem::Head startHead)
|
||||||
{
|
{
|
||||||
QMT_CHECK(!id.isEmpty());
|
QMT_CHECK(!id.isEmpty());
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
@@ -86,8 +86,8 @@ void RelationStarter::addArrow(const QString &id, ArrowItem::Shaft shaft, ArrowI
|
|||||||
arrow->setArrowSize(10.0);
|
arrow->setArrowSize(10.0);
|
||||||
arrow->setDiamondSize(15.0);
|
arrow->setDiamondSize(15.0);
|
||||||
arrow->setShaft(shaft);
|
arrow->setShaft(shaft);
|
||||||
arrow->setStartHead(start_head);
|
arrow->setStartHead(startHead);
|
||||||
arrow->setEndHead(end_head);
|
arrow->setEndHead(endHead);
|
||||||
arrow->setPoints(QList<QPointF>() << QPointF(0.0, 10.0) << QPointF(15.0, 0.0));
|
arrow->setPoints(QList<QPointF>() << QPointF(0.0, 10.0) << QPointF(15.0, 0.0));
|
||||||
arrow->setPos(6.0, m_arrows.size() * 20.0 + 8.0);
|
arrow->setPos(6.0, m_arrows.size() * 20.0 + 8.0);
|
||||||
arrow->update(m_diagramSceneModel->getStyleController()->getRelationStarterStyle());
|
arrow->update(m_diagramSceneModel->getStyleController()->getRelationStarterStyle());
|
||||||
@@ -154,11 +154,11 @@ void RelationStarter::keyPressEvent(QKeyEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationStarter::updateCurrentPreviewArrow(const QPointF &head_point)
|
void RelationStarter::updateCurrentPreviewArrow(const QPointF &headPoint)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
m_currentPreviewArrow->setPoints(QList<QPointF>() << m_owner->getRelationStartPos()
|
m_currentPreviewArrow->setPoints(QList<QPointF>() << m_owner->getRelationStartPos()
|
||||||
<< m_currentPreviewArrowIntermediatePoints << head_point);
|
<< m_currentPreviewArrowIntermediatePoints << headPoint);
|
||||||
m_currentPreviewArrow->update(m_diagramSceneModel->getStyleController()->getRelationStarterStyle());
|
m_currentPreviewArrow->update(m_diagramSceneModel->getStyleController()->getRelationStarterStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class RelationStarter :
|
|||||||
public QGraphicsRectItem
|
public QGraphicsRectItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RelationStarter(IRelationable *owner, DiagramSceneModel *diagram_scene_model, QGraphicsItem *parent = 0);
|
RelationStarter(IRelationable *owner, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~RelationStarter();
|
~RelationStarter();
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void addArrow(const QString &id, ArrowItem::Shaft shaft, ArrowItem::Head end_head, ArrowItem::Head start_head = ArrowItem::HEAD_NONE);
|
void addArrow(const QString &id, ArrowItem::Shaft shaft, ArrowItem::Head endHead, ArrowItem::Head startHead = ArrowItem::HEAD_NONE);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void updateCurrentPreviewArrow(const QPointF &head_point);
|
void updateCurrentPreviewArrow(const QPointF &headPoint);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -63,39 +63,39 @@ void TemplateParameterBox::setTextBrush(const QBrush &brush)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemplateParameterBox::setTemplateParameters(const QList<QString> &template_parameters)
|
void TemplateParameterBox::setTemplateParameters(const QList<QString> &templateParameters)
|
||||||
{
|
{
|
||||||
if (m_templateParameters != template_parameters) {
|
if (m_templateParameters != templateParameters) {
|
||||||
m_templateParameters = template_parameters;
|
m_templateParameters = templateParameters;
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemplateParameterBox::setBreakLines(bool break_lines)
|
void TemplateParameterBox::setBreakLines(bool breakLines)
|
||||||
{
|
{
|
||||||
if (break_lines != m_breakLines) {
|
if (breakLines != m_breakLines) {
|
||||||
m_breakLines = break_lines;
|
m_breakLines = breakLines;
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemplateParameterBox::updateText()
|
void TemplateParameterBox::updateText()
|
||||||
{
|
{
|
||||||
QString template_text;
|
QString templateText;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach (const QString ¶meter, m_templateParameters) {
|
foreach (const QString ¶meter, m_templateParameters) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
if (m_breakLines) {
|
if (m_breakLines) {
|
||||||
template_text += QLatin1Char('\n');
|
templateText += QLatin1Char('\n');
|
||||||
} else {
|
} else {
|
||||||
template_text += QStringLiteral(", ");
|
templateText += QStringLiteral(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template_text += parameter;
|
templateText += parameter;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (template_text != m_parametersText->text()) {
|
if (templateText != m_parametersText->text()) {
|
||||||
m_parametersText->setText(template_text);
|
m_parametersText->setText(templateText);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ public:
|
|||||||
|
|
||||||
void setTextBrush(const QBrush &brush);
|
void setTextBrush(const QBrush &brush);
|
||||||
|
|
||||||
void setTemplateParameters(const QList<QString> &template_parameters);
|
void setTemplateParameters(const QList<QString> &templateParameters);
|
||||||
|
|
||||||
void setBreakLines(bool break_lines);
|
void setBreakLines(bool breakLines);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace qmt {
|
|||||||
|
|
||||||
class DiagramsManager::ManagedDiagram {
|
class DiagramsManager::ManagedDiagram {
|
||||||
public:
|
public:
|
||||||
ManagedDiagram(DiagramSceneModel *diagram_scene_model, const QString &diagram_name);
|
ManagedDiagram(DiagramSceneModel *diagramSceneModel, const QString &diagramName);
|
||||||
|
|
||||||
~ManagedDiagram();
|
~ManagedDiagram();
|
||||||
|
|
||||||
@@ -62,9 +62,9 @@ private:
|
|||||||
QString m_diagramName;
|
QString m_diagramName;
|
||||||
};
|
};
|
||||||
|
|
||||||
DiagramsManager::ManagedDiagram::ManagedDiagram(DiagramSceneModel *diagram_scene_model, const QString &diagram_name)
|
DiagramsManager::ManagedDiagram::ManagedDiagram(DiagramSceneModel *diagramSceneModel, const QString &diagramName)
|
||||||
: m_diagramSceneModel(diagram_scene_model),
|
: m_diagramSceneModel(diagramSceneModel),
|
||||||
m_diagramName(diagram_name)
|
m_diagramName(diagramName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,67 +100,67 @@ void DiagramsManager::setModel(TreeModel *model)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsManager::setDiagramsView(DiagramsViewInterface *diagrams_view)
|
void DiagramsManager::setDiagramsView(DiagramsViewInterface *diagramsView)
|
||||||
{
|
{
|
||||||
m_diagramsView = diagrams_view;
|
m_diagramsView = diagramsView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsManager::setDiagramController(DiagramController *diagram_controller)
|
void DiagramsManager::setDiagramController(DiagramController *diagramController)
|
||||||
{
|
{
|
||||||
if (m_diagramController) {
|
if (m_diagramController) {
|
||||||
connect(m_diagramController, 0, this, 0);
|
connect(m_diagramController, 0, this, 0);
|
||||||
}
|
}
|
||||||
m_diagramController = diagram_controller;
|
m_diagramController = diagramController;
|
||||||
if (diagram_controller) {
|
if (diagramController) {
|
||||||
connect(diagram_controller, SIGNAL(diagramAboutToBeRemoved(const MDiagram*)), this, SLOT(removeDiagram(const MDiagram*)));
|
connect(diagramController, SIGNAL(diagramAboutToBeRemoved(const MDiagram*)), this, SLOT(removeDiagram(const MDiagram*)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsManager::setDiagramSceneController(DiagramSceneController *diagram_scene_controller)
|
void DiagramsManager::setDiagramSceneController(DiagramSceneController *diagramSceneController)
|
||||||
{
|
{
|
||||||
m_diagramSceneController = diagram_scene_controller;
|
m_diagramSceneController = diagramSceneController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsManager::setStyleController(StyleController *style_controller)
|
void DiagramsManager::setStyleController(StyleController *styleController)
|
||||||
{
|
{
|
||||||
m_styleController = style_controller;
|
m_styleController = styleController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsManager::setStereotypeController(StereotypeController *stereotype_controller)
|
void DiagramsManager::setStereotypeController(StereotypeController *stereotypeController)
|
||||||
{
|
{
|
||||||
m_stereotypeController = stereotype_controller;
|
m_stereotypeController = stereotypeController;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagramSceneModel *DiagramsManager::bindDiagramSceneModel(MDiagram *diagram)
|
DiagramSceneModel *DiagramsManager::bindDiagramSceneModel(MDiagram *diagram)
|
||||||
{
|
{
|
||||||
if (!m_diagramUidToManagedDiagramMap.contains(diagram->getUid())) {
|
if (!m_diagramUidToManagedDiagramMap.contains(diagram->getUid())) {
|
||||||
DiagramSceneModel *diagram_scene_model = new DiagramSceneModel();
|
DiagramSceneModel *diagramSceneModel = new DiagramSceneModel();
|
||||||
diagram_scene_model->setDiagramController(m_diagramController);
|
diagramSceneModel->setDiagramController(m_diagramController);
|
||||||
diagram_scene_model->setDiagramSceneController(m_diagramSceneController);
|
diagramSceneModel->setDiagramSceneController(m_diagramSceneController);
|
||||||
diagram_scene_model->setStyleController(m_styleController);
|
diagramSceneModel->setStyleController(m_styleController);
|
||||||
diagram_scene_model->setStereotypeController(m_stereotypeController);
|
diagramSceneModel->setStereotypeController(m_stereotypeController);
|
||||||
diagram_scene_model->setDiagram(diagram);
|
diagramSceneModel->setDiagram(diagram);
|
||||||
connect(diagram_scene_model, SIGNAL(diagramSceneActivated(const MDiagram*)), this, SIGNAL(diagramActivated(const MDiagram*)));
|
connect(diagramSceneModel, SIGNAL(diagramSceneActivated(const MDiagram*)), this, SIGNAL(diagramActivated(const MDiagram*)));
|
||||||
connect(diagram_scene_model, SIGNAL(selectionChanged(const MDiagram*)), this, SIGNAL(diagramSelectionChanged(const MDiagram*)));
|
connect(diagramSceneModel, SIGNAL(selectionChanged(const MDiagram*)), this, SIGNAL(diagramSelectionChanged(const MDiagram*)));
|
||||||
ManagedDiagram *managed_diagram = new ManagedDiagram(diagram_scene_model, diagram->getName());
|
ManagedDiagram *managedDiagram = new ManagedDiagram(diagramSceneModel, diagram->getName());
|
||||||
m_diagramUidToManagedDiagramMap.insert(diagram->getUid(), managed_diagram);
|
m_diagramUidToManagedDiagramMap.insert(diagram->getUid(), managedDiagram);
|
||||||
}
|
}
|
||||||
return getDiagramSceneModel(diagram);
|
return getDiagramSceneModel(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagramSceneModel *DiagramsManager::getDiagramSceneModel(const MDiagram *diagram) const
|
DiagramSceneModel *DiagramsManager::getDiagramSceneModel(const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
const ManagedDiagram *managed_diagram = m_diagramUidToManagedDiagramMap.value(diagram->getUid());
|
const ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.value(diagram->getUid());
|
||||||
QMT_CHECK(managed_diagram);
|
QMT_CHECK(managedDiagram);
|
||||||
return managed_diagram->getDiagramSceneModel();
|
return managedDiagram->getDiagramSceneModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsManager::unbindDiagramSceneModel(const MDiagram *diagram)
|
void DiagramsManager::unbindDiagramSceneModel(const MDiagram *diagram)
|
||||||
{
|
{
|
||||||
QMT_CHECK(diagram);
|
QMT_CHECK(diagram);
|
||||||
ManagedDiagram *managed_diagram = m_diagramUidToManagedDiagramMap.take(diagram->getUid());
|
ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.take(diagram->getUid());
|
||||||
QMT_CHECK(managed_diagram);
|
QMT_CHECK(managedDiagram);
|
||||||
delete managed_diagram;
|
delete managedDiagram;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsManager::openDiagram(MDiagram *diagram)
|
void DiagramsManager::openDiagram(MDiagram *diagram)
|
||||||
@@ -173,8 +173,8 @@ void DiagramsManager::openDiagram(MDiagram *diagram)
|
|||||||
void DiagramsManager::removeDiagram(const MDiagram *diagram)
|
void DiagramsManager::removeDiagram(const MDiagram *diagram)
|
||||||
{
|
{
|
||||||
if (diagram) {
|
if (diagram) {
|
||||||
ManagedDiagram *managed_diagram = m_diagramUidToManagedDiagramMap.value(diagram->getUid());
|
ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.value(diagram->getUid());
|
||||||
if (managed_diagram) {
|
if (managedDiagram) {
|
||||||
if (m_diagramsView) {
|
if (m_diagramsView) {
|
||||||
// closeDiagram() must call unbindDiagramSceneModel()
|
// closeDiagram() must call unbindDiagramSceneModel()
|
||||||
m_diagramsView->closeDiagram(diagram);
|
m_diagramsView->closeDiagram(diagram);
|
||||||
@@ -199,9 +199,9 @@ void DiagramsManager::onDataChanged(const QModelIndex &topleft, const QModelInde
|
|||||||
QModelIndex index = m_model->index(row, 0, topleft.parent());
|
QModelIndex index = m_model->index(row, 0, topleft.parent());
|
||||||
MDiagram *diagram = dynamic_cast<MDiagram *>(m_model->getElement(index));
|
MDiagram *diagram = dynamic_cast<MDiagram *>(m_model->getElement(index));
|
||||||
if (diagram) {
|
if (diagram) {
|
||||||
ManagedDiagram *managed_diagram = m_diagramUidToManagedDiagramMap.value(diagram->getUid());
|
ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.value(diagram->getUid());
|
||||||
if (managed_diagram && managed_diagram->getDiagramName() != diagram->getName()) {
|
if (managedDiagram && managedDiagram->getDiagramName() != diagram->getName()) {
|
||||||
managed_diagram->setDiagramName(diagram->getName());
|
managedDiagram->setDiagramName(diagram->getName());
|
||||||
if (m_diagramsView) {
|
if (m_diagramsView) {
|
||||||
m_diagramsView->onDiagramRenamed(diagram);
|
m_diagramsView->onDiagramRenamed(diagram);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,15 +83,15 @@ public:
|
|||||||
|
|
||||||
void setModel(TreeModel *model);
|
void setModel(TreeModel *model);
|
||||||
|
|
||||||
void setDiagramsView(DiagramsViewInterface *diagrams_view);
|
void setDiagramsView(DiagramsViewInterface *diagramsView);
|
||||||
|
|
||||||
void setDiagramController(DiagramController *diagram_controller);
|
void setDiagramController(DiagramController *diagramController);
|
||||||
|
|
||||||
void setDiagramSceneController(DiagramSceneController *diagram_scene_controller);
|
void setDiagramSceneController(DiagramSceneController *diagramSceneController);
|
||||||
|
|
||||||
void setStyleController(StyleController *style_controller);
|
void setStyleController(StyleController *styleController);
|
||||||
|
|
||||||
void setStereotypeController(StereotypeController *stereotype_controller);
|
void setStereotypeController(StereotypeController *stereotypeController);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ SceneInspector::~SceneInspector()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneInspector::setDiagramsManager(DiagramsManager *diagrams_manager)
|
void SceneInspector::setDiagramsManager(DiagramsManager *diagramsManager)
|
||||||
{
|
{
|
||||||
m_diagramsManager = diagrams_manager;
|
m_diagramsManager = diagramsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF SceneInspector::getRasterSize() const
|
QSizeF SceneInspector::getRasterSize() const
|
||||||
@@ -64,10 +64,10 @@ QSizeF SceneInspector::getRasterSize() const
|
|||||||
|
|
||||||
QSizeF SceneInspector::getMinimalSize(const DElement *element, const MDiagram *diagram) const
|
QSizeF SceneInspector::getMinimalSize(const DElement *element, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
DiagramSceneModel *diagram_scene_model = m_diagramsManager->getDiagramSceneModel(diagram);
|
DiagramSceneModel *diagramSceneModel = m_diagramsManager->getDiagramSceneModel(diagram);
|
||||||
QMT_CHECK(diagram_scene_model);
|
QMT_CHECK(diagramSceneModel);
|
||||||
if (diagram_scene_model) {
|
if (diagramSceneModel) {
|
||||||
const QGraphicsItem *item = diagram_scene_model->getGraphicsItem(const_cast<DElement *>(element));
|
const QGraphicsItem *item = diagramSceneModel->getGraphicsItem(const_cast<DElement *>(element));
|
||||||
QMT_CHECK(item);
|
QMT_CHECK(item);
|
||||||
if (item) {
|
if (item) {
|
||||||
if (const IResizable *resizable = dynamic_cast<const IResizable *>(item)) {
|
if (const IResizable *resizable = dynamic_cast<const IResizable *>(item)) {
|
||||||
@@ -81,10 +81,10 @@ QSizeF SceneInspector::getMinimalSize(const DElement *element, const MDiagram *d
|
|||||||
|
|
||||||
IMoveable *SceneInspector::getMoveable(const DElement *element, const MDiagram *diagram) const
|
IMoveable *SceneInspector::getMoveable(const DElement *element, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
DiagramSceneModel *diagram_scene_model = m_diagramsManager->getDiagramSceneModel(diagram);
|
DiagramSceneModel *diagramSceneModel = m_diagramsManager->getDiagramSceneModel(diagram);
|
||||||
QMT_CHECK(diagram_scene_model);
|
QMT_CHECK(diagramSceneModel);
|
||||||
if (diagram_scene_model) {
|
if (diagramSceneModel) {
|
||||||
QGraphicsItem *item = diagram_scene_model->getGraphicsItem(const_cast<DElement *>(element));
|
QGraphicsItem *item = diagramSceneModel->getGraphicsItem(const_cast<DElement *>(element));
|
||||||
QMT_CHECK(item);
|
QMT_CHECK(item);
|
||||||
if (item) {
|
if (item) {
|
||||||
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item)) {
|
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item)) {
|
||||||
@@ -98,10 +98,10 @@ IMoveable *SceneInspector::getMoveable(const DElement *element, const MDiagram *
|
|||||||
|
|
||||||
IResizable *SceneInspector::getResizable(const DElement *element, const MDiagram *diagram) const
|
IResizable *SceneInspector::getResizable(const DElement *element, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
DiagramSceneModel *diagram_scene_model = m_diagramsManager->getDiagramSceneModel(diagram);
|
DiagramSceneModel *diagramSceneModel = m_diagramsManager->getDiagramSceneModel(diagram);
|
||||||
QMT_CHECK(diagram_scene_model);
|
QMT_CHECK(diagramSceneModel);
|
||||||
if (diagram_scene_model) {
|
if (diagramSceneModel) {
|
||||||
QGraphicsItem *item = diagram_scene_model->getGraphicsItem(const_cast<DElement *>(element));
|
QGraphicsItem *item = diagramSceneModel->getGraphicsItem(const_cast<DElement *>(element));
|
||||||
QMT_CHECK(item);
|
QMT_CHECK(item);
|
||||||
if (item) {
|
if (item) {
|
||||||
if (IResizable *resizeable = dynamic_cast<IResizable *>(item)) {
|
if (IResizable *resizeable = dynamic_cast<IResizable *>(item)) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setDiagramsManager(DiagramsManager *diagrams_manager);
|
void setDiagramsManager(DiagramsManager *diagramsManager);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -56,24 +56,24 @@ DiagramsView::~DiagramsView()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsView::setDiagramsManager(DiagramsManager *diagrams_manager)
|
void DiagramsView::setDiagramsManager(DiagramsManager *diagramsManager)
|
||||||
{
|
{
|
||||||
m_diagramsManager = diagrams_manager;
|
m_diagramsManager = diagramsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsView::openDiagram(MDiagram *diagram)
|
void DiagramsView::openDiagram(MDiagram *diagram)
|
||||||
{
|
{
|
||||||
QMT_CHECK(diagram);
|
QMT_CHECK(diagram);
|
||||||
DiagramView *diagram_view = m_diagramViews.value(diagram->getUid());
|
DiagramView *diagramView = m_diagramViews.value(diagram->getUid());
|
||||||
if (!diagram_view) {
|
if (!diagramView) {
|
||||||
DiagramSceneModel *diagram_scene_model = m_diagramsManager->bindDiagramSceneModel(diagram);
|
DiagramSceneModel *diagramSceneModel = m_diagramsManager->bindDiagramSceneModel(diagram);
|
||||||
DiagramView *diagram_view = new DiagramView(this);
|
DiagramView *diagramView = new DiagramView(this);
|
||||||
diagram_view->setDiagramSceneModel(diagram_scene_model);
|
diagramView->setDiagramSceneModel(diagramSceneModel);
|
||||||
int tab_index = addTab(diagram_view, diagram->getName());
|
int tabIndex = addTab(diagramView, diagram->getName());
|
||||||
setCurrentIndex(tab_index);
|
setCurrentIndex(tabIndex);
|
||||||
m_diagramViews.insert(diagram->getUid(), diagram_view);
|
m_diagramViews.insert(diagram->getUid(), diagramView);
|
||||||
} else {
|
} else {
|
||||||
setCurrentWidget(diagram_view);
|
setCurrentWidget(diagramView);
|
||||||
}
|
}
|
||||||
emit someDiagramOpened(!m_diagramViews.isEmpty());
|
emit someDiagramOpened(!m_diagramViews.isEmpty());
|
||||||
}
|
}
|
||||||
@@ -84,10 +84,10 @@ void DiagramsView::closeDiagram(const MDiagram *diagram)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagramView *diagram_view = m_diagramViews.value(diagram->getUid());
|
DiagramView *diagramView = m_diagramViews.value(diagram->getUid());
|
||||||
if (diagram_view) {
|
if (diagramView) {
|
||||||
removeTab(indexOf(diagram_view));
|
removeTab(indexOf(diagramView));
|
||||||
delete diagram_view;
|
delete diagramView;
|
||||||
m_diagramViews.remove(diagram->getUid());
|
m_diagramViews.remove(diagram->getUid());
|
||||||
}
|
}
|
||||||
emit someDiagramOpened(!m_diagramViews.isEmpty());
|
emit someDiagramOpened(!m_diagramViews.isEmpty());
|
||||||
@@ -96,24 +96,24 @@ void DiagramsView::closeDiagram(const MDiagram *diagram)
|
|||||||
void DiagramsView::closeAllDiagrams()
|
void DiagramsView::closeAllDiagrams()
|
||||||
{
|
{
|
||||||
for (int i = count() - 1; i >= 0; --i) {
|
for (int i = count() - 1; i >= 0; --i) {
|
||||||
DiagramView *diagram_view = dynamic_cast<DiagramView *>(widget(i));
|
DiagramView *diagramView = dynamic_cast<DiagramView *>(widget(i));
|
||||||
if (diagram_view) {
|
if (diagramView) {
|
||||||
removeTab(i);
|
removeTab(i);
|
||||||
delete diagram_view;
|
delete diagramView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_diagramViews.clear();
|
m_diagramViews.clear();
|
||||||
emit someDiagramOpened(!m_diagramViews.isEmpty());
|
emit someDiagramOpened(!m_diagramViews.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsView::onCurrentChanged(int tab_index)
|
void DiagramsView::onCurrentChanged(int tabIndex)
|
||||||
{
|
{
|
||||||
emit currentDiagramChanged(getDiagram(tab_index));
|
emit currentDiagramChanged(getDiagram(tabIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsView::onTabCloseRequested(int tab_index)
|
void DiagramsView::onTabCloseRequested(int tabIndex)
|
||||||
{
|
{
|
||||||
emit diagramCloseRequested(getDiagram(tab_index));
|
emit diagramCloseRequested(getDiagram(tabIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramsView::onDiagramRenamed(const MDiagram *diagram)
|
void DiagramsView::onDiagramRenamed(const MDiagram *diagram)
|
||||||
@@ -121,24 +121,24 @@ void DiagramsView::onDiagramRenamed(const MDiagram *diagram)
|
|||||||
if (!diagram) {
|
if (!diagram) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DiagramView *diagram_view = m_diagramViews.value(diagram->getUid());
|
DiagramView *diagramView = m_diagramViews.value(diagram->getUid());
|
||||||
if (diagram_view) {
|
if (diagramView) {
|
||||||
setTabText(indexOf(diagram_view), diagram->getName());
|
setTabText(indexOf(diagramView), diagram->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MDiagram *DiagramsView::getDiagram(int tab_index) const
|
MDiagram *DiagramsView::getDiagram(int tabIndex) const
|
||||||
{
|
{
|
||||||
DiagramView *diagram_view = dynamic_cast<DiagramView *>(widget(tab_index));
|
DiagramView *diagramView = dynamic_cast<DiagramView *>(widget(tabIndex));
|
||||||
return getDiagram(diagram_view);
|
return getDiagram(diagramView);
|
||||||
}
|
}
|
||||||
|
|
||||||
MDiagram *DiagramsView::getDiagram(DiagramView *diagram_view) const
|
MDiagram *DiagramsView::getDiagram(DiagramView *diagramView) const
|
||||||
{
|
{
|
||||||
if (!diagram_view || diagram_view->getDiagramSceneModel()) {
|
if (!diagramView || diagramView->getDiagramSceneModel()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return diagram_view->getDiagramSceneModel()->getDiagram();
|
return diagramView->getDiagramSceneModel()->getDiagram();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ signals:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setDiagramsManager(DiagramsManager *diagrams_manager);
|
void setDiagramsManager(DiagramsManager *diagramsManager);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
@@ -84,15 +84,15 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onCurrentChanged(int tab_index);
|
void onCurrentChanged(int tabIndex);
|
||||||
|
|
||||||
void onTabCloseRequested(int tab_index);
|
void onTabCloseRequested(int tabIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MDiagram *getDiagram(int tab_index) const;
|
MDiagram *getDiagram(int tabIndex) const;
|
||||||
|
|
||||||
MDiagram *getDiagram(DiagramView * diagram_view) const;
|
MDiagram *getDiagram(DiagramView * diagramView) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user