(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 27173, 742] NotebookOptionsPosition[ 26291, 706] NotebookOutlinePosition[ 26774, 727] CellTagsIndexPosition[ 26731, 724] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Simple circuit builder", "Title", TextAlignment->Center, TextJustification->0], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell["\<\ This example demonstrates the power of the Graphics\[Breve]Region concept. It \ is a prototype circuit builder. You can drag circuit symbols from the left \ hand column on to the graph-paper area. When released these components will \ snap to the grid, and can, if necessary, be dragged further to adjust their \ position. Lines can be drawn between components representing wires. This is \ only a prototype because lots of features could be added, but would just \ clutter the code and make it hard to understand, however, if you understand \ this example it should be easy to construct any number of related \ applications.\ \>", "Text"], Cell[CellGroupData[{ Cell["Code", "Subsection"], Cell[BoxData[ RowBox[{ RowBox[{"Needs", "[", "\"\\"", "]"}], ";"}]], "Input",\ CellLabel->"In[1]:="], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", "cached\[Breve]image", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"grid\[Breve]size", "=", "20"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"lh\[Breve]margin", "=", RowBox[{"7", "*", "grid\[Breve]size"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Image\[Breve]Insert", "[", RowBox[{ "file_", ",", "x_", ",", "y_", ",", "xscale_", ",", "yscale_", ",", "drag\[Breve]function_", ",", "name_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"image", ",", "dims", ",", "sx", ",", "sy"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"cached\[Breve]image", "[", "file", "]"}], "//", "Head"}], ")"}], "===", "cached\[Breve]image"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"cached\[Breve]image", "[", "file", "]"}], "=", RowBox[{"Import", "[", RowBox[{"file", ",", "\"\\""}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"image", "=", RowBox[{"cached\[Breve]image", "[", "file", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dims", "=", RowBox[{"Dimensions", "[", RowBox[{ RowBox[{"Cases", "[", RowBox[{"image", ",", "_Raster", ",", "\[Infinity]"}], "]"}], "[", RowBox[{"[", RowBox[{"1", ",", "1"}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sx", "=", RowBox[{ RowBox[{"dims", "[", RowBox[{"[", "2", "]"}], "]"}], "*", "xscale"}]}], ";", "\[IndentingNewLine]", RowBox[{"sy", "=", RowBox[{ RowBox[{"dims", "[", RowBox[{"[", "1", "]"}], "]"}], "*", "yscale"}]}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"x", "+", "sx", "-", "1"}], ",", RowBox[{"y", "+", "sy", "-", "1"}]}], "}"}], ",", "image"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics\[Breve]Region", "[", RowBox[{"name", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"x", "+", "sx", "-", "1"}], ",", "y"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"x", "+", "sx", "-", "1"}], ",", RowBox[{"y", "+", "sy", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"y", "+", "sy", "-", "1"}]}], "}"}]}], "}"}], ",", RowBox[{"Mouse\[Breve]Cursor", "->", "\"\\""}], ",", RowBox[{ "Action\[Breve]Function", "\[Rule]", "drag\[Breve]function"}], ",", RowBox[{"Menu", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\"\\"", ",", "a1"}], "}"}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"{", RowBox[{"{", RowBox[{"\"\\"", ",", "d1"}], "}"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", "b1"}], "}"}]}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"Leave\[Breve]Dragged\[Breve]Image", "\[Rule]", "True"}], ",", RowBox[{ "Mouse\[Breve]Mode", "\[Rule]", "Region\[Breve]Drag\[Breve]Action"}]}], "]"}]}], "}"}]}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Note", " ", "that", " ", "none", " ", "of", " ", "these", " ", "do", " ", "anything", " ", "at", " ", "present", " ", "\[Dash]", " ", "they", " ", "could", " ", "be", " ", "configured", " ", "as", " ", "required"}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"a1", "[", "x_", "]"}], ":=", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"b1", "[", "x_", "]"}], ":=", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"d1", "[", "x_", "]"}], ":=", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "x"}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.4350642343125*^9, 3.435064241515625*^9}}, CellLabel->"In[2]:="], Cell[BoxData[{ RowBox[{ RowBox[{"ToExpression", "[", "\"\<{clip}\>\"", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"draw\[Breve]component", "[", RowBox[{"resistor", "[", RowBox[{"name_", ",", "x_", ",", "y_"}], "]"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Image\[Breve]Insert", "[", RowBox[{ RowBox[{ RowBox[{"SuperWidgetPackagePath", "[", "]"}], "<>", "\"\\""}], ",", "x", ",", "y", ",", "1", ",", "1", ",", "resistorDrag", ",", "name"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\n", RowBox[{ RowBox[{ RowBox[{"draw\[Breve]component", "[", RowBox[{"pnp\[Breve]transistor", "[", RowBox[{"name_", ",", "x_", ",", "y_"}], "]"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Image\[Breve]Insert", "[", RowBox[{ RowBox[{ RowBox[{"SuperWidgetPackagePath", "[", "]"}], "<>", "\"\\""}], ",", "x", ",", "y", ",", "1", ",", "1", ",", "pnp\[Breve]trDrag", ",", "name"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\n", RowBox[{ RowBox[{ RowBox[{ RowBox[{"draw\[Breve]component", "[", RowBox[{"npn\[Breve]transistor", "[", RowBox[{"name_", ",", "x_", ",", "y_"}], "]"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Image\[Breve]Insert", "[", RowBox[{ RowBox[{ RowBox[{"SuperWidgetPackagePath", "[", "]"}], "<>", "\"\\""}], ",", "x", ",", "y", ",", "1", ",", "1", ",", "npn\[Breve]trDrag", ",", "name"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"draw\[Breve]component", "[", RowBox[{"wire", "[", RowBox[{"x1_", ",", "y1_", ",", "x2_", ",", "y2_"}], "]"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"AbsoluteThickness", "[", "2", "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"x1", ",", "y1"}], "}"}], ",", RowBox[{"{", RowBox[{"x2", ",", "y2"}], "}"}]}], "}"}], "]"}]}], "}"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"draw\[Breve]component", "[", RowBox[{"capacitor", "[", RowBox[{"name_", ",", "x_", ",", "y_"}], "]"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Image\[Breve]Insert", "[", RowBox[{ RowBox[{ RowBox[{"SuperWidgetPackagePath", "[", "]"}], "<>", "\"\\""}], ",", "x", ",", "y", ",", "1", ",", "1", ",", "capacitorDrag", ",", "name"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"draw\[Breve]component", "[", RowBox[{"electrolytic", "[", RowBox[{"name_", ",", "x_", ",", "y_"}], "]"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Image\[Breve]Insert", "[", RowBox[{ RowBox[{ RowBox[{"SuperWidgetPackagePath", "[", "]"}], "<>", "\"\\""}], ",", "x", ",", "y", ",", "1", ",", "1", ",", "electrolyticDrag", ",", "name"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"clip", "[", "x_", "]"}], ":=", RowBox[{"grid\[Breve]size", "*", RowBox[{"Round", "[", RowBox[{"x", "/", "grid\[Breve]size"}], "]"}]}]}]}], "Input", CellLabel->"In[9]:="], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"ToExpression", "[", "\"\<{tr0,trx0}\>\"", "]"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"SetAttributes", "[", RowBox[{"trDrag", ",", "HoldFirst"}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"circuit", "=", RowBox[{"{", "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"pnp\[Breve]trDrag", "[", RowBox[{"v_", ",", "x1_", ",", "y1_", ",", "x2_", ",", "y2_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "tr\[Breve]name", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"tr\[Breve]name", "=", RowBox[{"Unique", "[", "\"\\"", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x1", ">", "lh\[Breve]margin"}], ",", "\[IndentingNewLine]", RowBox[{"circuit", "=", RowBox[{"DeleteCases", "[", RowBox[{"circuit", ",", RowBox[{"pnp\[Breve]transistor", "[", RowBox[{"v", ",", "_", ",", "_"}], "]"}], ",", "\[Infinity]"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x2", ">", "lh\[Breve]margin"}], ",", RowBox[{"circuit", "=", RowBox[{"Append", "[", RowBox[{"circuit", ",", RowBox[{"pnp\[Breve]transistor", "[", RowBox[{"tr\[Breve]name", ",", RowBox[{"clip", "[", "x2", "]"}], ",", RowBox[{"clip", "[", "y2", "]"}]}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"UpdateWidgetValue", "[", "vv", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"npn\[Breve]trDrag", "[", RowBox[{"v_", ",", "x1_", ",", "y1_", ",", "x2_", ",", "y2_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "tr\[Breve]name", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"tr\[Breve]name", "=", RowBox[{"Unique", "[", "\"\\"", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x1", ">", "lh\[Breve]margin"}], ",", "\[IndentingNewLine]", RowBox[{"circuit", "=", RowBox[{"DeleteCases", "[", RowBox[{"circuit", ",", RowBox[{"npn\[Breve]transistor", "[", RowBox[{"v", ",", "_", ",", "_"}], "]"}], ",", "\[Infinity]"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x2", ">", "lh\[Breve]margin"}], ",", RowBox[{"circuit", "=", RowBox[{"Append", "[", RowBox[{"circuit", ",", RowBox[{"npn\[Breve]transistor", "[", RowBox[{"tr\[Breve]name", ",", RowBox[{"clip", "[", "x2", "]"}], ",", RowBox[{"clip", "[", "y2", "]"}]}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"UpdateWidgetValue", "[", "vv", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"resistorDrag", "[", RowBox[{"v_", ",", "x1_", ",", "y1_", ",", "x2_", ",", "y2_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "tr\[Breve]name", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"res\[Breve]name", "=", RowBox[{"Unique", "[", "\"\\"", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x1", ">", "lh\[Breve]margin"}], ",", "\[IndentingNewLine]", RowBox[{"circuit", "=", RowBox[{"DeleteCases", "[", RowBox[{"circuit", ",", RowBox[{"resistor", "[", RowBox[{"v", ",", "_", ",", "_"}], "]"}], ",", "\[Infinity]"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x2", ">", "lh\[Breve]margin"}], ",", RowBox[{"circuit", "=", RowBox[{"Append", "[", RowBox[{"circuit", ",", RowBox[{"resistor", "[", RowBox[{"res\[Breve]name", ",", RowBox[{"clip", "[", "x2", "]"}], ",", RowBox[{"clip", "[", "y2", "]"}]}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"UpdateWidgetValue", "[", "vv", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"capacitorDrag", "[", RowBox[{"v_", ",", "x1_", ",", "y1_", ",", "x2_", ",", "y2_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "tr\[Breve]name", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"res\[Breve]name", "=", RowBox[{"Unique", "[", "\"\\"", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x1", ">", "lh\[Breve]margin"}], ",", "\[IndentingNewLine]", RowBox[{"circuit", "=", RowBox[{"DeleteCases", "[", RowBox[{"circuit", ",", RowBox[{"capacitor", "[", RowBox[{"v", ",", "_", ",", "_"}], "]"}], ",", "\[Infinity]"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x2", ">", "lh\[Breve]margin"}], ",", RowBox[{"circuit", "=", RowBox[{"Append", "[", RowBox[{"circuit", ",", RowBox[{"capacitor", "[", RowBox[{"res\[Breve]name", ",", RowBox[{"clip", "[", "x2", "]"}], ",", RowBox[{"clip", "[", "y2", "]"}]}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"UpdateWidgetValue", "[", "vv", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"electrolyticDrag", "[", RowBox[{"v_", ",", "x1_", ",", "y1_", ",", "x2_", ",", "y2_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "tr\[Breve]name", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"res\[Breve]name", "=", RowBox[{"Unique", "[", "\"\\"", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x1", ">", "lh\[Breve]margin"}], ",", "\[IndentingNewLine]", RowBox[{"circuit", "=", RowBox[{"DeleteCases", "[", RowBox[{"circuit", ",", RowBox[{"electrolytic", "[", RowBox[{"v", ",", "_", ",", "_"}], "]"}], ",", "\[Infinity]"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"x2", ">", "lh\[Breve]margin"}], ",", RowBox[{"circuit", "=", RowBox[{"Append", "[", RowBox[{"circuit", ",", RowBox[{"electrolytic", "[", RowBox[{"res\[Breve]name", ",", RowBox[{"clip", "[", "x2", "]"}], ",", RowBox[{"clip", "[", "y2", "]"}]}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"UpdateWidgetValue", "[", "vv", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"circuit\[Breve]resize", "[", RowBox[{"_", ",", "w_", ",", "h_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"circuit\[Breve]width", "=", "w"}], ";", "\[IndentingNewLine]", RowBox[{"circuit\[Breve]height", "=", "h"}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"UpdateWidgetValue", "[", RowBox[{"vv", ",", RowBox[{"ReCalibrate", "\[Rule]", "True"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"draw\[Breve]wire", "[", RowBox[{"var_", ",", "x1_", ",", "y1_", ",", "x2_", ",", "y2_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"x2", ">", "lh\[Breve]margin"}], ",", RowBox[{"circuit", "=", RowBox[{"Append", "[", RowBox[{"circuit", ",", RowBox[{"wire", "[", RowBox[{ RowBox[{"x1", "//", "clip"}], ",", RowBox[{"y1", "//", "clip"}], ",", RowBox[{"x2", "//", "clip"}], ",", RowBox[{"y2", "//", "clip"}]}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"UpdateWidgetValue", "[", "vv", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"circuit\[Breve]width", "=", "800"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"circuit\[Breve]height", "=", "600"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Circuit\[Breve]Diagram", "[", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"width", "=", "circuit\[Breve]width"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"0.8", ",", "0.8", ",", "0.8"}], "]"}], ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"lh\[Breve]margin", ",", "circuit\[Breve]height"}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"0.7", ",", "0.7", ",", "0.7"}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"lh\[Breve]margin", ",", "k"}], "}"}], ",", RowBox[{"{", RowBox[{"width", ",", "k"}], "}"}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{ "k", ",", "0", ",", "circuit\[Breve]height", ",", "grid\[Breve]size"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"k", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", "circuit\[Breve]height"}], "}"}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{ "k", ",", "lh\[Breve]margin", ",", "circuit\[Breve]width", ",", "grid\[Breve]size"}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"Map", "[", RowBox[{"draw\[Breve]component", ",", RowBox[{"Join", "[", RowBox[{"circuit", ",", RowBox[{"{", RowBox[{ RowBox[{"pnp\[Breve]transistor", "[", RowBox[{"tr0", ",", "0", ",", "0"}], "]"}], ",", " ", RowBox[{"npn\[Breve]transistor", "[", RowBox[{"trx0", ",", "0", ",", "100"}], "]"}], ",", RowBox[{"resistor", "[", RowBox[{"R0", ",", "0", ",", "200"}], "]"}], ",", RowBox[{"capacitor", "[", RowBox[{"C0", ",", "0", ",", "300"}], "]"}], ",", RowBox[{"electrolytic", "[", RowBox[{"V0", ",", "0", ",", "400"}], "]"}]}], "}"}]}], "]"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics\[Breve]Region", "[", RowBox[{"surface", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"lh\[Breve]margin", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"lh\[Breve]margin", ",", RowBox[{"circuit\[Breve]height", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"circuit\[Breve]width", "-", "1"}], ",", RowBox[{"circuit\[Breve]height", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"circuit\[Breve]width", "-", "1"}], ",", "0"}], "}"}]}], "}"}], ",", RowBox[{ "Mouse\[Breve]Mode", "\[Rule]", "Line\[Breve]Drag\[Breve]Action"}], ",", RowBox[{"Action\[Breve]Function", "\[Rule]", "draw\[Breve]wire"}], ",", RowBox[{ "Leave\[Breve]Dragged\[Breve]Image", "\[Rule]", "True"}]}], "]"}]}], "}"}], ",", RowBox[{"ImageSize", "\[Rule]", RowBox[{"{", RowBox[{"circuit\[Breve]width", ",", "circuit\[Breve]height"}], "}"}]}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "circuit\[Breve]width"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "circuit\[Breve]height"}], "}"}]}], "}"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}]}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"vv", "=", RowBox[{"Circuit\[Breve]Diagram", "[", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"SuperWidgetFrame", "[", RowBox[{"fr1", ",", RowBox[{"{", RowBox[{"SuperWidgetGraphicsPanel", "[", RowBox[{"vv", ",", RowBox[{"ResizeFunction", "\[Rule]", "circuit\[Breve]resize"}]}], " ", "]"}], "}"}], ",", RowBox[{"Window\[Breve]Position", "\[Rule]", RowBox[{"{", RowBox[{"10", ",", "10"}], "}"}]}]}], "]"}], "//", "SuperGUIRunModal"}], ";"}]}], "Input", CellLabel->"In[17]:="] }, Open ]], Cell[CellGroupData[{ Cell["Comments", "Subsection"], Cell["", "Text"] }, Open ]] }, Open ]] }, Open ]] }, AutoGeneratedPackage->Automatic, WindowToolbars->"EditBar", WindowSize->{994, 887}, WindowMargins->{{108, Automatic}, {Automatic, 0}}, Visible->True, ShowSelection->True, ShowCellLabel->False, Magnification->1.25, FrontEndVersion->"6.0 for Microsoft Windows (64-bit) (May 21, 2008)", StyleDefinitions->"HelpBrowser.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 86, 2, 128, "Title"], Cell[CellGroupData[{ Cell[701, 29, 31, 0, 78, "Section"], Cell[735, 31, 649, 10, 82, "Text"], Cell[CellGroupData[{ Cell[1409, 45, 26, 0, 46, "Subsection"], Cell[1438, 47, 127, 4, 30, "Input"], Cell[1568, 53, 5052, 135, 493, "Input"], Cell[6623, 190, 4239, 112, 669, "Input"], Cell[10865, 304, 15300, 390, 1769, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[26202, 699, 30, 0, 48, "Subsection"], Cell[26235, 701, 16, 0, 29, "Text"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)