R/newinterface.r

#' @export
qsetClass("cpGUI", Qt$QTabWidget, function(object = NULL, parent = NULL ) {
  super(parent)
  
  this$lslayout <- Qt$QGroupBox()
  this$lslayout$setFlat(TRUE)
  
  this$gplayout <- Qt$QGroupBox()
  this$gplayout$setFlat(TRUE)
  
  this$rblayout <- Qt$QGroupBox()
  this$rblayout$setFlat(TRUE)
  
  this$fplayout <- Qt$QGroupBox()
  this$fplayout$setFlat(TRUE)
  
  this$addTab( lslayout, 
               label = "Load Sample")
  this$addTab( gplayout, 
               label = "Generate Profile")
  this$addTab( rblayout, 
               label = "Remove Baseline")
  this$addTab( fplayout, 
               label = "Find Peaks")
  this$setTabPosition(2)
  this$setTabsClosable(FALSE)
  populateparams(object = object)
  
  this
})


qsetMethod('populateparams', cpGUI, function(object = NULL){
  file <- Qt$QLineEdit()
  if(!is.null(object)){
    ## check if the input object is supported
    if(!class(object) %in% c('xcmsRaw', 'cpSample')){
      stop('==> cpGUI :: Object of class "', class(object), 
           '" not supported!')
    } else if(attr(class(object), 'package') == 'xcms'){
    ## for xcms objects, figure out if object is at loadSample 
    ## or genProfile
      if(length(object@profparam) == 0){ ## at loadSample state
        protocols <- list(Protocol("loadSample", "xcms", 
                includeMSn = ifelse(is.null(object@env$msnMz),  
                            FALSE, TRUE)))
        object <- new('cpgSample', object, 
                      pipeline = new('Pipeline', c(protocols)))
      } else {
        ## how to tell between genProfile state or removeBaseline ???
        ## is it enough to figure out that min(object@env$profile) < 0
      }
    }
    file$text <- object@filepath
  }
  browse <- Qt$QPushButton('&Browse')
  qconnect(browse, "clicked", loadFromFile)
  
  profstep <- Qt$QLineEdit()
  profmethod <- Qt$QLineEdit()
  includemsn <- Qt$QLineEdit()
  ms_levels <- Qt$QLineEdit()
  scan_ranges <- Qt$QLineEdit()
  if(!is.null(object)){
   
    profstep$text <- profStep(object)
    profmethod$text <- profMethod(object)
    includemsn$text <- ifelse(is.null(object@env$msnMz),  
                              FALSE, TRUE)
    ms_levels$text <- ifelse(length(object@msnLevel) == 0, 'NULL', 
                             object@msnLevel)
  } else {
    profstep$text <- 1
    profmethod$text <- 'intlin'
    includemsn$text <- FALSE
    ms_levels$text <- 'NULL'
  }
  
  plotButton <- Qt$QPushButton("Generate &Plots")
  glay <- Qt$QGridLayout()
  glay$setAlignment(Qt$Qt$AlignTop)
  
  
  glay$addWidget(Qt$QLabel('File: '), 0, 0, Qt$Qt$AlignRight)
  glay$addWidget(file, 0, 1)
  glay$addWidget(browse, 0, 2)
  glay$addWidget(Qt$QLabel('profstep: '), 1, 0, Qt$Qt$AlignRight)
  glay$addWidget(profstep, 1, 1)
  glay$addWidget(Qt$QLabel('profmethod: '), 2, 0, Qt$Qt$AlignRight)
  glay$addWidget(profmethod, 2,1)
  glay$addWidget(Qt$QLabel('includeMSn: '), 3, 0, Qt$Qt$AlignRight)
  glay$addWidget(includemsn, 3,1)
  glay$addWidget(Qt$QLabel('mslevel: '), 4, 0, Qt$Qt$AlignRight)
  glay$addWidget(ms_levels, 4, 1)
  glay$addWidget(plotButton, 5, 1)

  lslayout$setLayout(glay)  

  
  }, 'private')

qsetMethod('loadFromFile', cpGUI, function(){
  fileName <-  Qt$QFileDialog$getOpenFileName(this, 
                "Open raw data file", "", 
                "(*.CDF);;All Files (*)")
  if (!nchar(fileName))
    return()
})
mariev/chromatoplotsgui documentation built on May 21, 2019, 11:46 a.m.