void MidiInstrumentMapper::RemoveAllMaps() {
     midiMapsMutex.Lock();
     midiMaps.clear();
     SetDefaultMap(-1);
     fireMidiInstrumentMapCountChanged(Maps().size());
     midiMapsMutex.Unlock();
 }
 int MidiInstrumentMapper::AddMap(String MapName) throw (Exception) {
     int ID;
     midiMapsMutex.Lock();
     if (midiMaps.empty()) ID = 0;
     else {
         // get the highest existing map ID
         uint lastIndex = (--(midiMaps.end()))->first;
         // check if we reached the index limit
         if (lastIndex + 1 < lastIndex) {
             // search for an unoccupied map ID starting from 0
             for (uint i = 0; i < lastIndex; i++) {
                 if (midiMaps.find(i) != midiMaps.end()) continue;
                 // we found an unused ID, so insert the new map there
                 ID = i;
                 goto __create_map;
             }
             throw Exception("Internal error: could not find unoccupied MIDI instrument map ID.");
         }
         ID = lastIndex + 1;
     }
     __create_map:
     midiMaps[ID].name = MapName;
     
     fireMidiInstrumentMapCountChanged(Maps().size());
     // If there were no maps until now we must set a default map.
     if (midiMaps.size() == 1) SetDefaultMap(ID);
     midiMapsMutex.Unlock();
     
     return ID;
 }
Exemplo n.º 3
0
int main( int argc, char **argv )
{
  QApplication app(argc,argv);

  qt4plot Plot;

  std::vector< scigraphics::graphMV* > Maps( 12, (scigraphics::graphMV*)NULL );

  Maps[0] = Plot.createGraph<scigraphics::graphMV>( "gray" );
  Maps[1] = Plot.createGraph<scigraphics::graphMV>( "color1" );
  Maps[2] = Plot.createGraph<scigraphics::graphMV>( "color2" );

  Maps[0]->getView().setColorStrategy( new scigraphics::map::graphViewRectangle::grayscalePointColorStrategy() );
  Maps[1]->getView().setColorStrategy( new scigraphics::map::graphViewRectangle::redYellowBluePointColorStrategy() );
  Maps[2]->getView().setColorStrategy( new scigraphics::map::graphViewRectangle::yellowRedBluePointColorStrategy() );
 
  const size_t SizeX = 20*8, SizeY = 20*8;
  for ( unsigned i = 0; i < Maps.size(); ++i )
  {
    if ( Maps[i] == NULL )
      continue;
    Maps[i]->resize( SizeX, SizeY );
    Maps[i]->setIntervalX( -3, 2 );
    Maps[i]->setIntervalY( -5, 3 );
  }

  for ( unsigned ix = 0; ix < SizeX; ix++ )
  {
    for ( unsigned iy = 0; iy < SizeY; iy++ ) 
    {
      scigraphics::graphMV *Map = Maps[ ix > iy && SizeX-ix > iy ? 0 : 
                                            ix < iy && SizeX-ix < iy ? 1 : 2 ];
      if ( Map == NULL )
        continue;
      double x = Map->coordinateX(ix);
      double y = Map->coordinateY(iy);
      double Value = std::sin(x*y);
      if ( ix == SizeX/4 )
        Value = 1;
      Map->set( ix, iy, Value );
      //std::cout << "Set: " << ix << " " << iy << " -> ( " << x << " " << y << " ) -> " << Sqr->at( ix, iy ) << std::endl;
    }
  }

  qt4plotSettings Settings;
  Settings.addSettingWidget( new qt4plotSettingsSelections(&Settings) );
  //Settings.replaceLayout( new QVBoxLayout() );
  Settings.connectToPlot(&Plot);
  Settings.show();
 

  Plot.move( 200, 200 );
  Plot.resize( 700, 800 );
  Plot.show();
  Plot.replot();

  return app.exec();
}
 void MidiInstrumentMapper::RemoveMap(int Map) {
     midiMapsMutex.Lock();
     midiMaps.erase(Map);
     if(Map == GetDefaultMap()) {
         SetDefaultMap(midiMaps.empty() ? -1 : (*(midiMaps.begin())).first);
     }
     fireMidiInstrumentMapCountChanged(Maps().size());
     midiMapsMutex.Unlock();
 }