controlP5 tab & canvas & moveTo

edited November 2013 in Library Questions

I'm working on an sketch which requires the use of 2 canvas. One for main 3D work, and one for layout and 2D. I would like the 2nd Canvas to be added to a tab in the main control window. Is this possible?

i.e cp5.getCanvas(canvas).moveTo("Layout");

There is no get getCanvas, but in principle the moveTo() does according to the reference allow you to move a ControlWindowCanvas to a ControlGroup - which I believe is created in the tab as "Layout". However the moveTo() doesn't accept "Layout" as an argument.

note. Previously, I was using a second ControlWindow and adding the ControlWindowCanvas to this, however I'd like to run everything in the main.

Any help much appreciated.

Thanks, P.

    Slider l, w, gCon, p, maxP, tabSize;
    Bang newNet, checkNet,updateNet, exportNet, Angles, exportSchedule;
    ControlWindowCanvas canvas;
    Textlabel myLabel, myAreaLabel, mySmallestLabel, myLongestLabel, myinfoLabel, myLabelFab;

    int Grid_Length = 10;
    int Grid_Width = 10;
    int Ground_Condition = 1;
    int Selected_Panel = 100;
    int Max_Edge_Length = 35;

    void GUI_setup(){

       cp5 = new ControlP5(this);

       //---------------------------------------------------------
       //Create extra controlwindow:
      //ControlWindow window = cp5.addControlWindow("Fabrication_Info",20,20,300,600);
      //window.setUpdateMode(ControlWindow.NORMAL);

       //Create canvas:
       canvas = new CanvasW();
       canvas.draw(this);

       cp5.getTab("default")
         .activateEvent(true)
         .setLabel("Design")
         .setId(1)
       ;

       cp5.addTab("Layout")
         .activateEvent(true)
         .setLabel("Fabrication")
         .setId(2)
       ;

      // window.draw();

       //----------------------------------------------------------
       //Create sliders:
       int slider_x = 30;
       int slider_y = height - 60;

       l = cp5.addSlider("Grid_Length")
         .setPosition(slider_x,slider_y)
         .setRange(0,15)
         ;

       w = cp5.addSlider("Grid_Width")
         .setPosition(slider_x,slider_y - 20)
         .setRange(0,15)
         ;

       gCon = cp5.addSlider("Ground_Condition")
         .setPosition(slider_x,slider_y + 20)
         .setRange(1,5)
         .setNumberOfTickMarks(5)
         .showTickMarks(false)
         .snapToTickMarks(true)
         ;

        maxP = cp5.addSlider("Max_Edge_Length")
         .setDecimalPrecision(0)
         .setValue(50)
         .setPosition(slider_x,120)
         .setRange(0,100)
         ;

        tabSize = cp5.addSlider("Tab_Size")
         .setDecimalPrecision(0)
         .setValue(50)
         .setPosition(slider_x,60)
         .setRange(0,100)
         ;

       newNet = cp5.addBang("NewGrid")
         .setPosition(slider_x,slider_y - 60)
         .setSize(55,10)
         .setTriggerEvent(Bang.RELEASE)
         .setColorActive(color(255,255,0))
         .setLabel("Update Model")
         ;

       checkNet = cp5.addBang("CheckGrid")
         .setPosition(slider_x+70,slider_y - 60)
         .setSize(55,10)
         .setTriggerEvent(Bang.RELEASE)
         .setColorActive(color(255,255,0))
         .setLabel("Check Model")
         ;

      exportNet = cp5.addBang("ExportNet")
         .setPosition(slider_x+140,slider_y - 60)
         .setSize(55,10)
         .setTriggerEvent(Bang.RELEASE)
         .setColorActive(color(255,255,0))
         .setLabel("Export to DXF")
         ;

      exportSchedule = cp5.addBang("Schedule")
         .setPosition(slider_x+210,slider_y - 60)
         .setSize(55,10)
         .setTriggerEvent(Bang.RELEASE)
         .setColorActive(color(255,255,0))
         .setLabel("Export Schedule")
         ;

       //Content for fab tab:
       p = cp5.addSlider("Selected_Panel")
         .setRange(0,(((Grid_Length-1)*(Grid_Width-1))-1))
         .setDecimalPrecision(0)
         .setValue(50)
         .setPosition(slider_x,90)
         .setRange(0,100)
         ;

      myLabel = cp5.addTextlabel("label")
                        .setText("TO TOGGLE ON/OFF USE:  M  =  MESH,  N  =  NODES,  L  =  LINES,  P  =  PANELS,  R  =  RECORD MOVIE ON/OFF")
                        .setPosition(30,30)
                        .setColorValue(color(255))
                        //.setFont(createFont("Arial",10))
                        ;

       myLabelFab = cp5.addTextlabel("labelFab")
                        .setText("TO TOGGLE ON/OFF USE:  M  =  MESH,  N  =  NODES,  L  =  LINES,  P  =  PANELS,  R  =  RECORD MOVIE ON/OFF")
                        .setPosition(30,30)
                        .setColorValue(color(255))
                        //.setFont(createFont("Arial",10))
                        ;

      myAreaLabel = cp5.addTextlabel("area")
                        .setText("TOTAL AREA:   " + pG.totalArea + " cm2")
                        .setPosition(30,60)
                        .setColorValue(color(255))
                        //.setFont(createFont("Arial",10))
                        ;

      mySmallestLabel = cp5.addTextlabel("smallestedge")
                        .setText("SHORTEST EDGE:   " + pG.shortestEdge + " cm")
                        .setPosition(30,80)
                        .setColorValue(color(255))
                        //.setFont(createFont("Arial",10))
                        ;

       myLongestLabel = cp5.addTextlabel("longestedge")
                        .setText("LONGEST EDGE:   " + pG.longestEdge + " cm")
                        .setPosition(30,100)
                        .setColorValue(color(255))
                        //.setFont(createFont("Arial",10))
                        ;

       myinfoLabel = cp5.addTextlabel("info")
                        .setText("CHANGES THE STANDARD LENGTH OF THE GUAD GRID")
                        .setPosition(30,140)
                        .setColorValue(color(255))
                        ;

       cp5.getController("labelFab").moveTo("Layout");
       cp5.getController("Tab_Size").moveTo("Layout");
       cp5.getController("Selected_Panel").moveTo("Layout");
//cp5.addCanvas(canvas);
       //cp5.moveTo("Layout", canvas);

       cp5.setAutoDraw(false);  

    }

    void gui() {
      cam.beginHUD();
      stroke(255);
      line(35,50,70,50);
      cp5.draw();
      cam.endHUD();
      checkMouseGUI();
    }

Answers

  • Hi,

    I want to do something similar.. I created a second Applet that I use to display text and general info staff that I don't want in the main window, but when I'm adding buttons in the second they don't pass the values to the main one.

    Have solved your issue, or do you have any idea with my problem?

    Thanks Achilleas

Sign In or Register to comment.