Skip to content

Commit

Permalink
qrmc :(
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaLitvinova committed Aug 13, 2012
1 parent 770eb19 commit 5e3508b
Show file tree
Hide file tree
Showing 35 changed files with 163 additions and 58 deletions.
11 changes: 6 additions & 5 deletions plugins/metaEditor/metaEditorSupport/metaEditorSupportPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ QList<ActionInfo> MetaEditorSupportPlugin::actions()
ActionInfo generateEditorForQrxcActionInfo(&mGenerateEditorForQrxcAction, "generators", "tools");
connect(&mGenerateEditorForQrxcAction, SIGNAL(triggered()), this, SLOT(generateEditorForQrxc()));

/*mGenerateEditorWithQrmcAction.setText(tr("Generate editor (qrmc)"));
mGenerateEditorWithQrmcAction.setText(tr("Generate editor (qrmc)"));
ActionInfo generateEditorWithQrmcActionInfo(&mGenerateEditorWithQrmcAction, "generators", "tools");
connect(&mGenerateEditorWithQrmcAction, SIGNAL(triggered()), this, SLOT(generateEditorWithQrmc()));

/*
mParseEditorXmlAction.setText(tr("Parse editor xml"));
ActionInfo parseEditorXmlActionInfo(&mParseEditorXmlAction, "generators", "tools");
connect(&mParseEditorXmlAction, SIGNAL(triggered()), this, SLOT(parseEditorXml()));
*/

return QList<ActionInfo>() << generateEditorForQrxcActionInfo;
//<< generateEditorWithQrmcActionInfo
return QList<ActionInfo>() << generateEditorForQrxcActionInfo
<< generateEditorWithQrmcActionInfo;
//<< parseEditorXmlActionInfo;
}

Expand Down Expand Up @@ -99,7 +100,7 @@ void MetaEditorSupportPlugin::generateEditorForQrxc()

