comparison main/MainWindow.cpp @ 73:e200055fe80b

* Add vertical zooming and snap-to-selection for OSC control; add a demo script
author Chris Cannam
date Wed, 15 Nov 2006 18:22:26 +0000
parents 34dc23246f46
children bedc7517b6e8
comparison
equal deleted inserted replaced
72:34dc23246f46 73:e200055fe80b
149 this, SLOT(currentPaneChanged(Pane *))); 149 this, SLOT(currentPaneChanged(Pane *)));
150 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)), 150 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)),
151 this, SLOT(currentLayerChanged(Pane *, Layer *))); 151 this, SLOT(currentLayerChanged(Pane *, Layer *)));
152 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)), 152 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)),
153 this, SLOT(rightButtonMenuRequested(Pane *, QPoint))); 153 this, SLOT(rightButtonMenuRequested(Pane *, QPoint)));
154 connect(m_paneStack, SIGNAL(propertyStacksResized()),
155 this, SLOT(propertyStacksResized()));
154 156
155 m_overview = new Overview(frame); 157 m_overview = new Overview(frame);
156 m_overview->setViewManager(m_viewManager); 158 m_overview->setViewManager(m_viewManager);
157 m_overview->setFixedHeight(40); 159 m_overview->setFixedHeight(40);
158 160
2984 m_document->addLayerToView(pane, newLayer); 2986 m_document->addLayerToView(pane, newLayer);
2985 2987
2986 m_paneStack->setCurrentPane(pane); 2988 m_paneStack->setCurrentPane(pane);
2987 m_paneStack->setCurrentLayer(pane, newLayer); 2989 m_paneStack->setCurrentLayer(pane, newLayer);
2988 2990
2991 std::cerr << "MainWindow::addPane: global centre frame is "
2992 << m_viewManager->getGlobalCentreFrame() << std::endl;
2993 pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
2994
2989 CommandHistory::getInstance()->endCompoundOperation(); 2995 CommandHistory::getInstance()->endCompoundOperation();
2990 2996
2991 updateMenuStates(); 2997 updateMenuStates();
2992 } 2998 }
2993 2999
3449 m_paneStack->setCurrentPane(pane); 3455 m_paneStack->setCurrentPane(pane);
3450 m_rightButtonMenu->popup(position); 3456 m_rightButtonMenu->popup(position);
3451 } 3457 }
3452 3458
3453 void 3459 void
3460 MainWindow::propertyStacksResized()
3461 {
3462 /*
3463 std::cerr << "MainWindow::propertyStacksResized" << std::endl;
3464 Pane *pane = m_paneStack->getCurrentPane();
3465 if (pane && m_overview) {
3466 std::cerr << "Fixed width: " << pane->width() << std::endl;
3467 m_overview->setFixedWidth(pane->width());
3468 }
3469 */
3470 }
3471
3472 void
3454 MainWindow::showLayerTree() 3473 MainWindow::showLayerTree()
3455 { 3474 {
3456 QTreeView *view = new QTreeView(); 3475 QTreeView *view = new QTreeView();
3457 LayerTreeModel *tree = new LayerTreeModel(m_paneStack); 3476 LayerTreeModel *tree = new LayerTreeModel(m_paneStack);
3458 view->expand(tree->index(0, 0, QModelIndex())); 3477 view->expand(tree->index(0, 0, QModelIndex()));
3634 } else if (message.getMethod() == "select" || 3653 } else if (message.getMethod() == "select" ||
3635 message.getMethod() == "addselect") { 3654 message.getMethod() == "addselect") {
3636 3655
3637 if (getMainModel()) { 3656 if (getMainModel()) {
3638 3657
3639 unsigned long f0 = getMainModel()->getStartFrame(); 3658 int f0 = getMainModel()->getStartFrame();
3640 unsigned long f1 = getMainModel()->getEndFrame(); 3659 int f1 = getMainModel()->getEndFrame();
3641 3660
3642 bool done = false; 3661 bool done = false;
3643 3662
3644 if (message.getArgCount() == 2 && 3663 if (message.getArgCount() == 2 &&
3645 message.getArg(0).canConvert(QVariant::Double) && 3664 message.getArg(0).canConvert(QVariant::Double) &&
3651 if (t0 < 0.0) t0 = 0.0; 3670 if (t0 < 0.0) t0 = 0.0;
3652 if (t1 < 0.0) t1 = 0.0; 3671 if (t1 < 0.0) t1 = 0.0;
3653 3672
3654 f0 = lrint(t0 * getMainModel()->getSampleRate()); 3673 f0 = lrint(t0 * getMainModel()->getSampleRate());
3655 f1 = lrint(t1 * getMainModel()->getSampleRate()); 3674 f1 = lrint(t1 * getMainModel()->getSampleRate());
3675
3676 Pane *pane = m_paneStack->getCurrentPane();
3677 Layer *layer = 0;
3678 if (pane) layer = pane->getSelectedLayer();
3679 if (layer) {
3680 size_t resolution;
3681 layer->snapToFeatureFrame(pane, f0, resolution,
3682 Layer::SnapLeft);
3683 layer->snapToFeatureFrame(pane, f1, resolution,
3684 Layer::SnapRight);
3685 }
3656 3686
3657 } else if (message.getArgCount() == 1 && 3687 } else if (message.getArgCount() == 1 &&
3658 message.getArg(0).canConvert(QVariant::String)) { 3688 message.getArg(0).canConvert(QVariant::String)) {
3659 3689
3660 QString str = message.getArg(0).toString(); 3690 QString str = message.getArg(0).toString();
3841 if (level < 1.0) level = 1.0; 3871 if (level < 1.0) level = 1.0;
3842 if (currentPane) currentPane->setZoomLevel(lrint(level)); 3872 if (currentPane) currentPane->setZoomLevel(lrint(level));
3843 } 3873 }
3844 } 3874 }
3845 3875
3876 } else if (message.getMethod() == "zoomvertical") {
3877
3878 Pane *pane = m_paneStack->getCurrentPane();
3879 Layer *layer = 0;
3880 if (pane && pane->getLayerCount() > 0) {
3881 layer = pane->getLayer(pane->getLayerCount() - 1);
3882 }
3883 int defaultStep = 0;
3884 int steps = 0;
3885 if (layer) {
3886 steps = layer->getVerticalZoomSteps(defaultStep);
3887 if (message.getArgCount() == 1 && steps > 0) {
3888 if (message.getArg(0).canConvert(QVariant::String) &&
3889 message.getArg(0).toString() == "in") {
3890 int step = layer->getCurrentVerticalZoomStep() + 1;
3891 if (step < steps) layer->setVerticalZoomStep(step);
3892 } else if (message.getArg(0).canConvert(QVariant::String) &&
3893 message.getArg(0).toString() == "out") {
3894 int step = layer->getCurrentVerticalZoomStep() - 1;
3895 if (step >= 0) layer->setVerticalZoomStep(step);
3896 } else if (message.getArg(0).canConvert(QVariant::String) &&
3897 message.getArg(0).toString() == "default") {
3898 layer->setVerticalZoomStep(defaultStep);
3899 }
3900 } else if (message.getArgCount() == 2) {
3901 if (message.getArg(0).canConvert(QVariant::Double) &&
3902 message.getArg(1).canConvert(QVariant::Double)) {
3903 double min = message.getArg(0).toDouble();
3904 double max = message.getArg(1).toDouble();
3905 layer->setDisplayExtents(min, max);
3906 }
3907 }
3908 }
3909
3846 } else if (message.getMethod() == "quit") { 3910 } else if (message.getMethod() == "quit") {
3847 3911
3848 m_abandoning = true; 3912 m_abandoning = true;
3849 close(); 3913 close();
3850 3914
3884 TransformName transform = message.getArg(0).toString(); 3948 TransformName transform = message.getArg(0).toString();
3885 3949
3886 Layer *newLayer = m_document->createDerivedLayer 3950 Layer *newLayer = m_document->createDerivedLayer
3887 (transform, 3951 (transform,
3888 getMainModel(), 3952 getMainModel(),
3889 PluginTransform::ExecutionContext(), 3953 TransformFactory::getInstance()->getDefaultContextForTransform
3954 (transform, getMainModel()),
3890 ""); 3955 "");
3891 3956
3892 if (newLayer) { 3957 if (newLayer) {
3893 m_document->addLayerToView(pane, newLayer); 3958 m_document->addLayerToView(pane, newLayer);
3894 m_recentTransforms.add(transform); 3959 m_recentTransforms.add(transform);