Exemplo n.º 1
0
void MainWindow::createActions()
{ 
   //exportAct = new QAction(tr("&Export as ..."),this);
   //exportAct->setShortcut(tr("Ctrl+E"));
   //connect(exportAct, SIGNAL(triggered()), this, SLOT(export_as()));
   zoomAllAct = new QAction(QIcon(":/images/home.png"),tr("Zoom All"),this);
   connect(zoomAllAct, SIGNAL(triggered()), this, SLOT(zoom_all()));
    
   zoomBoxAct = new QAction(QIcon(":/images/zoombox.png"),tr("Zoom To Box"),this);
   zoomBoxAct->setCheckable(true);
   connect(zoomBoxAct, SIGNAL(triggered()), this, SLOT(zoom_to_box()));
    
   panAct = new QAction(QIcon(":/images/pan.png"),tr("Pan"),this);
   panAct->setCheckable(true);
   connect(panAct, SIGNAL(triggered()), this, SLOT(pan()));
    
   infoAct = new QAction(QIcon(":/images/info.png"),tr("Info"),this);
   infoAct->setCheckable(true);
   connect(infoAct, SIGNAL(triggered()), this, SLOT(info()));
   
   toolsGroup=new QActionGroup(this);
   toolsGroup->addAction(zoomBoxAct);
   toolsGroup->addAction(panAct);
   toolsGroup->addAction(infoAct);
   zoomBoxAct->setChecked(true);
       
   openAct=new QAction(tr("Open Map definition"),this);
   connect(openAct,SIGNAL(triggered()),this,SLOT(open()));
   saveAct=new QAction(tr("Save Map definition"),this);
   connect(saveAct,SIGNAL(triggered()),this,SLOT(save()));

   panLeftAct = new QAction(QIcon(":/images/left.png"),tr("&Pan Left"),this);
   connect(panLeftAct, SIGNAL(triggered()), this, SLOT(pan_left()));
   panRightAct = new QAction(QIcon(":/images/right.png"),tr("&Pan Right"),this);
   connect(panRightAct, SIGNAL(triggered()), this, SLOT(pan_right()));
   panUpAct = new QAction(QIcon(":/images/up.png"),tr("&Pan Up"),this);
   connect(panUpAct, SIGNAL(triggered()), this, SLOT(pan_up()));
   panDownAct = new QAction(QIcon(":/images/down.png"),tr("&Pan Down"),this);
   connect(panDownAct, SIGNAL(triggered()), this, SLOT(pan_down()));
   
   reloadAct = new QAction(QIcon(":/images/reload.png"),tr("Reload"),this);
   connect(reloadAct, SIGNAL(triggered()), this, SLOT(reload()));
   
   layerInfo = new QAction(QIcon(":/images/info.png"),tr("&Layer info"),layerTab_);
   connect(layerInfo, SIGNAL(triggered()), layerTab_,SLOT(layerInfo()));
   connect(layerTab_, SIGNAL(doubleClicked(QModelIndex const&)), layerTab_,SLOT(layerInfo2(QModelIndex const&)));
   foreach (QByteArray format, QImageWriter::supportedImageFormats()) 
   {
      QString text = tr("%1...").arg(QString(format).toUpper());
      
      QAction *action = new QAction(text, this);
      action->setData(format);
      connect(action, SIGNAL(triggered()), this, SLOT(export_as()));
      exportAsActs.append(action);
   }
Exemplo n.º 2
0
void BackwardParabolicIBVP::gridMethod(DoubleMatrix &p, SweepMethodDirection direction) const
{
    typedef void (*t_algorithm)(const double*, const double*, const double*, const double*, double*, unsigned int);
    t_algorithm algorithm = &tomasAlgorithm;
    if (direction == ForwardSweep) algorithm = &tomasAlgorithmL2R;
    if (direction == BackwardSweep) algorithm = &tomasAlgorithmR2L;

    Dimension time = mtimeDimension;
    Dimension dim1 = mspaceDimension.at(0);

    double ht = time.step();
    unsigned int minM = time.min();
    unsigned int maxM = time.max();
    unsigned int M = maxM-minM;

    double hx = dim1.step();
    unsigned int minN = dim1.min();
    unsigned int maxN = dim1.max();
    unsigned int N = maxN-minN;

    double h = ht/(hx*hx);

    p.clear();
    p.resize(M+1, N+1);

    double *ka = (double*) malloc(sizeof(double)*(N-1));
    double *kb = (double*) malloc(sizeof(double)*(N-1));
    double *kc = (double*) malloc(sizeof(double)*(N-1));
    double *kd = (double*) malloc(sizeof(double)*(N-1));
    double *rx = (double*) malloc(sizeof(double)*(N-1));

    /* initial condition */
    SpaceNodePDE isn;
    for (unsigned int n=0; n<=N; n++)
    {
        isn.i = n+minN;
        isn.x = isn.i*hx;
        p[M][n] = initial(isn);
    }
    layerInfo(p, M);

    SpaceNodePDE lsn;
    lsn.i = minN;
    lsn.x = minN*hx;

    SpaceNodePDE rsn;
    rsn.i = maxN;
    rsn.x = maxN*hx;

    TimeNodePDE tn;
    for (unsigned int m=M-1; m!=UINT32_MAX; m--)
    {
        tn.i = m+minM;
        tn.t = tn.i*ht;

        for (unsigned int n=1; n<=N-1; n++)
        {
            isn.i = n+minN;
            isn.x = isn.i*hx;

            double alpha = -a(isn,tn)*h;
            double betta = 1.0 - 2.0*alpha;

            ka[n-1] = alpha;
            kb[n-1] = betta;
            kc[n-1] = alpha;
            kd[n-1] = p[m+1][n] - ht * f(isn, tn);
        }

        ka[0]   = 0.0;
        kc[N-2] = 0.0;

        /* border conditions */
        p[m][0] = boundary(lsn, tn);
        p[m][N] = boundary(rsn, tn);

        kd[0]   += a(lsn,tn) * h * p[m][0];
        kd[N-2] += a(rsn,tn) * h * p[m][N];

        (*algorithm)(ka, kb, kc, kd, rx, N-1);

        for (unsigned int n=1; n<=N-1; n++) p[m][n] = rx[n-1];

        layerInfo(p, m);
    }

    free(ka);
    free(kb);
    free(kc);
    free(kd);
    free(rx);
}