void MetaEditorSupportPlugin::generateEditorWithQrmc()
{
qrmc::MetaCompiler metaCompiler(qApp->applicationDirPath() + "/../qrmc", mRepoControlApi->workingFile());
qrmc::MetaCompiler metaCompiler(qApp->applicationDirPath() + "/../qrmc", mLogicalRepoApi);

IdList const metamodels = mLogicalRepoApi->children(Id::rootId());

Expand All @@ -119,7 +120,7 @@ void MetaEditorSupportPlugin::generateEditorWithQrmc()

foreach (Id const &key, metamodels) {
QString const objectType = key.element();
if (objectType == "MetamodelDiagram") {
if (objectType == "MetamodelDiagram" && mLogicalRepoApi->isLogicalElement(key)) {
QString name = mLogicalRepoApi->stringProperty(key, "name of the directory");
if (QMessageBox::question(mMainWindowInterface->windowWidget()
, tr("loading..")
Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/edgeType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using namespace qrmc;
using namespace qReal;

EdgeType::EdgeType(Diagram *diagram, qrRepo::RepoApi *api, const qReal::Id &id) : GraphicType(diagram, api, id)
EdgeType::EdgeType(Diagram *diagram, qrRepo::LogicalRepoApi *api, const qReal::Id &id) : GraphicType(diagram, api, id)
{
mLineType = mApi->stringProperty(id, "lineType");
initLabels();
Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/edgeType.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace qrmc {
class EdgeType : public GraphicType
{
public:
EdgeType(Diagram *diagram, qrRepo::RepoApi *api, qReal::Id const &id);
EdgeType(Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id const &id);
virtual Type* clone() const;
virtual ~EdgeType();

Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/enumType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using namespace qReal;
using namespace qrmc;

EnumType::EnumType(Diagram *diagram, qrRepo::RepoApi *api, const qReal::Id &id) : NonGraphicType(diagram, api, id)
EnumType::EnumType(Diagram *diagram, qrRepo::LogicalRepoApi *api, const qReal::Id &id) : NonGraphicType(diagram, api, id)
{
}

Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/enumType.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace qrmc {
class EnumType : public NonGraphicType
{
public:
EnumType(Diagram *diagram, qrRepo::RepoApi *api, qReal::Id const &id);
EnumType(Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id const &id);

virtual bool init(QString const &context);
virtual Type* clone() const;
Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/graphicType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GraphicType::ResolvingHelper::ResolvingHelper(bool &resolvingFlag)
mResolvingFlag = true;
}

GraphicType::GraphicType(Diagram *diagram, qrRepo::RepoApi *api, const qReal::Id &id)
GraphicType::GraphicType(Diagram *diagram, qrRepo::LogicalRepoApi *api, const qReal::Id &id)
: Type(false, diagram, api, id), mResolving(false)
{
}
Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/graphicType.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace qrmc {
class GraphicType : public Type
{
public:
GraphicType(Diagram *diagram, qrRepo::RepoApi *api, qReal::Id const &id);
GraphicType(Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id const &id);
virtual ~GraphicType();
virtual bool init(QString const &context);
virtual bool resolve();
Expand Down
6 changes: 6 additions & 0 deletions qrmc/classes/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ using namespace qrmc;
bool Label::init(QDomElement const &element, int index, bool nodeLabel)
{
mX = element.attribute("x", "0");
if (mX.contains("a")) {
mX.chop(1);
}
mY = element.attribute("y", "0");
if (mY.contains("a")) {
mY.chop(1);
}
mCenter = element.attribute("center", "false");
mText = element.attribute("text");
mTextBinded = element.attribute("textBinded");
Expand Down
5 changes: 3 additions & 2 deletions qrmc/classes/nodeType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
using namespace qrmc;
using namespace qReal;

NodeType::NodeType(Diagram *diagram, qrRepo::RepoApi *api, qReal::Id id) : GraphicType(diagram, api, id), mIsPin(false),
mIsHavePin(false)
NodeType::NodeType(Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id id) : GraphicType(diagram, api, id), mIsPin(false),
mIsHavePin(false)
{
}

Expand Down Expand Up @@ -77,6 +77,7 @@ QString NodeType::generateNodeClass(const QString &classTemplate)
.replace(nodeBorderTag, border)
.replace(isNodeTag, "true")
.replace(elementNameTag, name())
.replace(isResizeable, loadBoolProperty(mId, "isResizeable"))
.replace("\\n", "\n");
nodeClass += endline;
return nodeClass;
Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/nodeType.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace qrmc {
class NodeType : public GraphicType
{
public:
NodeType(Diagram *diagram, qrRepo::RepoApi *api, qReal::Id const id);
NodeType(Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id const id);
virtual Type* clone() const;
virtual ~NodeType();

Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/nonGraphicType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using namespace qrmc;

NonGraphicType::NonGraphicType(Diagram *diagram, qrRepo::RepoApi *api, qReal::Id const &id)
NonGraphicType::NonGraphicType(Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id const &id)
: Type(true, diagram, api, id)
{}

Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/nonGraphicType.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ namespace qrmc {
virtual QString generateResourceLine(QString const &resourceTemplate) const;

protected:
NonGraphicType(Diagram *diagram, qrRepo::RepoApi *api, qReal::Id const &id);
NonGraphicType(Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id const &id);
};
}
2 changes: 1 addition & 1 deletion qrmc/classes/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using namespace qrmc;

Property::Property(qrRepo::RepoApi *api, qReal::Id const &id) : mApi(api), mId(id)
Property::Property(qrRepo::LogicalRepoApi *api, qReal::Id const &id) : mApi(api), mId(id)
{

}
Expand Down
4 changes: 2 additions & 2 deletions qrmc/classes/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace qrmc {
class Property
{
public:
Property(qrRepo::RepoApi *api, qReal::Id const &id);
Property(qrRepo::LogicalRepoApi *api, qReal::Id const &id);

bool init();
QString name();
Expand All @@ -23,7 +23,7 @@ namespace qrmc {
QString generateDefaultsLine(QString const &lineTemplate) const;

private:
qrRepo::RepoApi *mApi;
qrRepo::LogicalRepoApi *mApi;
qReal::Id mId;
QString mName;
QString mType;
Expand Down
2 changes: 1 addition & 1 deletion qrmc/classes/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using namespace qrmc;

Type::Type(bool isResolved, Diagram *diagram, qrRepo::RepoApi *api, const qReal::Id &id)
Type::Type(bool isResolved, Diagram *diagram, qrRepo::LogicalRepoApi *api, const qReal::Id &id)
: mResolvingFinished(isResolved), mDiagram(diagram), mId(id), mApi(api)
{
}
Expand Down
4 changes: 2 additions & 2 deletions qrmc/classes/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace qrmc {
class Type
{
public:
Type(bool isResolved, Diagram *diagram, qrRepo::RepoApi *api, qReal::Id const &id);
Type(bool isResolved, Diagram *diagram, qrRepo::LogicalRepoApi *api, qReal::Id const &id);
virtual ~Type();
virtual Type* clone() const = 0;
virtual bool resolve() = 0;
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace qrmc {
bool mResolvingFinished;
Diagram *mDiagram;
qReal::Id mId;
qrRepo::RepoApi *mApi;
qrRepo::LogicalRepoApi *mApi;
QString mName; // metatype name
QString mContext; // context if metatype. e.g. Kernel::Node: Node - name, Kernel - context.
QString mNativeContext; // native context, doesn't change on import and is used for element resolving
Expand Down
2 changes: 1 addition & 1 deletion qrmc/diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using namespace qReal;
using namespace qrmc;

Diagram::Diagram(qReal::Id const &id, qrRepo::RepoApi *api, Editor *editor)
Diagram::Diagram(qReal::Id const &id, qrRepo::LogicalRepoApi *api, Editor *editor)
: mId(id), mApi(api), mEditor(editor)
{
mDiagramName = mApi->name(id);
Expand Down
4 changes: 2 additions & 2 deletions qrmc/diagram.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace qrmc {
class Diagram
{
public:
Diagram(qReal::Id const &id, qrRepo::RepoApi *api, Editor *editor);
Diagram(qReal::Id const &id, qrRepo::LogicalRepoApi *api, Editor *editor);
~Diagram();
bool init();
bool resolve();
Expand Down Expand Up @@ -51,7 +51,7 @@ namespace qrmc {
QString displayedName;
};
qReal::Id mId;
qrRepo::RepoApi *mApi;
qrRepo::LogicalRepoApi *mApi;
QMap<QString, Type*> mTypes;
QString mDiagramName;
QString mDiagramNodeName; // TODO: replace with QStringList for multiple nodeNames
Expand Down
6 changes: 3 additions & 3 deletions qrmc/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using namespace qReal;
using namespace qrmc;

Editor::Editor(MetaCompiler *metaCompiler, qrRepo::RepoApi *api, const qReal::Id &id)
Editor::Editor(MetaCompiler *metaCompiler, qrRepo::LogicalRepoApi *api, const qReal::Id &id)
: mMetaCompiler(metaCompiler), mApi(api), mId(id), mLoadingComplete(false)
{
mName = mApi->property(mId, nameOfTheDirectory).toString().section("/", -1);
Expand Down Expand Up @@ -362,7 +362,7 @@ void Editor::generateDiagramsMap()
foreach(Diagram *diagram, mDiagrams) {
QString newline = line;
initNameMapBody += newline.replace(diagramDisplayedNameTag, diagram->displayedName())
.replace(diagramNameTag, diagram->name()) + endline;
.replace(diagramNameTag, diagram->name()) + endline;
}
// inserting generated lines into main template
mSourceTemplate.replace(initDiagramNameMapLineTag, initNameMapBody);
Expand All @@ -373,7 +373,7 @@ void Editor::generateDiagramNodeNamesMap()
// preparing template for diagramNodeNameMap inits
QString initNodeNameMapBody = "";
QString const line = mUtilsTemplate[initDiagramNodeNameMapLineTag];
foreach(Diagram *diagram, mDiagrams) {
foreach(Diagram *diagram, mDiagrams) {
QString newline = line;
initNodeNameMapBody += newline.replace(diagramNodeNameTag, diagram->nodeName())
.replace(diagramNameTag, diagram->name()) + endline;
Expand Down
4 changes: 2 additions & 2 deletions qrmc/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace qrmc {
class Editor
{
public:
Editor(MetaCompiler *metaCompiler, qrRepo::RepoApi *api, qReal::Id const &id);
Editor(MetaCompiler *metaCompiler, qrRepo::LogicalRepoApi *api, qReal::Id const &id);
~Editor();
MetaCompiler *metaCompiler();
qReal::Id id();
Expand Down Expand Up @@ -62,7 +62,7 @@ namespace qrmc {
void generatePossibleEdges();

MetaCompiler *mMetaCompiler;
qrRepo::RepoApi *mApi;
qrRepo::LogicalRepoApi *mApi;
qReal::Id mId;
QString mName;
bool mLoadingComplete;
Expand Down
3 changes: 2 additions & 1 deletion qrmc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ int main(int argc, char *argv[])
QString workingCopyDir = argv[1];
// QString workingCopyDir = "../qrgui/save";

MetaCompiler metaCompiler(qApp->applicationDirPath() + "/../qrmc/", workingCopyDir);
qrRepo::RepoApi *mRepoApi = new qrRepo::RepoApi(workingCopyDir);
MetaCompiler metaCompiler(qApp->applicationDirPath() + "/../qrmc/", mRepoApi);
if (!metaCompiler.compile()) {
qDebug() << "compilation failed";
return 1;
Expand Down
21 changes: 11 additions & 10 deletions qrmc/metaCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
using namespace qReal;
using namespace qrmc;

MetaCompiler::MetaCompiler(QString const &qrmcDir, QString const &workingCopyDir) : mApi(workingCopyDir)
MetaCompiler::MetaCompiler(QString const &qrmcDir, qrRepo::LogicalRepoApi *mLogicalRepoApi) : mApi(mLogicalRepoApi)
{
mLocalDir = qrmcDir;
mApi.setName(Id::rootId(), Id::rootId().toString());
mApi->setName(Id::rootId(), Id::rootId().toString());
loadTemplateFromFile(pluginHeaderTemplate, mPluginHeaderTemplate);
loadTemplateFromFile(pluginSourceTemplate, mPluginSourceTemplate);
loadTemplateFromFile(nodeClassTemplate, mNodeTemplate);
Expand All @@ -41,18 +41,19 @@ MetaCompiler::~MetaCompiler()
bool MetaCompiler::compile(QString const &targetMetamodel)
{
mTargetMetamodel = targetMetamodel;
IdList rootItems = mApi.children(Id::rootId());
IdList rootItems = mApi->children(Id::rootId());
//mApi.printDebug();
qDebug() << "root diagrams:" << rootItems.size();
if (rootItems.isEmpty())
qDebug() << "couldn't load any root diagrams";
foreach(qReal::Id editorId, rootItems) {
if (!mApi.isLogicalElement(editorId))
if (!mApi->isLogicalElement(editorId))
continue;

if (editorId.element() == metamodelDiagram) {
if (!mTargetMetamodel.isEmpty() && mApi.name(editorId) != mTargetMetamodel )
if (!mTargetMetamodel.isEmpty() && mApi->name(editorId) != mTargetMetamodel )
continue;
mPluginName = NameNormalizer::normalize(mApi.property(editorId, nameOfTheDirectory)
mPluginName = NameNormalizer::normalize(mApi->property(editorId, nameOfTheDirectory)
.toString().section("/", -1));
if (!loadMetaModel(editorId))
return false;
Expand Down Expand Up @@ -121,8 +122,8 @@ bool MetaCompiler::loadTemplateUtils()

Editor* MetaCompiler::loadMetaModel(Id const &metamodelId)
{
qDebug() << "Loading metamodel started: " << mApi.name(metamodelId);
QString metamodelName = mApi.name(metamodelId);
qDebug() << "Loading metamodel started: " << mApi->name(metamodelId);
QString metamodelName = mApi->name(metamodelId);

if (mEditors.contains(metamodelName)) {
Editor *editor = mEditors[metamodelName];
Expand All @@ -134,7 +135,7 @@ Editor* MetaCompiler::loadMetaModel(Id const &metamodelId)
return NULL;
}
} else {
Editor *editor = new Editor(this, &mApi, metamodelId);
Editor *editor = new Editor(this, mApi, metamodelId);
if (!editor->load()) {
qDebug() << "ERROR: Failed to load file";
delete editor;
Expand Down Expand Up @@ -162,7 +163,7 @@ void MetaCompiler::generateCode()

QString pluginNames;
foreach (Editor *editor, mEditors) {
if (!mTargetMetamodel.isEmpty() && mApi.name(editor->id()) != mTargetMetamodel )
if (!mTargetMetamodel.isEmpty() && mApi->name(editor->id()) != mTargetMetamodel )
continue;
pluginNames += nodeIndent + editor->name() + "\\" + endline;
editor->generate(mPluginHeaderTemplate, mPluginSourceTemplate,
Expand Down
4 changes: 2 additions & 2 deletions qrmc/metaCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace qrmc {
class MetaCompiler
{
public:
MetaCompiler(QString const &qrmcDir, QString const &workingCopyDir);
MetaCompiler(QString const &qrmcDir, qrRepo::LogicalRepoApi *mLogicalRepoApi);
~MetaCompiler();
bool compile(QString const &metamodel = "");
Editor *loadMetaModel(qReal::Id const &id);
Expand All @@ -26,7 +26,7 @@ namespace qrmc {
QString getTemplateUtils(QString const &tmpl) const;

private:
qrRepo::RepoApi mApi;
qrRepo::LogicalRepoApi *mApi;
QMap<QString, Editor*> mEditors;

QString mLocalDir;
Expand Down
2 changes: 1 addition & 1 deletion qrmc/plugins/pluginsCommon.pri
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += plugin
DESTDIR = ../../../qrgui/plugins/
DESTDIR = ../../../bin/plugins/
MOC_DIR = .moc
RCC_DIR = .moc
OBJECTS_DIR = .obj
Expand Down
10 changes: 5 additions & 5 deletions qrmc/plugins/pluginsSdk.pri
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SOURCES +=

HEADERS += \
$$QRMC_ROOT/../../qrgui/pluginInterface/sdfRendererInterface.h \
$$QRMC_ROOT/../../qrgui/pluginInterface/elementImpl.h \
$$QRMC_ROOT/../../qrgui/pluginInterface/elementRepoInterface.h \
$$QRMC_ROOT/../../qrgui/pluginInterface/elementTitleHelpers.h \
$$QRMC_ROOT/../../qrgui/pluginInterface/editorInterface.h \
$$QRMC_ROOT/../../qrgui/editorPluginInterface/sdfRendererInterface.h \
$$QRMC_ROOT/../../qrgui/editorPluginInterface/elementImpl.h \
$$QRMC_ROOT/../../qrgui/editorPluginInterface/elementRepoInterface.h \
$$QRMC_ROOT/../../qrgui/editorPluginInterface/elementTitleHelpers.h \
$$QRMC_ROOT/../../qrgui/editorPluginInterface/editorInterface.h \
Loading

0 comments on commit 5e3508b

Please sign in to comment.