Beispiel #1
0
/**
 * Extract the quid attribute from a petal node and return it as a Uml::IDType.
 */
Uml::IDType quid(const PetalNode *node)
{
    QString quidStr = node->findAttribute("quid").string;
    if (quidStr.isEmpty())
        return Uml::id_None;
    quidStr.remove('\"');
    return STR2ID(quidStr);
}
Beispiel #2
0
ulong MWPFileNameMap::map(const std::string& filename)
{
	ulong id = STR2ID(filename.c_str());

	MWPMap::iterator it = mMWPMap.find(id);
	if (it != mMWPMap.end()) // found
		return (*it).first;

	mMWPMap[id] = filename;
	return id;
}
Beispiel #3
0
Lexan::Lexan(identifier filename)
	: BaseObject(),
	m_source(),
	m_defines(),
	m_int(0),
	m_float(0.0f),
	m_string(""),
	m_identifier(0),
	m_currently_processed_function(STR2ID("none"))
{
	m_source.push(new LexanIteratorFile(ID2STR(filename)));
}
Beispiel #4
0
/**
 * Reimplemented from UMLWidget::loadFromXMI to load note
 * widget info from XMI.
 */
bool NoteWidget::loadFromXMI(QDomElement& qElement)
{
    if ( !UMLWidget::loadFromXMI(qElement))
        return false;
    setDocumentation(qElement.attribute("text", ""));
    QString diagramlink = qElement.attribute("diagramlink", "");
    if (!diagramlink.isEmpty()) {
        m_diagramLink = STR2ID(diagramlink);
    }
    QString type = qElement.attribute("noteType", "");
    setNoteType( (NoteType)type.toInt() );
    return true;
}
Beispiel #5
0
bool Lexan::expandMacro(void)
{
	map<identifier, string>::iterator it = m_defines.find(STR2ID(m_string));

	if(it != m_defines.end())
	{
//		DBG << getPosition() << _("Expanding macro: ") << ID2STR(it->first) << endl;
		m_source.push(new LexanIteratorString(getFile(), getLine(), it->first, it->second));
		return true;// Macro expanded
	}

	return false;// It wasn't a macro
}
Beispiel #6
0
/**
 * Set the class attributes of this object from
 * the passed element node.
 */
void CodeOperation::setAttributesFromNode ( QDomElement & element)
{
    CodeMethodBlock::setAttributesFromNode(element); // superclass

    // now set local attributes

    // oops..this is done in the parent class "ownedcodeblock".
    // we simply need to record the parent operation here
    // m_parentOperation->disconnect(this); // always disconnect from current parent

    QString idStr = element.attribute("parent_id","-1");
    Uml::IDType id = STR2ID(idStr);
    UMLObject * obj = UMLApp::app()->document()->findObjectById(id);
    UMLOperation * op = dynamic_cast<UMLOperation*>(obj);

    if (op)
        init(op);
    else
        uError() << "ERROR: could not load code operation because of missing UMLoperation, corrupt savefile?";
}
Beispiel #7
0
/**
 * Extract and load code for operations from xmi section.
 * Probably we have code which was entered in classpropdlg for an operation.
 */
