merge trunk 17122:17213
[blender-staging.git] / source / blender / src / drawview.c
index de3e464060d00b8e955d49b1c9aa8a732ba6eede..dbc9dcfd805043ae96f3857d5b9eaade791ed744 100644 (file)
 #include "BIF_resources.h"
 #include "BIF_retopo.h"
 #include "BIF_screen.h"
+#include "BIF_sketch.h"
 #include "BIF_space.h"
 
 #ifdef WITH_VERSE
 #include "BDR_vpaint.h"
 #include "BDR_sculptmode.h"
 #include "BDR_gpencil.h"
+#include "BDR_sketch.h"
 
 #include "BSE_drawview.h"
 #include "BSE_filesel.h"
@@ -2271,6 +2273,62 @@ static void view3d_panel_transform_spaces(short cntrl)
        if(yco < 0) uiNewPanelHeight(block, height-yco);
 }
 
+static void delete_sketch_armature(void *arg1, void *arg2)
+{
+       BIF_deleteSketch();
+}
+
+static void convert_sketch_armature(void *arg1, void *arg2)
+{
+       BIF_convertSketch();
+}
+
+static void view3d_panel_bonesketch_spaces(short cntrl)
+{
+       uiBlock *block;
+       uiBut *but;
+       int yco = 70, height = 140;
+//     int index;
+
+       /* replace with check call to sketching lib */
+       if (G.obedit && G.obedit->type == OB_ARMATURE)
+       {
+               block= uiNewBlock(&curarea->uiblocks, "view3d_panel_bonesketch_spaces", UI_EMBOSS, UI_HELV, curarea->win);
+               uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE  | cntrl);
+               uiSetPanelHandler(VIEW3D_HANDLER_BONESKETCH);  // for close and esc
+       
+               if(uiNewPanel(curarea, block, "Bone Sketching", "View3d", 10, 230, 318, height)==0) return;
+       
+               uiNewPanelHeight(block, height);
+       
+               uiBlockBeginAlign(block);
+               
+               /* use real flag instead of 1 */
+               uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, 225, 130, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
+               uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 140, 225, 20, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
+               but = uiDefBut(block, BUT, B_REDR, "Convert", 10,205,150,20, 0, 0, 0, 0, 0, "Convert sketch to armature");
+               uiButSetFunc(but, convert_sketch_armature, NULL, NULL);
+               but = uiDefBut(block, BUT, B_REDR, "Delete", 10,185,150,20, 0, 0, 0, 0, 0, "Delete sketch");
+               uiButSetFunc(but, delete_sketch_armature, NULL, NULL);
+               
+               uiBlockEndAlign(block);
+
+               uiBlockBeginAlign(block);
+
+               uiDefButBitS(block, TOG, SKGEN_CUT_LENGTH, B_REDR,              "Length",               10, 155, 60, 19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,                             "Subdivide arcs in bones of equal length");
+               uiDefButF(block, NUM, B_REDR,                                                   "L:",                   70, 155, 90, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,            "Maximum length of the bones when subdividing");
+
+               uiDefButBitS(block, TOG, SKGEN_CUT_CORRELATION, B_REDR, "Correlation",  10, 135, 60, 19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,                                     "Subdivide arcs based on correlation");
+               uiDefButF(block, NUM, B_REDR,                                                   "T:",                   70, 135, 90, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0,     "Specify the threshold correlation for subdivision");
+       
+               uiDefButBitS(block, TOG, SKGEN_CUT_FIXED, B_REDR,               "Fixed",                10, 115, 60, 19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,                                     "Subdivide arcs based on a fixed number of bones");
+               uiDefButC(block, NUM, B_REDR,                                                   "N:",                   70, 115, 90, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Specify the bones to subdivide into");
+
+               uiBlockEndAlign(block);
+               
+               if(yco < 0) uiNewPanelHeight(block, height-yco);
+       }
+}
 
 static void view3d_panel_object(short cntrl)   // VIEW3D_HANDLER_OBJECT
 {
@@ -2662,6 +2720,9 @@ static void view3d_blockhandlers(ScrArea *sa)
                case VIEW3D_HANDLER_GREASEPENCIL:
                        view3d_panel_gpencil(v3d->blockhandler[a+1]);
                        break;
+               case VIEW3D_HANDLER_BONESKETCH:
+                       view3d_panel_bonesketch_spaces(v3d->blockhandler[a+1]);
+                       break;
                }
                /* clear action value for event */
                v3d->blockhandler[a+1]= 0;
@@ -3270,6 +3331,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
        /* draw grease-pencil stuff */
        if (v3d->flag2 & V3D_DISPGP)
                draw_gpencil_3dview(sa, 1);
+               
+       BDR_drawSketch();
        
        persp(PERSP_WIN);  // set ortho