예제 #1
0
void DlgInspector::setDocument(Gui::Document* doc)
{
    setNodeNames(doc);

    View3DInventor* view = qobject_cast<View3DInventor*>(doc->getActiveView());
    if (view) {
        View3DInventorViewer* viewer = view->getViewer();
        setNode(viewer->getSceneGraph());
        ui->treeView->expandToDepth(3);
    }
}
예제 #2
0
void Flag::mouseMoveEvent(QMouseEvent *e)
{
    if (e->buttons() & Qt::LeftButton) {
        move(e->globalPos() - dragPosition);
        e->accept();
#if defined(HAVE_QT5_OPENGL)
        View3DInventorViewer* viewer = dynamic_cast<View3DInventorViewer*>(parentWidget());
        if (viewer)
            viewer->getSoRenderManager()->scheduleRedraw();
#endif
    }
}
void DlgInspector::on_refreshButton_clicked()
{
    View3DInventor* child = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
    if (child) {
        View3DInventorViewer* viewer = child->getViewer();
        setNode(viewer->getSceneGraph());
        ui->treeView->expandToDepth(3);
    }
    else {
        SceneModel* model = static_cast<SceneModel*>(ui->treeView->model());
        model->clear();
    }
}
void StdCmdAlignment::activated(int iMsg)
{
    std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType
                                            (App::GeoFeature::getClassTypeId());
    ManualAlignment* align = ManualAlignment::instance();
    QObject::connect(align, SIGNAL(emitCanceled()), align, SLOT(deleteLater()));
    QObject::connect(align, SIGNAL(emitFinished()), align, SLOT(deleteLater()));

    // Get the fixed and moving meshes
    FixedGroup fixedGroup;
    std::map<int, MovableGroup> groupMap;
    fixedGroup.addView(sel[0]);
    groupMap[0].addView(sel[1]);

    // add the fixed group
    align->setFixedGroup(fixedGroup);

    // create the model of movable groups
    MovableGroupModel model;
    model.addGroups(groupMap);
    align->setModel(model);
    Base::Type style = Base::Type::fromName("Gui::CADNavigationStyle");
    Base::Vector3d upDir(0,1,0), viewDir(0,0,-1);
    Gui::Document* doc = Application::Instance->activeDocument();
    if (doc) {
        View3DInventor* mdi = qobject_cast<View3DInventor*>(doc->getActiveView());
        if (mdi) {
            View3DInventorViewer* viewer = mdi->getViewer();
            SoCamera* camera = viewer->getCamera();
            if (camera) {
                SbVec3f up(0,1,0), dir(0,0,-1);
                camera->orientation.getValue().multVec(dir, dir);
                viewDir.Set(dir[0],dir[1],dir[2]);
                camera->orientation.getValue().multVec(up, up);
                upDir.Set(up[0],up[1],up[2]);
            }
            style = viewer->navigationStyle()->getTypeId();
        }
    }

    align->setMinPoints(1);
    align->startAlignment(style);
    align->setViewingDirections(viewDir,upDir, viewDir,upDir);
    Gui::Selection().clearSelection();
}
예제 #5
0
void DlgInspector::on_refreshButton_clicked()
{
    Gui::Document* doc = Application::Instance->activeDocument();
    if (doc) {
        setNodeNames(doc);

        View3DInventor* view = qobject_cast<View3DInventor*>(doc->getActiveView());
        if (view) {
            View3DInventorViewer* viewer = view->getViewer();
            setNode(viewer->getSceneGraph());
            ui->treeView->expandToDepth(3);
        }
    }
    else {
        SceneModel* model = static_cast<SceneModel*>(ui->treeView->model());
        model->clear();
    }
}
void ViewProviderDocumentObjectGroup::updateData(const App::Property* prop)
{
#if 0
    if (prop->getTypeId() == App::PropertyLinkList::getClassTypeId()) {
        std::vector<App::DocumentObject*> obj =
            static_cast<const App::PropertyLinkList*>(prop)->getValues();
        Gui::Document* doc = Gui::Application::Instance->getDocument
            (&this->getObject()->getDocument());
        MDIView* mdi = doc->getActiveView();
        if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) {
            View3DInventorViewer* view = static_cast<View3DInventor*>(mdi)->getViewer();
            SoSeparator* scene_graph = static_cast<SoSeparator*>(view->getSceneGraph());
            std::vector<ViewProvider*> current_nodes;
            for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it)
                current_nodes.push_back(doc->getViewProvider(*it));
            std::sort(current_nodes.begin(), current_nodes.end());
            std::sort(this->nodes.begin(), this->nodes.end());
            // get the removed views
            std::vector<ViewProvider*> diff_1, diff_2;
            std::back_insert_iterator<std::vector<ViewProvider*> > biit(diff_2);
            std::set_difference(this->nodes.begin(), this->nodes.end(), 
                                current_nodes.begin(), current_nodes.end(), biit);
            diff_1 = diff_2;
            diff_2.clear();
            // get the added views
            std::set_difference(current_nodes.begin(), current_nodes.end(),
                                this->nodes.begin(), this->nodes.end(), biit);
            this->nodes = current_nodes;
            // move from root node to switch
            for (std::vector<ViewProvider*>::iterator it = diff_1.begin(); it != diff_1.end(); ++it) {
                view->addViewProviderToGroup(*it, scene_graph);
                view->removeViewProviderFromGroup(*it, this->pcModeSwitch);
            }
            // move from switch node to root node
            for (std::vector<ViewProvider*>::iterator it = diff_2.begin(); it != diff_2.end(); ++it) {
                view->addViewProviderToGroup(*it, this->pcModeSwitch);
                view->removeViewProviderFromGroup(*it, scene_graph);
            }
        }
    }
#else
    Q_UNUSED(prop);
#endif
}