void CodeGenerator::loadCodeForOperation(const QString& idStr, const QDomElement& codeDocElement)
{
    Uml::IDType id = STR2ID(idStr);
    UMLObject *obj = m_document->findObjectById(id);
    if (obj) {
        uDebug() << "found UMLObject for id:" << idStr;
        QString value = codeDocElement.attribute("value", "");

        Uml::Object_Type t = obj->baseType();
        if (t == Uml::ot_Operation) {
            UMLOperation *op = static_cast<UMLOperation*>(obj);
            op->setSourceCode(value);
        }
        else {
            uError() << "sourcecode id " << idStr << " has unexpected type " << t;
        }
    }
    else {
        uError() << "unknown sourcecode id " << idStr;
    }
}
Beispiel #8
0
bool PreconditionWidget::loadFromXMI( QDomElement & qElement )
{
    if( !UMLWidget::loadFromXMI( qElement ) )
        return false;
    QString widgetaid = qElement.attribute( "widgetaid", "-1" );
    m_Text = qElement.attribute( "preconditionname", "" );
    m_Doc = qElement.attribute( "documentation", "" );

    Uml::IDType aId = STR2ID(widgetaid);

    UMLWidget *pWA = m_scene -> findWidget( aId );
    if (pWA == NULL) {
        uDebug() << "role A object " << ID2STR(aId) << " not found";
        return false;
    }

    m_pOw = dynamic_cast<ObjectWidget*>(pWA);
    if (m_pOw == NULL) {
        uDebug() << "role A widget " << ID2STR(aId) << " is not an ObjectWidget";
        return false;
    }

    return true;
}
Beispiel #9
0
UMLWidget* makeWidgetFromXMI(const QString& tag,
                             const QString& idStr, UMLView *view)
{
    UMLWidget *widget = NULL;

        // Loading of widgets which do NOT represent any UMLObject,
        // just graphic stuff with no real model information
        //FIXME while boxes and texts are just diagram objects, activities and
        // states should be UMLObjects
    if (tag == "statewidget" || tag == "UML:StateWidget") {
        widget = new StateWidget(view, StateWidget::Normal, Uml::id_Reserved);
    } else if (tag == "notewidget" || tag == "UML:NoteWidget") {
        widget = new NoteWidget(view, NoteWidget::Normal, Uml::id_Reserved);
    } else if (tag == "boxwidget") {
        widget = new BoxWidget(view, Uml::id_Reserved);
    } else if (tag == "floatingtext" || tag == "UML:FloatingTextWidget") {
        widget = new FloatingTextWidget(view, Uml::tr_Floating, "", Uml::id_Reserved);
    } else if (tag == "activitywidget" || tag == "UML:ActivityWidget") {
        widget = new ActivityWidget(view, ActivityWidget::Initial, Uml::id_Reserved);
    } else if (tag == "messagewidget") {
        widget = new MessageWidget(view, Uml::sequence_message_asynchronous, Uml::id_Reserved);
    } else if (tag == "forkjoin") {
        widget = new ForkJoinWidget(view, false, Uml::id_Reserved);
    } else if (tag == "preconditionwidget") {
        widget = new PreconditionWidget(view, NULL, Uml::id_Reserved);
    } else if (tag == "combinedFragmentwidget") {
        widget = new CombinedFragmentWidget(view, CombinedFragmentWidget::Ref, Uml::id_Reserved);
    } else if (tag == "signalwidget") {
        widget = new SignalWidget(view, SignalWidget::Send,  Uml::id_Reserved);
    } else if (tag == "floatingdashlinewidget") {
        widget = new FloatingDashLineWidget(view, Uml::id_Reserved);
    } else if (tag == "objectnodewidget") {
        widget = new ObjectNodeWidget(view, ObjectNodeWidget::Normal, Uml::id_Reserved);
    } else if (tag == "regionwidget") {
        widget = new RegionWidget(view, Uml::id_Reserved);
    } else if (tag == "pinwidget") {
        widget = new PinWidget(view, NULL, Uml::id_Reserved);
    }
    else
    {
        // Loading of widgets which represent an UMLObject

        // Find the UMLObject and create the Widget to represent it
        Uml::IDType id = STR2ID(idStr);
        UMLDoc *umldoc = UMLApp::app()->document();
        UMLObject *o = umldoc->findObjectById(id);
        if (o == NULL) {
            uDebug() << "makeWidgetFromXMI: cannot find object with id "
                << ID2STR(id) << endl;
        }

        if (tag == "actorwidget" || tag == "UML:ActorWidget") {
            if (validateObjType(Uml::ot_Actor, o, id))
                widget = new ActorWidget(view, static_cast<UMLActor*>(o));
        } else if (tag == "usecasewidget" || tag ==  "UML:UseCaseWidget") {
            if (validateObjType(Uml::ot_UseCase, o, id))
                widget = new UseCaseWidget(view, static_cast<UMLUseCase*>(o));
        } else if (tag == "classwidget" || tag == "UML:ClassWidget") {
            if (validateObjType(Uml::ot_Class, o, id))
                widget = new ClassifierWidget(view, static_cast<UMLClassifier*>(o));
        } else if (tag == "packagewidget") {
            if (validateObjType(Uml::ot_Package, o, id))
                widget = new PackageWidget(view, static_cast<UMLPackage*>(o));
        } else if (tag == "componentwidget") {
            if (validateObjType(Uml::ot_Component, o, id))
                widget = new ComponentWidget(view, static_cast<UMLComponent*>(o));
        } else if (tag == "nodewidget") {
            if (validateObjType(Uml::ot_Node, o, id))
                widget = new NodeWidget(view, static_cast<UMLNode*>(o));
        } else if (tag == "artifactwidget") {
            if (validateObjType(Uml::ot_Artifact, o, id))
                widget = new ArtifactWidget(view, static_cast<UMLArtifact*>(o));
        } else if (tag == "interfacewidget") {
            if (validateObjType(Uml::ot_Interface, o, id))
                widget = new ClassifierWidget(view, static_cast<UMLClassifier*>(o));
        } else if (tag == "datatypewidget") {
            if (validateObjType(Uml::ot_Datatype, o, id))
                widget = new DatatypeWidget(view, static_cast<UMLClassifier*>(o));
        } else if (tag == "enumwidget") {
            if (validateObjType(Uml::ot_Enum, o, id))
                widget = new EnumWidget(view, static_cast<UMLEnum*>(o));
        } else if (tag == "entitywidget") {
            if (validateObjType(Uml::ot_Entity, o, id))
                widget = new EntityWidget(view, static_cast<UMLEntity*>(o));
        } else if (tag == "categorywidget") {
            if (validateObjType(Uml::ot_Category, o, id))
                widget = new CategoryWidget(view, static_cast<UMLCategory*>(o));
        } else if (tag == "objectwidget" || tag == "UML:ObjectWidget") {
            widget = new ObjectWidget(view, o );
        } else {
            uWarning() << "Trying to create an unknown widget:" << tag;
        }
    }
    return widget;

}
// Sigh. NOT optimal. The only reason that we need to have this
// is so we can create the CPPHeaderClassDeclarationBlock.
// would be better if we could create a handler interface that each
// codeblock used so all we have to do here is add the handler
void CPPHeaderCodeDocument::loadChildTextBlocksFromNode ( QDomElement & root)
{

    QDomNode tnode = root.firstChild();
    QDomElement telement = tnode.toElement();
    bool loadCheckForChildrenOK = false;
    while( !telement.isNull() ) {
        QString nodeName = telement.tagName();

        if( nodeName == "textblocks" ) {

            QDomNode node = telement.firstChild();
            QDomElement element = node.toElement();

            // if there is nothing to begin with, then we don't worry about it
            loadCheckForChildrenOK = element.isNull() ? true : false;

            while( !element.isNull() ) {
                QString name = element.tagName();

                if( name == "codecomment" ) {
                    CodeComment * block = new CPPCodeDocumentation(this);
                    block->loadFromXMI(element);
                    if(!addTextBlock(block))
                    {
                        kError()<<"Unable to add codeComment to :"<<this<<endl;
                        block->deleteLater();
                    } else
                        loadCheckForChildrenOK= true;
                } else
                    if( name == "codeaccessormethod" ||
                            name == "ccfdeclarationcodeblock"
                      ) {
                        QString acctag = element.attribute("tag","");
                        // search for our method in the
                        TextBlock * tb = findCodeClassFieldTextBlockByTag(acctag);
                        if(!tb || !addTextBlock(tb))
                        {
                            kError()<<"Unable to add codeclassfield child method to:"<<this<<endl;
                            // DON'T delete
                        } else
                            loadCheckForChildrenOK= true;

                    } else
                        if( name == "codeblock" ) {
                            CodeBlock * block = newCodeBlock();
                            block->loadFromXMI(element);
                            if(!addTextBlock(block))
                            {
                                kError()<<"Unable to add codeBlock to :"<<this<<endl;
                                block->deleteLater();
                            } else
                                loadCheckForChildrenOK= true;
                        } else
                            if( name == "codeblockwithcomments" ) {
                                CodeBlockWithComments * block = newCodeBlockWithComments();
                                block->loadFromXMI(element);
                                if(!addTextBlock(block))
                                {
                                    kError()<<"Unable to add codeBlockwithcomments to:"<<this<<endl;
                                    block->deleteLater();
                                } else
                                    loadCheckForChildrenOK= true;
                            } else
                                if( name == "header" ) {
                                    // do nothing.. this is treated elsewhere
                                } else
                                    if( name == "hierarchicalcodeblock" ) {
                                        HierarchicalCodeBlock * block = newHierarchicalCodeBlock();
                                        block->loadFromXMI(element);
                                        if(!addTextBlock(block))
                                        {
                                            kError()<<"Unable to add hierarchicalcodeBlock to:"<<this<<endl;
                                            block->deleteLater();
                                        } else
                                            loadCheckForChildrenOK= true;
                                    } else
                                        if( name == "codeoperation" ) {
                                            // find the code operation by id
                                            QString id = element.attribute("parent_id","-1");
                                            UMLObject * obj = UMLApp::app()->getDocument()->findObjectById(STR2ID(id));
                                            UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
                                            if(op) {
                                                CodeOperation * block = new CPPHeaderCodeOperation(this, op);
                                                block->loadFromXMI(element);
                                                if(addTextBlock(block))
                                                    loadCheckForChildrenOK= true;
                                                else
                                                {
                                                    kError()<<"Unable to add codeoperation to:"<<this<<endl;
                                                    block->deleteLater();
                                                }
                                            } else
                                                kError()<<"Unable to find operation create codeoperation for:"<<this<<endl;
                                        }
                                        else
                                            if( name == "cppheaderclassdeclarationblock" )
                                            {
                                                CPPHeaderClassDeclarationBlock * block = getClassDecl();
                                                block->loadFromXMI(element);
                                                // normally this would be populated by the following syncToparent
                                                // call, but we cant wait for it, so lets just do it now.
                                                namespaceBlock = getHierarchicalCodeBlock("namespace", "Namespace", 0);

                                                if(!namespaceBlock || !namespaceBlock->addTextBlock(block))
                                                {
                                                    kError()<<"Error:cant add class declaration codeblock"<<endl;
                                                    // DON'T delete/release block
                                                    // block->release();
                                                } else
                                                    loadCheckForChildrenOK= true;

                                            }
                // only needed for extreme debugging conditions (E.g. making new codeclassdocument loader)
                //else
                //kDebug()<<" LoadFromXMI: Got strange tag in text block stack:"<<name<<", ignorning"<<endl;

                node = element.nextSibling();
                element = node.toElement();
            }
            break;
        }

        tnode = telement.nextSibling();
        telement = tnode.toElement();
    }

    if(!loadCheckForChildrenOK)
    {
        CodeDocument * test = dynamic_cast<CodeDocument*>(this);
        if(test)
        {
            kWarning()<<" loadChildBlocks : unable to initialize any child blocks in doc: "<<test->getFileName()<<" "<<this<<endl;
        } else {
            HierarchicalCodeBlock * hb = dynamic_cast<HierarchicalCodeBlock*>(this);
            if(hb)
                kWarning()<<" loadChildBlocks : unable to initialize any child blocks in Hblock: "<<hb->getTag()<<" "<<this<<endl;
            else
                kDebug()<<" loadChildBlocks : unable to initialize any child blocks in UNKNOWN OBJ:"<<this<<endl;
        }
    }

}
Beispiel #11
0
bool UMLRole::load( QDomElement & element ) {
    UMLDoc * doc = UMLApp::app()->getDocument();
    QString type = element.attribute("type", "");
    if (!type.isEmpty()) {
        if (!m_SecondaryId.isEmpty())
            kWarning() << "UMLRole::load: overwriting old m_SecondaryId \""
            << m_SecondaryId << " with new value \""
            << type << "\"" << endl;
        m_SecondaryId = type;
    }
    // Inspect child nodes - for multiplicity (and type if not set above.)
    for (QDomNode node = element.firstChild(); !node.isNull(); node = node.nextSibling()) {
        if (node.isComment())
            continue;
        QDomElement tempElement = node.toElement();
        QString tag = tempElement.tagName();
        if (Uml::tagEq(tag, "name")) {
            m_Name = tempElement.text();
        } else if (Uml::tagEq(tag, "AssociationEnd.multiplicity")) {
            /**
             * There are different ways in which the multiplicity might be given:
             *  - direct value in the <AssociationEnd.multiplicity> tag,
             *  - attributes "lower" and "upper" of a subordinate <MultiplicityRange>,
             *  - direct value in subordinate <MultiplicityRange.lower> and
             *    <MultiplicityRange.upper> tags
             */
            QDomNode n = tempElement.firstChild();
            if (node.isNull() || tempElement.isNull() || n.isNull() ||
                    n.toElement().isNull()) {
                m_Multi = tempElement.text().stripWhiteSpace();
                continue;
            }
            tempElement = n.toElement();
            tag = tempElement.tagName();
            if (!Uml::tagEq(tag, "Multiplicity")) {
                m_Multi = tempElement.text().stripWhiteSpace();
                continue;
            }
            n = tempElement.firstChild();
            tempElement = n.toElement();
            tag = tempElement.tagName();
            if (!Uml::tagEq(tag, "Multiplicity.range")) {
                m_Multi = tempElement.text().stripWhiteSpace();
                continue;
            }
            n = tempElement.firstChild();
            tempElement = n.toElement();
            tag = tempElement.tagName();
            if (!Uml::tagEq(tag, "MultiplicityRange")) {
                m_Multi = tempElement.text().stripWhiteSpace();
                continue;
            }
            QString multiUpper;
            if (tempElement.hasAttribute("lower")) {
                m_Multi = tempElement.attribute("lower", "");
                multiUpper = tempElement.attribute("upper", "");
                if (!multiUpper.isEmpty()) {
                    if (!m_Multi.isEmpty())
                        m_Multi.append("..");
                    m_Multi.append(multiUpper);
                }
                continue;
            }
            n = tempElement.firstChild();
            while (!n.isNull()) {
                tempElement = n.toElement();
                tag = tempElement.tagName();
                if (Uml::tagEq(tag, "MultiplicityRange.lower")) {
                    m_Multi = tempElement.text();
                } else if (Uml::tagEq(tag, "MultiplicityRange.upper")) {
                    multiUpper = tempElement.text();
                }
                n = n.nextSibling();
            }
            if (!multiUpper.isEmpty()) {
                if (!m_Multi.isEmpty())
                    m_Multi.append("..");
                m_Multi.append(multiUpper);
            }
        } else if (m_SecondaryId.isEmpty() &&
                   (Uml::tagEq(tag, "type") ||
                    Uml::tagEq(tag, "participant"))) {
            m_SecondaryId = tempElement.attribute("xmi.id", "");
            if (m_SecondaryId.isEmpty())
                m_SecondaryId = tempElement.attribute("xmi.idref", "");
            if (m_SecondaryId.isEmpty()) {
                QDomNode inner = tempElement.firstChild();
                QDomElement innerElem = inner.toElement();
                m_SecondaryId = innerElem.attribute("xmi.id", "");
                if (m_SecondaryId.isEmpty())
                    m_SecondaryId = innerElem.attribute("xmi.idref", "");
            }
        }
    }
    if (!m_Multi.isEmpty())
        kDebug() << "UMLRole::load(" << m_Name << "): m_Multi is " << m_Multi << endl;
    if (m_SecondaryId.isEmpty()) {
        kError() << "UMLRole::load(" << m_Name << "): type not given or illegal" << endl;
        return false;
    }
    UMLObject * obj;
    obj = doc->findObjectById(STR2ID(m_SecondaryId));
    if (obj) {
        m_pSecondary = obj;
        m_SecondaryId = "";
    }

    // block signals to prevent needless updating
    blockSignals(true);
    // Here comes the handling of the association type.
    // This is open for discussion - I'm pretty sure there are better ways..

    // Yeah, for one, setting the *parent* object parameters from here is sucky
    // as hell. Why are we using roleA to store what is essentially a parent (association)
    // parameter, eh? The UML13.dtd is pretty silly, but since that is what
    // is driving us to that point, we have to go with it. Some analysis of
    // the component roles/linked items needs to be done in order to get things
    // right. *sigh* -b.t.

    // Setting association type from the role (A)
    // Determination of the "aggregation" attribute used to be done only
    // when (m_role == Uml::A) but some XMI writers (e.g. StarUML) place
    // the aggregation attribute at role B.
    // The role end with the aggregation unequal to "none" wins.
    QString aggregation = element.attribute("aggregation", "none");
    if (aggregation == "composite")
        m_pAssoc->setAssocType(Uml::at_Composition);
    else if (aggregation == "shared"       // UML1.3
          || aggregation == "aggregate")   // UML1.4
        m_pAssoc->setAssocType(Uml::at_Aggregation);

    if (!element.hasAttribute("isNavigable")) {
        /* Backward compatibility mode: In Umbrello version 1.3.x the
           logic for saving the isNavigable flag was wrong.
           May happen on loading role A.
         */
        m_pAssoc->setOldLoadMode(true);
    } else if (m_pAssoc->getOldLoadMode() == true) {
        /* Here is the original logic:
           " Role B:
             If isNavigable is not given, we make no change to the
             association type.
             If isNavigable is given, and is "true", then we assume that
             the association's other end (role A) is not navigable, and
             therefore we change the association type to UniAssociation.
             The case that isNavigable is given as "false" is ignored.
             Combined with the association type logic for role A, this
             allows us to support at_Association and at_UniAssociation. "
         */
        if (element.attribute("isNavigable") == "true")
            m_pAssoc->setAssocType(Uml::at_UniAssociation);
    } else if (element.attribute("isNavigable") == "false") {
        m_pAssoc->setAssocType(Uml::at_UniAssociation);
    }

    //FIXME not standard XMI
    if (element.hasAttribute("relationship")) {
        if (element.attribute("relationship") == "true") {
            m_pAssoc->setAssocType(Uml::at_Relationship);
        }
    }

    if (m_Multi.isEmpty())
        m_Multi = element.attribute("multiplicity", "");

    // Changeability defaults to Changeable if it cant set it here..
    m_Changeability = Uml::chg_Changeable;
    QString changeability = element.attribute("changeability", "");
    if (changeability.isEmpty())
        element.attribute("changeable", "");  // for backward compatibility
    if (changeability == "frozen")
        m_Changeability = Uml::chg_Frozen;
    else if (changeability == "addOnly")
        m_Changeability = Uml::chg_AddOnly;

    // finished config, now unblock
    blockSignals(false);
    return true;
}
Beispiel #12
0
LEXTOKEN Lexan::checkKeyword(void)
{
	// Check keywords
	if(m_string == "function")
		return LEX_FUNCTION;
	if(m_string == "return")
		return LEX_RETURN;
	if(m_string == "if")
		return LEX_IF;
	if(m_string == "else")
		return LEX_ELSE;
	if(m_string == "while")
		return LEX_WHILE;
	if(m_string == "for")
		return LEX_FOR;
	if(m_string == "foreach")
		return LEX_FOREACH;
	if(m_string == "break")
		return LEX_BREAK;
	if(m_string == "continue")
		return LEX_CONTINUE;
	if(m_string == "null")
		return LEX_NULL;
	if(m_string == "true")
		return LEX_TRUE;
	if(m_string == "false")
		return LEX_FALSE;
	if(m_string == "global")
		return LEX_GLOBAL;
	if(m_string == "__FILE__")
	{
		m_string = ID2STR(m_source.top()->getFile());
		return LEX_STRING;
	}
	if(m_string == "__LINE__")
	{
		m_int = m_source.top()->getLine();
		return LEX_INT;
	}
	if(m_string == "__FUNCTION__")
	{
		m_string = ID2STR(m_currently_processed_function);
		return LEX_STRING;
	}

	// Check include and define
	if(m_string == "include")
	{
		parseInclude();
		return nextToken();
	}
	if(m_string == "define")
	{
		parseDefine();
		return nextToken();
	}

	// Try to expand a macro
	if(expandMacro())
		return nextToken();

	// The string is variable or function name
	m_identifier = STR2ID(m_string);
	return LEX_IDENTIFIER;
}
Beispiel #13
0
bool GroundEyeshot::create(
						   SceneMgr *pSceneMgr,
						   int nMapWidth, 
						   int nMapHeight, 
						   int nGridWidth, 
						   int nGridHeight,
						   xs::Rect* lprcViewport,
						   xs::IResourceManager *pResourceManager,
						   xs::Stream *pMapFile,
						   const std::string& mapFilename,
						   bool bDynamic)
{
	m_bDynamic = bDynamic;
	m_pResourceManager = pResourceManager;

	m_hash = STR2ID(mapFilename.c_str());

	if(m_pResourceManager && NULL == m_ResourceLoader)
	{
		m_ResourceLoader = new ResourceLoaderGT();
		m_pResourceManager->registerResourceLoader(typeResourceGroundTile,m_ResourceLoader);
	}
	m_pSceneMgr = pSceneMgr;

	m_nMapWidth = nMapWidth;
	m_nMapHeight = nMapHeight;
	m_rcMapRect.right = nMapWidth;
	m_rcMapRect.bottom = nMapHeight;

	m_nGridWidth = nGridWidth;
	m_nGridHeight = nGridHeight;

	m_nViewWidth = lprcViewport->right - lprcViewport->left;
	m_nViewHeight = lprcViewport->bottom - lprcViewport->top;
	
	m_nTotalGridX = Ceil(m_nMapWidth, nGridWidth);
	m_nTotalGridY = Ceil(m_nMapHeight, nGridHeight);

	m_SceneCo.create(nMapWidth, nMapHeight);

	int nTotalGrid = m_nTotalGridX * m_nTotalGridY;
	m_pGroundTile = new GroundTile[nTotalGrid];
	if(m_pGroundTile == 0)
		return false;

	Info("m_pGroundTile:"<<(ulong)m_pGroundTile<<endl);

	for(int i = 0;i < nTotalGrid;i++)
	{
		m_pGroundTile[i].m_pGround = this;
		m_pGroundTile[i].m_ptCoord.x = i % m_nTotalGridX;
		m_pGroundTile[i].m_ptCoord.y = i / m_nTotalGridX;

		
	}

	if(pMapFile)
	{
		load(pMapFile);
	}

	//for(int i = 0;i < nTotalGrid;i++)
	//{
	//	//add by yhc//预加载地表,解决动态加载地表卡的问题
	//	GroundTile * pGT = &m_pGroundTile[i];
	//	if ( pGT != NULL && m_pResourceManager != NULL && m_pMapStream != NULL )
	//	{
	//		m_pMapStream->seek(m_pGroundTileTable[i]);
	//		pGT->loadAlphaMaps(m_pMapStream);
	//		pGT->setResHandle(m_pResourceManager->requestResource((m_hash ^ (ulong)pGT),typeResourceGroundTile,true));
	//	}
	//}

	xs::Rect rc = *lprcViewport;
	/*if(!m_bDynamic)
	{
		rc.left = 0;
		rc.top = 0;
		rc.right = nMapWidth;
		rc.bottom = nMapHeight;
	}*/
	m_bFirstEnterArea = true;
	if(!m_Eyeshot.create(this,nMapWidth, nMapHeight, nGridWidth, nGridHeight, &rc,m_bDynamic))
	{
		m_bFirstEnterArea =false;
		return false;
	}
	
	calcViewTileRect();

	m_groundRenderQueue.initialize();
	m_bFirstEnterArea =false;
	return true;
}
Beispiel #14
0
/**
 * Set the class attributes of this object from
 * the passed element node.
 */
