void WikiMainPage::execute() { bool createMainPage = wm -> checkCreateMainPages(); if( createMainPage == false ) { logger.logInfo( "skip creating main page" ); return; } String wikiDir = wm -> getWikiPath(); String wikiPage = wm -> getMainPage(); // get sorted circuit list MindService *ms = MindService::getService(); MindMap *mm = ms -> getMindMap(); ClassList<MindGlobalCircuitDef>& circuitList = mm -> getMindGlobalCircuits(); MapStringToClass<MindGlobalCircuitDef> circuitMap; for( int k = 0; k < circuitList.count(); k++ ) { MindGlobalCircuitDef *cd = circuitList.get( k ); circuitMap.add( cd -> getName() , cd ); } // collect model circuit section lines StringList lines; for( int k = 0; k < circuitMap.count(); k++ ) { MindGlobalCircuitDef *cd = circuitMap.getClassByIndex( k ); String name = cd -> getName(); String id = cd -> getId(); lines.add( " * [" + id + " " + name + "]" ); } String sectionName = "Circuits"; wm -> updateFileSection( wikiDir , wikiPage , sectionName , lines ); }
void WikiAreaPages::createAreaPages_getExternalConnections( MindArea *area , MindLocalCircuitDef& circuit , MapStringToClass<MindLocalCircuitConnectionDef>& connections , bool isin ) { ClassList<MindLocalCircuitConnectionDef> links; circuit.getExternalConnections( links , isin ); MindService *ms = MindService::getService(); for( int k = 0; k < links.count(); k++ ) { MindLocalCircuitConnectionDef *c = links.get( k ); // ignore secondary if( !c -> isPrimary() ) continue; String key; if( isin == false ) { MindRegion *region = ms -> getMindRegion( c -> getDstRegion() ); key = region -> getArea() -> getAreaId() + "#" + c -> getSrcRegion() + "#" + c -> getDstRegion() + "#1"; if( connections.get( key ) == NULL ) connections.add( key , c ); } else { MindRegion *region = ms -> getMindRegion( c -> getSrcRegion() ); key = region -> getArea() -> getAreaId() + "#" + c -> getDstRegion() + "#" + c -> getSrcRegion() + "#2"; if( connections.get( key ) == NULL ) connections.add( key , c ); } } }
void WikiAreaPages::createAreaPages_createAreaCircuitTable( MapStringToClass<MindLocalCircuitDef>& circuits , StringList& lines ) { createAreaPages_createAreaCircuitTableLine( NULL , lines ); for( int k = 0; k < circuits.count(); k++ ) { MindLocalCircuitDef *circuit = circuits.getClassByIndex( k ); createAreaPages_createAreaCircuitTableLine( circuit , lines ); } }
void WikiTractsPages::createTracts_addTractTableLines( MapStringToClass<XmlBrainTractSet>& tractsets , StringList& lines ) { lines.add( "*Tracts overview*:" ); lines.add( "|| *Tract* || *Name* || *Function* ||" ); for( int k = 0; k < tractsets.count(); k++ ) { XmlBrainTractSet& one = tractsets.getClassRefByIndex( k ); createTracts_addTractSetTableLines( one , lines ); } }
void WikiAreaPages::createDotFile( MindArea *area , MindLocalCircuitDef& circuit , MapStringToClass<MindLocalCircuitConnectionDef>& internals , MapStringToClass<MindLocalCircuitConnectionDef>& inputs , MapStringToClass<MindLocalCircuitConnectionDef>& outputs ) { // create dot file String fileName = wm -> getCircuitDotPath( circuit ); StringList text; // header text.add( "digraph \"" + area -> getAreaId() + "\" {" ); text.add( "\tcompound=true;" ); String defaultDotSetup = wm -> getDefaultDotSetup(); text.add( wm -> setSpecialCharacters( defaultDotSetup ) ); text.add( "" ); // list nodes text.add( "\tsubgraph cluster_" + area -> getAreaId() + " {" ); text.add( "\tlabel=<<b>" + area -> getMindAreaDef() -> getAreaName() + "</b>>;" ); MapStringToClass<MindRegionDef>& regions = circuit.getRegions(); for( int k = 0; k < regions.count(); k++ ) { MindRegionDef *region = regions.getClassByIndex( k ); String dotdef = wm -> hmindxml.getDotDef( region -> getId() ); String nodeline = "\t\"" + region -> getId() + "\""; if( !dotdef.isEmpty() ) { String s = wm -> setSpecialCharacters( dotdef ); s += ", label=<" + createDotFile_getRegionLabel( region ) + ">"; nodeline += " [" + s + "]"; } nodeline += ";"; text.add( nodeline ); } text.add( "\t}" ); // list connections text.add( "" ); for( int k = 0; k < internals.count(); k++ ) { MindLocalCircuitConnectionDef *c = internals.getClassByIndex( k ); MindConnectionLinkTypeDef *linkDef = c -> getPrimaryLinkType(); String props = wm -> getLinkProps( linkDef ); String linkline = "\t\"" + c -> getSrcRegion() + "\" -> \"" + c -> getDstRegion() + "\"" + props + ";"; text.add( linkline ); } // add subgraph String linkItem; createDotFile_subgraph( area , circuit , true , inputs , text , linkItem ); createDotFile_subgraph( area , circuit , false , outputs , text , linkItem ); // footer text.add( "}" ); // out to file wm -> createFileContent( fileName , text ); }
void WikiAreaPages::createAreaPages_addInternalConnections( MindArea *area , MindLocalCircuitDef& circuit , StringList& lines , MapStringToClass<MindLocalCircuitConnectionDef>& connections ) { if( connections.count() == 0 ) { lines.add( " * no connections" ); return; } createAreaPages_addInternalConnectionTableLine( area , circuit , NULL , lines ); for( int k = 0; k < connections.count(); k++ ) { MindLocalCircuitConnectionDef *c = connections.getClassByIndex( k ); createAreaPages_addInternalConnectionTableLine( area , circuit , c , lines ); } }
void WikiAreaPages::createAreaPages_createCircuitsAndReferencesTableSection( String wikiDir , MindArea *area ) { // skip circuits for target areas - will be in region pages if( area -> isTargetArea() ) return; // collect circuits which reference any of area regions MindService *ms = MindService::getService(); StringList circuits; wm -> circuitsxml.getCircuitList( circuits ); MapStringToString circuitKeys; for( int k = 0; k < circuits.count(); k++ ) { String circuitId = circuits.get( k ); XmlCircuitInfo& info = wm -> circuitsxml.getCircuitInfo( circuitId ); String key = createAreaPages_getCircuitKey( area , info ); if( key.isEmpty() ) continue; circuitKeys.add( key , circuitId ); } // add circuits section - sorted by relevance StringList lines; for( int k = circuitKeys.count() - 1; k >= 0; k-- ) { String circuitId = circuitKeys.getClassByIndex( k ); XmlCircuitInfo& info = wm -> circuitsxml.getCircuitInfo( circuitId ); createAreaPages_getCircuitLines( info , lines ); } String sectionName = "Thirdparty Circuits"; String wikiPage = wm -> getAreaPage( area -> getAreaId() ); wm -> updateFileSection( wikiDir , wikiPage , sectionName , lines ); lines.clear(); // add unique and sorted references - sorted by relevance MapStringToClass<MindArea> refs; for( int k = circuitKeys.count() - 1; k >= 0; k-- ) { String circuitId = circuitKeys.getClassByIndex( k ); XmlCircuitInfo& info = wm -> circuitsxml.getCircuitInfo( circuitId ); if( !info.reference.equals( "UNKNOWN" ) ) if( refs.get( info.reference ) == NULL ) { refs.add( info.reference , area ); lines.add( String( " * " ) + info.reference ); } } sectionName = "References"; wm -> updateFileSection( wikiDir , wikiPage , sectionName , lines ); }
void WikiAreaPages::createAreaPages_getInternalConnections( MindArea *area , MindLocalCircuitDef& circuit , MapStringToClass<MindLocalCircuitConnectionDef>& connections ) { ClassList<MindLocalCircuitConnectionDef> links; circuit.getInternalConnections( links ); for( int k = 0; k < links.count(); k++ ) { MindLocalCircuitConnectionDef *c = links.get( k ); // ignore secondary if( !c -> isPrimary() ) continue; String key = c -> getSrcRegion() + "#" + c -> getDstRegion(); if( connections.get( key ) == NULL ) connections.add( key , c ); } }
void MindMap::getMapRegions( MapStringToClass<MindRegionDef>& regionMap ) { for( int k = 0; k < mindAreaMap.count(); k++ ) { MindAreaDef *areaDef = mindAreaMap.getClassByIndex( k ); ClassList<MindRegionDef>& regionlist = areaDef -> getRegions(); for( int m = 0; m < regionlist.count(); m++ ) { MindRegionDef *regionDef = regionlist.get( m ); regionMap.add( regionDef -> getId() , regionDef ); } } }
void WikiAreaPages::createAreaPages_addExternalConnections( MindArea *area , MindLocalCircuitDef& circuit , StringList& lines , MapStringToClass<MindLocalCircuitConnectionDef>& connections , bool p_inputs ) { if( connections.count() == 0 ) { lines.add( " * no connections" ); return; } createAreaPages_getExternalConnectionTableLine( area , circuit , NULL , lines , p_inputs , NULL ); // split connections by area types MindService *ms = MindService::getService(); MapStringToClass<MapStringToClass<MindLocalCircuitConnectionDef>> groups; for( int k = 0; k < connections.count(); k++ ) { MindLocalCircuitConnectionDef *c = connections.getClassByIndex( k ); String regionId = ( p_inputs )? c -> getSrcRegion() : c -> getDstRegion(); MindRegion *region = ms -> getMindRegion( regionId ); String areaType = region -> getArea() -> getMindAreaDef() -> getAreaType(); MapStringToClass<MindLocalCircuitConnectionDef> *z = groups.get( areaType ); if( z == NULL ) { z = new MapStringToClass<MindLocalCircuitConnectionDef>; groups.add( areaType , z ); } String key = connections.getKeyByIndex( k ); z -> add( key , c ); } for( int k = 0; k < groups.count(); k++ ) { String areaType = groups.getKeyByIndex( k ); MapStringToClass<MindLocalCircuitConnectionDef> *z = groups.getClassByIndex( k ); createAreaPages_getExternalConnectionTableLine( area , circuit , NULL , lines , p_inputs , areaType ); for( int m = 0; m < z -> count(); m++ ) { MindLocalCircuitConnectionDef *c = z -> getClassByIndex( m ); createAreaPages_getExternalConnectionTableLine( area , circuit , c , lines , p_inputs , NULL ); } } }
void XmlSpinalCordLayout::loadLevel( Xml xmlLevel , MapStringToClass<StringList>& levelData ) { for( Xml xmlChild = xmlLevel.getFirstChild( "lamina" ); xmlChild.exists(); xmlChild = xmlChild.getNextChild( "lamina" ) ) { String id = xmlChild.getAttribute( "id" ); String elements = xmlChild.getAttribute( "elements" ); StringList& items = levelData.getRef( id ); StringList parts; elements.split( parts , "," ); for( int k = 0; k < parts.count(); k++ ) { String element = parts.get( k ); ASSERTMSG( hmind -> getIndexedElement( element ) != NULL , "unknown element index=" + element ); if( items.find( element ) < 0 ) items.add( element ); } } }
void WikiAreaPages::createDotFile_subgraph( MindArea *area , MindLocalCircuitDef& circuit , bool p_inputs , MapStringToClass<MindLocalCircuitConnectionDef>& connections , StringList& text , String& linkItem ) { MindService *ms = MindService::getService(); String postfix = ( p_inputs )? "IN" : "OUT"; String postfixString = ( p_inputs )? "Inputs" : "Outputs"; // inter-area links text.add( "" ); if( p_inputs ) { text.add( "\tsubgraph cluster_ExtIn {" ); text.add( "\tlabel=<<b>Inputs</b>>;" ); text.add( "\t/* external inbound links */" ); } else { text.add( "\tsubgraph cluster_ExtOut {" ); text.add( "\tlabel=<<b>Outputs</b>>;" ); text.add( "\t/* external outbound links */" ); } MapStringToClass<MindRegion> areaTypes; MapStringToString areas; MapStringToClass<MapStringToClass<MindRegion>> areaTypeRegionMap; MapStringToClass<ClassList<MindLocalCircuitConnectionDef>> areaTypeConnectivityMap; for( int k = 0; k < connections.count(); k++ ) { MindLocalCircuitConnectionDef *c = connections.getClassByIndex( k ); String regionId = ( p_inputs )? c -> getSrcRegion() : c -> getDstRegion(); String regionLocalId = ( p_inputs )? c -> getDstRegion() : c -> getSrcRegion(); MindRegion *region = ms -> getMindRegion( regionId ); MindRegion *regionLocal = ms -> getMindRegion( regionLocalId ); String areaId = region -> getArea() -> getAreaId(); String areaType = region -> getArea() -> getMindAreaDef() -> getAreaType(); String key = areaType; MapStringToClass<MindRegion> *typeRegions = areaTypeRegionMap.get( key ); ClassList<MindLocalCircuitConnectionDef> *typeConnectivity = areaTypeConnectivityMap.get( key ); if( typeRegions == NULL ) { typeRegions = new MapStringToClass<MindRegion>; typeConnectivity = new ClassList<MindLocalCircuitConnectionDef>; areaTypeRegionMap.add( key , typeRegions ); areaTypeConnectivityMap.add( key , typeConnectivity ); } if( typeRegions -> get( regionId ) == NULL ) typeRegions -> add( regionId , region ); areas.addnew( areaId , areaType ); areaTypes.addnew( areaType , regionLocal ); typeConnectivity -> add( c ); } // add named lines String s; String localArea = area -> getAreaId(); // header text.add( "" ); for( int k = 0; k < areaTypes.count(); k++ ) { String areaType = areaTypes.getKeyByIndex( k ); text.add( "\tsubgraph cluster_" + areaType + "_" + postfix + " {" ); text.add( "\tlabel=\"" + areaType + " " + postfixString + "\";" ); text.add( "\t\"" + areaType + "." + postfix + "\" [ shape=box, style=dotted , label = <" ); text.add( "\t\t<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"4\" CELLPADDING=\"2\"><TR>" ); // regions MapStringToClass<MindRegion> *typeRegions = areaTypeRegionMap.get( areaType ); for( int a = 0; a < typeRegions -> count(); a++ ) { String regionId = typeRegions -> getKeyByIndex( a ); MindRegion *region = typeRegions -> getClassByIndex( a ); String color = getRegionColor( regionId ); String label = createDotFile_getRegionLabel( region -> getRegionInfo() ); text.add( "\t\t<TD PORT=\"" + regionId + "\" BGCOLOR=\"" + color + "\">" + label + "</TD>" ); } text.add( "\t\t</TR></TABLE>> ];" ); text.add( "\t}" ); text.add( "" ); // links ClassList<MindLocalCircuitConnectionDef> *typeConnectivity = areaTypeConnectivityMap.get( areaType ); for( int a = 0; a < typeConnectivity -> count(); a++ ) { MindLocalCircuitConnectionDef *c = typeConnectivity -> get( a ); MindConnectionLinkTypeDef *linkDef = c -> getPrimaryLinkType(); String props = wm -> getLinkProps( linkDef ); String srcId; String dstId; if( p_inputs ) { srcId = "\"" + areaType + "." + postfix + "\":\"" + c -> getSrcRegion() + "\""; dstId = "\"" + c -> getDstRegion() + "\""; } else { srcId = "\"" + c -> getSrcRegion() + "\""; dstId = "\"" + areaType + "." + postfix + "\":\"" + c -> getDstRegion() + "\""; } text.add( "\t" + srcId + " -> " + dstId + props + ";" ); } text.add( "" ); } text.add( "\t}" ); areaTypeRegionMap.destroy(); areaTypeConnectivityMap.destroy(); }
void WikiTractsPages::createNeurons_addFibers( int level , MapStringToClass<XmlBrainFiber>& fibers , StringList& lines ) { for( int k = 0; k < fibers.count(); k++ ) { XmlBrainFiber& fiber = fibers.getClassRefByIndex( k ); createNeurons_addFiberInfo( level , fiber , lines ); } }