Beispiel #1
0
void FLConnectDBDialog::popupMarks()
{
  QPopupMenu *marks = new QPopupMenu(this, "marks");
  QActionGroup *ag = new QActionGroup(this, 0);
  QSignalMapper *marksMapper = new QSignalMapper(this);

  connect(marksMapper, SIGNAL(mapped(const QString &)), this, SLOT(tryConnectMark(const QString &)));

  QStringList list;
  for (int i = 0; i < comboBoxMarks->count(); i++)
    list << comboBoxMarks->text(i);
  list.sort();
  QDict < int >marksDict(17, false);

  for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
    QString marksStr = *it;
    QString marksAccel = marksStr;

    if (marksDict[ marksAccel.left(1)]) {
      for (uint i = 0; i < marksAccel.length(); i++) {
        if (!marksDict[ marksAccel.mid(i, 1)]) {
          marksDict.insert(marksAccel.mid(i, 1), (const int *) 1);
          marksAccel = marksAccel.insert(i, '&');
          break;
        }
      }
    } else {
      marksDict.insert(marksAccel.left(1), (const int *) 1);
      marksAccel = "&" + marksAccel;
    }
    QAction *a = new QAction(marksStr, QIconSet(), marksAccel, 0, ag, 0, ag->isExclusive());
    connect(a, SIGNAL(activated()), marksMapper, SLOT(map()));
    marksMapper->setMapping(a, a->text());
  }
  ag->addTo(marks);

  marks->setPalette(palette());
  marks->popup(QCursor::pos());
}
TxqPlot3DWindow::TxqPlot3DWindow( char *thisLabel, WindowType myWindow )
    : QWidget( )
{

    // set thisWindow so that all class members may access
    thisWindow = myWindow;

    // Set the title
    setPalette( QPalette( Qt::lightGray ) );
    setCaption(thisLabel);
    setIconText(thisLabel);

    // Create top-level layout manager
    QHBoxLayout* hlayout = new QHBoxLayout( this, 20, 20, "hlayout");

    // Create a popup menu containing Close
    QPopupMenu *file = new QPopupMenu();
    file->setPalette( QPalette( Qt::lightGray ) );
    file->insertItem( "Close",  this, SLOT( close() ), CTRL+Key_Q );

    // Create a menu bar
    QMenuBar *m = new QMenuBar( this );
    m->setSeparator( QMenuBar::InWindowsStyle );
    m->insertItem("&File", file );
    hlayout->setMenuBar( m );

    // Create a layout manager for the sliders
    QVBoxLayout* vlayout = new QVBoxLayout( 20, "vlayout");
    hlayout->addLayout( vlayout );

    // Create a nice frame tp put around the openGL widget
    QFrame* f = new QFrame( this, "frame" );
    f->setFrameStyle( QFrame::Sunken | QFrame::Panel );
    f->setLineWidth( 2 );
    hlayout->addWidget( f, 1 );

    // Create a layout manager for the openGL widget
    QHBoxLayout* flayout = new QHBoxLayout( f, 2, 2, "flayout");

    // Create an openGL widget
    plot3D = new GLPlot3D( f, "glbox");
    plot3D->setData(thisLabel, myWindow);
    plot3D->setMinimumSize( 50, 50 );
    flayout->addWidget( plot3D, 1 );
    flayout->activate();

    // Create the three sliders; one for each rotation axis
    QSlider* x = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "xsl" );
    x->setTickmarks( QSlider::Left );
    x->setMinimumSize( x->sizeHint() );
    vlayout->addWidget( x );
    QObject::connect( x, SIGNAL(valueChanged(int)),plot3D,SLOT(setXRotation(int)) );

    QSlider* y = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "ysl" );
    y->setTickmarks( QSlider::Left );
    y->setMinimumSize( y->sizeHint() );
    vlayout->addWidget( y );
    QObject::connect( y, SIGNAL(valueChanged(int)),plot3D,SLOT(setYRotation(int)) );

    QSlider* z = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "zsl" );
    z->setTickmarks( QSlider::Left );
    z->setMinimumSize( z->sizeHint() );
    vlayout->addWidget( z );
    QObject::connect( z, SIGNAL(valueChanged(int)),plot3D,SLOT(setZRotation(int)) );

    // create the slider for the eye translation
    QSlider* t = new QSlider ( -15, -5, 1, -15, QSlider::Vertical, this, "tsl" );
    t->setTickmarks( QSlider::Left );
    t->setMinimumSize( x->sizeHint() );
    vlayout->addWidget( t );
    QObject::connect( t, SIGNAL(valueChanged(int)),plot3D,SLOT(setTranslation(int)) );

    // Start the geometry management
    hlayout->activate();
}