Skip to content

Commit

Permalink
working on visual design and sound
Browse files Browse the repository at this point in the history
  • Loading branch information
obviousjim committed Apr 17, 2013
1 parent 5889c94 commit 6578811
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 29,927 deletions.
4 changes: 2 additions & 2 deletions CloudsFCPParser/CloudsFCPParser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,10 @@
E7432D88170F42CE00C554EC /* CloudsStoryEngine.cpp */,
E7432D85170F42CE00C554EC /* CloudsFCPVisualizer.h */,
E7432D84170F42CE00C554EC /* CloudsFCPVisualizer.cpp */,
E7485408171A048E007B9793 /* CloudsPlaybackController.h */,
E7485407171A048E007B9793 /* CloudsPlaybackController.cpp */,
E7432D81170F42CE00C554EC /* CloudsD3Exporter.h */,
E7432D80170F42CE00C554EC /* CloudsD3Exporter.cpp */,
E7485407171A048E007B9793 /* CloudsPlaybackController.cpp */,
E7485408171A048E007B9793 /* CloudsPlaybackController.h */,
);
path = src;
sourceTree = "<group>";
Expand Down
29,281 changes: 0 additions & 29,281 deletions CloudsFCPParser/bin/data/gephi_edges.csv

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions CloudsFCPParser/src/ViewerApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
- (void)exit;

- (IBAction) togglePlay:(id)sender;
- (IBAction) next:(id)sender;
- (IBAction) prev:(id)sender;

- (void)keyPressed:(int)key;
- (void)keyReleased:(int)key;
Expand Down
16 changes: 4 additions & 12 deletions CloudsFCPParser/src/ViewerApp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ - (IBAction) togglePlay:(id)sender
}
}

- (IBAction) next:(id)sender
{

}

- (IBAction) prev:(id)sender
{

}

- (void)update
{
Expand All @@ -57,10 +48,11 @@ - (void)draw
if(mainview.preview.isLoaded() && mainview.preview.isPlaying()){
mainview.preview.draw(0, 0, 960, 540);
}

ofSetColor(0xc965e2, 50);
ofPushStyle();
ofSetColor(0xc965e2, 150);
float percentDone = [mainview clipPercentComplete];
ofRect(0, ofGetHeight()-10, 540, 10);
ofRect(0, ofGetHeight()-10, 540*percentDone, 10);
ofPopStyle();
}

- (void)exit
Expand Down
2 changes: 1 addition & 1 deletion CloudsFCPParser/src/testView.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
float storyStartTime;

bool movieFileMissing;

bool onPlaylist;
}

@property(nonatomic,readonly) int clipEndFrame;
Expand Down
16 changes: 12 additions & 4 deletions CloudsFCPParser/src/testView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ - (void)setup

movieFileMissing = false;
autoProgressStory = false;
onPlaylist = false;

playingPlaylist = false;
currentPlaylistIndex = 0;
Expand Down Expand Up @@ -51,6 +52,7 @@ - (void)setup
storyEngine.network = &parser;
storyEngine.maxTimesOnTopic = 4;


float randomClip = ofRandom(parser.getAllClips().size() );

cout << "seeding random " << randomClip << "/" << parser.getAllClips().size() << endl;
Expand Down Expand Up @@ -88,7 +90,7 @@ - (void)setup
gui->loadSettings("settings.xml");
gui->disable();

exporter.saveGephiCSV(parser);
//exporter.saveGephiCSV(parser);
}