void CodeParameter::setAttributesFromNode ( QDomElement & root)
{
    // set local attributes, parent object first
    QString idStr = root.attribute("parent_id","-1");
    Uml::IDType id = STR2ID(idStr);

    // always disconnect
    m_parentObject->disconnect(this);

    // now, what is the new object we want to set?
    UMLObject * obj = UMLApp::app()->document()->findObjectById(id);
    if(obj)
    {
        // FIX..one day.
        // Ugh. This is UGLY, but we have to do it this way because UMLRoles
        // don't go into the document list of UMLobjects, and have the same
        // ID as their parent UMLAssociations. So..the drill is then special
        // for Associations..in that case we need to find out which role will
        // serve as the parameter here. The REAL fix, of course, would be to
        // treat UMLRoles on a more even footing, but im not sure how that change
        // might ripple throughout the code and cause problems. Thus, since the
        // change appears to be needed for only this part, I'll do this crappy
        // change instead. -b.t.
        UMLAssociation * assoc = dynamic_cast<UMLAssociation*>(obj);
        if(assoc) {
            // In this case we init with indicated role child obj.
            UMLRole * role = 0;
            int role_id = root.attribute("role_id","-1").toInt();
            if(role_id == 1)
                role = assoc->getUMLRole(Uml::A);
            else if(role_id == 0)
                role = assoc->getUMLRole(Uml::B);
            else
                uError() << "corrupt save file? "
                << "cant get proper UMLRole for codeparameter uml id:"
                << ID2STR(id) << " w/role_id:" << role_id;

            // init using UMLRole obj
            initFields ( m_parentDocument, role);

        } else
            initFields ( m_parentDocument, obj); // just the regular approach

    } else
        uError() << "Cant load CodeParam: parentUMLObject w/id:"
        << ID2STR(id) << " not found, corrupt save file?";

    // other attribs now
    setInitialValue(root.attribute("initialValue",""));

    // load comment now
    // by looking for our particular child element
    QDomNode node = root.firstChild();
    QDomElement element = node.toElement();
    bool gotComment = false;
    while( !element.isNull() ) {
        QString tag = element.tagName();
        if( tag == "header" ) {
            QDomNode cnode = element.firstChild();
            QDomElement celem = cnode.toElement();
            getComment()->loadFromXMI(celem);
            gotComment = true;
            break;
        }
        node = element.nextSibling();
        element = node.toElement();
    }

    if(!gotComment)
        uWarning()<<" loadFromXMI : Warning: unable to initialize CodeComment in codeparam:"<<this;
}