void snapShots3Dviewer(V3DPluginCallback2 & v3d, QWidget * parent)
{
    QFileDialog inANO_d(parent);
    inANO_d.setWindowTitle(QObject::tr("Choose input ano filename"));
    inANO_d.setAcceptMode(QFileDialog::AcceptOpen);
    if (!inANO_d.exec()) return;
    QString inANO_fn = (inANO_d.selectedFiles())[0];

    P_ObjectFileType cc;
    if(! loadAnoFile(inANO_fn,cc)){
        cout <<"Fail to load ano file" <<endl;
        return;
    }


    QString output_d=QFileDialog::getExistingDirectory(parent,
    QString(QObject::tr("Choose the output directory, where the snapshots would be saved.")));


    float x_rot = QInputDialog::getDouble(parent, "Roation about x axis",
                                 "Rotation about x :",
                                 90, -180, 180);


    float  y_rot = QInputDialog::getDouble(parent, "Roation about y axis",
                                 "Rotation about y :",
                                0, -180, 180);



    float z_rot = QInputDialog::getDouble(parent, "Roation about z axis",
                                 "Rotation about z :",
                                 90, -180, 180);

    for(int i = 0; i <cc.swc_file_list.size(); i++)
    {
        QString swc_file = cc.swc_file_list[i];

        v3d.open3DViewerForSingleSurfaceFile(swc_file);

        QList<V3dR_MainWindow * > list_3dviewer = v3d.getListAll3DViewers();
        V3dR_MainWindow * surface_win = list_3dviewer[i];
        if (!surface_win)
        {
            cout << "surface_win is empty"<<endl;
        }
        View3DControl  *view = v3d.getView3DControl_Any3DViewer(surface_win);
        view->doAbsoluteRot(x_rot,y_rot,z_rot);
        swc_file = QFileInfo(swc_file).fileName();
        QString BMPfilename = QDir(output_d).absolutePath()+ '/'+swc_file;
       // v3d_msg(BMPfilename);
        v3d.update_3DViewer(surface_win);
        v3d.screenShot_Any3DViewer(surface_win, BMPfilename);

        v3d.close3DWindow(surface_win);
    }

}
void SetNeuronDisplayColor::do1clickcolor(V3DPluginCallback2 &callback, QWidget *parent)
{
    //select the window to operate
    QList <V3dR_MainWindow *> allWindowList = callback.getListAll3DViewers();
    QList <V3dR_MainWindow *> selectWindowList;
    V3dR_MainWindow * v3dwin;
    QList<NeuronTree> * ntTreeList;
    int winid;
    qDebug("search for 3D windows");
    for (V3DLONG i=0;i<allWindowList.size();i++)
    {
        ntTreeList = callback.getHandleNeuronTrees_Any3DViewer(allWindowList[i]);
        if(ntTreeList->size()>0)
            selectWindowList.append(allWindowList[i]);
    }
    qDebug("match and select 3D windows");
    if(selectWindowList.size()<1){
        v3d_msg("Cannot find 3D view with SWC file. Please load the SWC files you want to color in the 3D view");
        return;
    }else if(selectWindowList.size()>1){
        //pop up a window to select

        QStringList items;
        for(int i=0; i<selectWindowList.size(); i++){
            items.append(callback.getImageName(selectWindowList[i]));
        }
        bool ok;
        QString selectitem = QInputDialog::getItem(parent, QString::fromUtf8("1-click neuron color"), QString::fromUtf8("Select A Window to Operate"), items, 0, false, &ok);
        if(!ok) return;
        for(int i=0; i<selectWindowList.size(); i++){
            if(selectitem==callback.getImageName(selectWindowList[i]))
            {
                winid=i;
                break;
            }
        }
    }else{
        winid=0;
    }
    v3dwin = selectWindowList[winid];

    //load neuron tree
    ntTreeList=callback.getHandleNeuronTrees_Any3DViewer(v3dwin);
    for(int i=0; i<ntTreeList->size(); i++){
        NeuronTree* p = (NeuronTree*)&(ntTreeList->at(i));
        int k=i%8;
        p->color.r=R_table[k];
        p->color.g=G_table[k];
        p->color.b=B_table[k];
        p->color.a=255;
    }
    qDebug("Done Setting Color");
    callback.update_3DViewer(v3dwin);
}