Changeset 12783

Show
Ignore:
Timestamp:
05.11.2009 16:19:05 (2 weeks ago)
Author:
raider
Message:

fixed some bugs. gtk prover gui almost working. moved GUIMVar to HTkUtils

Location:
trunk/GUI
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/GUI/GraphTypes.hs

    r12755 r12783  
    2626 
    2727import GUI.GraphAbstraction(GraphInfo, initGraph) 
    28 import GUI.HTkProverGUI (GUIMVar) 
     28import GUI.HTkUtils (GUIMVar) 
    2929import GUI.UDGUtils 
    3030 
  • trunk/GUI/GtkGenericATP.hs

    r12779 r12783  
    2222import Interfaces.GenericATPState 
    2323 
    24 import Control.Concurrent (forkIO, killThread, myThreadId) 
     24import Control.Concurrent (forkIO, killThread, yield) 
    2525import Control.Concurrent.MVar 
     26import Control.Monad (unless, when) 
    2627 
    2728import Common.AS_Annotation as AS_Anno 
     
    9596 
    9697    stateMVar <- newMVar initState 
    97     tid' <- myThreadId 
    98     threadId <- newMVar tid' 
     98    threadId <- newEmptyMVar 
     99    finished <- newEmptyMVar 
    99100 
    100101    -- setting up lists 
     
    176177    -- show details of selected goal 
    177178    onClicked btnStop $ do 
    178       tryTakeMVar threadId >>=maybe (return ()) killThread 
    179       putMVar threadId tid' 
     179      tryTakeMVar threadId >>= maybe (error "MVar 'tId' not set") killThread 
     180      putMVar finished () 
    180181 
    181182    -- show details of selected goal 
     
    227228                              $ map AS_Anno.senAttr $ goalsList s 
    228229            opts = words opts' 
    229             afterEachProofAttempt = (\ gPSF nSen nextSen cfg@(retval,_) -> do 
     230            afterEachProofAttempt = \ gPSF nSen nextSen cfg@(retval,_) -> do 
    230231              cont <- goalProcessed stateMVar timeout opts numGoals prName 
    231232                                    gPSF nSen False cfg 
     
    233234                ATPError m -> errorDialog "Error" m 
    234235                _ -> return () 
    235               postGUIAsync $ do 
    236                 let progress = fromIntegral gPSF / fromIntegral numGoals 
    237                 if cont then updat progress $ AS_Anno.senAttr $ fromJust nextSen 
    238                   else do 
    239                     switchAll True 
    240                     takeMVar threadId 
    241                     return () 
     236              postGUISync $ do 
    242237                s' <- readMVar stateMVar 
    243238                update' s' 
    244               return cont) 
     239                let progress = fromIntegral gPSF / fromIntegral numGoals 
     240                when cont $ updat progress $ AS_Anno.senAttr $ fromJust nextSen 
     241                return cont 
    245242        updat 0 firstGoalName 
    246         switchAll False 
    247         mtid <- tryTakeMVar threadId 
    248         maybe (error "MVar was not set.") (\ _ -> return ()) mtid 
    249243        tid <- forkIO $ do 
     244          yield 
    250245          genericProveBatch False timeout opts inclProven saveBatch 
    251246            afterEachProofAttempt (atpInsertSentence atpFun) (runProver atpFun) 
    252247            prName thName s Nothing 
    253           return () 
    254         putMVar threadId tid 
     248          b <- isEmptyMVar threadId 
     249          unless b $ putMVar finished () 
     250        b <- tryPutMVar threadId tid 
     251        unless b $ error "MVar 'threadId' already set" 
     252        switchAll False 
    255253        forkIO_ $ do 
    256           putMVar threadId tid' 
    257           postGUISync $ do 
     254          takeMVar finished 
     255          tryTakeMVar threadId 
     256          postGUIAsync $ do 
    258257            switchAll True 
    259258            exit 
  • trunk/GUI/GtkProverGUI.hs

    r12779 r12783  
    158158 
    159159    onClicked btnGoalsSelectOpen $ modifyMVar_ state $ \ s -> do 
    160       model <- treeViewGetModel trvGoals 
    161160      sel <- treeViewGetSelection trvGoals 
    162       let isOpen st = let thst = thmStatus st in 
    163             null thst || case maximum $ map snd thst of 
    164               BasicProof _ pst -> isOpenGoal $ goalStatus pst 
    165               _ -> False 
    166       treeModelForeach (fromJust model) $ \ i -> do 
    167         (row:[]) <- treeModelGetPath (fromJust model) i 
    168         key <- listStoreGetValue listGoals row 
    169         (if isOpen $ fromJust $ OMap.lookup (gName key) $ goalMap s 
    170           then treeSelectionSelectIter else treeSelectionUnselectIter) sel i 
    171         return False 
     161      treeSelectionSelectAll sel 
     162      rs <- treeSelectionGetSelectedRows sel 
     163      mapM_ ( \ p@(row:[]) -> do 
     164        i <- listStoreGetValue listGoals row 
     165        let isOpen st = let thst = thmStatus st in 
     166              null thst || case maximum $ map snd thst of 
     167                BasicProof _ pst -> isOpenGoal $ goalStatus pst 
     168                _ -> False 
     169        (if isOpen $ fromJust $ OMap.lookup (gName i) $ goalMap s 
     170          then treeSelectionSelectPath else treeSelectionUnselectPath) sel p) rs 
    172171      update s 
    173172 
     
    175174    setListSelectorMultiple trvAxioms btnAxiomsAll btnAxiomsNone btnAxiomsInvert 
    176175      $ modifyMVar_ state update 
     176 
    177177    onClicked btnAxiomsFormer $ modifyMVar_ state $ \ s -> do 
    178       aM <- axiomMap s 
    179       model <- treeViewGetModel trvAxioms 
    180178      sel <- treeViewGetSelection trvAxioms 
    181       treeModelForeach (fromJust model) $ \ i -> do 
    182         (row:[]) <- treeModelGetPath (fromJust model) i 
    183         key <- listStoreGetValue listAxioms row 
    184         k <- case stripPrefix "(Th) " key of 
    185           Just k -> return k 
    186           Nothing -> return key 
    187         (if not $ wasTheorem $ fromJust $ OMap.lookup k aM 
    188           then treeSelectionSelectIter else treeSelectionUnselectIter) sel i 
    189         return False 
     179      treeSelectionSelectAll sel 
     180      rs <- treeSelectionGetSelectedRows sel 
     181      mapM_ ( \ p@(row:[]) -> do 
     182        i <- listStoreGetValue listAxioms row 
     183        (if wasTheorem $ fromJust $ OMap.lookup (stripPrefixAxiom i) axioms 
     184          then treeSelectionUnselectPath else treeSelectionSelectPath) sel p) rs 
    190185      update s 
    191186 
     
    199194    onClicked btnClose $ widgetDestroy window 
    200195 
    201     onClicked btnShowTheory $ 
    202       displayTheoryWithWarning "Theory" thName warn th 
    203  
    204     onClicked btnShowSelectedTheory $ do 
    205       s <- readMVar state 
    206       displayTheoryWithWarning "Selected Theory" thName warn $ selectedTheory s 
     196    onClicked btnShowTheory $ displayTheoryWithWarning "Theory" thName warn th 
     197 
     198    onClicked btnShowSelectedTheory $ readMVar state >>= 
     199      displayTheoryWithWarning "Selected Theory" thName warn . selectedTheory 
    207200 
    208201    onClicked btnDisplay $ readMVar state >>= displayGoals 
    209202 
    210     onClicked btnProofDetails $ do 
    211       s <- readMVar state 
    212       forkIO_ $ doShowProofDetails s 
     203    onClicked btnProofDetails $ forkIO_ $ readMVar state >>= doShowProofDetails 
    213204 
    214205    onClicked btnProve $ do 
     
    351342  axioms <- getSelectedMultiple axs listAxs 
    352343  theorems <- getSelectedMultiple ths listThs 
    353   return s { includedAxioms   = map snd axioms 
     344  return s { includedAxioms   = map (stripPrefixAxiom . snd) axioms 
    354345           , includedTheorems = map snd theorems } 
     346 
     347stripPrefixAxiom :: String -> String 
     348stripPrefixAxiom a = case stripPrefix "(Th) " a of 
     349  Just a' -> a' 
     350  Nothing -> a 
    355351 
    356352-- | Called whenever a prover is selected from the "Pick Theorem Prover" list. 
  • trunk/GUI/HTkProverGUI.hs

    r12755 r12783  
    4343 
    4444-- * Proof Management GUI 
    45  
    46 -- ** some types 
    47  
    48 -- | Type for storing the proof management window 
    49 type GUIMVar = Conc.MVar (Maybe Toplevel) 
    5045 
    5146-- ** Defining the view 
     
    331326                closing the window; while the window is open it is filled with 
    332327                the Toplevel -} 
    333     -> IO (Result.Result G_theory) 
     328  -> IO (Result.Result G_theory) 
    334329proofManagementGUI lid prGuiAcs 
    335330                   thName warningTxt th 
  • trunk/GUI/HTkUtils.hs

    r12739 r12783  
    1515  , LBStatusIndicator (..) 
    1616  , EnableWid (..) 
     17  , GUIMVar 
    1718  , listBox 
    1819  , errorMess 
     
    5152 
    5253import Common.DocUtils 
     54 
     55import Control.Concurrent.MVar 
     56 
     57 
     58-- ** some types 
     59 
     60-- | Type for storing the proof management window 
     61type GUIMVar = MVar (Maybe Toplevel) 
    5362 
    5463-- | create a window with title and list of options, return selected option