From 724d03b8d05b5ef7ef944c648aae8f43dde625be Mon Sep 17 00:00:00 2001
From: bob <bcz@cs.brown.edu>
Date: Tue, 9 Jul 2019 14:18:26 -0400
Subject: from last

---
 .../CollectionFreeFormLinksView.tsx                | 111 ++++++++++-----------
 1 file changed, 53 insertions(+), 58 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
index ebeb1fcee..2d94f1b8e 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
@@ -17,58 +17,56 @@ export class CollectionFreeFormLinksView extends React.Component<CollectionViewP
 
     _brushReactionDisposer?: IReactionDisposer;
     componentDidMount() {
-        this._brushReactionDisposer = reaction(
-            () => {
-                let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
-                return { doclist: doclist ? doclist : [], xs: doclist.map(d => d.x) };
-            },
-            () => {
-                let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
-                let views = doclist ? doclist.filter(doc => StrCast(doc.backgroundLayout).indexOf("istogram") !== -1) : [];
-                views.forEach((dstDoc, i) => {
-                    views.forEach((srcDoc, j) => {
-                        let dstTarg = dstDoc;
-                        let srcTarg = srcDoc;
-                        let x1 = NumCast(srcDoc.x);
-                        let x2 = NumCast(dstDoc.x);
-                        let x1w = NumCast(srcDoc.width, -1) / NumCast(srcDoc.zoomBasis, 1);
-                        let x2w = NumCast(dstDoc.width, -1) / NumCast(srcDoc.zoomBasis, 1);
-                        if (x1w < 0 || x2w < 0 || i === j) { }
-                        else {
-                            let findBrush = (field: (Doc | Promise<Doc>)[]) => field.findIndex(brush => {
-                                let bdocs = brush instanceof Doc ? Cast(brush.brushingDocs, listSpec(Doc), []) : undefined;
-                                return bdocs && bdocs.length && ((bdocs[0] === dstTarg && bdocs[1] === srcTarg)) ? true : false;
-                            });
-                            let brushAction = (field: (Doc | Promise<Doc>)[]) => {
-                                let found = findBrush(field);
-                                if (found !== -1) {
-                                    console.log("REMOVE BRUSH " + srcTarg.title + " " + dstTarg.title);
-                                    field.splice(found, 1);
-                                }
-                            };
-                            if (Math.abs(x1 + x1w - x2) < 20) {
-                                let linkDoc: Doc = new Doc();
-                                linkDoc.title = "Histogram Brush";
-                                linkDoc.linkDescription = "Brush between " + StrCast(srcTarg.title) + " and " + StrCast(dstTarg.Title);
-                                linkDoc.brushingDocs = new List([dstTarg, srcTarg]);
+        // this._brushReactionDisposer = reaction(
+        //     () => {
+        //         let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
+        //         return { doclist: doclist ? doclist : [], xs: doclist.map(d => d.x) };
+        //     },
+        //     () => {
+        //         let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
+        //         let views = doclist ? doclist.filter(doc => StrCast(doc.backgroundLayout).indexOf("istogram") !== -1) : [];
+        //         views.forEach((dstDoc, i) => {
+        //             views.forEach((srcDoc, j) => {
+        //                 let dstTarg = dstDoc;
+        //                 let srcTarg = srcDoc;
+        //                 let x1 = NumCast(srcDoc.x);
+        //                 let x2 = NumCast(dstDoc.x);
+        //                 let x1w = NumCast(srcDoc.width, -1) / NumCast(srcDoc.zoomBasis, 1);
+        //                 let x2w = NumCast(dstDoc.width, -1) / NumCast(srcDoc.zoomBasis, 1);
+        //                 if (x1w < 0 || x2w < 0 || i === j) { }
+        //                 else {
+        //                     let findBrush = (field: (Doc | Promise<Doc>)[]) => field.findIndex(brush => {
+        //                         let bdocs = brush instanceof Doc ? Cast(brush.brushingDocs, listSpec(Doc), []) : undefined;
+        //                         return bdocs && bdocs.length && ((bdocs[0] === dstTarg && bdocs[1] === srcTarg)) ? true : false;
+        //                     });
+        //                     let brushAction = (field: (Doc | Promise<Doc>)[]) => {
+        //                         let found = findBrush(field);
+        //                         if (found !== -1) {
+        //                             field.splice(found, 1);
+        //                         }
+        //                     };
+        //                     if (Math.abs(x1 + x1w - x2) < 20) {
+        //                         let linkDoc: Doc = new Doc();
+        //                         linkDoc.title = "Histogram Brush";
+        //                         linkDoc.linkDescription = "Brush between " + StrCast(srcTarg.title) + " and " + StrCast(dstTarg.Title);
+        //                         linkDoc.brushingDocs = new List([dstTarg, srcTarg]);
 
-                                brushAction = (field: (Doc | Promise<Doc>)[]) => {
-                                    if (findBrush(field) === -1) {
-                                        console.log("ADD BRUSH " + srcTarg.title + " " + dstTarg.title);
-                                        field.push(linkDoc);
-                                    }
-                                };
-                            }
-                            if (dstTarg.brushingDocs === undefined) dstTarg.brushingDocs = new List<Doc>();
-                            if (srcTarg.brushingDocs === undefined) srcTarg.brushingDocs = new List<Doc>();
-                            let dstBrushDocs = Cast(dstTarg.brushingDocs, listSpec(Doc), []);
-                            let srcBrushDocs = Cast(srcTarg.brushingDocs, listSpec(Doc), []);
-                            brushAction(dstBrushDocs);
-                            brushAction(srcBrushDocs);
-                        }
-                    });
-                });
-            });
+        //                         brushAction = (field: (Doc | Promise<Doc>)[]) => {
+        //                             if (findBrush(field) === -1) {
+        //                                 field.push(linkDoc);
+        //                             }
+        //                         };
+        //                     }
+        //                     if (dstTarg.brushingDocs === undefined) dstTarg.brushingDocs = new List<Doc>();
+        //                     if (srcTarg.brushingDocs === undefined) srcTarg.brushingDocs = new List<Doc>();
+        //                     let dstBrushDocs = Cast(dstTarg.brushingDocs, listSpec(Doc), []);
+        //                     let srcBrushDocs = Cast(srcTarg.brushingDocs, listSpec(Doc), []);
+        //                     brushAction(dstBrushDocs);
+        //                     brushAction(srcBrushDocs);
+        //                 }
+        //             });
+        //         });
+        //     });
     }
     componentWillUnmount() {
         if (this._brushReactionDisposer) {
@@ -115,19 +113,16 @@ export class CollectionFreeFormLinksView extends React.Component<CollectionViewP
             });
             return drawnPairs;
         }, [] as { a: Doc, b: Doc, l: Doc[] }[]);
-        return connections.map(c => {
-            let x = c.l.reduce((p, l) => p + l[Id], "");
-            return <CollectionFreeFormLinkView key={x} A={c.a} B={c.b} LinkDocs={c.l}
-                removeDocument={this.props.removeDocument} addDocument={this.props.addDocument} />;
-        });
+        return connections.map(c => <CollectionFreeFormLinkView key={c.l.reduce((p, l) => p + l[Id], "")} A={c.a} B={c.b} LinkDocs={c.l}
+            removeDocument={this.props.removeDocument} addDocument={this.props.addDocument} />);
     }
 
     render() {
         return (
             <div className="collectionfreeformlinksview-container">
-                <svg className="collectionfreeformlinksview-svgCanvas">
+                {/* <svg className="collectionfreeformlinksview-svgCanvas">
                     {this.uniqueConnections}
-                </svg>
+                </svg> */}
                 {this.props.children}
             </div>
         );
-- 
cgit v1.2.3-70-g09d2