- (IBAction) regenerateGraph:(id)sender
Expand Down Expand Up @@ -132,7 +134,7 @@ - (float) clipPercentComplete
- (IBAction) nextOnPlaylist:(id)sender
{
// if(playlistTable.selectedRow < visualizer.pathByClip.size()){

if(playlistTable.selectedRow == storyEngine.getClipHistory().size()-1){
if(!storyEngine.selectNewClip()){
return;
Expand All @@ -158,12 +160,14 @@ - (IBAction) prevOnPlaylist:(id)sender

- (IBAction) playCurrentPlaylist:(id)sender
{

if(playlistTable.selectedRow < 0){
[playlistTable selectRowIndexes:[[NSIndexSet alloc] initWithIndex:0]
byExtendingSelection:NO];
}

[self playDoubleClickedRow:playlistTable];
onPlaylist = true;
}

- (IBAction) addClip:(id)sender
Expand Down Expand Up @@ -200,7 +204,9 @@ - (void)update
preview.update();
if(preview.getCurrentFrame() >= clipEndFrame){
preview.stop();
[self nextOnPlaylist:self];
if(onPlaylist){
[self nextOnPlaylist:self];
}
}
}

Expand Down Expand Up @@ -245,7 +251,6 @@ - (void)keyPressed:(int)key

if(key == 'h'){
cout << "toggling vis" << endl;

gui->disable();
}
if(key == 's'){
Expand Down Expand Up @@ -339,6 +344,9 @@ - (IBAction) saveLinks:(id)sender

- (IBAction) playDoubleClickedRow:(id)sender
{

onPlaylist = false; //will get set to true again if we are coming from a playlist

ClipMarker clip;
if(sender == clipTable && clipTable.selectedRow >= 0){
clip = [self selectedClip];
Expand Down
5 changes: 4 additions & 1 deletion CloudsLibrary/src/CloudsD3Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ void CloudsD3Exporter::saveGephiCSV(CloudsFCPParser& parser){
string name = mark.getLinkName();
vector<ClipMarker> links = parser.getClipsWithKeyword(mark.keywords);
for(int j = 0; j < links.size(); j++){
if(name != links[j].getLinkName()){
if(name != links[j].getLinkName() &&
mark.person != links[j].person &&
parser.getNumberOfSharedKeywords(mark, links[j]) > 1 )
{
csvBuffer.append(name + "," + links[j].getLinkName() + "\n");
}
}
Expand Down
27 changes: 26 additions & 1 deletion CloudsLibrary/src/CloudsFCPParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ void CloudsFCPParser::saveLinks(string linkFile){
map<string, vector<CloudsLink> >::iterator it;
int numClips = 0;
for(it = sourceLinks.begin(); it != sourceLinks.end(); it++){
vector<CloudsLink>& clipLinks = it->second;
if(clipLinks.size() == 0){
continue;
}
linksXML.addTag("clip");
linksXML.pushTag("clip", numClips++);

linksXML.addValue("name", it->first);
//linksXML.addValue("meta", sourceLinks[it->first].getMetaInfo() );
vector<CloudsLink>& clipLinks = it->second;
for(int l = 0; l < clipLinks.size(); l++){

linksXML.addTag("link");
Expand Down Expand Up @@ -276,6 +279,18 @@ float CloudsFCPParser::percentOfClipsLinked(){
return (1.0*clipsLinked)/markers.size();
}

void CloudsFCPParser::suppressConnection(ClipMarker& a, ClipMarker& b){

}

void CloudsFCPParser::unsuppressConnection(ClipMarker& a, ClipMarker& b){

}

bool CloudsFCPParser::isConnectionSuppressed(ClipMarker& a, ClipMarker& b){

}

vector<string>& CloudsFCPParser::getAllKeywords(){
if(keywordsDirty){
refreshKeywordVector();
Expand Down Expand Up @@ -375,6 +390,16 @@ int CloudsFCPParser::getNumberOfSharedClips(string keywordA, string keywordB){
return clipsInCommon;
}

int CloudsFCPParser::getNumberOfSharedKeywords(ClipMarker& a, ClipMarker& b){
int sharedKeywordCount = 0;
for(int i = 0; i < a.keywords.size(); i++){
if(ofContains(b.keywords, a.keywords[i])){
sharedKeywordCount++;
}
}
return sharedKeywordCount;
}

//
//Return a vector of keywords shared by both clips
vector<string> CloudsFCPParser::getSharedKeywords(ClipMarker& a, ClipMarker& b){
Expand Down
10 changes: 9 additions & 1 deletion CloudsLibrary/src/CloudsFCPParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CloudsFCPParser {
CloudsFCPParser();
void setup(string directory);
void refreshXML();

#pragma mark Clips
ClipMarker getClipWithLinkName( string linkname );

Expand Down Expand Up @@ -73,6 +74,11 @@ class CloudsFCPParser {

float percentOfClipsLinked();

#pragma mark Liking
void suppressConnection(ClipMarker& a, ClipMarker& b);
void unsuppressConnection(ClipMarker& a, ClipMarker& b);
bool isConnectionSuppressed(ClipMarker& a, ClipMarker& b);

#pragma mark Keywords
void sortKeywordsByOccurrence(bool byOccurrence);
vector<string>& getAllKeywords();
Expand All @@ -81,6 +87,7 @@ class CloudsFCPParser {
vector<ClipMarker> getClipsWithKeyword(string filterWord);
vector<ClipMarker> getClipsWithKeyword(const vector<string>& filter);
set<string> getRelatedKeywords(string filterWord);
int getNumberOfSharedKeywords(ClipMarker& a, ClipMarker& b);
vector<string> getSharedKeywords(ClipMarker& a, ClipMarker& b);
int getNumberOfSharedClips(string keywordA, string keywordB);

Expand All @@ -103,7 +110,8 @@ class CloudsFCPParser {
vector<string> keywordVector;

map<string, vector<CloudsLink> > sourceLinks;

map<string, vector<string> > sourceSupression;

bool keywordsDirty;
void refreshKeywordVector();
bool sortedByOccurrence;
Expand Down
24 changes: 17 additions & 7 deletions CloudsLibrary/src/CloudsFCPVisualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ CloudsFCPVisualizer::CloudsFCPVisualizer(){
maxRadius = 50;
minMass = 1;
maxMass = 0;
minScore = 0;
maxScore = 1;
cursorRadius = 10;

/*
Expand Down Expand Up @@ -83,6 +85,7 @@ void CloudsFCPVisualizer::clear(){
pathByClip.clear();
pathByParticles.clear();
pathBySprings.clear();
springScores.clear();

pathChanged = true;
centerNode = NULL;
Expand Down Expand Up @@ -122,11 +125,12 @@ void CloudsFCPVisualizer::setupPhysics(){
physics.setWorldSize(ofVec2f(0,0), ofVec2f(width*10,height*10));
physics.setSectorCount(1);
physics.setDrag(0.1f);
// physics.setDrag(.);
}


void CloudsFCPVisualizer::addLinksToPhysics(ClipMarker& center, vector<ClipMarker>& connections)
void CloudsFCPVisualizer::addLinksToPhysics(ClipMarker& center,
vector<ClipMarker>& connections,
vector<float>& scores)
{

vector<msa::physics::Particle2D*> newParticles;
Expand All @@ -139,8 +143,14 @@ void CloudsFCPVisualizer::addLinksToPhysics(ClipMarker& center, vector<ClipMarke
cout << "re adding " << center.getLinkName() << endl;
return;
}

pathChanged = true;

for(int i = 0; i < scores.size(); i++){
maxScore = MAX(maxScore, scores[i]);
minScore = MIN(minScore, scores[i]);
}

msa::physics::Particle2D* p;
if(hasParticle( mainLinkName )){
p = particlesByTag[ mainLinkName];
Expand Down Expand Up @@ -198,6 +208,7 @@ void CloudsFCPVisualizer::addLinksToPhysics(ClipMarker& center, vector<ClipMarke
springs.find( make_pair(p, a) ) == springs.end() ){
//use clips in common to weight the lines
msa::physics::Spring2D* newSpring = physics.makeSpring(a, p, springStrength, restLength );
springScores[newSpring] = scores[i];
springs[ make_pair(p, a) ] = newSpring;
keywordsInSpring[ newSpring ] = database->getSharedKeywords(center, relatedClip);
if(isLink){
Expand Down Expand Up @@ -231,7 +242,6 @@ void CloudsFCPVisualizer::addLinksToPhysics(ClipMarker& center, vector<ClipMarke
pathSpring->setRestLength(restLength*3);
pathBySprings.push_back( pathSpring );
}

}

bool CloudsFCPVisualizer::getPathChanged(){
Expand Down Expand Up @@ -338,12 +348,12 @@ void CloudsFCPVisualizer::drawPhysics(){

if(linkSprings.find(s) != linkSprings.end()){
// ofSetColor(selectedColor, ofMap(numClips*2, 1, 10, 50, 255));
ofSetColor(nodeColor, 128);
ofSetLineWidth(2.5);
ofSetColor(hoverColor, 128);
ofSetLineWidth(4);
}
else{
ofSetColor(lineColor, ofMap(numClips, 1, 10, 50, 255));
ofSetLineWidth(.5 + numClips/2.0);
ofSetLineWidth( ofMap(springScores[s], minScore, maxScore, .1, 5) );
}

ofVec2f pos1 = s->getOneEnd()->getPosition();
Expand Down Expand Up @@ -428,7 +438,7 @@ void CloudsFCPVisualizer::drawPhysics(){
ofVec2f pos1 = s->getOneEnd()->getPosition();
ofVec2f pos2 = s->getTheOtherEnd()->getPosition();
ofVec2f middle = screenPointForGraphPoint( pos1.getInterpolated(pos2, .5) );
string keywordString = ofJoinString(keywordsInSpring[s], "\n");
string keywordString = "Score: " + ofToString(springScores[s],2) + "\n" + ofJoinString(keywordsInSpring[s], "\n");

ofSetColor(220);
font.drawString(keywordString, middle.x, middle.y);
Expand Down
4 changes: 3 additions & 1 deletion CloudsLibrary/src/CloudsFCPVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CloudsFCPVisualizer {

void addAllClipsWithAttraction();
void addTagToPhysics(string tag);
void addLinksToPhysics(ClipMarker& center, vector<ClipMarker>& connections);
void addLinksToPhysics(ClipMarker& center, vector<ClipMarker>& connections, vector<float>& scores);

void mousePressed(ofMouseEventArgs& args);
void mouseMoved(ofMouseEventArgs& args);
Expand All @@ -65,6 +65,7 @@ class CloudsFCPVisualizer {
vector< ClipMarker > pathByClip;
vector< msa::physics::Particle2D* > pathByParticles;
vector< msa::physics::Spring2D* > pathBySprings;
map< msa::physics::Spring2D*, float > springScores;

string currentTopic;

Expand Down Expand Up @@ -124,6 +125,7 @@ class CloudsFCPVisualizer {

float cursorRadius;
float minMass, maxMass;
float minScore, maxScore;
float radiusForNode(float mass);

bool pathChanged;
Expand Down
Loading

0 comments on commit 6578811

Please sign in to comment.