66 * Copyright (c) 2013 Ross Kirsling
77 * Released under the MIT License.
88 */
9-
10- // const { index } = require("d3");
11-
12- // app mode constants
139var MODE = {
1410 EDIT : 0 ,
1511 EVAL : 1 ,
@@ -187,8 +183,8 @@ var varCountButtons = d3.selectAll('#edit-pane .var-count button'),
187183 selectedNodeLabel = d3 . select ( '#edit-pane .selected-node-id' ) ,
188184 evalInput = d3 . select ( '#eval-pane .eval-input' ) ,
189185 evalOutput = d3 . select ( '#eval-pane .eval-output' ) ,
190- currentFormula = d3 . select ( '#app-body .current-formula' ) ;
191- currentSubFormula = d3 . select ( '#app-body .current-subformula' ) ;
186+ currentFormula = d3 . select ( '#app-body .current-formula' ) ,
187+ currentSubformula = d3 . select ( '#app-body .current-subformula' ) ,
192188 btnSubformulae = d3 . select ( '#btn-formulae' ) ;
193189
194190function announceFormula ( ) {
@@ -347,30 +343,38 @@ function evaluateFormula() {
347343 . classed ( 'false' , ! truthVal ) ;
348344 } ) ;
349345
346+ currentFormula
347+ . append ( "div" )
348+ // .attr("class", "dropdown-content")
349+
350350 // display evaluated formula
351351 currentFormula
352352 . html ( '<strong>Current formula:</strong><br>$' + wff . latex ( ) + '$' )
353- . classed ( 'inactive' , false ) ;
353+ . classed ( 'inactive' , false )
354+ . on ( 'click' , function ( event ) {
355+ console . log ( 'hola' )
356+ } ) ;
354357
355- currentSubFormula . selectAll ( "*" ) . remove ( ) ;
358+ currentSubformula . selectAll ( "*" ) . remove ( ) ;
356359
357- //display subformulas
358- currentSubFormula
360+ currentSubformula
359361 . classed ( 'inactive' , false ) ;
360362
361- currentSubFormula
363+ currentSubformula
362364 . append ( "button" )
363365 . attr ( "class" , "btn btn-primary" )
364366 . attr ( "id" , "btn-subformulae" )
365367 . html ( "Subformulas" )
366368
367- currentSubFormula
369+ // currentSubformula
370+
371+ currentSubformula
368372 . append ( "div" )
369373 . attr ( "class" , "dropdown-content" )
370374
371- let dropdownmenu = d3 . select ( '.dropdown-content' ) ;
375+ let dropdownmenu = d3 . select ( '.dropdown-content' ) ;
372376 subFormulas . forEach ( ( subf , index ) => {
373- dropdownmenu . append ( "a" )
377+ dropdownmenu . append ( "a" )
374378 . attr ( "id" , `subFormulaRadio_${ index } ` )
375379 . html ( "$" + subf . latex ( ) + "$" )
376380 . on ( "click" , ( ) => {
@@ -379,17 +383,18 @@ function evaluateFormula() {
379383
380384 } )
381385
382- // display truth evaluation
386+ // display true evaluation
383387 var latexTrue = trueStates . length ? '$w_{' + trueStates . join ( '},$ $w_{' ) + '}$' : '$\\varnothing$' ,
384- latexFalse = falseStates . length ? '$w_{' + falseStates . join ( '},$ $w_{' ) + '}$' : '$\\varnothing$' ;
388+ latexFalse = falseStates . length ? '$w_{' + falseStates . join ( '},$ $w_{' ) + '}$' : '$\\varnothing$' ;
389+
385390 evalOutput
386391 . html ( '<div class="alert alert-success"><strong>True:</strong><div><div>' + latexTrue + '</div></div></div>' +
387392 '<div class="alert alert-danger"><strong>False:</strong><div><div>' + latexFalse + '</div></div></div>' )
388393 . classed ( 'inactive' , false ) ;
389394
390395 // re-render LaTeX
391396 MathJax . Hub . Queue ( [ 'Typeset' , MathJax . Hub , currentFormula . node ( ) ] ) ;
392- MathJax . Hub . Queue ( [ 'Typeset' , MathJax . Hub , currentSubFormula . node ( ) ] ) ;
397+ MathJax . Hub . Queue ( [ 'Typeset' , MathJax . Hub , currentSubformula . node ( ) ] ) ;
393398 MathJax . Hub . Queue ( [ 'Typeset' , MathJax . Hub , evalOutput . node ( ) ] ) ;
394399}
395400
@@ -620,7 +625,18 @@ function getSingleCurvedSVGPath([x1, y1], [x2, y2], curviness) {
620625 ',' + x2 + ' ' + y2 ;
621626}
622627
623- function printGraph ( relations ) {
628+ function printGraphAtoms ( ) {
629+ circle . selectAll ( 'text.atoms' )
630+ . text ( function ( d ) {
631+ return propvars
632+ . filter ( function ( _ , i ) { return d . vals [ i ] ; } )
633+ . join ( ', ' ) ;
634+ } )
635+ . attr ( 'y' , 5 ) ;
636+ }
637+
638+
639+ function printGraphRelations ( relations ) {
624640 //remove groups links
625641 links = links . filter ( d => d . agent !== ( 'g' ) && d . agent !== ( 'h' ) ) ;
626642 relations . forEach ( rel => {
@@ -657,7 +673,7 @@ function printGraph(relations){
657673
658674function resetGraph ( ) {
659675 let rel = model . getAllRelationsOfList ( epistemicAgents )
660- printGraph ( rel ) ;
676+ printGraphRelations ( rel ) ;
661677}
662678
663679function subformulaeGraph ( wff ) {
@@ -683,7 +699,7 @@ function subformulaeGraph(wff){
683699 // For showing other arrows.
684700 //links = links.filter(d => !agents.includes(d.agent));
685701 links = [ ]
686- printGraph ( commonRelations )
702+ printGraphRelations ( commonRelations )
687703 } else if ( json . dist_start && json . dist_start . group_end && json . dist_start . group_end [ 0 ] . prop ) {
688704 links = [ ]
689705 const agents = json . dist_start . group_end [ 0 ] . prop . split ( '' ) ;
@@ -692,11 +708,11 @@ function subformulaeGraph(wff){
692708 return { ...rel , agent : 'h' } ;
693709 } ) ;
694710 distRelations = removeDuplicates ( distRelations ) ;
695- printGraph ( distRelations )
711+ printGraphRelations ( distRelations )
696712
697713 } else {
698714 const relations = model . getAllRelationsOfList ( epistemicAgents ) ;
699- printGraph ( relations )
715+ printGraphRelations ( relations )
700716 }
701717 MathJax . Hub . Queue ( [ 'Typeset' , MathJax . Hub , dropbtn ] ) ;
702718}
@@ -1183,9 +1199,10 @@ function setAppMode(newMode) {
11831199 . classed ( 'true' , false )
11841200 . classed ( 'false' , false ) ;
11851201
1186- currentFormula . classed ( 'inactive' , true ) ;
1187- currentSubFormula . classed ( 'inactive' , true ) ;
1188- currentSubFormula . selectAll ( "*" ) . remove ( ) ;
1202+ currentFormula . classed ( 'inactive' , true ) ;
1203+ currentSubformula . classed ( 'inactive' , true ) ;
1204+ currentSubformula . selectAll ( "*" ) . remove ( ) ;
1205+
11891206 } else if ( newMode === MODE . EVAL || newMode === MODE . TEXT ) {
11901207 // disable listeners (except for I-bar prevention)
11911208 svg . classed ( 'edit' , false )
0 commit comments