📄 mapper.cpp
字号:
state = STATE_DRAW_INTERZONE_LINKS; break; } // get first link from vector currentLink = remainingLinkVect.begin(); fromModule = getModule( currentLink->fromModule ); toModule = getModule( currentLink->toModule ); //cout << currentLink->fromModule << " -> " << currentLink->toModule << "\n"; if ( fromModule != NULL && toModule != NULL && fromModule->visible && toModule->visible ) { if ( fromModule->lowerNeighbor == toModule->getId() ) { // the two modules follow eachother DRAW_LINE( fromModule->getOutputXPosition( currentLink->fromPort ), fromModule->getOutputYPosition(), toModule->getInputXPosition( currentLink->toPort ), toModule->getInputYPosition() ); // remove link from vector remainingLinkVect.erase( remainingLinkVect.begin() ); break; } else { // the modules do not follow eachother // vertical outwards line DRAW_POLY_START( fromModule->getOutputXPosition( currentLink->fromPort ), fromModule->getOutputYPosition() ); DRAW_POLY_REL( 0, fromModule->outLinkSpace ); fromModule->outLinkSpace -= LINK_Y_INTERVAL; // horizontal outwards line DRAW_POLY( inputMaxXTab[ fromModule->zone ], startY ); inputMaxXTab[ fromModule->zone ] += LINK_X_INTERVAL; // side line DRAW_POLY( startX, toModule->y - toModule->inLinkSpace ); toModule->inLinkSpace -= LINK_Y_INTERVAL; // horizontal inwards line DRAW_POLY( toModule->getInputXPosition( currentLink->toPort ), startY ); // vertical inwards line DRAW_POLY( startX, toModule->getInputYPosition() ); // remove link from vector remainingLinkVect.erase( remainingLinkVect.begin() ); break; } // end else (not neighbor) } // end if(..visible..) else { // the module has not yet been drawn if ( fromModule ){ fromModule->outLinkSpace += LINK_Y_INTERVAL; } state = STATE_DRAW_DIRECT_SUITE; break; } case STATE_DRAW_INTERZONE_LINKS: /******************************************************************/ /* Part 1.3: Draw the interzone links, which are stored in */ /* interzoneLinkVect. */ /******************************************************************/ if ( interzoneLinkVect.size() < 1 ) { interzoneFinished = true; break; } else { int minY; if ( fromModule ){ minY = fromModule->getOutputYPosition(); } else { minY = 0; } // get the last link from the vector (LIFO queue) currentLink = &interzoneLinkVect.back(); fromModule = getModule( currentLink->fromModule ); toModule = getModule( currentLink->toModule ); //cout << currentLink->fromModule << " -> " << currentLink->toModule << "\n"; // find the min y coord of 'highest' column between fromZone and toZone // note: toZone is always smaller than fromZone. int limit; if ( toModule == stfa ) // stfa has '-1' as zone number, be careful when accessing // an array element at index [module->zone] limit = currentLink->toPort; else limit = toModule->zone + 1; for ( int j = fromModule->zone + 1; j <= limit; j++ ) { minY = MINIMUM( minY, inputMinYTab[ j ] ); } if ( fromModule->getOutputYPosition() >= minY ) minY -= LINK_Y_INTERVAL; else minY = fromModule->getOutputYPosition() + fromModule->outLinkSpace; // for each zone between fromModule's zone and toModule's zone: // update the corresponding value in inputMinYTab for ( int j = fromModule->zone + 1; j <= limit; j++ ) { inputMinYTab[ j ] = minY; } // draw the links // Vertical outwards line DRAW_POLY_START( fromModule->getOutputXPosition( currentLink->fromPort ), fromModule->getOutputYPosition() ); DRAW_POLY_REL( 0, fromModule->outLinkSpace ); fromModule->outLinkSpace -= LINK_Y_INTERVAL; // Horizontal outwards line DRAW_POLY( inputMaxXTab[ fromModule->zone ], startY ); inputMaxXTab[ fromModule->zone ] += LINK_X_INTERVAL; DRAW_POLY( startX, minY ); if ( ( toModule->upperNeighbor >= 0 ) || ( toModule == stfa && minY < fromModule->getOutputYPosition() + fromModule->outLinkSpace ) ) { // there are other modules to bypass if ( toModule == stfa ) { endX = MAXIMUM( stfa->getInputXPosition( currentLink->toPort ), inputMaxXTab[ currentLink->toPort - 1 ] ); inputMaxXTab[ currentLink->toPort ] += LINK_X_INTERVAL; } else { endX = inputMaxXTab[ toModule->zone ]; inputMaxXTab[ toModule->zone ] += LINK_X_INTERVAL; } endY = startY; DRAW_POLY( endX, endY ); DRAW_POLY( startX, toModule->y - toModule->inLinkSpace ); toModule->inLinkSpace += LINK_Y_INTERVAL; } // Horizontal inwards line DRAW_POLY( toModule->getInputXPosition( currentLink->toPort ), startY ); // Vertical inwards line DRAW_POLY( startX, toModule->getInputYPosition() ); // remove link from vect interzoneLinkVect.erase( &interzoneLinkVect.back() ); break; } default: break; } // end switch(state) } // end while(!columnFinished) } // end for(all input ports of stfa) /************************************************************************/ /* Part 2: Draw the modules that are under the STFA. */ /************************************************************************/ // for all output ports of the stfa for ( int portNb = 0; portNb < stfa->greatestPortUsed; portNb++ ) { if ( portNb >= stfa->numberOut ){ break; } // update maxX outputMaxXTab[ portNb ] = MAXIMUM( outputMaxXTab[ portNb ], outputMaxXTab[ MAXIMUM( portNb - 1, 0 ) ] ); // currentY = stfa->y + stfa->height; currentY = stfa->getOutputYPosition(); // currentLink = &(stfa->outputLinkVect.at(portNb)); atp_( currentLink, stfa->outputLinkVect, portNb, 4 ); if ( currentLink->toModule < 0 ) continue; previousModule = stfa; columnFinished = false; interzoneFinished = false; state = STATE_DRAW_DIRECT_SUITE; while ( !( columnFinished && interzoneFinished ) ) { switch ( state ) { case STATE_DRAW_DIRECT_SUITE: /****************************************************************/ /* Part 2.1: Draw the modules that are met for the first time. */ /* Draw the link between the modules. When entering */ /* this state, currentLink's 'toModule' must be the */ /* last module that was drawn and 'fromModule' is */ /* valid. */ /****************************************************************/ // the next module to draw currentModule = getModule( currentLink->toModule ); if ( currentModule == NULL ) { cout << "There is no module " << currentLink->toModule << "\n"; columnFinished = interzoneFinished = true; continue; } if ( currentModule->visible ) { // the module has already been drawn, draw the link later if ( currentModule->zone == previousModule->zone ) { // the two modules are in the same zone remainingLinkVect.push_back( *currentLink ); } // end if(currentModule->zone == previousModule->zone) else { // the two modules are not in the same zone interzoneLinkVect.push_back( *currentLink ); } bool linkFound = false; // get the following 'valid' link for ( int i = currentLink->fromPort; i < previousModule->numberOut; i++ ) { IOLink* link; // = &previousModule->outputLinkVect.at(i); atp_( link, previousModule->outputLinkVect, i, 5 ); if ( !link ) { cout << "Link " << i << " is NULL at mapper.cpp:552" << endl; continue; } if ( link->toModule >= 0 && !getModule( link->toModule ) ->visible ) { currentLink = link; currentModule = getModule( currentLink->toModule ); linkFound = true; break; } } // end for(i) if ( !linkFound ) { state = STATE_DRAW_REMAINING_LINKS; break; } } // end if(currentModule->visible) else { // currentModule is not visible // draw the module //cout << currentLink->fromModule << " -> " << currentLink->toModule << "\n"; // set the zone number currentModule->zone = portNb; // set the 'neighbor' information previousModule->lowerNeighbor = currentModule->getId(); currentModule->upperNeighbor = previousModule->getId(); // set the vertical (Y) position of 'currentModule' currentModule->setY( currentY + MAXIMUM( ( previousModule->numberOutUsed ) * LINK_Y_INTERVAL + ( currentModule->numberInUsed ) * LINK_Y_INTERVAL, MODULE_Y_INTERVAL ) ); // update the maximum Y coordinate used by this column (of modules) outputMaxYTab[ portNb ] = currentModule->getOutputYPosition(); // update the current x position if ( portNb == 0 ) { currentX = previousModule->getOutputXPosition( currentLink->fromPort ) - LEG_LEFT_OFFSET - LEG_WIDTH / 2; } else { if ( previousModule == stfa ) { currentX = MAXIMUM( outputMaxXTab[ portNb - 1 ], previousModule->getOutputXPosition( currentLink->fromPort ) - LEG_LEFT_OFFSET - LEG_WIDTH / 2 ); } else { currentX = MAXIMUM( outputMaxXTab[ portNb - 1 ], previousModule->x ); } } // end else // set the horizontal (X) position currentModule->setX( currentX ); // update the maximum X coordinate used by this column (of modules) outputMaxXTab[ portNb ] = currentModule->getMaxX() + MODULE_X_INTERVAL / 2; currentModule->show(); // draw the direct-link lines between 'previousModule' and 'currentModule' if ( ( previousModule == stfa ) || ( currentLink->fromModule == previousModule->getId() ) ) { startX = previousModule->getOutputXPosition( currentLink->fromPort ); startY = previousModule->getOutputYPosition(); endX = currentModule->getInputXPosition( currentLink->toPort ); endY = currentModule->getInputYPosition(); DRAW_LINE( startX, startY, endX, endY ); } currentY = currentModule->y + currentModule->height; // check if the previous module had more than one output if ( previousModule != stfa && previousModule->numberOutUsed > 1 ) { for ( int j = 1; j < previousModule->numberOut; j++ ) { IOLink *link; // = new IOLink( previousModule->outputLinkVect.at( j ) ); atp_( link, previousModule->outputLinkVect, j, 6 ); if ( link->toModule >= 0 && link->fromModule >= 0 ) { // then put all remaining links to the vectors if ( getModule( link->toModule ) ->zone == portNb || !getModule( link->toModule ) ->visible ) { remainingLinkVect.push_back( *link ); } else interzoneLinkVect.push_back( *link ); } } // end for } // end if(previousModule->numberOutUsed > 1) // update currentLink
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -